use of org.neo4j.internal.kernel.api.security.AuthenticationResult in project neo4j by neo4j.
the class BasicSystemGraphRealm method login.
@Override
public LoginContext login(Map<String, Object> authToken, ClientConnectionInfo connectionInfo) throws InvalidAuthTokenException {
try {
assertValidScheme(authToken);
String username = AuthToken.safeCast(AuthToken.PRINCIPAL, authToken);
byte[] password = AuthToken.safeCastCredentials(AuthToken.CREDENTIALS, authToken);
try {
User user = systemGraphRealmHelper.getUser(username);
AuthenticationResult result = authenticationStrategy.authenticate(user, password);
if (result == AuthenticationResult.SUCCESS && user.passwordChangeRequired()) {
result = AuthenticationResult.PASSWORD_CHANGE_REQUIRED;
}
return new BasicLoginContext(user, result, connectionInfo);
} catch (InvalidArgumentsException | FormatException e) {
return new BasicLoginContext(null, AuthenticationResult.FAILURE, connectionInfo);
}
} finally {
AuthToken.clearCredentials(authToken);
}
}
Aggregations