Search in sources :

Example 1 with AuthenticationResult

use of org.neo4j.bolt.security.auth.AuthenticationResult in project neo4j by neo4j.

the class BoltAuthenticationHelper method processAuthentication.

public static boolean processAuthentication(String userAgent, Map<String, Object> authToken, StateMachineContext context, RoutingContext routingContext) throws BoltConnectionFatality {
    try {
        BoltStateMachineSPI boltSpi = context.boltSpi();
        AuthenticationResult authResult = boltSpi.authenticate(authToken);
        String username = authResult.getLoginContext().subject().username();
        context.authenticatedAsUser(username, userAgent);
        context.initStatementProcessorProvider(authResult, routingContext);
        if (authResult.credentialsExpired()) {
            context.connectionState().onMetadata("credentials_expired", Values.TRUE);
        }
        context.connectionState().onMetadata("server", Values.utf8Value(boltSpi.version()));
        return true;
    } catch (Throwable t) {
        context.handleFailure(t, true);
        return false;
    }
}
Also used : BoltStateMachineSPI(org.neo4j.bolt.runtime.statemachine.BoltStateMachineSPI) AuthenticationResult(org.neo4j.bolt.security.auth.AuthenticationResult)

Aggregations

BoltStateMachineSPI (org.neo4j.bolt.runtime.statemachine.BoltStateMachineSPI)1 AuthenticationResult (org.neo4j.bolt.security.auth.AuthenticationResult)1