use of org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncContext in project jackrabbit-oak by apache.
the class PreAuthDefaultExternalLoginModuleTest method testExistingExternalNoSync.
@Test
public void testExistingExternalNoSync() throws Exception {
// prevent expiration of the user
syncConfig.user().setExpirationTime(Long.MAX_VALUE);
// sync user upfront
SyncContext syncContext = new DefaultSyncContext(syncConfig, idp, getUserManager(root), getValueFactory(root));
SyncResult result = syncContext.sync(idp.getUser(TestIdentityProvider.ID_TEST_USER));
long lastSynced = result.getIdentity().lastSynced();
root.commit();
PreAuthCredentials creds = new PreAuthCredentials(TestIdentityProvider.ID_TEST_USER);
ContentSession cs = null;
try {
cs = login(creds);
assertEquals(PreAuthCredentials.PRE_AUTH_DONE, creds.getMessage());
assertEquals(TestIdentityProvider.ID_TEST_USER, cs.getAuthInfo().getUserID());
root.refresh();
User u = getUserManager(root).getAuthorizable(TestIdentityProvider.ID_TEST_USER, User.class);
assertNotNull(u);
// user _should_ not have been re-synced
assertEquals(lastSynced, DefaultSyncContext.createSyncedIdentity(u).lastSynced());
} finally {
if (cs != null) {
cs.close();
}
}
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncContext in project jackrabbit-oak by apache.
the class AbstractJmxTest method sync.
SyncResult sync(@Nonnull ExternalIdentity externalIdentity, @Nonnull ExternalIdentityProvider idp) throws Exception {
SyncContext ctx = new DefaultSyncContext(syncConfig, idp, getUserManager(root), getValueFactory(root));
SyncResult res = ctx.sync(externalIdentity);
root.commit();
return res;
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncContext in project jackrabbit-oak by apache.
the class DynamicSyncContextTest method testSyncExternalGroupExisting.
@Test
public void testSyncExternalGroupExisting() throws Exception {
// create an external external group that already has been synced into the repo
ExternalGroup externalGroup = idp.listGroups().next();
SyncContext ctx = new DefaultSyncContext(syncConfig, idp, userManager, valueFactory);
ctx.sync(externalGroup);
ctx.close();
// synchronizing using DynamicSyncContext must update the existing group
syncContext.setForceGroupSync(true);
SyncResult result = syncContext.sync(externalGroup);
assertSame(SyncResult.Status.UPDATE, result.getStatus());
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncContext in project jackrabbit-oak by apache.
the class DynamicSyncContextTest method testSyncMembershipWithChangedExistingGroups.
@Test
public void testSyncMembershipWithChangedExistingGroups() throws Exception {
long nesting = 1;
syncConfig.user().setMembershipNestingDepth(nesting);
ExternalUser externalUser = idp.getUser(USER_ID);
DefaultSyncContext ctx = new DefaultSyncContext(syncConfig, idp, userManager, valueFactory);
ctx.sync(externalUser);
ctx.close();
Authorizable a = userManager.getAuthorizable(externalUser.getId());
assertSyncedMembership(userManager, a, externalUser);
// sync user with modified membership => must be reflected
// 1. empty set of declared groups
ExternalUser mod = new TestUserWithGroupRefs(externalUser, ImmutableSet.<ExternalIdentityRef>of());
syncContext.syncMembership(mod, a, nesting);
assertSyncedMembership(userManager, a, mod);
// 2. set with different groups that defined on IDP
mod = new TestUserWithGroupRefs(externalUser, ImmutableSet.<ExternalIdentityRef>of(idp.getGroup("a").getExternalId(), idp.getGroup("aa").getExternalId(), idp.getGroup("secondGroup").getExternalId()));
syncContext.syncMembership(mod, a, nesting);
assertSyncedMembership(userManager, a, mod);
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncContext in project jackrabbit-oak by apache.
the class DynamicSyncContextTest method testSyncMembershipForExternalGroup.
@Test
public void testSyncMembershipForExternalGroup() throws Exception {
// a group that has declaredGroups
ExternalGroup externalGroup = idp.getGroup("a");
SyncContext ctx = new DefaultSyncContext(syncConfig, idp, userManager, valueFactory);
ctx.sync(externalGroup);
ctx.close();
r.commit();
Authorizable gr = userManager.getAuthorizable(externalGroup.getId());
syncContext.syncMembership(externalGroup, gr, 1);
assertFalse(gr.hasProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES));
assertFalse(r.hasPendingChanges());
}
Aggregations