Search in sources :

Example 6 with PrincipalConfiguration

use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalConfiguration in project jackrabbit-oak by apache.

the class SecurityProviderImplTest method testUnbinPrincipalConfiguration.

@Test
public void testUnbinPrincipalConfiguration() {
    CompositePrincipalConfiguration cpc = (CompositePrincipalConfiguration) securityProvider.getConfiguration(PrincipalConfiguration.class);
    PrincipalConfiguration pc = Mockito.mock(PrincipalConfiguration.class);
    when(pc.getParameters()).thenReturn(ConfigurationParameters.EMPTY);
    securityProvider.bindPrincipalConfiguration(pc);
    assertTrue(cpc.getConfigurations().contains(pc));
    securityProvider.unbindPrincipalConfiguration(pc);
    assertFalse(cpc.getConfigurations().contains(pc));
}
Also used : CompositePrincipalConfiguration(org.apache.jackrabbit.oak.spi.security.principal.CompositePrincipalConfiguration) CompositePrincipalConfiguration(org.apache.jackrabbit.oak.spi.security.principal.CompositePrincipalConfiguration) PrincipalConfiguration(org.apache.jackrabbit.oak.spi.security.principal.PrincipalConfiguration) Test(org.junit.Test)

Example 7 with PrincipalConfiguration

use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalConfiguration in project jackrabbit-oak by apache.

the class SecurityProviderRegistrationTest method testPrincipalContext.

@Test
public void testPrincipalContext() throws Exception {
    Tree t = root.getTree("/");
    Field f = registration.getClass().getDeclaredField("principalConfiguration");
    f.setAccessible(true);
    PrincipalConfiguration pc = new PrincipalConfigurationImpl();
    registration.bindPrincipalConfiguration(pc, PROPS);
    CompositePrincipalConfiguration cpc = (CompositePrincipalConfiguration) f.get(registration);
    Context ctx = cpc.getContext();
    // expected size = 0 because PrincipalConfigurationImpl comes with the default ctx
    assertContext(ctx, 0, t, false);
    PrincipalConfiguration pc1 = mockConfiguration(PrincipalConfiguration.class);
    registration.bindPrincipalConfiguration(pc1, PROPS);
    cpc = (CompositePrincipalConfiguration) f.get(registration);
    ctx = cpc.getContext();
    // expected size 1 because the PrincipalConfigurationImpl comes with the default ctx
    assertContext(ctx, 1, t, true);
    PrincipalConfiguration pc2 = mockConfiguration(PrincipalConfiguration.class);
    registration.bindPrincipalConfiguration(pc2, PROPS);
    cpc = (CompositePrincipalConfiguration) f.get(registration);
    ctx = cpc.getContext();
    assertContext(ctx, 2, t, true);
    // unbind again:
    registration.unbindPrincipalConfiguration(pc, PROPS);
    cpc = (CompositePrincipalConfiguration) f.get(registration);
    ctx = cpc.getContext();
    assertContext(ctx, 2, t, true);
    registration.unbindPrincipalConfiguration(pc1, PROPS);
    cpc = (CompositePrincipalConfiguration) f.get(registration);
    ctx = cpc.getContext();
    assertContext(ctx, 1, t, true);
    registration.unbindPrincipalConfiguration(pc2, PROPS);
    cpc = (CompositePrincipalConfiguration) f.get(registration);
    ctx = cpc.getContext();
    assertContext(ctx, 0, t, false);
}
Also used : OsgiContext(org.apache.sling.testing.mock.osgi.junit.OsgiContext) Context(org.apache.jackrabbit.oak.spi.security.Context) Field(java.lang.reflect.Field) CompositePrincipalConfiguration(org.apache.jackrabbit.oak.spi.security.principal.CompositePrincipalConfiguration) CompositePrincipalConfiguration(org.apache.jackrabbit.oak.spi.security.principal.CompositePrincipalConfiguration) PrincipalConfiguration(org.apache.jackrabbit.oak.spi.security.principal.PrincipalConfiguration) Tree(org.apache.jackrabbit.oak.api.Tree) PrincipalConfigurationImpl(org.apache.jackrabbit.oak.security.principal.PrincipalConfigurationImpl) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 8 with PrincipalConfiguration

use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalConfiguration in project jackrabbit-oak by apache.

the class InternalSecurityProviderTest method testDefaultPrincipalConfiguration.

@Test
public void testDefaultPrincipalConfiguration() {
    PrincipalConfiguration defaultConfig = securityProvider.getConfiguration(PrincipalConfiguration.class);
    assertNull(defaultConfig);
}
Also used : PrincipalConfiguration(org.apache.jackrabbit.oak.spi.security.principal.PrincipalConfiguration) Test(org.junit.Test)

Aggregations

PrincipalConfiguration (org.apache.jackrabbit.oak.spi.security.principal.PrincipalConfiguration)8 Test (org.junit.Test)5 CompositePrincipalConfiguration (org.apache.jackrabbit.oak.spi.security.principal.CompositePrincipalConfiguration)3 RepositoryException (javax.jcr.RepositoryException)2 SecurityConfiguration (org.apache.jackrabbit.oak.spi.security.SecurityConfiguration)2 AuthorizationConfiguration (org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration)2 IOException (java.io.IOException)1 Field (java.lang.reflect.Field)1 CheckForNull (javax.annotation.CheckForNull)1 UnsupportedCallbackException (javax.security.auth.callback.UnsupportedCallbackException)1 JackrabbitSession (org.apache.jackrabbit.api.JackrabbitSession)1 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)1 Root (org.apache.jackrabbit.oak.api.Root)1 Tree (org.apache.jackrabbit.oak.api.Tree)1 PrincipalConfigurationImpl (org.apache.jackrabbit.oak.security.principal.PrincipalConfigurationImpl)1 ConfigurationParameters (org.apache.jackrabbit.oak.spi.security.ConfigurationParameters)1 Context (org.apache.jackrabbit.oak.spi.security.Context)1 SecurityProvider (org.apache.jackrabbit.oak.spi.security.SecurityProvider)1 PrincipalProviderCallback (org.apache.jackrabbit.oak.spi.security.authentication.callback.PrincipalProviderCallback)1 PrincipalProvider (org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider)1