Class 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.

    • Method Detail

      • add

        public void add​(AuthMethod auth)
        Add a new AuthMethod 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 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:
        NexmoUnacceptableAuthException - if no appropriate AuthMethod is held by this AuthCollection