use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.
the class CugConfigurationOsgiTest method testCugExcludeExcludedPrincipal.
@Test
public void testCugExcludeExcludedPrincipal() {
context.registerInjectActivateService(cugExclude, ImmutableMap.of("principalNames", new String[] { EXCLUDED_PRINCIPAL_NAME }));
context.registerInjectActivateService(cugConfiguration, PROPERTIES);
AuthorizationConfiguration config = context.getService(AuthorizationConfiguration.class);
PermissionProvider permissionProvider = config.getPermissionProvider(root, wspName, ImmutableSet.of(new PrincipalImpl(EXCLUDED_PRINCIPAL_NAME)));
assertSame(EmptyPermissionProvider.getInstance(), permissionProvider);
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl 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();
}
}
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.
the class EveryoneGroupTest method testGroupPrincipal.
@Test
public void testGroupPrincipal() throws Exception {
Principal everyonePrincipal = everyone.getPrincipal();
assertTrue(everyonePrincipal instanceof GroupPrincipal);
assertTrue(everyonePrincipal.equals(EveryonePrincipal.getInstance()));
assertTrue(EveryonePrincipal.getInstance().equals(everyonePrincipal));
GroupPrincipal gr = (GroupPrincipal) everyonePrincipal;
assertFalse(gr.isMember(everyonePrincipal));
assertTrue(gr.isMember(getTestUser(superuser).getPrincipal()));
assertTrue(gr.isMember(new PrincipalImpl("test")));
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.
the class ExternalGroupPrincipalProviderTest method testGetGroupMembershipExternalUser2.
@Test
public void testGetGroupMembershipExternalUser2() throws Exception {
Authorizable user = getUserManager(root).getAuthorizable(USER_ID);
assertNotNull(user);
Set<Principal> expected = getExpectedGroupPrincipals(USER_ID);
// same as in test before even if the principal is not a tree-based-principal
Set<? extends Principal> principals = principalProvider.getMembershipPrincipals(new PrincipalImpl(user.getPrincipal().getName()));
assertEquals(expected, principals);
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.
the class ExternalGroupPrincipalProviderTest method testGetGroupMembershipDefaultSync2.
@Test
public void testGetGroupMembershipDefaultSync2() throws Exception {
// synchronized by default sync-context => no 'dynamic' group principals
Authorizable user = getUserManager(root).getAuthorizable(TestIdentityProvider.ID_SECOND_USER);
assertNotNull(user);
// same as in test before even if the principal is not a tree-based-principal
Set<? extends Principal> principals = principalProvider.getMembershipPrincipals(new PrincipalImpl(user.getPrincipal().getName()));
assertTrue(principals.isEmpty());
}
Aggregations