/** * Given the input context sees whether or not the request matches this * policy. This must be called by combining algorithms before they * evaluate a policy. This is also used in the initial policy finding * operation to determine which top-level policies might apply to the * request. * * @param context the representation of the request * * @return the result of trying to match the policy and the request */ public MatchResult match(EvaluationCtx context) { //https://issues.jboss.org/browse/SECURITY-574 if( target == null) throw new RuntimeException("No Target found in policy with id="+idAttr); return target.match(context); }
/** * Given the input context sees whether or not the request matches this * <code>Rule</code>'s <code>Target</code>. Note that unlike the matching * done by the <code>evaluate</code> method, if the <code>Target</code> * is missing than this will return Indeterminate. This lets you write * your own custom matching routines for rules but lets evaluation * proceed normally. * * @param context the representation of the request * * @return the result of trying to match this rule and the request */ public MatchResult match(EvaluationCtx context) { if (target == null) { ArrayList code = new ArrayList(); code.add(Status.STATUS_PROCESSING_ERROR); Status status = new Status(code, "no target available for " + "matching a rule"); return new MatchResult(MatchResult.INDETERMINATE, status); } return target.match(context); }
/** * Given the input context sees whether or not the request matches this * policy. This must be called by combining algorithms before they * evaluate a policy. This is also used in the initial policy finding * operation to determine which top-level policies might apply to the * request. If the policy is invalid or can't be retrieved, then a * runtime exception is thrown. * * @param context the representation of the request * * @return the result of trying to match the policy and the request */ public MatchResult match(EvaluationCtx context) { try { return getTarget().match(context); } catch (ProcessingException pe) { // this means that we couldn't resolve the policy ArrayList code = new ArrayList(); code.add(Status.STATUS_PROCESSING_ERROR); Status status = new Status(code, "couldn't resolve policy ref"); return new MatchResult(MatchResult.INDETERMINATE, status); } }
MatchResult match = target.match(context); int result = match.getResult();