Search in sources :

Example 1 with SyncManager

use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncManager in project jackrabbit-oak by apache.

the class ExternalLoginModule method initialize.

//--------------------------------------------------------< LoginModule >---
@Override
public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> opts) {
    super.initialize(subject, callbackHandler, sharedState, opts);
    // merge options with osgi options if needed
    if (osgiConfig != null) {
        options = ConfigurationParameters.of(osgiConfig, options);
    }
    Whiteboard whiteboard = getWhiteboard();
    if (whiteboard == null) {
        log.error("External login module needs whiteboard. Will not be used for login.");
        return;
    }
    String idpName = options.getConfigValue(PARAM_IDP_NAME, "");
    if (idpName.isEmpty()) {
        log.error("External login module needs IPD name. Will not be used for login.");
    } else {
        if (idpManager == null) {
            idpManager = WhiteboardUtils.getService(whiteboard, ExternalIdentityProviderManager.class);
        }
        if (idpManager == null) {
            log.error("External login module needs IDPManager. Will not be used for login.");
        } else {
            idp = idpManager.getProvider(idpName);
            if (idp == null) {
                log.error("No IDP found with name {}. Will not be used for login.", idpName);
            }
        }
    }
    String syncHandlerName = options.getConfigValue(PARAM_SYNC_HANDLER_NAME, "");
    if (syncHandlerName.isEmpty()) {
        log.error("External login module needs SyncHandler name. Will not be used for login.");
    } else {
        if (syncManager == null) {
            syncManager = WhiteboardUtils.getService(whiteboard, SyncManager.class);
        }
        if (syncManager == null) {
            log.error("External login module needs SyncManager. Will not be used for login.");
        } else {
            syncHandler = syncManager.getSyncHandler(syncHandlerName);
            if (syncHandler == null) {
                log.error("No SyncHandler found with name {}. Will not be used for login.", syncHandlerName);
            }
        }
    }
    if (idp instanceof CredentialsSupport) {
        credentialsSupport = (CredentialsSupport) idp;
    } else {
        log.debug("No 'SupportedCredentials' configured. Using default implementation supporting 'SimpleCredentials'.");
    }
}
Also used : SimpleCredentialsSupport(org.apache.jackrabbit.oak.spi.security.authentication.credentials.SimpleCredentialsSupport) CredentialsSupport(org.apache.jackrabbit.oak.spi.security.authentication.credentials.CredentialsSupport) SyncManager(org.apache.jackrabbit.oak.spi.security.authentication.external.SyncManager) ExternalIdentityProviderManager(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityProviderManager) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard)

Example 2 with SyncManager

use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncManager 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

ExternalIdentityProviderManager (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityProviderManager)2 SyncManager (org.apache.jackrabbit.oak.spi.security.authentication.external.SyncManager)2 CheckForNull (javax.annotation.CheckForNull)1 CredentialsSupport (org.apache.jackrabbit.oak.spi.security.authentication.credentials.CredentialsSupport)1 SimpleCredentialsSupport (org.apache.jackrabbit.oak.spi.security.authentication.credentials.SimpleCredentialsSupport)1 ExternalIdentityProvider (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityProvider)1 SyncHandler (org.apache.jackrabbit.oak.spi.security.authentication.external.SyncHandler)1 DefaultSyncHandler (org.apache.jackrabbit.oak.spi.security.authentication.external.impl.DefaultSyncHandler)1 Whiteboard (org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard)1 Before (org.junit.Before)1