Search in sources :

Example 6 with ResourceName

use of com.sun.identity.policy.interfaces.ResourceName 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;
}
Also used : PolicyDecision(com.sun.identity.policy.PolicyDecision) Set(java.util.Set) HashSet(java.util.HashSet) RequestSet(com.iplanet.services.comm.share.RequestSet) ResourceName(com.sun.identity.policy.interfaces.ResourceName)

Aggregations

ResourceName (com.sun.identity.policy.interfaces.ResourceName)6 PolicyDecision (com.sun.identity.policy.PolicyDecision)3 RequestSet (com.iplanet.services.comm.share.RequestSet)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 Set (java.util.Set)2 PolicyException (com.sun.identity.policy.PolicyException)1 ResourceMatch (com.sun.identity.policy.ResourceMatch)1 ResourceResult (com.sun.identity.policy.ResourceResult)1 PrefixResourceName (com.sun.identity.policy.plugins.PrefixResourceName)1 PolicyEvaluationException (com.sun.identity.policy.remote.PolicyEvaluationException)1 Iterator (java.util.Iterator)1 StringTokenizer (java.util.StringTokenizer)1 JSONArray (org.json.JSONArray)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1