use of javax.jcr.SimpleCredentials in project jackrabbit-oak by apache.
the class ExternalLoginModuleDynamicMembershipTest method testSyncUpdateAfterXmlImport.
@Test
public void testSyncUpdateAfterXmlImport() throws Exception {
try {
// force initial sync
login(new SimpleCredentials(USER_ID, new char[0])).close();
// remove properties according to the behavior in the XML-import
Root systemRoot = getSystemRoot();
UserManager userManager = getUserManager(systemRoot);
Authorizable a = userManager.getAuthorizable(USER_ID);
a.removeProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES);
a.removeProperty(ExternalIdentityConstants.REP_LAST_SYNCED);
systemRoot.commit();
// login again to force sync of the user (and it's group membership)
login(new SimpleCredentials(USER_ID, new char[0])).close();
systemRoot.refresh();
a = userManager.getAuthorizable(USER_ID);
assertTrue(a.hasProperty(ExternalIdentityConstants.REP_LAST_SYNCED));
assertExternalPrincipalNames(userManager, USER_ID);
} finally {
options.clear();
}
}
use of javax.jcr.SimpleCredentials in project jackrabbit-oak by apache.
the class ExternalLoginModuleTest method testSyncUpdate.
@Test
public void testSyncUpdate() throws Exception {
// create user upfront in order to test update mode
UserManager userManager = getUserManager(root);
ExternalUser externalUser = idp.getUser(USER_ID);
Authorizable user = userManager.createUser(externalUser.getId(), null);
user.setProperty(DefaultSyncContext.REP_EXTERNAL_ID, getValueFactory().createValue(externalUser.getExternalId().getString()));
root.commit();
ContentSession cs = null;
try {
cs = login(new SimpleCredentials(USER_ID, new char[0]));
root.refresh();
Authorizable a = userManager.getAuthorizable(USER_ID);
assertNotNull(a);
for (String prop : externalUser.getProperties().keySet()) {
assertTrue(a.hasProperty(prop));
}
} finally {
if (cs != null) {
cs.close();
}
options.clear();
}
}
use of javax.jcr.SimpleCredentials in project jackrabbit-oak by apache.
the class PreAuthDefaultExternalLoginModuleTest method testSimpleLocal.
@Test
public void testSimpleLocal() throws Exception {
User testUser = getTestUser();
ContentSession cs = null;
try {
cs = login(new SimpleCredentials(testUser.getID(), testUser.getID().toCharArray()));
assertEquals(testUser.getID(), cs.getAuthInfo().getUserID());
} finally {
if (cs != null) {
cs.close();
}
}
}
use of javax.jcr.SimpleCredentials in project jackrabbit-oak by apache.
the class PreAuthLoginModule method login.
@Override
public boolean login() {
Credentials credentials = getCredentials();
if (credentials instanceof PreAuthCredentials) {
PreAuthCredentials pac = (PreAuthCredentials) credentials;
String userId = pac.getUserId();
if (userId == null) {
pac.setMessage(PreAuthCredentials.PRE_AUTH_FAIL);
} else {
sharedState.put(SHARED_KEY_PRE_AUTH_LOGIN, new PreAuthenticatedLogin(userId));
sharedState.put(SHARED_KEY_CREDENTIALS, new SimpleCredentials(userId, new char[0]));
sharedState.put(SHARED_KEY_LOGIN_NAME, userId);
pac.setMessage(PreAuthCredentials.PRE_AUTH_DONE);
}
}
return false;
}
use of javax.jcr.SimpleCredentials in project jackrabbit-oak by apache.
the class ExternalLoginModuleTest method testSyncCreateUser.
@Test
public void testSyncCreateUser() throws Exception {
UserManager userManager = getUserManager(root);
ContentSession cs = null;
try {
assertNull(userManager.getAuthorizable(USER_ID));
cs = login(new SimpleCredentials(USER_ID, new char[0]));
root.refresh();
Authorizable a = userManager.getAuthorizable(USER_ID);
assertNotNull(a);
ExternalUser user = idp.getUser(USER_ID);
for (String prop : user.getProperties().keySet()) {
assertTrue(a.hasProperty(prop));
}
assertEquals(TEST_CONSTANT_PROPERTY_VALUE, a.getProperty(TEST_CONSTANT_PROPERTY_NAME)[0].getString());
} finally {
if (cs != null) {
cs.close();
}
options.clear();
}
}
Aggregations