use of org.apache.jackrabbit.oak.spi.security.authentication.external.impl.DefaultSyncHandler in project jackrabbit-oak by apache.
the class ExternalPrincipalConfigurationTest method testAddingSyncHandler.
@Test
public void testAddingSyncHandler() throws Exception {
Map<String, Object> enableProps = ImmutableMap.<String, Object>of(DefaultSyncConfigImpl.PARAM_USER_DYNAMIC_MEMBERSHIP, true);
Map<String, Object> disableProps = ImmutableMap.<String, Object>of(DefaultSyncConfigImpl.PARAM_USER_DYNAMIC_MEMBERSHIP, false);
SyncHandler sh = new DefaultSyncHandler();
context.registerService(SyncHandler.class, sh, ImmutableMap.<String, Object>of());
assertIsEnabled(principalConfiguration, false);
context.registerService(SyncHandler.class, sh, disableProps);
assertIsEnabled(principalConfiguration, false);
context.registerService(SyncHandler.class, sh, enableProps);
assertIsEnabled(principalConfiguration, true);
context.registerService(DefaultSyncHandler.class, new DefaultSyncHandler(), enableProps);
assertIsEnabled(principalConfiguration, true);
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.impl.DefaultSyncHandler in project jackrabbit-oak by apache.
the class ExternalPrincipalConfigurationTest method testRemoveSyncHandler.
@Test
public void testRemoveSyncHandler() throws Exception {
Dictionary<String, Object> enableProps = new Hashtable(ImmutableMap.<String, Object>of(DefaultSyncConfigImpl.PARAM_USER_DYNAMIC_MEMBERSHIP, true));
Dictionary<String, Object> disableProps = new Hashtable(ImmutableMap.<String, Object>of(DefaultSyncConfigImpl.PARAM_USER_DYNAMIC_MEMBERSHIP, false));
DefaultSyncHandler sh = new DefaultSyncHandler();
BundleContext bundleContext = context.bundleContext();
ServiceRegistration registration1 = bundleContext.registerService(SyncHandler.class.getName(), sh, enableProps);
ServiceRegistration registration2 = bundleContext.registerService(SyncHandler.class.getName(), sh, enableProps);
ServiceRegistration registration3 = bundleContext.registerService(SyncHandler.class.getName(), sh, disableProps);
assertIsEnabled(principalConfiguration, true);
registration2.unregister();
assertIsEnabled(principalConfiguration, true);
registration1.unregister();
assertIsEnabled(principalConfiguration, false);
registration3.unregister();
assertIsEnabled(principalConfiguration, false);
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.impl.DefaultSyncHandler in project jackrabbit-oak by apache.
the class ExternalLoginModuleAutoMembershipTest method before.
@Override
public void before() throws Exception {
super.before();
r = getSystemRoot();
userManager = getUserManager(r);
valueFactory = getValueFactory(r);
syncConfig.user().setDynamicMembership(true);
// register the ExternalPrincipal configuration in order to have it's
// activate method invoked.
context.registerInjectActivateService(externalPrincipalConfiguration);
// first configuration based on test base-setup with
// - dynamic membership = true
// - auto-membership = 'gr_default' and 'nonExisting'
syncConfig.user().setDynamicMembership(true);
setup1 = new ExternalSetup(idp, syncConfig, WhiteboardUtils.getService(whiteboard, SyncHandler.class), "gr" + UUID.randomUUID());
// second configuration with different IDP ('idp2') and
// - dynamic membership = true
// - auto-membership = 'gr_name2' and 'nonExisting'
DefaultSyncConfig sc2 = new DefaultSyncConfig();
sc2.setName("name2").user().setDynamicMembership(true);
setup2 = new ExternalSetup(new TestIdentityProvider("idp2"), sc2);
// third configuration with different IDP ('idp3') and
// - dynamic membership = false
// - auto-membership = 'gr_name3' and 'nonExisting'
DefaultSyncConfig sc3 = new DefaultSyncConfig();
sc3.setName("name3");
setup3 = new ExternalSetup(new TestIdentityProvider("idp3"), sc3);
// forth configuration based on different IDP ('idp4') but re-using
// sync-handler configuration (sc2)
setup4 = new ExternalSetup(new TestIdentityProvider("idp4"), sc2);
// fifth configuration with different IDP ('idp5') and
// - dynamic membership = true
// - auto-membership => nothing configured
DefaultSyncConfig sc5 = new DefaultSyncConfig();
sc5.setName("name5").user().setDynamicMembership(true);
setup5 = new ExternalSetup(new TestIdentityProvider("idp5"), sc5, new DefaultSyncHandler(sc5), null);
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.impl.DefaultSyncHandler in project jackrabbit-oak by apache.
the class ExternalPrincipalConfigurationTest method testModifySyncHandler.
@Ignore("TODO: mock doesn't reflect property-changes on the registration.")
@Test
public void testModifySyncHandler() throws Exception {
Dictionary<String, Object> enableProps = new Hashtable(ImmutableMap.<String, Object>of(DefaultSyncConfigImpl.PARAM_USER_DYNAMIC_MEMBERSHIP, true));
Dictionary<String, Object> disableProps = new Hashtable(ImmutableMap.<String, Object>of(DefaultSyncConfigImpl.PARAM_USER_DYNAMIC_MEMBERSHIP, false));
DefaultSyncHandler sh = new DefaultSyncHandler();
BundleContext bundleContext = context.bundleContext();
ServiceRegistration registration = bundleContext.registerService(DefaultSyncHandler.class.getName(), sh, disableProps);
assertIsEnabled(principalConfiguration, false);
registration.setProperties(enableProps);
assertIsEnabled(principalConfiguration, true);
registration.setProperties(disableProps);
assertIsEnabled(principalConfiguration, false);
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.impl.DefaultSyncHandler in project jackrabbit-oak by apache.
the class SyncMBeanImplTest method before.
@Before
public void before() throws Exception {
super.before();
syncMgr = new SyncManager() {
@CheckForNull
@Override
public SyncHandler getSyncHandler(@Nonnull String name) {
if (SYNC_NAME.equals(name)) {
return new DefaultSyncHandler(syncConfig);
} else if (ThrowingSyncHandler.NAME.equals(name)) {
return new ThrowingSyncHandler(false);
} else if (ThrowingSyncHandler.NAME_ALLOWS_IDENTITY_LISTING.equals(name)) {
return new ThrowingSyncHandler(true);
} else {
return null;
}
}
};
idpMgr = new ExternalIdentityProviderManager() {
@CheckForNull
@Override
public ExternalIdentityProvider getProvider(@Nonnull String name) {
if (name.equals(idp.getName())) {
return idp;
} else {
return null;
}
}
};
syncMBean = createSyncMBeanImpl(SYNC_NAME, idp.getName());
}
Aggregations