use of org.apache.jackrabbit.api.security.user.Authorizable in project jackrabbit by apache.
the class UserManagerImplTest method testFindAuthorizableByAddedProperty.
public void testFindAuthorizableByAddedProperty() throws RepositoryException, NotExecutableException {
Principal p = getTestPrincipal();
Authorizable auth = null;
try {
auth = userMgr.createGroup(p);
auth.setProperty("E-Mail", new Value[] { superuser.getValueFactory().createValue("anyVal") });
save(superuser);
boolean found = false;
Iterator<Authorizable> result = userMgr.findAuthorizables("E-Mail", "anyVal");
while (result.hasNext()) {
Authorizable a = result.next();
if (a.getID().equals(auth.getID())) {
found = true;
}
}
assertTrue(found);
} finally {
// remove the create group again.
if (auth != null) {
auth.remove();
save(superuser);
}
}
}
use of org.apache.jackrabbit.api.security.user.Authorizable in project jackrabbit-oak by apache.
the class LdapLoginTestBase method after.
@After
public void after() throws Exception {
if (!USE_COMMON_LDAP_FIXTURE) {
LDAP_SERVER.tearDown();
}
try {
Authorizable a = userManager.getAuthorizable(USER_ID);
if (a != null) {
a.remove();
}
if (GROUP_DN != null) {
a = userManager.getAuthorizable(GROUP_DN);
if (a != null) {
a.remove();
}
}
root.commit();
} finally {
root.refresh();
super.after();
}
}
use of org.apache.jackrabbit.api.security.user.Authorizable in project jackrabbit-oak by apache.
the class LdapLoginTestBase method testSyncCreateUser.
@Test
public void testSyncCreateUser() throws Exception {
ContentSession cs = null;
try {
cs = login(new SimpleCredentials(USER_ID, USER_PWD.toCharArray()));
root.refresh();
Authorizable user = userManager.getAuthorizable(USER_ID);
assertNotNull(user);
assertTrue(user.hasProperty(USER_PROP));
Tree userTree = cs.getLatestRoot().getTree(user.getPath());
assertFalse(userTree.hasProperty(UserConstants.REP_PASSWORD));
assertNull(userManager.getAuthorizable(GROUP_DN));
} finally {
if (cs != null) {
cs.close();
}
options.clear();
}
}
use of org.apache.jackrabbit.api.security.user.Authorizable in project jackrabbit-oak by apache.
the class LdapLoginTestBase method testSyncUpdate.
@Test
public void testSyncUpdate() throws Exception {
// create user upfront in order to test update mode
Authorizable user = userManager.createUser(USER_ID, null);
ExternalUser externalUser = idp.getUser(USER_ID);
user.setProperty("rep:externalId", new ValueFactoryImpl(root, NamePathMapper.DEFAULT).createValue(externalUser.getExternalId().getString()));
root.commit();
ContentSession cs = null;
try {
cs = login(new SimpleCredentials(USER_ID, USER_PWD.toCharArray()));
root.refresh();
user = userManager.getAuthorizable(USER_ID);
assertNotNull(user);
assertTrue(user.hasProperty(USER_PROP));
assertNull(userManager.getAuthorizable(GROUP_DN));
} finally {
if (cs != null) {
cs.close();
}
options.clear();
}
}
use of org.apache.jackrabbit.api.security.user.Authorizable in project jackrabbit-oak by apache.
the class LdapLoginTestBase method testReLogin.
@Test
public void testReLogin() throws Exception {
ContentSession cs = null;
try {
cs = login(new SimpleCredentials(USER_ID, USER_PWD.toCharArray()));
root.refresh();
Authorizable user = userManager.getAuthorizable(USER_ID);
assertNotNull(user);
assertFalse(root.getTree(user.getPath()).hasProperty(UserConstants.REP_PASSWORD));
cs.close();
// login again
cs = login(new SimpleCredentials(USER_ID, USER_PWD.toCharArray()));
root.refresh();
assertEquals(USER_ID, cs.getAuthInfo().getUserID());
} finally {
if (cs != null) {
cs.close();
}
options.clear();
}
}
Aggregations