Package org.jboss.security.xacml.sunxacml.finder

Examples of org.jboss.security.xacml.sunxacml.finder.PolicyFinderResult


            throw new ProcessingException("couldn't find the policy with " +
                                          "a null finder");
        }

        PolicyFinderResult pfr =
            finder.findPolicy(reference, policyType, constraints,
                              parentMetaData);
       
        if (pfr.notApplicable())
            throw new ProcessingException("couldn't resolve the policy");
       
        if (pfr.indeterminate())
            throw new ProcessingException("error resolving the policy");

        return pfr.getPolicy();
    }
View Full Code Here


        // if there is no finder, then we return NotApplicable
        if (finder == null)
            return new Result(Result.DECISION_NOT_APPLICABLE,
                              context.getResourceId().encode());

        PolicyFinderResult pfr = finder.findPolicy(reference, policyType,
                                                   constraints,
                                                   parentMetaData);

        // if we found nothing, then we return NotApplicable
        if (pfr.notApplicable())
            return new Result(Result.DECISION_NOT_APPLICABLE,
                              context.getResourceId().encode());

        // if there was an error, we return that status data
        if (pfr.indeterminate())
            return new Result(Result.DECISION_INDETERMINATE, pfr.getStatus(),
                              context.getResourceId().encode());

        // we must have found a policy
        return pfr.getPolicy().evaluate(context);
    }
View Full Code Here

            MatchResult match = policy.match(context);
            int result = match.getResult();
           
            // if there was an error, we stop right away
            if (result == MatchResult.INDETERMINATE)
                return new PolicyFinderResult(match.getStatus());

            if (result == MatchResult.MATCH) {
                // if we matched before, this is an error...
                if (selectedPolicy != null) {
                    ArrayList code = new ArrayList();
                    code.add(Status.STATUS_PROCESSING_ERROR);
                    Status status = new Status(code, "too many applicable top-"
                                               + "level policies");
                    return new PolicyFinderResult(status);
                }

                // ...otherwise remember this policy
                selectedPolicy = policy;
            }
        }

        // if we found a policy, return it, otherwise we're N/A
        if (selectedPolicy != null)
            return new PolicyFinderResult(selectedPolicy);
        else
            return new PolicyFinderResult();
    }
View Full Code Here

            MatchResult match = policy.match(context);
            int result = match.getResult();

            // if target matching was indeterminate, then return the error
            if (result == MatchResult.INDETERMINATE)
                return new PolicyFinderResult(match.getStatus());

            // see if the target matched
            if (result == MatchResult.MATCH) {
                // see if we previously found another match
                if (selectedPolicy != null) {
                    // we found a match before, so this is an error
                    ArrayList code = new ArrayList();
                    code.add(Status.STATUS_PROCESSING_ERROR);
                    Status status = new Status(code, "too many applicable "
                                               + "top-level policies");
                    return new PolicyFinderResult(status);
                }

                // this is the first match we've found, so remember it
                selectedPolicy = policy;
            }
        }

        // return the single applicable policy (if there was one)
        return new PolicyFinderResult(selectedPolicy);
    }
View Full Code Here

       
        // based on the type, see if we have any references available, and
        // if we do then get the filename
        if (type == PolicyReference.POLICY_REFERENCE) {
            if (policyRefs == null)
                return new PolicyFinderResult();

            fileName = (String)(policyRefs.get(idReference.toString()));
        } else {
            if (policySetRefs == null)
                return new PolicyFinderResult();

            fileName = (String)(policySetRefs.get(idReference.toString()));
        }

        // if we had no mapping available, return with no referenced policy
        if (fileName == null)
            return new PolicyFinderResult();

        // append the correct prefix to the filename
        if (type == PolicyReference.POLICY_REFERENCE)
            fileName = policyRefPrefix + fileName;
        else
            fileName = policySetRefPrefix + fileName;

        // load the referenced policy
        AbstractPolicy policy = loadPolicy(fileName, finder);
        // if there was an error loading the policy, return the error
        if (policy == null) {
            ArrayList code = new ArrayList();
            code.add(Status.STATUS_PROCESSING_ERROR);
            Status status = new Status(code,
                                       "couldn't load referenced policy");
            return new PolicyFinderResult(status);
        }
       
        // return the referenced policy
        return new PolicyFinderResult(policy);
    }
