Search in sources :

Example 1 with AuthModuleEntry

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;
}
Also used : AuthModuleEntry(org.jboss.security.auth.container.config.AuthModuleEntry) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) JASPIAuthenticationInfo(org.jboss.security.auth.login.JASPIAuthenticationInfo) LoginModuleStackHolder(org.jboss.security.auth.login.LoginModuleStackHolder) AppConfigurationEntry(javax.security.auth.login.AppConfigurationEntry) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Aggregations

HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 AppConfigurationEntry (javax.security.auth.login.AppConfigurationEntry)1 ModelNode (org.jboss.dmr.ModelNode)1 Property (org.jboss.dmr.Property)1 AuthModuleEntry (org.jboss.security.auth.container.config.AuthModuleEntry)1 JASPIAuthenticationInfo (org.jboss.security.auth.login.JASPIAuthenticationInfo)1 LoginModuleStackHolder (org.jboss.security.auth.login.LoginModuleStackHolder)1