Search in sources :

Example 1 with ControlFlag

use of org.jboss.security.config.ControlFlag in project wildfly by wildfly.

the class SecurityDomainAdd method processAuthorization.

private boolean processAuthorization(OperationContext context, String securityDomain, ModelNode node, ApplicationPolicy applicationPolicy) throws OperationFailedException {
    node = peek(node, AUTHORIZATION, CLASSIC, POLICY_MODULE);
    if (node == null) {
        return false;
    }
    AuthorizationInfo authzInfo = new AuthorizationInfo(securityDomain);
    for (Property moduleProperty : node.asPropertyList()) {
        ModelNode module = moduleProperty.getValue();
        String codeName = extractCode(context, module, ModulesMap.AUTHORIZATION_MAP);
        String flag = LoginModuleResourceDefinition.FLAG.resolveModelAttribute(context, module).asString();
        ControlFlag controlFlag = ControlFlag.valueOf(flag);
        Map<String, Object> options = extractOptions(context, module);
        AuthorizationModuleEntry authzModuleEntry = new AuthorizationModuleEntry(codeName, options);
        authzModuleEntry.setControlFlag(controlFlag);
        authzInfo.add(authzModuleEntry);
        ModelNode moduleName = LoginModuleResourceDefinition.MODULE.resolveModelAttribute(context, module);
        if (moduleName.isDefined() && !moduleName.asString().isEmpty()) {
            authzInfo.addJBossModuleName(moduleName.asString());
        } else {
            authzInfo.addJBossModuleName(DEFAULT_MODULE);
        }
    }
    applicationPolicy.setAuthorizationInfo(authzInfo);
    return true;
}
Also used : ModelNode(org.jboss.dmr.ModelNode) AuthorizationInfo(org.jboss.security.config.AuthorizationInfo) Property(org.jboss.dmr.Property) AuthorizationModuleEntry(org.jboss.security.authorization.config.AuthorizationModuleEntry) ControlFlag(org.jboss.security.config.ControlFlag) LoginModuleControlFlag(javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag)

Example 2 with ControlFlag

use of org.jboss.security.config.ControlFlag in project wildfly by wildfly.

the class SecurityDomainAdd method processACL.

private boolean processACL(OperationContext context, String securityDomain, ModelNode node, ApplicationPolicy applicationPolicy) throws OperationFailedException {
    node = peek(node, ACL, CLASSIC, ACL_MODULE);
    if (node == null) {
        return false;
    }
    ACLInfo aclInfo = new ACLInfo(securityDomain);
    for (Property moduleProperty : node.asPropertyList()) {
        ModelNode module = moduleProperty.getValue();
        String codeName = LoginModuleResourceDefinition.CODE.resolveModelAttribute(context, module).asString();
        String flag = LoginModuleResourceDefinition.FLAG.resolveModelAttribute(context, module).asString();
        ControlFlag controlFlag = ControlFlag.valueOf(flag);
        Map<String, Object> options = extractOptions(context, module);
        ACLProviderEntry entry = new ACLProviderEntry(codeName, options);
        entry.setControlFlag(controlFlag);
        aclInfo.add(entry);
        ModelNode moduleName = LoginModuleResourceDefinition.MODULE.resolveModelAttribute(context, module);
        if (moduleName.isDefined() && !moduleName.asString().isEmpty()) {
            aclInfo.addJBossModuleName(moduleName.asString());
        } else {
            aclInfo.addJBossModuleName(DEFAULT_MODULE);
        }
    }
    applicationPolicy.setAclInfo(aclInfo);
    return true;
}
Also used : ACLInfo(org.jboss.security.config.ACLInfo) ACLProviderEntry(org.jboss.security.acl.config.ACLProviderEntry) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property) ControlFlag(org.jboss.security.config.ControlFlag) LoginModuleControlFlag(javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag)

Example 3 with ControlFlag

use of org.jboss.security.config.ControlFlag in project wildfly by wildfly.

the class SecurityDomainAdd method processIdentityTrust.

