if (_logger.isLoggable(Level.FINE)) {
_logger.entering("EJBSecurityManager", "isCallerInRole", role);
}
EJBRoleRefPermission ejbrr = new EJBRoleRefPermission(ejbName, role);
SecurityContext sc;
if (runAs != null) {
ComponentInvocation ci = invMgr.getCurrentInvocation();
sc = (SecurityContext) ci.getOldSecurityContext();
} else {
sc = SecurityContext.getCurrent();
}
Set principalSet = null;
if (sc != null) principalSet = sc.getPrincipalSet();
ProtectionDomain prdm = getCachedProtectionDomain(principalSet, true);
String oldContextId = null;
try {
// set the policy context in the TLS.
oldContextId = setPolicyContext(this.contextId);
ret = policy.implies(prdm, ejbrr);
} catch (SecurityException se) {
_logger.log(Level.SEVERE, "jacc_is_caller_in_role_exception", se);
ret = false;
} catch (Throwable t) {
_logger.log(Level.SEVERE, "jacc_is_caller_in_role_exception", t);
ret = false;
} finally {
try {
resetPolicyContext(oldContextId, this.contextId);
} catch (Throwable ex) {
_logger.log(Level.SEVERE, "jacc_policy_context_exception", ex);
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;
}