use of org.neo4j.internal.kernel.api.security.AbstractSecurityLog in project neo4j by neo4j.
the class CommunityEditionModule method setupSecurityGraphInitializer.
private void setupSecurityGraphInitializer(GlobalModule globalModule) {
Config config = globalModule.getGlobalConfig();
FileSystemAbstraction fileSystem = globalModule.getFileSystem();
LogProvider logProvider = globalModule.getLogService().getUserLogProvider();
AbstractSecurityLog securityLog = new CommunitySecurityLog((LogExtended) logProvider.getLog(UserSecurityGraphComponent.class));
var communityComponent = CommunitySecurityModule.createSecurityComponent(securityLog, config, fileSystem, logProvider);
Dependencies dependencies = globalModule.getGlobalDependencies();
SystemGraphComponents systemGraphComponents = dependencies.resolveDependency(SystemGraphComponents.class);
systemGraphComponents.register(communityComponent);
}
use of org.neo4j.internal.kernel.api.security.AbstractSecurityLog in project neo4j by neo4j.
the class TransactionEventsIT method shouldGetSpecifiedUsernameAndMetaDataInTXData.
@Test
void shouldGetSpecifiedUsernameAndMetaDataInTXData() {
final AtomicReference<String> usernameRef = new AtomicReference<>();
final AtomicReference<Map<String, Object>> metaDataRef = new AtomicReference<>();
dbms.registerTransactionEventListener(DEFAULT_DATABASE_NAME, getBeforeCommitListener(txData -> {
usernameRef.set(txData.username());
metaDataRef.set(txData.metaData());
}));
AuthSubject subject = mock(AuthSubject.class);
when(subject.username()).thenReturn("Christof");
LoginContext loginContext = new LoginContext(subject, EMBEDDED_CONNECTION) {
@Override
public SecurityContext authorize(IdLookup idLookup, String dbName, AbstractSecurityLog securityLog) {
return new SecurityContext(subject, AccessMode.Static.WRITE, EMBEDDED_CONNECTION, dbName);
}
};
Map<String, Object> metadata = genericMap("username", "joe");
runTransaction(loginContext, metadata);
assertThat(usernameRef.get()).as("Should have specified username").isEqualTo("Christof");
assertThat(metaDataRef.get()).as("Should have metadata with specified username").isEqualTo(metadata);
}
Aggregations