use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.
the class Delegatee method syncUser.
@Nonnull
private List<SyncResult> syncUser(@Nonnull ExternalIdentity id, @Nonnull List<SyncResult> results, @Nonnull List<String> list) {
try {
SyncResult r = context.sync(id);
if (r.getIdentity() == null) {
r = new DefaultSyncResultImpl(new DefaultSyncedIdentity(id.getId(), id.getExternalId(), false, -1), SyncResult.Status.NO_SUCH_IDENTITY);
log.warn("sync failed. {}", r.getIdentity());
} else {
log.info("synced {}", r.getIdentity());
}
results.add(r);
} catch (SyncException e) {
log.error(ERROR_SYNC_USER, id, e);
results.add(new ErrorSyncResult(id.getExternalId(), e));
}
return commit(list, results, batchSize);
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testSyncAutoMembershipListsNonExistingGroup.
@Test
public void testSyncAutoMembershipListsNonExistingGroup() throws Exception {
syncConfig.user().setAutoMembership("nonExistingGroup");
SyncResult result = syncCtx.sync(idp.listUsers().next());
assertEquals(SyncResult.Status.ADD, result.getStatus());
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testLostMembershipDifferentIDP.
@Test
public void testLostMembershipDifferentIDP() throws Exception {
// create a group in the repository which is marked as being external
// and associated with another IPD.
Group gr = createTestGroup();
setExternalID(gr, "differentIDP");
// sync an external user from the IDP into the repo and make it member
// of the test group
SyncResult result = syncCtx.sync(idp.listUsers().next());
User user = userManager.getAuthorizable(result.getIdentity().getId(), User.class);
gr.addMember(user);
root.commit();
// enforce synchronization of the user and it's group membership
syncCtx.setForceUserSync(true);
syncConfig.user().setMembershipExpirationTime(-1);
syncConfig.user().setMembershipNestingDepth(1);
assertEquals(SyncResult.Status.UPDATE, syncCtx.sync(user.getID()).getStatus());
// since the group is not associated with the test-IDP the group-membership
// must NOT be modified during the sync.
assertTrue(gr.isDeclaredMember(user));
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testSyncExternalToExistingLocalUser.
@Test
public void testSyncExternalToExistingLocalUser() throws Exception {
ExternalUser external = idp.listUsers().next();
syncCtx.sync(external);
User u = userManager.getAuthorizable(external.getId(), User.class);
u.removeProperty(ExternalIdentityConstants.REP_EXTERNAL_ID);
SyncResult result = syncCtx.sync(external);
assertEquals(SyncResult.Status.FOREIGN, result.getStatus());
SyncedIdentity si = result.getIdentity();
assertNotNull(si);
assertEquals(external.getExternalId(), si.getExternalIdRef());
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testSyncExternalUser.
@Test
public void testSyncExternalUser() throws Exception {
ExternalUser user = idp.listUsers().next();
assertNotNull(user);
SyncResult result = syncCtx.sync(user);
assertEquals(SyncResult.Status.ADD, result.getStatus());
result = syncCtx.sync(user);
assertEquals(SyncResult.Status.NOP, result.getStatus());
syncCtx.setForceUserSync(true);
result = syncCtx.sync(user);
assertEquals(SyncResult.Status.UPDATE, result.getStatus());
}
Aggregations