Search in sources :

Example 6 with ServerAuthModule

use of javax.security.auth.message.module.ServerAuthModule 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

ServerAuthModule (javax.security.auth.message.module.ServerAuthModule)6 HashMap (java.util.HashMap)3 AuthException (javax.security.auth.message.AuthException)3 Map (java.util.Map)2 Subject (javax.security.auth.Subject)2 SSOToken (com.iplanet.sso.SSOToken)1 AuthPolicy (com.sun.enterprise.security.jauth.AuthPolicy)1 FailureException (com.sun.enterprise.security.jauth.FailureException)1 PendingException (com.sun.enterprise.security.jauth.PendingException)1 AuthLoginException (com.sun.identity.authentication.spi.AuthLoginException)1 AuthenticationException (com.sun.identity.authentication.spi.AuthenticationException)1 IOException (java.io.IOException)1 Constructor (java.lang.reflect.Constructor)1 Principal (java.security.Principal)1 PrivilegedActionException (java.security.PrivilegedActionException)1 ArrayList (java.util.ArrayList)1 Callback (javax.security.auth.callback.Callback)1 LoginException (javax.security.auth.login.LoginException)1 MessageInfo (javax.security.auth.message.MessageInfo)1 ServerAuthConfig (javax.security.auth.message.config.ServerAuthConfig)1