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");
/*AuthorizationManager am = (AuthorizationManager) map.get("authorizationManager");
if(am == null)
throw new IllegalStateException("Authorization Manager is null");
if(am instanceof PolicyRegistration)
this.policyRegistration = (PolicyRegistration) am; */
this.policyRegistration = (PolicyRegistration) map.get(ResourceKeys.POLICY_REGISTRATION);
this.roleName = (String)map.get(ResourceKeys.ROLENAME);
this.roleRefCheck = (Boolean)map.get(ResourceKeys.ROLEREF_PERM_CHECK);
this.callerRunAs = ejbResource.getCallerRunAsIdentity();
this.ejbMethod = ejbResource.getEjbMethod();
this.ejbName = ejbResource.getEjbName();
this.ejbPrincipal = ejbResource.getPrincipal();
this.methodInterface = ejbResource.getEjbMethodInterface();
this.methodRoles = ejbResource.getEjbMethodRoles();
this.securityRoleReferences = ejbResource.getSecurityRoleReferences();
if(this.roleRefCheck == Boolean.TRUE)
return checkRoleRef(role);
else
return process(role);