Class UserCredential

  • All Implemented Interfaces:
    TokenCredential

    public final class UserCredential
    extends Credential
    implements TokenCredential
    Represents a named user credential. User credentials will be used to authenticate against HTTP-secured services, and to generate tokens for authenticating token-secured services.
    Since:
    100.0.0
    • Constructor Detail

      • UserCredential

        public UserCredential​(String username,
                              String password)
        Constructs a UserCredential with the specified username and password. The username and password will be used for authenticating against services.
        Parameters:
        username - the user name of the user
        password - the password of the user
        Throws:
        IllegalArgumentException - if the username or password is null or empty
        Since:
        100.0.0
      • UserCredential

        public UserCredential​(String username,
                              String password,
                              String referer)
        Constructs a UserCredential with the specified username, password, and referer. The username and password will be used for authenticating against services, while the referer indicates the entity on behalf of which authentication is requested.
        Parameters:
        username - the user name of the user
        password - the password of the user
        referer - the referer
        Throws:
        IllegalArgumentException - if the username or password is null or empty
        Since:
        100.0.0
    • Method Detail

      • createFromToken

        public static UserCredential createFromToken​(String token,
                                                     String referer)
        Creates a UserCredential with the specified token and referer. The token will be used for authenticating against services, while the referer indicates the entity on behalf of which authentication is requested.
        Parameters:
        token - the token with which to authenticate
        referer - the referer
        Throws:
        IllegalArgumentException - if the token is null or empty
        IllegalArgumentException - if the referer is null or empty
        Since:
        100.1.0
      • setUsername

        public void setUsername​(String username)
        Sets the username of the credential.
        Parameters:
        username - the username to set
        Throws:
        IllegalArgumentException - if username is null or empty
        Since:
        100.0.0
      • getPassword

        public String getPassword()
        Gets the password to use for authenticating with this credential.
        Returns:
        the password
        Since:
        100.0.0
      • setPassword

        public void setPassword​(String password)
        Sets the password to use for authenticating with this credential.
        Parameters:
        password - the password to set
        Throws:
        IllegalArgumentException - if password is null or empty
        Since:
        100.0.0
      • getReferer

        public String getReferer()
        Gets the referer of this credential, that is the entity that is using the credential to authenticate.
        Returns:
        the referer
        Since:
        100.0.0
      • setReferer

        public void setReferer​(String referer)
        Sets the referer of this credential, that is the entity that is using the credential to authenticate.
        Parameters:
        referer - the referer to set
        Since:
        100.0.0
      • equals

        public boolean equals​(Object o)
        Compares this instance with the specified object and indicates if they are equal. In order to be equal, o must represent the same object as this instance using a class-specific comparison. The general contract is that this comparison should be reflexive, symmetric, and transitive. Also, no object reference other than null is equal to null.
        Overrides:
        equals in class Object
        Parameters:
        o - the object to compare this instance with.
        Returns:
        true if the specified object is equal to this Object; false otherwise.
        See Also:
        hashCode()
      • copy

        public UserCredential copy()
        Creates a deep copy of this UserCredential instance.
        Specified by:
        copy in class Credential
        Returns:
        a deep copy of this UserCredential instance
        Since:
        100.1.0