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 ofAuthMethod
s.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 void
add(AuthMethod auth)
Add a newAuthMethod
to the set managed by this AuthCollectionAuthMethod
getAcceptableAuthMethod(java.util.Set<java.lang.Class> acceptableAuthMethodClasses)
Obtain anAuthMethod
instance 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 newAuthMethod
to 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 anAuthMethod
instance 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
-
-