Package com.vonage.client.auth
Class AuthCollection
java.lang.Object
com.vonage.client.auth.AuthCollection
public class AuthCollection extends java.lang.Object
Internal class, managing a collection of
AuthMethods.
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
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 Details
-
AuthCollection
public AuthCollection()Create a new AuthCollection with an empty set of AuthMethods. -
AuthCollection
-
AuthCollection
-
-
Method Details
-
add
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 VonageUnacceptableAuthExceptionObtain 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:
VonageUnacceptableAuthException- if no matching AuthMethod is found.
-
getAcceptableAuthMethod
public AuthMethod getAcceptableAuthMethod(java.util.Set<java.lang.Class> acceptableAuthMethodClasses) throws VonageUnacceptableAuthExceptionObtain 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:
VonageUnacceptableAuthException- if no appropriate AuthMethod is held by this AuthCollection
-