private boolean processIdentityTrust(OperationContext context, String securityDomain, ModelNode node, ApplicationPolicy applicationPolicy) throws OperationFailedException {
    node = peek(node, IDENTITY_TRUST, CLASSIC, TRUST_MODULE);
    if (node == null) {
        return false;
    }
    IdentityTrustInfo identityTrustInfo = new IdentityTrustInfo(securityDomain);
    for (Property moduleProperty : node.asPropertyList()) {
        ModelNode module = moduleProperty.getValue();
        String codeName = LoginModuleResourceDefinition.CODE.resolveModelAttribute(context, module).asString();
        String flag = LoginModuleResourceDefinition.FLAG.resolveModelAttribute(context, module).asString();
        ControlFlag controlFlag = ControlFlag.valueOf(flag);
        Map<String, Object> options = extractOptions(context, module);
        IdentityTrustModuleEntry entry = new IdentityTrustModuleEntry(codeName, options);
        entry.setControlFlag(controlFlag);
        identityTrustInfo.add(entry);
        ModelNode moduleName = LoginModuleResourceDefinition.MODULE.resolveModelAttribute(context, module);
        if (moduleName.isDefined() && !moduleName.asString().isEmpty()) {
            identityTrustInfo.addJBossModuleName(moduleName.asString());
        } else {
            identityTrustInfo.addJBossModuleName(DEFAULT_MODULE);
        }
    }
    applicationPolicy.setIdentityTrustInfo(identityTrustInfo);
    return true;
}
Also used : IdentityTrustModuleEntry(org.jboss.security.identitytrust.config.IdentityTrustModuleEntry) IdentityTrustInfo(org.jboss.security.config.IdentityTrustInfo) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property) ControlFlag(org.jboss.security.config.ControlFlag) LoginModuleControlFlag(javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag)

Example 4 with ControlFlag

use of org.jboss.security.config.ControlFlag in project jbossws-cxf by jbossws.

the class JBossWSClientAuthConfig method getAuthContext.

@SuppressWarnings({ "rawtypes", "unchecked" })
public ClientAuthContext getAuthContext(String authContextID, Subject clientSubject, Map properties) throws AuthException {
    List<ControlFlag> controlFlags = new ArrayList<ControlFlag>();
    Map<String, Map> mapOptionsByName = new HashMap<String, Map>();
    JASPIAuthenticationInfo jai = (JASPIAuthenticationInfo) properties.get("jaspi-policy");
    AuthModuleEntry[] amearr = jai.getAuthModuleEntry();
    ClassLoader moduleCL = null;
    String jbossModule = jai.getJBossModuleName();
    if (jbossModule != null && !jbossModule.isEmpty()) {
        ClassLoaderLocator locator = ClassLoaderLocatorFactory.get();
        if (locator != null)
            moduleCL = locator.get(jbossModule);
    }
    for (AuthModuleEntry ame : amearr) {
        try {
            mapOptionsByName.put(ame.getAuthModuleName(), ame.getOptions());
            controlFlags.add(ame.getControlFlag());
            ClientAuthModule sam = this.createCAM(moduleCL, ame.getAuthModuleName());
            Map options = new HashMap();
            sam.initialize(null, null, callbackHandler, options);
            modules.add(sam);
        } catch (Exception e) {
            throw new AuthException(e.getLocalizedMessage());
        }
    }
    JBossWSClientAuthContext clientAuthContext = new JBossWSClientAuthContext(modules, mapOptionsByName, this.callbackHandler);
    clientAuthContext.setControlFlags(controlFlags);
    return clientAuthContext;
}
Also used : AuthModuleEntry(org.jboss.security.auth.container.config.AuthModuleEntry) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) JASPIAuthenticationInfo(org.jboss.security.auth.login.JASPIAuthenticationInfo) AuthException(javax.security.auth.message.AuthException) SOAPException(javax.xml.soap.SOAPException) AuthException(javax.security.auth.message.AuthException) ControlFlag(org.jboss.security.config.ControlFlag) ClientAuthModule(javax.security.auth.message.module.ClientAuthModule) ClassLoaderLocator(org.jboss.security.plugins.ClassLoaderLocator) HashMap(java.util.HashMap) Map(java.util.Map)

Example 5 with ControlFlag

use of org.jboss.security.config.ControlFlag in project jbossws-cxf by jbossws.

the class JBossWSServerAuthConfig method getAuthContext.

