Search in sources :

Example 16 with EnterpriseSecurityContext

use of org.neo4j.kernel.enterprise.api.security.EnterpriseSecurityContext in project neo4j by neo4j.

the class LdapCachingTest method shouldInvalidateAuthorizationCacheAfterTTL.

@Test
public void shouldInvalidateAuthorizationCacheAfterTTL() throws InvalidAuthTokenException {
    // Given
    EnterpriseSecurityContext mike = authManager.login(authToken("mike", "123"));
    mike.mode().allowsReads();
    assertThat("Test realm did not receive a call", testRealm.takeAuthorizationFlag(), is(true));
    // When
    fakeTicker.advance(99, TimeUnit.MILLISECONDS);
    mike.mode().allowsWrites();
    // Then
    assertThat("Test realm received a call", testRealm.takeAuthorizationFlag(), is(false));
    // When
    fakeTicker.advance(2, TimeUnit.MILLISECONDS);
    mike.mode().allowsWrites();
    // Then
    assertThat("Test realm did not received a call", testRealm.takeAuthorizationFlag(), is(true));
}
Also used : EnterpriseSecurityContext(org.neo4j.kernel.enterprise.api.security.EnterpriseSecurityContext) Test(org.junit.Test)

Example 17 with EnterpriseSecurityContext

use of org.neo4j.kernel.enterprise.api.security.EnterpriseSecurityContext in project neo4j by neo4j.

the class UserManagementProceduresLoggingTest method setUp.

@Before
public void setUp() throws Throwable {
    log = new AssertableLogProvider();
    SecurityLog securityLog = new SecurityLog(log.getLog(getClass()));
    authProcedures = new TestUserManagementProcedures();
    authProcedures.graph = mock(GraphDatabaseAPI.class);
    authProcedures.securityLog = securityLog;
    generalUserManager = getUserManager();
    EnterpriseSecurityContext adminContext = new TestSecurityContext("admin", true, generalUserManager);
    matsContext = new TestSecurityContext("mats", false, generalUserManager);
    setSubject(adminContext);
}
Also used : EnterpriseSecurityContext(org.neo4j.kernel.enterprise.api.security.EnterpriseSecurityContext) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) SecurityLog(org.neo4j.server.security.enterprise.log.SecurityLog) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Before(org.junit.Before)

Aggregations

EnterpriseSecurityContext (org.neo4j.kernel.enterprise.api.security.EnterpriseSecurityContext)17 Test (org.junit.Test)14 Matchers.containsString (org.hamcrest.Matchers.containsString)3 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)3 GraphDatabaseFacade (org.neo4j.kernel.impl.factory.GraphDatabaseFacade)3 Before (org.junit.Before)2 ResourceIterator (org.neo4j.graphdb.ResourceIterator)2 RestrictedAccessMode (org.neo4j.kernel.impl.api.security.RestrictedAccessMode)2 EmbeddedInteraction (org.neo4j.server.security.enterprise.auth.EmbeddedInteraction)2 AuthenticationException (org.apache.shiro.authc.AuthenticationException)1 ExcessiveAttemptsException (org.apache.shiro.authc.ExcessiveAttemptsException)1 UnsupportedTokenException (org.apache.shiro.authc.pam.UnsupportedTokenException)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 QueryExecutionException (org.neo4j.graphdb.QueryExecutionException)1 Result (org.neo4j.graphdb.Result)1 AuthProviderTimeoutException (org.neo4j.graphdb.security.AuthProviderTimeoutException)1 AuthSubject (org.neo4j.kernel.api.security.AuthSubject)1 InvalidAuthTokenException (org.neo4j.kernel.api.security.exception.InvalidAuthTokenException)1 EnterpriseAuthManager (org.neo4j.kernel.enterprise.api.security.EnterpriseAuthManager)1 OverriddenAccessMode (org.neo4j.kernel.impl.api.security.OverriddenAccessMode)1