use of javax.security.auth.login.Configuration in project zm-mailbox by Zimbra.
the class SaslAuthenticator method getLoginContext.
private LoginContext getLoginContext() throws LoginException {
Map<String, String> options = new HashMap<String, String>();
options.put("debug", Boolean.toString(config.getLogger().isDebugEnabled()));
options.put("principal", getPrincipal());
// options.put("useTicketCache", "true");
// options.put("storeKey", "true");
final AppConfigurationEntry ace = new AppConfigurationEntry(LOGIN_MODULE_NAME, AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, options);
Configuration config = new Configuration() {
@Override
public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
return new AppConfigurationEntry[] { ace };
}
@Override
public void refresh() {
}
};
return new LoginContext("krb5", null, new SaslCallbackHandler(), config);
}
use of javax.security.auth.login.Configuration in project jackrabbit-oak by apache.
the class TokenDefaultLoginModuleTest method getConfiguration.
@Override
protected Configuration getConfiguration() {
return new Configuration() {
@Override
public AppConfigurationEntry[] getAppConfigurationEntry(String s) {
AppConfigurationEntry tokenEntry = new AppConfigurationEntry(TokenLoginModule.class.getName(), AppConfigurationEntry.LoginModuleControlFlag.SUFFICIENT, Collections.<String, Object>emptyMap());
AppConfigurationEntry defaultEntry = new AppConfigurationEntry(LoginModuleImpl.class.getName(), AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, Collections.<String, Object>emptyMap());
return new AppConfigurationEntry[] { tokenEntry, defaultEntry };
}
};
}
use of javax.security.auth.login.Configuration in project jackrabbit-oak by apache.
the class GuestDefaultLoginModuleTest method getConfiguration.
@Override
protected Configuration getConfiguration() {
return new Configuration() {
@Override
public AppConfigurationEntry[] getAppConfigurationEntry(String s) {
AppConfigurationEntry guestEntry = new AppConfigurationEntry(GuestLoginModule.class.getName(), AppConfigurationEntry.LoginModuleControlFlag.OPTIONAL, Collections.<String, Object>emptyMap());
AppConfigurationEntry defaultEntry = new AppConfigurationEntry(LoginModuleImpl.class.getName(), AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, Collections.<String, Object>emptyMap());
return new AppConfigurationEntry[] { guestEntry, defaultEntry };
}
};
}
use of javax.security.auth.login.Configuration in project sling by apache.
the class DelegatingLoginModule method initialize.
public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options) {
Configuration config = null;
try {
config = Configuration.getInstance(JAAS_CONFIG_ALGO_NAME, null, providerName);
} catch (NoSuchProviderException e) {
logger.debug("No provider " + providerName + "found so far", e);
} catch (NoSuchAlgorithmException e) {
logger.debug("No provider " + providerName + "found so far for fetching JAAS " + "config with algorithm name " + JAAS_CONFIG_ALGO_NAME, e);
}
if (config != null) {
final Thread current = Thread.currentThread();
final ClassLoader orig = current.getContextClassLoader();
try {
current.setContextClassLoader(DelegatingLoginModule.class.getClassLoader());
loginContext = new LoginContext(appName, subject, callbackHandler, config);
} catch (LoginException e) {
loginException = e;
} finally {
current.setContextClassLoader(orig);
}
} else {
//No support so far from OSGi so would use default logic used by Jackrabbit
//to construct the LoginModule
Properties p = new Properties();
p.putAll(options);
BeanConfig bc = new BeanConfig(delegateLoginModuleClass, p);
LoginModuleConfig lmc = new LoginModuleConfig(bc);
try {
delegate = lmc.getLoginModule();
delegate.initialize(subject, callbackHandler, sharedState, options);
logger.info("No JAAS Configuration provider found would be directly invoking LoginModule {}", delegateLoginModuleClass);
} catch (ConfigurationException e) {
//Behaviour is same as org.apache.jackrabbit.core.security.authentication.LocalAuthContext.login()
loginException = new LoginException(e.getMessage());
}
}
}
use of javax.security.auth.login.Configuration in project camel by apache.
the class HdfsComponent method getJAASConfiguration.
static Configuration getJAASConfiguration() {
Configuration auth = null;
try {
auth = Configuration.getConfiguration();
LOG.trace("Existing JAAS Configuration {}", auth);
} catch (SecurityException e) {
LOG.trace("Cannot load existing JAAS configuration", e);
}
return auth;
}
Aggregations