use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testSyncMembershipGroupIsExternalUser.
@Test
public void testSyncMembershipGroupIsExternalUser() throws Exception {
// sync the 'wrong' external group into the repository
ExternalIdentity externalIdentity = idp.listUsers().next();
sync(externalIdentity);
// create external user with an synced-ext-user as declared group
ExternalUser withWrongDeclaredGroup = new ExternalUserWithDeclaredGroup(externalIdentity.getExternalId());
try {
Authorizable a = syncCtx.createUser(withWrongDeclaredGroup);
root.commit();
syncCtx.syncMembership(withWrongDeclaredGroup, a, 1);
assertFalse(root.hasPendingChanges());
} finally {
Authorizable a = userManager.getAuthorizable(withWrongDeclaredGroup.getId());
if (a != null) {
a.remove();
root.commit();
}
}
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser in project jackrabbit-oak by apache.
the class DynamicSyncContextTest method testSyncExternalUserDepthInfinite.
@Test
public void testSyncExternalUserDepthInfinite() throws Exception {
syncConfig.user().setMembershipNestingDepth(Long.MAX_VALUE);
ExternalUser externalUser = idp.getUser(USER_ID);
sync(externalUser, SyncResult.Status.ADD);
Tree tree = r.getTree(userManager.getAuthorizable(USER_ID).getPath());
PropertyState extPrincipalNames = tree.getProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES);
assertNotNull(extPrincipalNames);
Set<String> pNames = Sets.newHashSet(extPrincipalNames.getValue(Type.STRINGS));
Set<String> expected = Sets.newHashSet();
collectGroupPrincipals(expected, externalUser.getDeclaredGroups(), Long.MAX_VALUE);
assertEquals(expected, pNames);
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testSyncMembershipDepth1.
@Test
public void testSyncMembershipDepth1() throws Exception {
ExternalUser externalUser = idp.listUsers().next();
Authorizable a = syncCtx.createUser(externalUser);
syncCtx.syncMembership(externalUser, a, 1);
assertTrue(root.hasPendingChanges());
for (ExternalIdentityRef ref : externalUser.getDeclaredGroups()) {
Group g = userManager.getAuthorizable(ref.getId(), Group.class);
assertNotNull(g);
assertTrue(g.isDeclaredMember(a));
}
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser in project jackrabbit-oak by apache.
the class LdapProviderTest method testGetUserByRef.
@Test
public void testGetUserByRef() throws Exception {
ExternalIdentityRef ref = new ExternalIdentityRef(TEST_USER1_DN, IDP_NAME);
ExternalIdentity id = idp.getIdentity(ref);
assertTrue("User instance", id instanceof ExternalUser);
assertEquals("User ID", TEST_USER1_UID, id.getId());
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser in project jackrabbit-oak by apache.
the class PrincipalProviderDeepNestingTest method testGetPrincipalInheritedGroups.
@Override
@Test
public void testGetPrincipalInheritedGroups() throws Exception {
ExternalUser externalUser = idp.getUser(USER_ID);
for (ExternalIdentityRef ref : externalUser.getDeclaredGroups()) {
ExternalIdentity externalGroup = idp.getIdentity(ref);
Principal grPrincipal = principalProvider.getPrincipal(externalGroup.getPrincipalName());
for (ExternalIdentityRef inheritedGroupRef : externalGroup.getDeclaredGroups()) {
String inheritedPrincName = idp.getIdentity(inheritedGroupRef).getPrincipalName();
Principal principal = principalProvider.getPrincipal(inheritedPrincName);
assertNotNull(principal);
assertTrue(principal instanceof java.security.acl.Group);
java.security.acl.Group inheritedGrPrincipal = (java.security.acl.Group) principal;
assertTrue(inheritedGrPrincipal.isMember(new PrincipalImpl(externalUser.getPrincipalName())));
assertFalse(inheritedGrPrincipal.isMember(grPrincipal));
}
}
}
Aggregations