use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider in project jackrabbit-oak by apache.
the class AbstractLoginModuleTest method testGetPrincipalProviderFromCallback.
@Test
public void testGetPrincipalProviderFromCallback() {
AbstractLoginModule loginModule = initLoginModule(TestCredentials.class, new TestCallbackHandler(new TestPrincipalProvider()));
assertNotNull(loginModule.getPrincipalProvider());
PrincipalProvider principalProvider = loginModule.getPrincipalProvider();
assertNotNull(principalProvider);
// principalProvider is stored as field -> second access returns the same object
assertSame(principalProvider, loginModule.getPrincipalProvider());
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider in project jackrabbit-oak by apache.
the class AbstractLoginModuleTest method testGetPrincipalsFromPrincipal.
@Test
public void testGetPrincipalsFromPrincipal() {
PrincipalProvider principalProvider = new TestPrincipalProvider();
AbstractLoginModule loginModule = initLoginModule(TestCredentials.class, new TestCallbackHandler(principalProvider));
Principal principal = principalProvider.findPrincipals(PrincipalManager.SEARCH_TYPE_NOT_GROUP).next();
Set<Principal> expected = new HashSet<>();
expected.add(principal);
expected.addAll(principalProvider.getGroupMembership(principal));
Set<? extends Principal> principals = loginModule.getPrincipals(principal);
assertFalse(principals.isEmpty());
assertEquals(expected, principals);
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider in project jackrabbit-oak by apache.
the class LdapLoginTestBase method testPrincipalsFromAuthInfo.
@Test
public void testPrincipalsFromAuthInfo() throws Exception {
ContentSession cs = null;
try {
SimpleCredentials sc = new SimpleCredentials(USER_ID, USER_PWD.toCharArray());
sc.setAttribute("attr", "val");
cs = login(sc);
AuthInfo ai = cs.getAuthInfo();
root.refresh();
PrincipalProvider pp = getSecurityProvider().getConfiguration(PrincipalConfiguration.class).getPrincipalProvider(root, NamePathMapper.DEFAULT);
Set<? extends Principal> expected = pp.getPrincipals(USER_ID);
assertEquals(3, expected.size());
assertEquals(expected, ai.getPrincipals());
} finally {
if (cs != null) {
cs.close();
}
}
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider in project jackrabbit-oak by apache.
the class ExternalPrincipalConfigurationTest method testGetPrincipalProviderEnabled.
@Test
public void testGetPrincipalProviderEnabled() {
enable();
PrincipalProvider pp = principalConfiguration.getPrincipalProvider(root, NamePathMapper.DEFAULT);
assertNotNull(pp);
assertTrue(pp instanceof ExternalGroupPrincipalProvider);
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider in project jackrabbit-oak by apache.
the class ExternalPrincipalConfigurationTest method assertIsEnabled.
private void assertIsEnabled(ExternalPrincipalConfiguration externalPrincipalConfiguration, boolean expected) throws Exception {
PrincipalProvider pp = externalPrincipalConfiguration.getPrincipalProvider(root, getNamePathMapper());
assertEquals(expected, pp instanceof ExternalGroupPrincipalProvider);
}
Aggregations