Search in sources :

Example 1 with DefaultSyncHandler

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);
}
Also used : SyncHandler(org.apache.jackrabbit.oak.spi.security.authentication.external.SyncHandler) DefaultSyncHandler(org.apache.jackrabbit.oak.spi.security.authentication.external.impl.DefaultSyncHandler) DefaultSyncHandler(org.apache.jackrabbit.oak.spi.security.authentication.external.impl.DefaultSyncHandler) AbstractExternalAuthTest(org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest) Test(org.junit.Test)

Example 2 with DefaultSyncHandler

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);
}
Also used : SyncHandler(org.apache.jackrabbit.oak.spi.security.authentication.external.SyncHandler) DefaultSyncHandler(org.apache.jackrabbit.oak.spi.security.authentication.external.impl.DefaultSyncHandler) Hashtable(java.util.Hashtable) DefaultSyncHandler(org.apache.jackrabbit.oak.spi.security.authentication.external.impl.DefaultSyncHandler) BundleContext(org.osgi.framework.BundleContext) ServiceRegistration(org.osgi.framework.ServiceRegistration) AbstractExternalAuthTest(org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest) Test(org.junit.Test)

Example 3 with DefaultSyncHandler

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);
}
Also used : DefaultSyncConfig(org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncConfig) DefaultSyncHandler(org.apache.jackrabbit.oak.spi.security.authentication.external.impl.DefaultSyncHandler)

Example 4 with DefaultSyncHandler

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);
}
Also used : Hashtable(java.util.Hashtable) DefaultSyncHandler(org.apache.jackrabbit.oak.spi.security.authentication.external.impl.DefaultSyncHandler) BundleContext(org.osgi.framework.BundleContext) ServiceRegistration(org.osgi.framework.ServiceRegistration) Ignore(org.junit.Ignore) AbstractExternalAuthTest(org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest) Test(org.junit.Test)

Example 5 with DefaultSyncHandler

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());
}
Also used : ExternalIdentityProvider(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityProvider) SyncHandler(org.apache.jackrabbit.oak.spi.security.authentication.external.SyncHandler) DefaultSyncHandler(org.apache.jackrabbit.oak.spi.security.authentication.external.impl.DefaultSyncHandler) CheckForNull(javax.annotation.CheckForNull) SyncManager(org.apache.jackrabbit.oak.spi.security.authentication.external.SyncManager) DefaultSyncHandler(org.apache.jackrabbit.oak.spi.security.authentication.external.impl.DefaultSyncHandler) ExternalIdentityProviderManager(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityProviderManager) Before(org.junit.Before)

Aggregations

DefaultSyncHandler (org.apache.jackrabbit.oak.spi.security.authentication.external.impl.DefaultSyncHandler)5 AbstractExternalAuthTest (org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest)3 SyncHandler (org.apache.jackrabbit.oak.spi.security.authentication.external.SyncHandler)3 Test (org.junit.Test)3 Hashtable (java.util.Hashtable)2 BundleContext (org.osgi.framework.BundleContext)2 ServiceRegistration (org.osgi.framework.ServiceRegistration)2 CheckForNull (javax.annotation.CheckForNull)1 ExternalIdentityProvider (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityProvider)1 ExternalIdentityProviderManager (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityProviderManager)1 SyncManager (org.apache.jackrabbit.oak.spi.security.authentication.external.SyncManager)1 DefaultSyncConfig (org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncConfig)1 Before (org.junit.Before)1 Ignore (org.junit.Ignore)1