@SuppressWarnings({ "rawtypes", "unchecked" })
public ServerAuthContext getAuthContext(String authContextID, Subject serviceSubject, Map properties) throws AuthException {
    List<ControlFlag> controlFlags = new ArrayList<ControlFlag>();
    Map<String, Map> mapOptionsByName = new HashMap<String, Map>();
    JASPIAuthenticationInfo jai = (JASPIAuthenticationInfo) properties.get("jaspi-policy");
    AuthModuleEntry[] amearr = jai.getAuthModuleEntry();
    ClassLoader moduleCL = null;
    String jbossModule = jai.getJBossModuleName();
    if (jbossModule != null && !jbossModule.isEmpty()) {
        ClassLoaderLocator locator = ClassLoaderLocatorFactory.get();
        if (locator != null)
            moduleCL = locator.get(jbossModule);
    }
    for (AuthModuleEntry ame : amearr) {
        if (ame.getLoginModuleStackHolderName() != null) {
            try {
                mapOptionsByName.put(ame.getAuthModuleName(), ame.getOptions());
                controlFlags.add(ame.getControlFlag());
                ServerAuthModule sam = this.createSAM(moduleCL, ame.getAuthModuleName(), ame.getLoginModuleStackHolderName());
                Map options = new HashMap();
                Bus bus = (Bus) properties.get(Bus.class);
                options.put(Bus.class, bus);
                javax.xml.ws.Endpoint endpoint = (javax.xml.ws.Endpoint) properties.get(javax.xml.ws.Endpoint.class);
                options.put(javax.xml.ws.Endpoint.class, endpoint);
                sam.initialize(null, null, callbackHandler, options);
                modules.add(sam);
            } catch (Exception e) {
                throw new AuthException(e.getLocalizedMessage());
            }
        } else {
            try {
                mapOptionsByName.put(ame.getAuthModuleName(), ame.getOptions());
                controlFlags.add(ame.getControlFlag());
                ServerAuthModule sam = this.createSAM(moduleCL, ame.getAuthModuleName());
                Map options = new HashMap();
                sam.initialize(null, null, callbackHandler, options);
                modules.add(sam);
            } catch (Exception e) {
                throw new AuthException(e.getLocalizedMessage());
            }
        }
    }
    JBossWSServerAuthContext serverAuthContext = new JBossWSServerAuthContext(modules, mapOptionsByName, this.callbackHandler);
    serverAuthContext.setControlFlags(controlFlags);
    return serverAuthContext;
}
Also used : AuthModuleEntry(org.jboss.security.auth.container.config.AuthModuleEntry) Bus(org.apache.cxf.Bus) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) JASPIAuthenticationInfo(org.jboss.security.auth.login.JASPIAuthenticationInfo) ServerAuthModule(javax.security.auth.message.module.ServerAuthModule) AuthException(javax.security.auth.message.AuthException) SOAPException(javax.xml.soap.SOAPException) AuthException(javax.security.auth.message.AuthException) ControlFlag(org.jboss.security.config.ControlFlag) ClassLoaderLocator(org.jboss.security.plugins.ClassLoaderLocator) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ControlFlag (org.jboss.security.config.ControlFlag)5 LoginModuleControlFlag (javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag)3 ModelNode (org.jboss.dmr.ModelNode)3 Property (org.jboss.dmr.Property)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 AuthException (javax.security.auth.message.AuthException)2 SOAPException (javax.xml.soap.SOAPException)2 AuthModuleEntry (org.jboss.security.auth.container.config.AuthModuleEntry)2 JASPIAuthenticationInfo (org.jboss.security.auth.login.JASPIAuthenticationInfo)2 ClassLoaderLocator (org.jboss.security.plugins.ClassLoaderLocator)2 ClientAuthModule (javax.security.auth.message.module.ClientAuthModule)1 ServerAuthModule (javax.security.auth.message.module.ServerAuthModule)1 Bus (org.apache.cxf.Bus)1 ACLProviderEntry (org.jboss.security.acl.config.ACLProviderEntry)1 AuthorizationModuleEntry (org.jboss.security.authorization.config.AuthorizationModuleEntry)1 ACLInfo (org.jboss.security.config.ACLInfo)1 AuthorizationInfo (org.jboss.security.config.AuthorizationInfo)1 IdentityTrustInfo (org.jboss.security.config.IdentityTrustInfo)1