/** * A private method that handles reading the policy and creates the correct * kind of AbstractPolicy. * Because this makes use of the policyFinder, it cannot be reused between finders. * Consider moving to policyManager, which is not intended to be reused outside * of a policyFinderModule, which is not intended to be reused amongst PolicyFinder instances. */ protected AbstractPolicy handleDocument(Document doc, PolicyFinder policyFinder) throws ParsingException { // handle the policy, if it's a known type Element root = doc.getDocumentElement(); String name = root.getTagName(); // see what type of policy this is if (name.equals("Policy")) { return Policy.getInstance(root); } else if (name.equals("PolicySet")) { return PolicySet.getInstance(root, policyFinder); } else { // this isn't a root type that we know how to handle throw new ParsingException("Unknown root document type: " + name); } }
/** * Encodes this <code>Policy</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)); }
String indent = indenter.makeString(); out.println(indent + "<Policy PolicyId=\"" + getId().toString() + "\" RuleCombiningAlgId=\"" + getCombiningAlg().getIdentifier().toString() + "\">"); String nextIndent = indenter.makeString(); String description = getDescription(); if (description != null) out.println(nextIndent + "<Description>" + description + "</Description>"); String version = getDefaultVersion(); if (version != null) out.println("<PolicyDefaults><XPathVersion>" + version + "</XPathVersion></PolicyDefaults>"); getTarget().encode(output, indenter); ((VariableDefinition)(it.next())).encode(output, indenter); encodeCommonElements(output, indenter);
HashMap parameters = new HashMap(); HashMap variableIds = new HashMap(); PolicyMetaData metaData = getMetaData(); parseParameters(list, child); } else { List list = new ArrayList(); parseParameters(list, child); parameters.put(ref, list); setChildren(elements);
/** * Creates an instance of a <code>Policy</code> object based on a * DOM node. The node must be the root of PolicyType XML object, * otherwise an exception is thrown. * * @param root the DOM root of a PolicyType XML type * * @throws ParsingException if the PolicyType is invalid */ public static Policy getInstance(Node root) throws ParsingException { // first off, check that it's the right kind of node if (! SunxacmlUtil.getNodeName(root).equals("Policy")) { throw new ParsingException("Cannot create Policy from root of " + "type " + SunxacmlUtil.getNodeName(root)); } return new Policy(root); }
/** * A private method that handles reading the policy and creates the * correct kind of AbstractPolicy. */ private AbstractPolicy handleDocument(Document doc) throws ParsingException { // handle the policy, if it's a known type Element root = doc.getDocumentElement(); String name = root.getTagName(); // see what type of policy this is if (name.equals("Policy")) { return Policy.getInstance(root); } else if (name.equals("PolicySet")) { return PolicySet.getInstance(root, finder); } else { // this isn't a root type that we know how to handle throw new ParsingException("Unknown root document type: " + name); } }
return Policy.getInstance(root); } else if (name.equals("PolicySet")) { return PolicySet.getInstance(root, finder);
policies.add(PolicySet.getInstance(child, finder)); } else if (name.equals("Policy")) { policies.add(Policy.getInstance(child)); } else if (name.equals("PolicySetIdReference")) { policies.add(PolicyReference.getInstance(child, finder,
try { if (rootName.equals("Policy")) { return Policy.getInstance(root); } else if (rootName.equals("PolicySet")) { return PolicySet.getInstance(root);
try { if (rootName.equals("Policy")) { return Policy.getInstance(root); } else if (rootName.equals("PolicySet")) { return PolicySet.getInstance(root);