Search in sources :

Example 1 with PrincipalProvider

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

the class ExternalPrincipalConfigurationTest method testGetPrincipalProvider.

@Test
public void testGetPrincipalProvider() throws Exception {
    PrincipalProvider pp = principalConfiguration.getPrincipalProvider(root, NamePathMapper.DEFAULT);
    assertNotNull(pp);
    assertFalse(pp instanceof ExternalGroupPrincipalProvider);
}
Also used : PrincipalProvider(org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider) AbstractExternalAuthTest(org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest) Test(org.junit.Test)

Example 2 with PrincipalProvider

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

the class PrincipalConfigurationImpl method getPrincipalProvider.

@Nonnull
@Override
public PrincipalProvider getPrincipalProvider(Root root, NamePathMapper namePathMapper) {
    UserConfiguration uc = getSecurityProvider().getConfiguration(UserConfiguration.class);
    PrincipalProvider principalProvider = uc.getUserPrincipalProvider(root, namePathMapper);
    if (principalProvider != null) {
        // use user-implementation specific principal provider implementation
        return principalProvider;
    } else {
        // use default implementation acting on user management API
        return new PrincipalProviderImpl(root, uc, namePathMapper);
    }
}
Also used : PrincipalProvider(org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider) UserConfiguration(org.apache.jackrabbit.oak.spi.security.user.UserConfiguration) Nonnull(javax.annotation.Nonnull)

Example 3 with PrincipalProvider

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

the class AbstractLoginModuleTest method testGetPrincipals.

@Test
public void testGetPrincipals() {
    PrincipalProvider principalProvider = new TestPrincipalProvider();
    AbstractLoginModule loginModule = initLoginModule(TestCredentials.class, new TestCallbackHandler(principalProvider));
    Principal principal = principalProvider.findPrincipals(PrincipalManager.SEARCH_TYPE_NOT_GROUP).next();
    String userId = TestPrincipalProvider.getIDFromPrincipal(principal);
    Set<? extends Principal> principals = loginModule.getPrincipals(userId);
    assertFalse(principals.isEmpty());
    assertEquals(principalProvider.getPrincipals(userId), principals);
}
Also used : TestPrincipalProvider(org.apache.jackrabbit.oak.spi.security.principal.TestPrincipalProvider) PrincipalProvider(org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider) TestPrincipalProvider(org.apache.jackrabbit.oak.spi.security.principal.TestPrincipalProvider) Principal(java.security.Principal) Test(org.junit.Test)

Example 4 with PrincipalProvider

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

the class PrincipalProviderCallbackTest method testCallback.

@Test
public void testCallback() {
    PrincipalProviderCallback cb = new PrincipalProviderCallback();
    PrincipalProvider principalProvider = Mockito.mock(PrincipalProvider.class);
    cb.setPrincipalProvider(principalProvider);
    assertSame(principalProvider, cb.getPrincipalProvider());
}
Also used : PrincipalProvider(org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider) Test(org.junit.Test)

Example 5 with PrincipalProvider

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

the class UserPrincipalProviderWithCacheTest method testGroupPrincipalNameEscape.

@Test
public void testGroupPrincipalNameEscape() throws Exception {
    String gId = null;
    try {
        Principal groupPrincipal = new PrincipalImpl(groupId + ",,%,%%");
        Group gr = getUserManager(root).createGroup(groupPrincipal);
        gId = gr.getID();
        gr.addMember(getTestUser());
        root.commit();
        systemRoot.refresh();
        PrincipalProvider pp = createPrincipalProvider(systemRoot);
        Set<? extends Principal> principals = pp.getPrincipals(userId);
        assertTrue(principals.contains(groupPrincipal));
        principals = pp.getPrincipals(userId);
        assertTrue(principals.contains(groupPrincipal));
    } finally {
        root.refresh();
        if (gId != null) {
            getUserManager(root).getAuthorizable(gId).remove();
            root.commit();
        }
    }
}
Also used : Group(org.apache.jackrabbit.api.security.user.Group) PrincipalProvider(org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider) EveryonePrincipal(org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal) Principal(java.security.Principal) PrincipalImpl(org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl) AbstractPrincipalProviderTest(org.apache.jackrabbit.oak.security.principal.AbstractPrincipalProviderTest) Test(org.junit.Test)

Aggregations

PrincipalProvider (org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider)30 Test (org.junit.Test)26 AbstractPrincipalProviderTest (org.apache.jackrabbit.oak.security.principal.AbstractPrincipalProviderTest)16 Tree (org.apache.jackrabbit.oak.api.Tree)10 Principal (java.security.Principal)6 Group (org.apache.jackrabbit.api.security.user.Group)5 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)4 Nonnull (javax.annotation.Nonnull)3 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)3 Root (org.apache.jackrabbit.oak.api.Root)3 EveryonePrincipal (org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal)3 TestPrincipalProvider (org.apache.jackrabbit.oak.spi.security.principal.TestPrincipalProvider)3 HashSet (java.util.HashSet)2 UserManager (org.apache.jackrabbit.api.security.user.UserManager)2 SecurityProvider (org.apache.jackrabbit.oak.spi.security.SecurityProvider)2 AbstractExternalAuthTest (org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest)2 PrincipalConfiguration (org.apache.jackrabbit.oak.spi.security.principal.PrincipalConfiguration)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 CheckForNull (javax.annotation.CheckForNull)1