if(_logger.isLoggable(Level.FINE)){
_logger.entering("EJBSecurityManager", "isCallerInRole", role);
}
EJBRoleRefPermission ejbrr = new EJBRoleRefPermission(ejbName, role);
SecurityContext sc;
if (runAs != null) {
InvocationManager im = theSwitch.getInvocationManager();
ComponentInvocation ci = im.getCurrentInvocation();
sc = ci.getOldSecurityContext();
} else {
sc = SecurityContext.getCurrent();
}
Set principalSet = null;
if (sc != null) principalSet = sc.getPrincipalSet();
ProtectionDomain prdm = getCachedProtectionDomain(principalSet,true);
try {
// set the policy context in the TLS.
String oldContextId = setPolicyContext(this.contextId);
try {
ret = policy.implies(prdm, ejbrr);
} catch (SecurityException se) {
_logger.log(Level.SEVERE, "JACC: Unexpected security exception isCallerInRole", se);
ret = false;
} catch (Throwable t) {
_logger.log(Level.SEVERE, "JACC: Unexpected exception isCallerInRole", t);
ret = false;
} finally {
resetPolicyContext(oldContextId, this.contextId);
}
} catch (Throwable t) {
_logger.log(Level.SEVERE, "JACC: Unexpected exception manipulating policy context", t);
ret = false;
}
if(_logger.isLoggable(Level.FINE)){
_logger.fine("JACC: isCallerInRole Result: " +ret + " EJBRoleRefPermission (Name) = "+ ejbrr.getName() + " (Action) = "+ ejbrr.getActions() + " (Codesource) = " + prdm.getCodeSource());
}
return ret;
}