use of org.jboss.security.AuthenticationManager in project wildfly by wildfly.
the class JNDIBasedSecurityManagement method createAuthenticationManager.
/**
* Creates an {@code AuthenticationManager}
*
* @param securityDomain name of the security domain
* @return an instance of {@code AuthenticationManager}
* @throws Exception if creation fails
*/
private AuthenticationManager createAuthenticationManager(String securityDomain) throws Exception {
int i = callbackHandlerClassName.lastIndexOf(":");
if (i == -1)
throw SecurityLogger.ROOT_LOGGER.missingModuleName("default-callback-handler-class-name attribute");
String moduleSpec = callbackHandlerClassName.substring(0, i);
String className = callbackHandlerClassName.substring(i + 1);
Class<?> callbackHandlerClazz = SecurityActions.getModuleClassLoader(loader, moduleSpec).loadClass(className);
CallbackHandler ch = (CallbackHandler) callbackHandlerClazz.newInstance();
i = authenticationManagerClassName.lastIndexOf(":");
if (i == -1)
throw SecurityLogger.ROOT_LOGGER.missingModuleName("authentication-manager-class-name attribute");
moduleSpec = authenticationManagerClassName.substring(0, i);
className = authenticationManagerClassName.substring(i + 1);
Class<?> clazz = SecurityActions.getModuleClassLoader(loader, moduleSpec).loadClass(className);
Constructor<?> ctr = clazz.getConstructor(new Class[] { String.class, CallbackHandler.class });
return (AuthenticationManager) ctr.newInstance(new Object[] { securityDomain, ch });
}
use of org.jboss.security.AuthenticationManager in project wildfly by wildfly.
the class JNDIBasedSecurityManagement method createSecurityDomainContext.
/**
* Creates a {@code SecurityDomainContext}
*
* @param securityDomain name of the security domain
* @param cacheFactory creates a cache implementation
* @return an instance of {@code SecurityDomainContext}
* @throws Exception if an error occurs during creation
*/
public SecurityDomainContext createSecurityDomainContext(String securityDomain, AuthenticationCacheFactory cacheFactory) throws Exception {
SecurityLogger.ROOT_LOGGER.debugf("Creating SDC for domain = %s", securityDomain);
AuthenticationManager am = createAuthenticationManager(securityDomain);
if (cacheFactory != null && am instanceof CacheableManager) {
// create authentication cache
final Map<Principal, ?> cache = cacheFactory.getCache();
if (cache != null) {
@SuppressWarnings({ "unchecked", "rawtypes" }) CacheableManager<Map, Principal> cm = (CacheableManager<Map, Principal>) am;
cm.setCache(cache);
}
}
// set DeepCopySubject option if supported
if (deepCopySubjectMode) {
setDeepCopySubjectMode(am);
}
SecurityDomainContext securityDomainContext = new SecurityDomainContext(am);
securityDomainContext.setAuthorizationManager(createAuthorizationManager(securityDomain));
securityDomainContext.setAuditManager(createAuditManager(securityDomain));
securityDomainContext.setIdentityTrustManager(createIdentityTrustManager(securityDomain));
securityDomainContext.setMappingManager(createMappingManager(securityDomain));
return securityDomainContext;
}
Aggregations