/** * Encodes this <code>Rule</code> into its XML representation and writes * this encoding to the given <code>OutputStream</code> with no * indentation. * * @param output a stream into which the XML-encoded data is written */ public void encode(OutputStream output) { encode(output, new Indenter(0)); }
/** * Returns a new instance of the <code>Rule</code> class based on a * DOM node. The node must be the root of an XML RuleType. * * @deprecated As of 2.0 you should avoid using this method and should * instead use the version that takes a * <code>PolicyMetaData</code> instance. This method will * only work for XACML 1.x policies. * * @param root the DOM root of a RuleType XML type * @param xpathVersion the XPath version to use in any selectors or XPath * functions, or null if this is unspecified (ie, not * supplied in the defaults section of the policy) * * @throws ParsingException if the RuleType is invalid */ public static Rule getInstance(Node root, String xpathVersion) throws ParsingException { return getInstance(root, new PolicyMetaData( PolicyMetaData.XACML_1_0_IDENTIFIER, xpathVersion), null); }
/** * Encodes this element's <code>Rule</code> and parameters into their * XML representation and writes this encoding to the given * <code>OutputStream</code> with indentation. * * @param output a stream into which the XML-encoded data is written * @param indenter an object that creates indentation strings */ public void encode(OutputStream output, Indenter indenter) { Iterator it = getParameters().iterator(); if (it.hasNext()) { PrintStream out = new PrintStream(output); String indent = indenter.makeString(); out.println(indent + "<RuleCombinerParameters RuleIdRef=\"" + getRule().getId() + "\">"); indenter.in(); while (it.hasNext()) { CombinerParameter param = (CombinerParameter)(it.next()); param.encode(output, indenter); } out.println(indent + "</RuleCombinerParameters>"); indenter.out(); } getRule().encode(output, indenter); }
rules.add(Rule.getInstance(child, metaData, manager)); } else if (name.equals("RuleCombinerParameters")) { String ref = child.getAttributes().getNamedItem("RuleIdRef"). String id = rule.getId().toString(); List list = (List)(parameters.remove(id));
return new Rule(id, effect, description, target, condition);
/** * Applies the combining rule to the set of rules based on the * evaluation context. * * @param context the context from the request * @param parameters a (possibly empty) non-null <code>List</code> of * <code>CombinerParameter<code>s * @param ruleElements the rules to combine * * @return the result of running the combining algorithm */ public Result combine(EvaluationCtx context, List parameters, List ruleElements) { Iterator it = ruleElements.iterator(); while (it.hasNext()) { Rule rule = ((RuleCombinerElement)(it.next())).getRule(); Result result = rule.evaluate(context); int value = result.getDecision(); // in the case of PERMIT, DENY, or INDETERMINATE, we always // just return that result, so only on a rule that doesn't // apply do we keep going... if (value != Result.DECISION_NOT_APPLICABLE) return result; } // if we got here, then none of the rules applied return new Result(Result.DECISION_NOT_APPLICABLE, context.getResourceId().encode()); }