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'.");
}
}
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());
}
Aggregations