Package com.floragunn.searchguard.user
Class AuthCredentials
- java.lang.Object
-
- com.floragunn.searchguard.user.AuthCredentials
-
public final class AuthCredentials extends Object
AuthCredentials are an abstraction to encapsulate credentials like passwords or generic native credentials like GSS tokens.
-
-
Constructor Summary
Constructors Constructor Description AuthCredentials(String username, byte[] password)Create new credentials with a username and passwordAuthCredentials(String username, Object nativeCredentials)Create new credentials with a username and native credentialsAuthCredentials(String username, String... backendRoles)Create new credentials with a username, a initial optional set of roles and empty password/native credentials
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAttribute(String name, String value)voidclearSecrets()Wipe password and native credentialsbooleanequals(Object obj)Map<String,String>getAttributes()Set<String>getBackendRoles()ObjectgetNativeCredentials()byte[]getPassword()StringgetUsername()inthashCode()booleanisComplete()AuthCredentialsmarkComplete()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.StringtoString()
-
-
-
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 emptynativeCredentials- 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 emptypassword- 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 emptybackendRoles- 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()
-
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
-
-