/** * @see AuthorizationModuleDelegate#authorize(Resource) */ 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); this.ejbCS = ejbResource.getCodeSource(); this.ejbMethod = ejbResource.getEjbMethod(); this.ejbName = ejbResource.getEjbName(); this.methodInterface = ejbResource.getEjbMethodInterface(); //isCallerInRole checks this.roleName = (String)map.get(ResourceKeys.ROLENAME); this.roleRefCheck = (Boolean)map.get(ResourceKeys.ROLEREF_PERM_CHECK); if(this.roleRefCheck == Boolean.TRUE) return checkRoleRef(callerSubject, role); else return process(callerSubject, role); }
this.ejbCS = ejbResource.getCodeSource(); this.ejbMethod = ejbResource.getEjbMethod(); this.ejbName = ejbResource.getEjbName();
/** * Validate that the EJBResource has all the parameters to make a decision * @param ejbResource */ private void validateEJBResource( EJBResource ejbResource ) throws MissingArgumentsException { if( ejbResource.getEjbName() == null ) throw PicketBoxMessages.MESSAGES.invalidNullArgument("ejbName"); if( ejbResource.getEjbMethod() == null ) throw PicketBoxMessages.MESSAGES.invalidNullArgument("ejbMethod"); if( ejbResource.getCodeSource() == null ) throw PicketBoxMessages.MESSAGES.invalidNullArgument("ejbCodeSource"); if( ejbResource.getPolicyContextID() == null ) throw PicketBoxMessages.MESSAGES.invalidNullArgument("contextID"); if( ejbResource.getCallerSubject() == null && ejbResource.getCallerRunAsIdentity() == null) throw new MissingArgumentsException(PicketBoxMessages.MESSAGES.missingCallerInfoMessage()); }