use of org.jboss.security.auth.container.config.AuthModuleEntry in project wildfly by wildfly.
the class SecurityDomainAdd method processJASPIAuth.
private boolean processJASPIAuth(OperationContext context, String securityDomain, ModelNode node, ApplicationPolicy applicationPolicy) throws OperationFailedException {
node = peek(node, AUTHENTICATION, JASPI);
if (node == null) {
return false;
}
JASPIAuthenticationInfo authenticationInfo = new JASPIAuthenticationInfo(securityDomain);
Map<String, LoginModuleStackHolder> holders = new HashMap<String, LoginModuleStackHolder>();
if (node.hasDefined(LOGIN_MODULE_STACK)) {
List<Property> stacks = node.get(LOGIN_MODULE_STACK).asPropertyList();
for (Property stack : stacks) {
String name = stack.getName();
ModelNode stackNode = stack.getValue();
final LoginModuleStackHolder holder = new LoginModuleStackHolder(name, null);
holders.put(name, holder);
authenticationInfo.add(holder);
if (stackNode.hasDefined(LOGIN_MODULE)) {
processLoginModules(context, stackNode.get(LOGIN_MODULE), authenticationInfo, new LoginModuleContainer() {
public void addAppConfigurationEntry(AppConfigurationEntry entry) {
holder.addAppConfigurationEntry(entry);
}
});
}
}
}
for (Property moduleProperty : node.get(AUTH_MODULE).asPropertyList()) {
ModelNode authModule = moduleProperty.getValue();
String code = extractCode(context, authModule, ModulesMap.AUTHENTICATION_MAP);
String loginStackRef = null;
if (authModule.hasDefined(LOGIN_MODULE_STACK_REF)) {
loginStackRef = JASPIMappingModuleDefinition.LOGIN_MODULE_STACK_REF.resolveModelAttribute(context, authModule).asString();
}
Map<String, Object> options = extractOptions(context, authModule);
AuthModuleEntry entry = new AuthModuleEntry(code, options, loginStackRef);
if (authModule.hasDefined(FLAG)) {
String flag = LoginModuleResourceDefinition.FLAG.resolveModelAttribute(context, authModule).asString();
entry.setControlFlag(ControlFlag.valueOf(flag));
}
if (loginStackRef != null) {
if (!holders.containsKey(loginStackRef)) {
throw SecurityLogger.ROOT_LOGGER.loginModuleStackIllegalArgument(loginStackRef);
}
entry.setLoginModuleStackHolder(holders.get(loginStackRef));
}
authenticationInfo.add(entry);
ModelNode moduleName = LoginModuleResourceDefinition.MODULE.resolveModelAttribute(context, authModule);
if (moduleName.isDefined() && !moduleName.asString().isEmpty()) {
authenticationInfo.addJBossModuleName(moduleName.asString());
} else {
authenticationInfo.addJBossModuleName(DEFAULT_MODULE);
}
}
applicationPolicy.setAuthenticationInfo(authenticationInfo);
return true;
}
Aggregations