Search in sources :

Example 1 with CommunitySecurityLog

use of org.neo4j.internal.kernel.api.security.CommunitySecurityLog 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);
}
Also used : SystemGraphComponents(org.neo4j.dbms.database.SystemGraphComponents) LogProvider(org.neo4j.logging.LogProvider) CommunitySecurityLog(org.neo4j.internal.kernel.api.security.CommunitySecurityLog) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) Config(org.neo4j.configuration.Config) AbstractSecurityLog(org.neo4j.internal.kernel.api.security.AbstractSecurityLog) Dependencies(org.neo4j.collection.Dependencies)

Example 2 with CommunitySecurityLog

use of org.neo4j.internal.kernel.api.security.CommunitySecurityLog in project neo4j by neo4j.

the class OperationsTest method setUp.

@BeforeEach
void setUp() throws Exception {
    TxState realTxState = new TxState();
    txState = Mockito.spy(realTxState);
    when(transaction.getReasonIfTerminated()).thenReturn(Optional.empty());
    when(transaction.lockClient()).thenReturn(locks);
    when(transaction.dataWrite()).thenReturn(write);
    when(transaction.isOpen()).thenReturn(true);
    when(transaction.lockTracer()).thenReturn(LockTracer.NONE);
    when(transaction.txState()).thenReturn(txState);
    when(transaction.securityContext()).thenReturn(SecurityContext.authDisabled(AccessMode.Static.FULL, EMBEDDED_CONNECTION, DB_NAME));
    logHelper = new SecurityLogHelper(getFormat());
    securityLog = new CommunitySecurityLog((LogExtended) logHelper.getLogProvider().getLog(this.getClass()));
    when(transaction.securityAuthorizationHandler()).thenReturn(new SecurityAuthorizationHandler(securityLog));
    DefaultPooledCursors cursors = mock(DefaultPooledCursors.class);
    nodeCursor = mock(FullAccessNodeCursor.class);
    propertyCursor = mock(FullAccessPropertyCursor.class);
    relationshipCursor = mock(DefaultRelationshipScanCursor.class);
    when(cursors.allocateFullAccessNodeCursor(NULL)).thenReturn(nodeCursor);
    when(cursors.allocateFullAccessPropertyCursor(NULL, INSTANCE)).thenReturn(propertyCursor);
    when(cursors.allocateRelationshipScanCursor(NULL)).thenReturn(relationshipCursor);
    StorageEngine engine = mock(StorageEngine.class);
    storageReader = mock(StorageReader.class);
    storageReaderSnapshot = mock(StorageSchemaReader.class);
    when(storageReader.nodeExists(anyLong(), any())).thenReturn(true);
    when(storageReader.constraintsGetForLabel(anyInt())).thenReturn(Collections.emptyIterator());
    when(storageReader.constraintsGetAll()).thenReturn(Collections.emptyIterator());
    when(storageReader.schemaSnapshot()).thenReturn(storageReaderSnapshot);
    when(engine.newReader()).thenReturn(storageReader);
    indexingService = mock(IndexingService.class);
    Dependencies dependencies = new Dependencies();
    var facade = mock(GraphDatabaseFacade.class);
    dependencies.satisfyDependency(facade);
    allStoreHolder = new AllStoreHolder(storageReader, transaction, cursors, mock(GlobalProcedures.class), mock(SchemaState.class), indexingService, mock(IndexStatisticsStore.class), dependencies, Config.defaults(), INSTANCE);
    constraintIndexCreator = mock(ConstraintIndexCreator.class);
    tokenHolders = mockedTokenHolders();
    creationContext = mock(CommandCreationContext.class);
    IndexingProvidersService indexingProvidersService = mock(IndexingProvidersService.class);
    when(indexingProvidersService.indexProviderByName("native-btree-1.0")).thenReturn(GenericNativeIndexProvider.DESCRIPTOR);
    when(indexingProvidersService.getDefaultProvider()).thenReturn(GenericNativeIndexProvider.DESCRIPTOR);
    when(indexingProvidersService.indexProviderByName("fulltext-1.0")).thenReturn(FulltextIndexProviderFactory.DESCRIPTOR);
    when(indexingProvidersService.getFulltextProvider()).thenReturn(FulltextIndexProviderFactory.DESCRIPTOR);
    when(indexingProvidersService.indexProviderByName("provider-1.0")).thenReturn(new IndexProviderDescriptor("provider", "1.0"));
    when(indexingProvidersService.completeConfiguration(any())).thenAnswer(inv -> inv.getArgument(0));
    operations = new Operations(allStoreHolder, storageReader, mock(IndexTxStateUpdater.class), creationContext, transaction, new KernelToken(storageReader, creationContext, transaction, tokenHolders), cursors, constraintIndexCreator, mock(ConstraintSemantics.class), indexingProvidersService, Config.defaults(), INSTANCE, () -> KernelVersion.LATEST, mock(DbmsRuntimeRepository.class));
    operations.initialize(NULL);
    this.order = inOrder(locks, txState, storageReader, storageReaderSnapshot, creationContext);
}
Also used : StorageReader(org.neo4j.storageengine.api.StorageReader) CommunitySecurityLog(org.neo4j.internal.kernel.api.security.CommunitySecurityLog) IndexingProvidersService(org.neo4j.kernel.impl.api.index.IndexingProvidersService) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) SecurityLogHelper(org.neo4j.logging.SecurityLogHelper) LogExtended(org.neo4j.logging.log4j.LogExtended) StorageEngine(org.neo4j.storageengine.api.StorageEngine) SecurityAuthorizationHandler(org.neo4j.internal.kernel.api.security.SecurityAuthorizationHandler) CommandCreationContext(org.neo4j.storageengine.api.CommandCreationContext) ConstraintIndexCreator(org.neo4j.kernel.impl.api.state.ConstraintIndexCreator) StorageSchemaReader(org.neo4j.storageengine.api.StorageSchemaReader) TxState(org.neo4j.kernel.impl.api.state.TxState) IndexingService(org.neo4j.kernel.impl.api.index.IndexingService) Dependencies(org.neo4j.collection.Dependencies) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

Dependencies (org.neo4j.collection.Dependencies)2 CommunitySecurityLog (org.neo4j.internal.kernel.api.security.CommunitySecurityLog)2 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Config (org.neo4j.configuration.Config)1 SystemGraphComponents (org.neo4j.dbms.database.SystemGraphComponents)1 AbstractSecurityLog (org.neo4j.internal.kernel.api.security.AbstractSecurityLog)1 SecurityAuthorizationHandler (org.neo4j.internal.kernel.api.security.SecurityAuthorizationHandler)1 IndexProviderDescriptor (org.neo4j.internal.schema.IndexProviderDescriptor)1 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)1 IndexingProvidersService (org.neo4j.kernel.impl.api.index.IndexingProvidersService)1 IndexingService (org.neo4j.kernel.impl.api.index.IndexingService)1 ConstraintIndexCreator (org.neo4j.kernel.impl.api.state.ConstraintIndexCreator)1 TxState (org.neo4j.kernel.impl.api.state.TxState)1 LogProvider (org.neo4j.logging.LogProvider)1 SecurityLogHelper (org.neo4j.logging.SecurityLogHelper)1 LogExtended (org.neo4j.logging.log4j.LogExtended)1 CommandCreationContext (org.neo4j.storageengine.api.CommandCreationContext)1 StorageEngine (org.neo4j.storageengine.api.StorageEngine)1 StorageReader (org.neo4j.storageengine.api.StorageReader)1 StorageSchemaReader (org.neo4j.storageengine.api.StorageSchemaReader)1