public final class InMemoryAuthenticator extends Object implements Authenticator<CredentialsUsernamePassword,Boolean>
Authenticator
.
Note that this implementation stores passwords in plain text in memory and is therefor only suitable for examples or very trivial, non-security-critical use cases.
Modifier and Type | Class and Description |
---|---|
static interface |
InMemoryAuthenticator.Provider
An
InMemoryAuthenticator -specific provider type. |
Modifier and Type | Method and Description |
---|---|
Boolean |
authenticate(CredentialsUsernamePassword credentials)
Returns
Boolean.FALSE if the attempt to authenticate the passed
credentials fails, Boolean.TRUE otherwise. |
boolean |
authenticate(String username,
String password) |
static InMemoryAuthenticator |
New(KeyValue<String,String>... usernamePasswords)
Creates a new
InMemoryAuthenticator instance using a copy of the
passed username/password array. |
static InMemoryAuthenticator |
New(Map<String,String> usernamePasswords)
Creates a new
InMemoryAuthenticator instance using a copy of the
passed username/password map. |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
lambda, sequence, then
public static final InMemoryAuthenticator New(Map<String,String> usernamePasswords)
InMemoryAuthenticator
instance using a copy of the
passed username/password map. The entries are interpreted as the keys
representing the key and the associated value representing the associated
password.usernamePasswords
- the username/password data.InMemoryAuthenticator
instance using the passed
data as a user inventory.@SafeVarargs public static final InMemoryAuthenticator New(KeyValue<String,String>... usernamePasswords)
InMemoryAuthenticator
instance using a copy of the
passed username/password array. The entries are interpreted as the keys
representing the key and the associated value representing the associated
password.usernamePasswords
- the username/password data.InMemoryAuthenticator
instance using the passed
data as a user inventory.public final boolean authenticate(String username, String password) throws AuthenticationFailedException
AuthenticationFailedException
public final Boolean authenticate(CredentialsUsernamePassword credentials) throws AuthenticationFailedException
Boolean.FALSE
if the attempt to authenticate the passed
credentials fails, Boolean.TRUE
otherwise.authenticate
in interface Authenticator<CredentialsUsernamePassword,Boolean>
credentials
- the credentials instance to be authenticated.Boolean
instance indicating the result of the
authentication attempt.AuthenticationFailedException
- never gets thrown in this simple implementation.