use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity in project jackrabbit-oak by apache.
the class LdapProviderTest method testGetUnknownUserByRef.
@Test
public void testGetUnknownUserByRef() throws Exception {
ExternalIdentityRef ref = new ExternalIdentityRef("bla=foo," + TEST_USER1_DN, IDP_NAME);
ExternalIdentity id = idp.getIdentity(ref);
assertNull("Unknown user must return null", id);
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity in project jackrabbit-oak by apache.
the class LdapProviderTest method testGetGroupByRef.
@Test
public void testGetGroupByRef() throws Exception {
ExternalIdentityRef ref = new ExternalIdentityRef(TEST_GROUP1_DN, IDP_NAME);
ExternalIdentity id = idp.getIdentity(ref);
assertTrue("Group instance", id instanceof ExternalGroup);
assertEquals("Group Name", TEST_GROUP1_NAME, id.getId());
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity in project jackrabbit-oak by apache.
the class Delegatee method syncExternalUsers.
/**
* @see SynchronizationMBean#syncExternalUsers(String[])
*/
@Nonnull
String[] syncExternalUsers(@Nonnull String[] externalIds) {
List<String> list = new ArrayList<String>();
context.setForceGroupSync(true).setForceUserSync(true);
List<SyncResult> results = new ArrayList<SyncResult>(batchSize);
for (String externalId : externalIds) {
ExternalIdentityRef ref = ExternalIdentityRef.fromString(externalId);
if (!idp.getName().equals(ref.getProviderName())) {
results.add(new DefaultSyncResultImpl(new DefaultSyncedIdentity(ref.getId(), ref, false, -1), SyncResult.Status.FOREIGN));
} else {
try {
ExternalIdentity id = idp.getIdentity(ref);
if (id != null) {
results = syncUser(id, results, list);
} else {
results.add(new DefaultSyncResultImpl(new DefaultSyncedIdentity("", ref, false, -1), SyncResult.Status.NO_SUCH_IDENTITY));
}
} catch (ExternalIdentityException e) {
log.warn("error while fetching the external identity {}", externalId, e);
results.add(new ErrorSyncResult(ref, e));
}
}
}
commit(list, results, NO_BATCH_SIZE);
return list.toArray(new String[list.size()]);
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testIsExpiredSyncedUser.
@Test
public void testIsExpiredSyncedUser() throws Exception {
ExternalIdentity externalUser = idp.listUsers().next();
sync(externalUser);
Authorizable a = userManager.getAuthorizable(externalUser.getId());
assertFalse(syncCtx.isExpired(a, syncConfig.user().getExpirationTime(), "any"));
assertTrue(syncCtx.isExpired(a, -1, "any"));
// create a ctx with a newer 'now'
DefaultSyncContext ctx = new DefaultSyncContext(syncConfig, idp, userManager, valueFactory);
long expTime = ctx.now - syncCtx.now - 1;
assertTrue(ctx.isExpired(a, expTime, "any"));
// remove last-sync property
a.removeProperty(DefaultSyncContext.REP_LAST_SYNCED);
assertTrue(syncCtx.isExpired(a, syncConfig.user().getExpirationTime(), "any"));
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testGetIdentityRefSyncUser.
@Test
public void testGetIdentityRefSyncUser() throws Exception {
ExternalIdentity externalUser = idp.listUsers().next();
sync(externalUser);
ExternalIdentityRef ref = DefaultSyncContext.getIdentityRef(userManager.getAuthorizable(externalUser.getId()));
assertNotNull(ref);
assertEquals(externalUser.getExternalId(), ref);
}
Aggregations