Search in sources :

Example 1 with BoltStateMachineSPI

use of org.neo4j.bolt.runtime.statemachine.BoltStateMachineSPI in project neo4j by neo4j.

the class BoltV4MachineRoom method newMachineWithTransactionSPI.

public static BoltStateMachine newMachineWithTransactionSPI(TransactionStateMachineSPI transactionSPI) throws BoltConnectionFatality, BoltIOException {
    BoltStateMachineSPI spi = mock(BoltStateMachineSPI.class, RETURNS_MOCKS);
    TransactionStateMachineSPIProvider transactionSPIProvider = mock(TransactionStateMachineSPIProvider.class);
    var memoryTracker = mock(MemoryTracker.class);
    when(transactionSPIProvider.getTransactionStateMachineSPI(any(String.class), any(StatementProcessorReleaseManager.class))).thenReturn(transactionSPI);
    when(spi.transactionStateMachineSPIProvider()).thenReturn(transactionSPIProvider);
    BoltChannel boltChannel = BoltTestUtil.newTestBoltChannel();
    BoltStateMachine machine = new BoltStateMachineV4(spi, boltChannel, Clock.systemUTC(), mock(DefaultDatabaseResolver.class), MapValue.EMPTY, memoryTracker);
    init(machine);
    return machine;
}
Also used : StatementProcessorReleaseManager(org.neo4j.bolt.runtime.statemachine.StatementProcessorReleaseManager) BoltStateMachine(org.neo4j.bolt.runtime.statemachine.BoltStateMachine) BoltChannel(org.neo4j.bolt.BoltChannel) BoltStateMachineV4(org.neo4j.bolt.v4.BoltStateMachineV4) DefaultDatabaseResolver(org.neo4j.kernel.database.DefaultDatabaseResolver) BoltStateMachineSPI(org.neo4j.bolt.runtime.statemachine.BoltStateMachineSPI) TransactionStateMachineSPIProvider(org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPIProvider)

Example 2 with BoltStateMachineSPI

use of org.neo4j.bolt.runtime.statemachine.BoltStateMachineSPI 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)2 BoltChannel (org.neo4j.bolt.BoltChannel)1 BoltStateMachine (org.neo4j.bolt.runtime.statemachine.BoltStateMachine)1 StatementProcessorReleaseManager (org.neo4j.bolt.runtime.statemachine.StatementProcessorReleaseManager)1 TransactionStateMachineSPIProvider (org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPIProvider)1 AuthenticationResult (org.neo4j.bolt.security.auth.AuthenticationResult)1 BoltStateMachineV4 (org.neo4j.bolt.v4.BoltStateMachineV4)1 DefaultDatabaseResolver (org.neo4j.kernel.database.DefaultDatabaseResolver)1