use of org.apache.jackrabbit.core.config.BeanConfig 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 org.apache.jackrabbit.core.config.BeanConfig in project jackrabbit by apache.
the class AccessControlProviderFactoryImpl method createProvider.
/**
* @see AccessControlProviderFactory#createProvider(Session, WorkspaceSecurityConfig)
*/
public AccessControlProvider createProvider(Session systemSession, WorkspaceSecurityConfig config) throws RepositoryException {
String workspaceName = systemSession.getWorkspace().getName();
AccessControlProvider prov;
Map props;
if (config != null && config.getAccessControlProviderConfig() != null) {
BeanConfig bc = config.getAccessControlProviderConfig();
prov = bc.newInstance(AccessControlProvider.class);
props = bc.getParameters();
} else {
log.debug("No ac-provider configuration for workspace " + workspaceName + " -> using defaults.");
if (workspaceName.equals(secWorkspaceName) && !workspaceName.equals(defaultWorkspaceName)) {
// UserAccessControlProvider is designed to work with an extra
// workspace storing user and groups. therefore avoid returning
// this ac provider for the default workspace.
prov = new UserAccessControlProvider();
} else {
prov = new ACLProvider();
}
log.debug("Default provider for workspace " + workspaceName + " = " + prov.getClass().getName());
props = Collections.emptyMap();
}
prov.init(systemSession, props);
return prov;
}
Aggregations