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);
}
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);
}
}
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);
}
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());
}
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();
}
}
}
Aggregations