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;
}
Aggregations