public javax.security.auth.message.config.ServerAuthContext | getAuthContext(java.lang.String operation, javax.security.auth.Subject subject, java.util.Map map)
PolicyMap pMap = (PolicyMap)map.get("POLICY");
WSDLPort port =(WSDLPort)map.get("WSDL_MODEL");
if (pMap == null || pMap.isEmpty()) {
//TODO: log warning here if pMap == null
return null;
}
//check if security is enabled
//if policy has changed due to redeploy, check if security is enabled
if (this.secDisabled == null || (policyMap != pMap)) {
try {
this.wLock.lock();
if (this.secDisabled == null || (policyMap != pMap)) {
if (!WSITAuthConfigProvider.isSecurityEnabled(pMap,port)) {
this.secDisabled = TRUE;
return null;
} else {
this.secDisabled = FALSE;
}
}
} finally {
this.wLock.unlock();
}
}
if (this.secDisabled == TRUE) {
return null;
}
try {
this.rLock.lock();
if (serverAuthContext != null) {
//return the cached one only if the same policyMap was passed in
if (policyMap == pMap) {
return serverAuthContext;
}
}
} finally {
this.rLock.unlock();
}
// make sure you don't hold the rlock when you request the wlock
// or you will encounter dealock
try {
this.wLock.lock();
// recheck the precondition, since the rlock was released.
if ((serverAuthContext == null) || (policyMap != pMap)) {
serverAuthContext = new WSITServerAuthContext(operation, subject, map);
policyMap = pMap;
}
return serverAuthContext;
} finally {
this.wLock.unlock();
}
|