@Override public SecurityContext securityContext() { return currentTransaction.securityContext(); }
@Override public SecurityContext securityContext() { return transaction.securityContext(); }
@Override public SecurityContext securityContext() { return internal.securityContext(); }
@Override public String username() { return transaction.securityContext().subject().username(); }
@Test public void shouldAccessUsernameFromAuthSubject() { AuthSubject authSubject = mock( AuthSubject.class ); when( authSubject.username() ).thenReturn( "Christof" ); when( transaction.securityContext() ) .thenReturn( new SecurityContext( authSubject, AccessMode.Static.FULL ) ); TxStateTransactionDataSnapshot transactionDataSnapshot = snapshot(); assertEquals( "Christof", transactionDataSnapshot.username() ); }
when( statement.queryRegistration() ).thenReturn( registryOperations ); when( statementBridge.get() ).thenReturn( statement ); when( kernelTransaction.securityContext() ).thenReturn( loginContext.authorize( s -> -1, GraphDatabaseSettings.DEFAULT_DATABASE_NAME ) ); when( kernelTransaction.transactionType() ).thenReturn( type ); when( database.getGraph() ).thenReturn( databaseFacade );
@Override public GraphDatabaseService apply( Context context ) throws ProcedureException { KernelTransaction tx = context.getOrElse( Context.KERNEL_TRANSACTION, null ); SecurityContext securityContext; if ( tx != null ) { securityContext = tx.securityContext(); } else { securityContext = context.get( Context.SECURITY_CONTEXT ); } GraphDatabaseFacade facade = new GraphDatabaseFacade(); ProcedureGDBFacadeSPI procedureGDBFacadeSPI = new ProcedureGDBFacadeSPI( dataSource, dataSource.neoStoreDataSource.getDependencyResolver(), availability, urlValidator, securityContext, bridge ); facade.init( procedureGDBFacadeSPI, bridge, platform.config, tokenHolders ); return facade; } }
@Test public void shouldGetEmptyUsernameForAnonymousContext() { when( transaction.securityContext() ).thenReturn( AnonymousContext.read().authorize( s -> -1, GraphDatabaseSettings.DEFAULT_DATABASE_NAME ) ); TxStateTransactionDataSnapshot transactionDataSnapshot = snapshot(); assertEquals( "", transactionDataSnapshot.username() ); }
@Override protected long fetchNext() { ktx.assertOpen(); while ( cursor.next() ) { long reference = cursor.nodeReference(); if ( ktx.dataRead().nodeExists( reference ) ) { return reference; } else if ( ktx.securityContext().mode().allowsWrites() ) { //remove it from index so it doesn't happen again try { NODE.remove( ktx.indexWrite(), name, reference ); } catch ( ExplicitIndexNotFoundKernelException | InvalidTransactionTypeKernelException e ) { //ignore } } } close(); return NO_ID; }
@Override protected long fetchNext() { ktx.assertOpen(); while ( cursor.next() ) { long reference = cursor.relationshipReference(); if ( ktx.dataRead().relationshipExists( reference ) ) { return reference; } else if ( ktx.securityContext().mode().allowsWrites() ) { //remove it from index so it doesn't happen again try { RELATIONSHIP.remove( ktx.indexWrite(), name, reference ); } catch ( ExplicitIndexNotFoundKernelException | InvalidTransactionTypeKernelException e ) { //ignore } } } close(); return NO_ID; }
@Override public SecurityContext securityContext() { return transaction.securityContext(); }
@Override public SecurityContext securityContext() { return currentTransaction.securityContext(); }
@Override public String username() { return transaction.securityContext().subject().username(); }
@Override public GraphDatabaseService apply( Context context ) throws ProcedureException { KernelTransaction tx = context.getOrElse( Context.KERNEL_TRANSACTION, null ); SecurityContext securityContext; if ( tx != null ) { securityContext = tx.securityContext(); } else { securityContext = context.get( Context.SECURITY_CONTEXT ); } GraphDatabaseFacade facade = new GraphDatabaseFacade(); ProcedureGDBFacadeSPI procedureGDBFacadeSPI = new ProcedureGDBFacadeSPI( dataSource, dataSource.neoStoreDataSource.getDependencyResolver(), availability, urlValidator, securityContext, bridge ); facade.init( procedureGDBFacadeSPI, bridge, platform.config, tokenHolders ); return facade; } }
@Override protected long fetchNext() { ktx.assertOpen(); while ( cursor.next() ) { long reference = cursor.nodeReference(); if ( ktx.dataRead().nodeExists( reference ) ) { return reference; } else if ( ktx.securityContext().mode().allowsWrites() ) { //remove it from index so it doesn't happen again try { NODE.remove( ktx.indexWrite(), name, reference ); } catch ( ExplicitIndexNotFoundKernelException | InvalidTransactionTypeKernelException e ) { //ignore } } } close(); return NO_ID; }
@Override protected long fetchNext() { ktx.assertOpen(); while ( cursor.next() ) { long reference = cursor.relationshipReference(); if ( ktx.dataRead().relationshipExists( reference ) ) { return reference; } else if ( ktx.securityContext().mode().allowsWrites() ) { //remove it from index so it doesn't happen again try { RELATIONSHIP.remove( ktx.indexWrite(), name, reference ); } catch ( ExplicitIndexNotFoundKernelException | InvalidTransactionTypeKernelException e ) { //ignore } } } close(); return NO_ID; }