Class AuthCollection

java.lang.Object
com.vonage.client.auth.AuthCollection

public class AuthCollection extends 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 Details

  • Method Details

    • add

      public void add(AuthMethod auth)
      Add a new AuthMethod to 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

      public <T extends AuthMethod> T getAuth(Class<T> type) throws VonageUnacceptableAuthException
      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 an AuthMethod 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:
      VonageUnacceptableAuthException - if no appropriate AuthMethod is held by this AuthCollection.
    • hasAuthMethod

      public boolean hasAuthMethod(Class<? extends AuthMethod> authMethod)
      Utility method for determining whether a certain authentication method has been registered.
      Parameters:
      authMethod - The authentication method type.
      Returns:
      true if the specified auth method is available, false otherwise.
      Since:
      7.3.0