use of org.apache.jackrabbit.oak.spi.security.authentication.credentials.CredentialsSupport 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.credentials.CredentialsSupport in project jackrabbit-oak by apache.
the class TokenConfigurationImplOSGiTest method testUnbindCredentialsSupport.
@Test
public void testUnbindCredentialsSupport() {
CredentialsSupport testSupport = new TestCredentialsSupport(sc.getUserID());
ServiceRegistration registration = context.bundleContext().registerService(CredentialsSupport.class.getName(), testSupport, new Hashtable());
TokenProvider tp = tokenConfiguration.getTokenProvider(root);
assertFalse(tp.doCreateToken(sc));
assertTrue(tp.doCreateToken(new TestCredentialsSupport.Creds()));
registration.unregister();
tp = tokenConfiguration.getTokenProvider(root);
assertTrue(tp.doCreateToken(sc));
assertFalse(tp.doCreateToken(new TestCredentialsSupport.Creds()));
}
Aggregations