Package com.vonage.client.auth
Class AuthCollection
java.lang.Object
com.vonage.client.auth.AuthCollection
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
ConstructorsConstructorDescriptionCreate a new AuthCollection with an empty set of AuthMethods.AuthCollection(AuthMethod... authMethods) AuthCollection(SortedSet<AuthMethod> authMethods) AuthCollection(UUID applicationId, byte[] privateKeyContents, String key, String secret, HashUtil.HashType hashType, String signature) -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(AuthMethod auth) Add a newAuthMethodto the set managed by this AuthCollection.getAcceptableAuthMethod(Set<Class<? extends AuthMethod>> acceptableAuthMethodClasses) Obtain anAuthMethodinstance for a set of acceptable AuthMethod classes.<T extends AuthMethod>
TObtain an AuthMethod of type T, if one is contained in this collection.booleanhasAuthMethod(Class<? extends AuthMethod> authMethod) Utility method for determining whether a certain authentication method has been registered.
-
Constructor Details
-
AuthCollection
public AuthCollection()Create a new AuthCollection with an empty set of AuthMethods. -
AuthCollection
-
AuthCollection
-
AuthCollection
public AuthCollection(UUID applicationId, byte[] privateKeyContents, String key, String secret, HashUtil.HashType hashType, String signature)
-
-
Method Details
-
add
Add a newAuthMethodto the set managed by this AuthCollection. If an auth method of this type already exists, this method will replace it with the new provided value.- Parameters:
auth- AuthMethod method to be added to this collection.
-
getAuth
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:
VonageUnacceptableAuthException- if no matching AuthMethod is found.
-
getAcceptableAuthMethod
public AuthMethod getAcceptableAuthMethod(Set<Class<? extends AuthMethod>> acceptableAuthMethodClasses) throws VonageUnacceptableAuthException 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:
VonageUnacceptableAuthException- if no appropriate AuthMethod is held by this AuthCollection.
-
hasAuthMethod
Utility method for determining whether a certain authentication method has been registered.- Parameters:
authMethod- The authentication method type.- Returns:
trueif the specified auth method is available,falseotherwise.- Since:
- 7.3.0
-