Class DigestAuthenticator

    • Field Detail

      • DEFAULT_MAX_SERVER_NONCE_AGE

        private static final long DEFAULT_MAX_SERVER_NONCE_AGE
        Default lifespan for generated nonces (5 minutes).
        See Also:
        Constant Field Values
      • domainRefs

        private volatile java.util.List<Reference> domainRefs
        The URI references that define the protection domains.
      • maxServerNonceAge

        private volatile long maxServerNonceAge
        Lifespan of nonce in milliseconds
      • serverKey

        private volatile java.lang.String serverKey
        The secret key known only to server.
    • Constructor Detail

      • DigestAuthenticator

        public DigestAuthenticator​(Context context,
                                   boolean optional,
                                   java.lang.String realm,
                                   java.util.List<Reference> domainRefs,
                                   java.lang.String serverKey)
        Constructor. Sets the challenge scheme to ChallengeScheme.HTTP_DIGEST and the nonce lifespan to 5 minutes by default.
        Parameters:
        context - The context.
        optional - Indicates if the authentication success is optional.
        realm - The authentication realm.
        domainRefs - The URI references that define the protection domains.
        serverKey - The secret key known only to server.
      • DigestAuthenticator

        public DigestAuthenticator​(Context context,
                                   java.lang.String realm,
                                   java.lang.String serverKey)
        Constructor. By default, it set the "optional" property to 'false' and the "domainUris" property to a single '/' URI.
        Parameters:
        context - The context.
        realm - The authentication realm.
        serverKey - secret key known only to server
    • Method Detail

      • generateServerNonce

        public java.lang.String generateServerNonce()
        Generates a server nonce.
        Returns:
        A new server nonce.
      • getDomainRefs

        public java.util.List<Reference> getDomainRefs()
        Returns the base URI references that collectively define the protected domains for the digest authentication. By default, it returns a list with a single "/" URI reference.
        Returns:
        The base URI references.
      • getHashedSecret

        public java.lang.String getHashedSecret​(java.lang.String identifier,
                                                char[] secret)
        Return the hashed secret. By default, it knows how to hash HTTP DIGEST secrets, specified as A1 in section 3.2.2.2 of RFC2617, or null if the identifier has no corresponding secret.
        Parameters:
        identifier - The user identifier to hash.
        secret - The user secret.
        Returns:
        A hash of the user name, realm, and password.
      • getMaxServerNonceAge

        public long getMaxServerNonceAge()
        Returns the number of milliseconds between each mandatory nonce refresh.
        Returns:
        The server nonce lifespan.
      • getServerKey

        public java.lang.String getServerKey()
        Returns the secret key known only by server.
        Returns:
        The server secret key.
      • setDomainRefs

        public void setDomainRefs​(java.util.List<Reference> domainRefs)
        Sets the URI references that define the protection domains for the digest authentication.
        Parameters:
        domainRefs - The base URI references.
      • setMaxServerNonceAge

        public void setMaxServerNonceAge​(long maxServerNonceAge)
        Sets the number of milliseconds between each mandatory nonce refresh.
        Parameters:
        maxServerNonceAge - The nonce lifespan in milliseconds.
      • setServerKey

        public void setServerKey​(java.lang.String serverKey)
        Sets the secret key known only by server.
        Parameters:
        serverKey - The server secret key.
      • setWrappedAlgorithm

        public void setWrappedAlgorithm​(java.lang.String wrappedAlgorithm)
        Sets the digest algorithm of secrets returned by the wrapped verifier. The secrets from the wrapped verifier are the ones used by the verifier to compare those sent by clients when attempting to authenticate.
        Parameters:
        wrappedAlgorithm - The digest algorithm of secrets returned by the wrapped verifier.
        See Also:
        Digest
      • setWrappedVerifier

        public void setWrappedVerifier​(LocalVerifier localVerifier)
        Sets the secret verifier that will be wrapped by real verifier supporting all the HTTP DIGEST verifications (nonce, domain URIs, etc.).
        Parameters:
        localVerifier - The local verifier to wrap.