public int authorize(Resource resource, Subject callerSubject, RoleGroup role)
{
if(resource instanceof EJBResource == false)
throw new IllegalArgumentException("resource is not an EJBResource");
EJBResource ejbResource = (EJBResource) resource;
//Get the context map
Map<String,Object> map = resource.getMap();
if(map == null)
throw new IllegalStateException("Map from the Resource is null");
this.policyRegistration = (PolicyRegistration) map.get(ResourceKeys.POLICY_REGISTRATION);
if(this.policyRegistration == null)
throw new IllegalStateException("Policy Registration passed is null");
this.callerRunAs = ejbResource.getCallerRunAsIdentity();
this.ejbName = ejbResource.getEjbName();
this.ejbMethod = ejbResource.getEjbMethod();
this.ejbPrincipal = ejbResource.getPrincipal();
this.policyContextID = ejbResource.getPolicyContextID();
if(policyContextID == null)
throw new IllegalStateException("Context ID is null");
this.securityRoleReferences = ejbResource.getSecurityRoleReferences();
//isCallerInRole checks
this.roleName = (String)map.get(ResourceKeys.ROLENAME);
Boolean roleRefCheck = checkBooleanValue((Boolean)map.get(ResourceKeys.ROLEREF_PERM_CHECK));