use of com.sun.identity.policy.PolicyDecision in project OpenAM by OpenRock.
the class ResourceResultCache method getPolicyDecisionFromResourceResults.
/**
* Returns policy decision computed from a set of
* <code>ResourceResult</code> objects
*
* @param resourceResults resource results used to compute policy decision
* @param resourceName resource name for which to get policy decision
* @param resourceComparator <code>ResourceName</code>, resource
* comparison algorithm used to compare resources
*
* @return computed policy decision
*
* @throws PolicyException if can not get policy decision
*/
private PolicyDecision getPolicyDecisionFromResourceResults(Set resourceResults, String resourceName, ResourceName resourceComparator, String serviceName) throws PolicyException {
PolicyDecision pd = new PolicyDecision();
Iterator resultsIter = resourceResults.iterator();
boolean processed = false;
while (!processed && resultsIter.hasNext()) {
ResourceResult resourceResult = (ResourceResult) resultsIter.next();
processed = mergePolicyDecisions(pd, resourceResult, resourceName, resourceComparator, serviceName);
}
return pd;
}
use of com.sun.identity.policy.PolicyDecision in project OpenAM by OpenRock.
the class ResourceResultCache method getPolicyDecision.
/**
* Returns policy decision
* @param appToken application sso token to identify the client to policy
* service
*
* @param serviceName name of service for which to get policy decision
* @param token session token of user for whom to get policy decision
* @param resourceName resource name for which to get policy decision
* @param actionNames action names for which to get policy decision
* @param env environment map to use to get policy decision
*
* @param useCache flag indicating whether to return a locally cached
* policy decision. Locally cached decision is returned only if the
* value is <code>true</code>. Otherwise, policy decision is fetched
* from policy service and returned.
*
* @return policy decision
* @throws PolicyException if can not get policy decision
* @throws SSOException if session token is not valid
*/
private PolicyDecision getPolicyDecision(SSOToken appToken, String serviceName, SSOToken token, String resourceName, Set actionNames, Map env, boolean useCache) throws InvalidAppSSOTokenException, PolicyException, SSOException {
String cacheMode = policyProperties.getCacheMode();
String rootResourceName = resourceName;
if (PolicyProperties.SUBTREE.equals(cacheMode)) {
rootResourceName = getRootResourceName(resourceName, serviceName);
if (debug.messageEnabled()) {
debug.message("ResourceResultCache.getPolicyDecision():" + "resourceName=" + resourceName + ":cacheMode=" + cacheMode + ":would get resource results for root resource=" + rootResourceName);
}
}
Set resourceResults = getResourceResults(appToken, serviceName, token, rootResourceName, actionNames, env, cacheMode, useCache);
ResourceName resourceComparator = (ResourceName) policyProperties.getResourceComparator(serviceName);
PolicyDecision pd = getPolicyDecisionFromResourceResults(resourceResults, resourceName, resourceComparator, serviceName);
if (debug.messageEnabled()) {
debug.message("ResourceResultCache.getPolicyDecision():" + ":serviceName=" + serviceName + ":token=" + token.getPrincipal().getName() + ":resourceName=" + resourceName + ":actionNames=" + actionNames + ":env" + ":cacehMode=" + cacheMode + ":useCache=" + useCache + ":returning policyDecision:" + pd);
}
return pd;
}
Aggregations