use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.
the class ExternalGroupPrincipalProviderTest method testFindPrincipalsContainingUnderscore.
@Test
public void testFindPrincipalsContainingUnderscore() throws Exception {
ExternalUser externalUser = idp.getUser(TestIdentityProvider.ID_WILDCARD_USER);
sync(externalUser);
Set<? extends Principal> expected = ImmutableSet.of(new PrincipalImpl("_gr_u_"));
Set<? extends Principal> res = ImmutableSet.copyOf(principalProvider.findPrincipals("_", PrincipalManager.SEARCH_TYPE_ALL));
assertEquals(expected, res);
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.
the class ExternalGroupPrincipalProviderTest method collectExpectedPrincipals.
private void collectExpectedPrincipals(Set<Principal> grPrincipals, @Nonnull Iterable<ExternalIdentityRef> declaredGroups, long depth) throws Exception {
if (depth <= 0) {
return;
}
for (ExternalIdentityRef ref : declaredGroups) {
ExternalIdentity ei = idp.getIdentity(ref);
grPrincipals.add(new PrincipalImpl(ei.getPrincipalName()));
collectExpectedPrincipals(grPrincipals, ei.getDeclaredGroups(), depth - 1);
}
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.
the class ExternalGroupPrincipalProviderTest method testFindPrincipalsByHintTypeGroup.
@Test
public void testFindPrincipalsByHintTypeGroup() throws Exception {
Set<? extends Principal> expected = ImmutableSet.of(new PrincipalImpl("a"));
Set<? extends Principal> res = ImmutableSet.copyOf(principalProvider.findPrincipals("a", PrincipalManager.SEARCH_TYPE_GROUP));
assertEquals(expected, res);
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.
the class XPathConditionVisitor method visit.
@Override
public void visit(Condition.Impersonation condition) {
String principalName = condition.getName();
boolean isAdmin = false;
try {
Authorizable authorizable = userMgr.getAuthorizable(new PrincipalImpl(principalName));
isAdmin = authorizable != null && !authorizable.isGroup() && ((User) authorizable).isAdmin();
} catch (RepositoryException e) {
// unable to retrieve authorizable
}
if (isAdmin) {
statement.append('@').append(QueryUtil.escapeForQuery(JcrConstants.JCR_PRIMARYTYPE, namePathMapper)).append("='").append(QueryUtil.escapeForQuery(UserConstants.NT_REP_USER, namePathMapper)).append('\'');
} else {
statement.append('@').append(QueryUtil.escapeForQuery(UserConstants.REP_IMPERSONATORS, namePathMapper)).append("='").append(condition.getName()).append('\'');
}
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.
the class IsMemberTest method beforeSuite.
@Override
protected void beforeSuite() throws Exception {
super.beforeSuite();
Session s = loginAdministrative();
try {
UserManager userManager = ((JackrabbitSession) s).getUserManager();
Group gr = userManager.createGroup(new PrincipalImpl(GROUP + 0), REL_TEST_PATH);
gPaths.add(gr.getPath());
for (int i = 1; i < GROUP_CNT; i++) {
Group g = userManager.createGroup(new PrincipalImpl(GROUP + i), REL_TEST_PATH);
if (nestedGroups) {
g.addMember(gr);
}
gr = g;
gPaths.add(gr.getPath());
}
int cnt = 0;
for (int i = 0; i <= numberOfUsers; i++) {
User u = userManager.createUser(USER + i, null, new PrincipalImpl(USER + i), REL_TEST_PATH);
uPaths.add(u.getPath());
getRandomGroup(userManager).addMember(u);
if (++cnt == 20000) {
s.save();
}
}
} finally {
s.save();
s.logout();
}
System.out.println("setup done");
}
Aggregations