Package com.nexmo.client.auth
Class AuthCollection
- java.lang.Object
-
- com.nexmo.client.auth.AuthCollection
-
public class AuthCollection extends java.lang.Object
Internal class, managing a collection ofAuthMethods.This holds a collection of AuthMethod instances, in order of preference, and allow for simple selection of an appropriate AuthMethod for a particular REST endpoint.
-
-
Constructor Summary
Constructors Constructor Description AuthCollection()Create a new AuthCollection with an empty set of AuthMethods.AuthCollection(AuthMethod... authMethods)AuthCollection(java.util.SortedSet<AuthMethod> authMethods)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(AuthMethod auth)Add a newAuthMethodto the set managed by this AuthCollectionAuthMethodgetAcceptableAuthMethod(java.util.Set<java.lang.Class> acceptableAuthMethodClasses)Obtain anAuthMethodinstance for a set of acceptable AuthMethod classes.<T extends AuthMethod>
TgetAuth(java.lang.Class<T> type)Obtain an AuthMethod of type T, if one is contained in this collection.
-
-
-
Constructor Detail
-
AuthCollection
public AuthCollection()
Create a new AuthCollection with an empty set of AuthMethods.
-
AuthCollection
public AuthCollection(AuthMethod... authMethods)
-
AuthCollection
public AuthCollection(java.util.SortedSet<AuthMethod> authMethods)
-
-
Method Detail
-
add
public void add(AuthMethod auth)
Add a newAuthMethodto the set managed by this AuthCollection- Parameters:
auth- AuthMethod method to be added to this collection
-
getAuth
public <T extends AuthMethod> T getAuth(java.lang.Class<T> type) throws NexmoUnacceptableAuthException
Obtain an AuthMethod of type T, if one is contained in this collection.- Type Parameters:
T- The type of AuthMethod which will be returned- Parameters:
type- The type of AuthMethod to be located- Returns:
- An AuthMethod subclass matching type
- Throws:
NexmoUnacceptableAuthException- if no matching AuthMethod is found.
-
getAcceptableAuthMethod
public AuthMethod getAcceptableAuthMethod(java.util.Set<java.lang.Class> acceptableAuthMethodClasses) throws NexmoUnacceptableAuthException
Obtain anAuthMethodinstance for a set of acceptable AuthMethod classes.- Parameters:
acceptableAuthMethodClasses- A Set of AuthMethod classes which are suitable for the target REST endpoint.- Returns:
- the preferred AuthMethod from the provided set of acceptable AuthMethod classes
- Throws:
NexmoUnacceptableAuthException- if no appropriate AuthMethod is held by this AuthCollection
-
-