Class AuthCredentials


  • public final class AuthCredentials
    extends Object
    AuthCredentials are an abstraction to encapsulate credentials like passwords or generic native credentials like GSS tokens.
    • Constructor Detail

      • AuthCredentials

        public AuthCredentials​(String username,
                               Object nativeCredentials)
        Create new credentials with a username and native credentials
        Parameters:
        username - The username, must not be null or empty
        nativeCredentials - Arbitrary credentials (like GSS tokens), must not be null
        Throws:
        IllegalArgumentException - if username or nativeCredentials are null or empty
      • AuthCredentials

        public AuthCredentials​(String username,
                               byte[] password)
        Create new credentials with a username and password
        Parameters:
        username - The username, must not be null or empty
        password - The password, must not be null or empty
        Throws:
        IllegalArgumentException - if username or password is null or empty
      • AuthCredentials

        public AuthCredentials​(String username,
                               String... backendRoles)
        Create new credentials with a username, a initial optional set of roles and empty password/native credentials
        Parameters:
        username - The username, must not be null or empty
        backendRoles - set of roles this user is a member of
        Throws:
        IllegalArgumentException - if username is null or empty
    • Method Detail

      • clearSecrets

        public void clearSecrets()
        Wipe password and native credentials
      • getUsername

        public String getUsername()
      • getPassword

        public byte[] getPassword()
        Returns:
        Defensive copy of the password
      • getNativeCredentials

        public Object getNativeCredentials()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getBackendRoles

        public Set<String> getBackendRoles()
        Returns:
        Defensive copy of the roles this user is member of.
      • isComplete

        public boolean isComplete()
      • markComplete

        public AuthCredentials markComplete()
        If the credentials are complete and no further roundtrips with the originator are due then this method must be called so that the authentication flow can proceed.

        If this credentials are already marked a complete then a call to this method does nothing.

        Returns:
        this
      • addAttribute

        public void addAttribute​(String name,
                                 String value)