public int authorize(Resource resource)
{
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;
//Populate local variables from the resource
/*this.ejbMethod = (Method)map.get(ResourceKeys.EJB_METHOD);
this.ejbName = (String)map.get(ResourceKeys.EJB_NAME);
this.ejbPrincipal = (Principal)map.get(ResourceKeys.EJB_PRINCIPAL);
this.methodInterface = (String)map.get(ResourceKeys.EJB_METHODINTERFACE);
this.methodRoles = (Set)map.get(ResourceKeys.EJB_METHODROLES);
this.callerRunAsIdentity = (RunAsIdentity)map.get(ResourceKeys.RUNASIDENTITY);
this.securityRoleReferences = (Set)map.get(ResourceKeys.SECURITY_ROLE_REFERENCES);
*/
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.getMethodRoles();
this.securityRoleReferences = ejbResource.getSecurityRoleReferences();
if(this.roleRefCheck == Boolean.TRUE)
return checkRoleRef();
else
return process();