View Full Code Here

     
      // based on the type, see if we have any references available, and
      // if we do then get the filename
      if (type == PolicyReference.POLICY_REFERENCE) {
          if (policyRefs == null)
              return new PolicyFinderResult();

          fileName = (String)(policyRefs.get(idReference.toString()));
      } else {
          if (policySetRefs == null)
              return new PolicyFinderResult();

          fileName = (String)(policySetRefs.get(idReference.toString()));
      }

      // if we had no mapping available, return with no referenced policy
      if (fileName == null)
          return new PolicyFinderResult();

      // load the referenced policy
      AbstractPolicy policy = loadPolicy(fileName, finder);

      // if there was an error loading the policy, return the error
      if (policy == null) {
          ArrayList code = new ArrayList();
          code.add(Status.STATUS_PROCESSING_ERROR);
          Status status = new Status(code,
                                     "couldn't load referenced policy");
          return new PolicyFinderResult(status);
      }
     
      // return the referenced policy
      return new PolicyFinderResult(policy);
   }
View Full Code Here

      try
      {
         AbstractPolicy policy = policies.getPolicy(context);

         if (policy == null)
            return new PolicyFinderResult();
         else
            return new PolicyFinderResult(policy);
      }
      catch (TopLevelPolicyException tlpe)
      {
         return new PolicyFinderResult(tlpe.getStatus());
      }
   }
View Full Code Here

     * A private helper routine that resolves a policy for the given
     * context, and then tries to evaluate based on the policy
     */
    private Result evaluateContext(EvaluationCtx context) {
        // first off, try to find a policy
        PolicyFinderResult finderResult = policyFinder.findPolicy(context);

        // see if there weren't any applicable policies
        if (finderResult.notApplicable())
            return new Result(Result.DECISION_NOT_APPLICABLE,
                              context.getResourceId().encode());

        // see if there were any errors in trying to get a policy
        if (finderResult.indeterminate())
            return new Result(Result.DECISION_INDETERMINATE,
                              finderResult.getStatus(),
                              context.getResourceId().encode());

        // we found a valid policy, so we can do the evaluation
        return finderResult.getPolicy().evaluate(context);
    }
View Full Code Here

         url = new URL(idReference.toString());
      }
      catch (MalformedURLException murle)
      {
         // it's not a URL, so we can't handle this reference
         return new PolicyFinderResult();
      }

      // try resolving the URL
      AbstractPolicy policy = null;
      try
      {
         policy = reader.readPolicy(url);
      }
      catch (ParsingException pe)
      {
         // An error loading the policy could be many things (the URL
         // doesn't actually resolve a policy, the server is down, the
         // policy is invalid, etc.). This could be interpreted as an
         // error case, or simply as a case where no applicable policy
         // is available (as is done when we pre-load policies). This
         // module chooses the latter interpretation.
         return new PolicyFinderResult();
      }

      // check that we got the right kind of policy...if we didn't, then
      // we can't handle the reference
      if (type == PolicyReference.POLICY_REFERENCE)
      {
         if (!(policy instanceof Policy))
            return new PolicyFinderResult();
      }
      else
      {
         if (!(policy instanceof PolicySet))
            return new PolicyFinderResult();
      }

      // finally, check that the constraints match ... note that in a more
      // powerful module, you could actually have used the constraints to
      // construct a more specific URL, passed the constraints to the
      // server, etc., but this example module is staying simple
      if (!constraints.meetsConstraint(policy.getVersion()))
         return new PolicyFinderResult();

      // if we got here, then we successfully resolved a policy that is
      // the correct type, so return it
      return new PolicyFinderResult(policy);
   }
View Full Code Here

      try
      {
         AbstractPolicy policy = ctxPolicies.getPolicy(context);

         if (policy == null)
            return new PolicyFinderResult();
         else
            return new PolicyFinderResult(policy);
      }
      catch (TopLevelPolicyException tlpe)
      {
         return new PolicyFinderResult(tlpe.getStatus());
      }
   }
View Full Code Here

TOP

Related Classes of org.jboss.security.xacml.sunxacml.finder.PolicyFinderResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.