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;
}
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;
}
}
Aggregations