use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.
the class RemoveMembersTest method beforeSuite.
@Override
public void beforeSuite() throws Exception {
super.beforeSuite();
Session s = loginAdministrative();
try {
UserManager userManager = ((JackrabbitSession) s).getUserManager();
createUsers(userManager);
for (int i = 0; i <= GROUP_CNT; i++) {
Group g = userManager.createGroup(new PrincipalImpl(GROUP + i), REL_TEST_PATH);
groupPaths.add(g.getPath());
List<String> ids = new ArrayList<String>();
for (int j = 0; j <= numberOfMembers; j++) {
ids.add(USER + j);
}
g.addMembers(ids.toArray(new String[ids.size()]));
s.save();
}
} finally {
s.logout();
}
System.out.println("setup done");
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.
the class AbstractExternalTest method beforeSuite.
@Override
protected void beforeSuite() throws Exception {
Set<String> autoMembership = syncConfig.user().getAutoMembership();
if (!autoMembership.isEmpty()) {
Session s = systemLogin();
UserManager userManager = ((JackrabbitSession) s).getUserManager();
for (String groupId : autoMembership) {
userManager.createGroup(groupId, new PrincipalImpl(groupId), PATH_PREFIX);
}
s.save();
}
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.
the class ExternalLoginModuleAutoMembershipTest method testLoginAfterSyncSetup5.
@Test
public void testLoginAfterSyncSetup5() throws Exception {
setup5.sync(USER_ID, false);
ContentSession cs = null;
try {
cs = login(new SimpleCredentials(USER_ID, new char[0]));
// the login must not set any auto-membership principals to the subject
// as auto-membership is not configured on this setup.
Set<Principal> principals = cs.getAuthInfo().getPrincipals();
Set<Principal> expected = ImmutableSet.of(EveryonePrincipal.getInstance(), userManager.getAuthorizable(USER_ID).getPrincipal());
assertEquals(expected, principals);
assertFalse(principals.contains(new PrincipalImpl(NON_EXISTING_NAME)));
assertFalse(principals.contains(setup1.gr.getPrincipal()));
assertFalse(principals.contains(setup2.gr.getPrincipal()));
assertFalse(principals.contains(setup3.gr.getPrincipal()));
assertFalse(principals.contains(setup4.gr.getPrincipal()));
} finally {
options.clear();
if (cs != null) {
cs.close();
}
}
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.
the class ExternalLoginModuleAutoMembershipTest method testLoginAfterSyncSetup1.
@Test
public void testLoginAfterSyncSetup1() throws Exception {
setup1.sync(USER_ID, false);
ContentSession cs = null;
try {
cs = login(new SimpleCredentials(USER_ID, new char[0]));
// the login must set the configured + existing auto-membership principals
// to the subject; non-existing auto-membership entries must be ignored.
Set<Principal> principals = cs.getAuthInfo().getPrincipals();
assertTrue(principals.contains(setup1.gr.getPrincipal()));
assertFalse(principals.contains(new PrincipalImpl(NON_EXISTING_NAME)));
assertFalse(principals.contains(setup2.gr.getPrincipal()));
assertFalse(principals.contains(setup3.gr.getPrincipal()));
// however, the existing auto-membership group must _not_ have changed
// and the test user must not be a stored member of this group.
root.refresh();
UserManager uMgr = getUserManager(root);
User user = uMgr.getAuthorizable(USER_ID, User.class);
Group gr = uMgr.getAuthorizable(setup1.gr.getID(), Group.class);
assertFalse(gr.isDeclaredMember(user));
assertFalse(gr.isMember(user));
} finally {
options.clear();
if (cs != null) {
cs.close();
}
}
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl in project jackrabbit-oak by apache.
the class AbstractGroupPrincipalTest method testIsMemberOfEveryone.
@Test
public void testIsMemberOfEveryone() throws Exception {
final Principal p = getTestUser().getPrincipal();
assertTrue(everyoneAgp.isMember(p));
assertTrue(everyoneAgp.isMember(new PrincipalImpl(p.getName())));
assertTrue(everyoneAgp.isMember(new Principal() {
@Override
public String getName() {
return p.getName();
}
}));
}
Aggregations