Class DigestCredentials

  • All Implemented Interfaces:
    java.io.Serializable

    public class DigestCredentials
    extends org.pac4j.core.credentials.TokenCredentials

    This credentials is retrieved from a HTTP request.

    A user profile can be attached with the credentials if it has been created by a Authenticator. In that case, the AuthenticatorProfileCreator must be used to retrieve the attached user profile.

    Since:
    1.9.0
    Author:
    Mircea Carasel
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      DigestCredentials​(java.lang.String token, java.lang.String httpMethod, java.lang.String username, java.lang.String realm, java.lang.String nonce, java.lang.String uri, java.lang.String cnonce, java.lang.String nc, java.lang.String qop)
      the token represents the client response attribute value in digest authorization header
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String calculateServerDigest​(boolean passwordAlreadyEncoded, java.lang.String password)
      This calculates the server digest value based on user stored password.
      boolean equals​(java.lang.Object o)  
      java.lang.String getUsername()  
      int hashCode()  
      java.lang.String toString()  
      • Methods inherited from class org.pac4j.core.credentials.TokenCredentials

        getToken
      • Methods inherited from class org.pac4j.core.credentials.Credentials

        getUserProfile, setUserProfile
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • DigestCredentials

        public DigestCredentials​(java.lang.String token,
                                 java.lang.String httpMethod,
                                 java.lang.String username,
                                 java.lang.String realm,
                                 java.lang.String nonce,
                                 java.lang.String uri,
                                 java.lang.String cnonce,
                                 java.lang.String nc,
                                 java.lang.String qop)
        the token represents the client response attribute value in digest authorization header
        Parameters:
        token - the token
        httpMethod - the HTTP method
        username - the user name
        realm - the realm
        nonce - nonce
        uri - uri
        cnonce - cnonce
        nc - nc
        qop - qop
    • Method Detail

      • calculateServerDigest

        public java.lang.String calculateServerDigest​(boolean passwordAlreadyEncoded,
                                                      java.lang.String password)
        This calculates the server digest value based on user stored password. If the server stores password in clear format then passwordAlreadyEncoded should be false. If the server stores the password in ha1, digest then the passwordAlreadyEncoded should be true.
        Parameters:
        passwordAlreadyEncoded - false if the server stored password is in clear, true otherwise
        password - user password stored server-side
        Returns:
        digest value. This value must match the client "response" value in the Authorization http header for a successful digest authentication
      • getUsername

        public java.lang.String getUsername()
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class org.pac4j.core.credentials.TokenCredentials
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class org.pac4j.core.credentials.TokenCredentials
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class org.pac4j.core.credentials.TokenCredentials