/** * Subclasses can use this method to leave the authorization * decision to the delegate configured */ protected int invokeDelegate(Resource resource) { int authorizationDecision = AuthorizationContext.DENY; ResourceType layer = resource.getLayer(); String delegateStr = (String)delegateMap.get(layer); if(delegateStr == null) throw new IllegalStateException("Delegate is missing for layer="+layer); AuthorizationModuleDelegate delegate = null; try { delegate = getDelegate(delegateStr); authorizationDecision = delegate.authorize(resource,this.subject, this.role); } catch(Exception e) { log.debug("Error with delegate:",e); IllegalStateException ise = new IllegalStateException(e.getLocalizedMessage()); ise.initCause(e); throw ise; } return authorizationDecision; }
private ACLInfo getACLInfo(String domainName, Resource resource) { ApplicationPolicy aPolicy = SecurityConfiguration.getApplicationPolicy(domainName); if (aPolicy == null) { if (trace) log.trace("Application Policy not obtained for domain=" + domainName + ". Trying to obtain the App policy for the default domain of the layer:"); aPolicy = SecurityConfiguration.getApplicationPolicy(resource.getLayer().name()); } if (aPolicy == null) throw new IllegalStateException("Application Policy is null for domain:" + domainName); return aPolicy.getAclInfo(); }
/** * Subclasses can use this method to leave the authorization * decision to the delegate configured */ protected int invokeDelegate(Resource resource) { int authorizationDecision = AuthorizationContext.DENY; ResourceType layer = resource.getLayer(); String delegateStr = (String)delegateMap.get(layer); if(delegateStr == null) throw PicketBoxMessages.MESSAGES.missingDelegateForLayer(layer != null ? layer.toString() : null); AuthorizationModuleDelegate delegate = null; try { delegate = getDelegate(delegateStr); authorizationDecision = delegate.authorize(resource,this.subject, this.role); } catch(Exception e) { IllegalStateException ise = new IllegalStateException(e.getLocalizedMessage()); ise.initCause(e); throw ise; } return authorizationDecision; }
private AuthorizationInfo getAuthorizationInfo(String domainName, Resource resource) ResourceType layer = resource.getLayer();
private AuthorizationInfo getAuthorizationInfo(String domainName, Resource resource) { ResourceType layer = resource.getLayer(); //Check if an instance of ApplicationPolicy is available if (this.applicationPolicy != null) return applicationPolicy.getAuthorizationInfo(); ApplicationPolicy aPolicy = SecurityConfiguration.getApplicationPolicy(domainName); if (aPolicy == null) { if (layer == ResourceType.EJB) aPolicy = SecurityConfiguration.getApplicationPolicy(EJB); else if (layer == ResourceType.WEB) aPolicy = SecurityConfiguration.getApplicationPolicy(WEB); } if (aPolicy == null) throw PicketBoxMessages.MESSAGES.failedToObtainApplicationPolicy(domainName); AuthorizationInfo ai = aPolicy.getAuthorizationInfo(); if (ai == null) return getAuthorizationInfo(layer); else return aPolicy.getAuthorizationInfo(); }