You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openaz.apache.org by pd...@apache.org on 2015/05/13 18:02:58 UTC
[36/56] [abbrv] [partial] incubator-openaz git commit: Merging
re-factoring with PMD work
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMPolicySet.java
----------------------------------------------------------------------
diff --cc openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMPolicySet.java
index 5ad821d,0000000..b4bac05
mode 100644,000000..100644
--- a/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMPolicySet.java
+++ b/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMPolicySet.java
@@@ -1,366 -1,0 +1,395 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+/*
+ * AT&T - PROPRIETARY
+ * THIS FILE CONTAINS PROPRIETARY INFORMATION OF
+ * AT&T AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN
+ * ACCORDANCE WITH APPLICABLE AGREEMENTS.
+ *
+ * Copyright (c) 2013 AT&T Knowledge Ventures
+ * Unpublished and Not for Publication
+ * All Rights Reserved
+ */
+package org.apache.openaz.xacml.pdp.policy.dom;
+
+import java.io.File;
+import java.util.Iterator;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.openaz.xacml.api.Identifier;
+import org.apache.openaz.xacml.api.XACML3;
+import org.apache.openaz.xacml.pdp.policy.CombiningAlgorithm;
+import org.apache.openaz.xacml.pdp.policy.CombiningAlgorithmFactory;
+import org.apache.openaz.xacml.pdp.policy.PolicyDefaults;
+import org.apache.openaz.xacml.pdp.policy.PolicySet;
+import org.apache.openaz.xacml.pdp.policy.PolicySetChild;
+import org.apache.openaz.xacml.std.StdStatusCode;
+import org.apache.openaz.xacml.std.dom.DOMProperties;
+import org.apache.openaz.xacml.std.dom.DOMStructureException;
+import org.apache.openaz.xacml.std.dom.DOMUtil;
+import org.apache.openaz.xacml.util.FactoryException;
+import org.apache.openaz.xacml.util.StringUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
- * DOMPolicySet extends {@link org.apache.openaz.xacml.pdp.policy.PolicySet} with methods for creation
- * from DOM {@link org.w3c.dom.Node}s.
- *
++ * DOMPolicySet extends {@link com.att.research.xacmlatt.pdp.policy.PolicySet} with methods for creation from
++ * DOM {@link org.w3c.dom.Node}s.
+ */
+public class DOMPolicySet {
- private static final Log logger = LogFactory.getLog(DOMPolicySet.class);
++ private static final Log logger = LogFactory.getLog(DOMPolicySet.class);
+
+ protected DOMPolicySet() {
+ }
+
+ /**
- * Creates a new <code>PolicySet</code> by parsing the given <code>Node</code> representing a XACML PolicySet element.
++ * Creates a new <code>PolicySet</code> by parsing the given <code>Node</code> representing a XACML
++ * PolicySet element.
+ *
+ * @param nodePolicySet the <code>Node</code> representing the XACML PolicySetelement
- * @param policyDefaultsParent the {@link org.apache.openaz.xacml.pdp.policy.PolicyDefaults} from the parent element
++ * @param policyDefaultsParent the {@link com.att.research.xacmlatt.pdp.policy.PolicyDefaults} from the
++ * parent element
+ * @return a new <code>PolicySet</code> parsed from the given <code>Node</code>
+ * @throws DOMStructureException if there is an error parsing the <code>Node</code>
+ */
- public static PolicySet newInstance(Node nodePolicySet, PolicySet policySetParent, PolicyDefaults policyDefaultsParent) throws DOMStructureException {
- Element elementPolicySet = DOMUtil.getElement(nodePolicySet);
- boolean bLenient = DOMProperties.isLenient();
++ public static PolicySet newInstance(Node nodePolicySet, PolicySet policySetParent,
++ PolicyDefaults policyDefaultsParent) throws DOMStructureException {
++ Element elementPolicySet = DOMUtil.getElement(nodePolicySet);
++ boolean bLenient = DOMProperties.isLenient();
+
- PolicySet domPolicySet = new PolicySet(policySetParent);
++ PolicySet domPolicySet = new PolicySet(policySetParent);
+
+ Iterator<?> iterator;
+ Identifier identifier;
+ Integer integer;
+
+ try {
- NodeList children = elementPolicySet.getChildNodes();
++ NodeList children = elementPolicySet.getChildNodes();
+ int numChildren;
+ if (children != null && (numChildren = children.getLength()) > 0) {
+ /*
+ * Run through once, quickly, to set the PolicyDefaults for the new DOMPolicySet
+ */
- for (int i = 0 ; i < numChildren ; i++) {
- Node child = children.item(i);
- if (DOMUtil.isNamespaceElement(child, XACML3.XMLNS) && XACML3.ELEMENT_POLICYDEFAULTS.equals(child.getLocalName())) {
++ for (int i = 0; i < numChildren; i++) {
++ Node child = children.item(i);
++ if (DOMUtil.isNamespaceElement(child, XACML3.XMLNS)
++ && XACML3.ELEMENT_POLICYDEFAULTS.equals(child.getLocalName())) {
+ if (domPolicySet.getPolicyDefaults() != null && !bLenient) {
+ throw DOMUtil.newUnexpectedElementException(child, nodePolicySet);
+ }
- domPolicySet.setPolicyDefaults(DOMPolicyDefaults.newInstance(child, policyDefaultsParent));
++ domPolicySet.setPolicyDefaults(DOMPolicyDefaults.newInstance(child,
++ policyDefaultsParent));
+ }
+ }
+ if (domPolicySet.getPolicyDefaults() == null) {
+ domPolicySet.setPolicyDefaults(policyDefaultsParent);
+ }
+
+ /*
+ * Now process the other elements so we can pull up the parent policy defaults
+ */
- for (int i = 0 ; i < numChildren ; i++) {
- Node child = children.item(i);
++ for (int i = 0; i < numChildren; i++) {
++ Node child = children.item(i);
+ if (DOMUtil.isElement(child)) {
+ if (DOMUtil.isInNamespace(child, XACML3.XMLNS)) {
- String childName = child.getLocalName();
++ String childName = child.getLocalName();
+ if (XACML3.ELEMENT_DESCRIPTION.equals(childName)) {
+ if (domPolicySet.getDescription() != null && !bLenient) {
+ throw DOMUtil.newUnexpectedElementException(child, nodePolicySet);
+ }
+ domPolicySet.setDescription(child.getTextContent());
+ } else if (XACML3.ELEMENT_POLICYISSUER.equals(childName)) {
+ if (domPolicySet.getPolicyIssuer() != null && !bLenient) {
+ throw DOMUtil.newUnexpectedElementException(child, nodePolicySet);
+ }
+ domPolicySet.setPolicyIssuer(DOMPolicyIssuer.newInstance(child));
- } else if (XACML3.ELEMENT_POLICYSETDEFAULTS.equals(childName)) {
++ } else if (XACML3.ELEMENT_POLICYSETDEFAULTS.equals(childName)) { //NOPMD
++ // TODO
+ } else if (XACML3.ELEMENT_TARGET.equals(childName)) {
+ if (domPolicySet.getTarget() != null && !bLenient) {
+ throw DOMUtil.newUnexpectedElementException(child, nodePolicySet);
+ }
+ domPolicySet.setTarget(DOMTarget.newInstance(child));
+ } else if (XACML3.ELEMENT_POLICYSET.equals(childName)) {
- domPolicySet.addChild(DOMPolicySet.newInstance(child, domPolicySet, domPolicySet.getPolicyDefaults()));
++ domPolicySet.addChild(DOMPolicySet.newInstance(child, domPolicySet,
++ domPolicySet
++ .getPolicyDefaults()));
+ } else if (XACML3.ELEMENT_POLICY.equals(childName)) {
- domPolicySet.addChild(DOMPolicy.newInstance(child, domPolicySet, domPolicySet.getPolicyDefaults()));
++ domPolicySet
++ .addChild(DOMPolicy.newInstance(child, domPolicySet,
++ domPolicySet.getPolicyDefaults()));
+ } else if (XACML3.ELEMENT_POLICYIDREFERENCE.equals(childName)) {
+ domPolicySet.addChild(DOMPolicyIdReference.newInstance(child, domPolicySet));
+ } else if (XACML3.ELEMENT_POLICYSETIDREFERENCE.equals(childName)) {
- domPolicySet.addChild(DOMPolicySetIdReference.newInstance(child, domPolicySet));
++ domPolicySet.addChild(DOMPolicySetIdReference
++ .newInstance(child, domPolicySet));
+ } else if (XACML3.ELEMENT_COMBINERPARAMETERS.equals(childName)) {
+ domPolicySet.addCombinerParameters(DOMCombinerParameter.newList(child));
+ } else if (XACML3.ELEMENT_POLICYCOMBINERPARAMETERS.equals(childName)) {
- domPolicySet.addPolicyCombinerParameter(DOMPolicyCombinerParameter.newInstance(child));
++ domPolicySet.addPolicyCombinerParameter(DOMPolicyCombinerParameter
++ .newInstance(child));
+ } else if (XACML3.ELEMENT_POLICYSETCOMBINERPARAMETERS.equals(childName)) {
- domPolicySet.addPolicyCombinerParameter(DOMPolicySetCombinerParameter.newInstance(child));
++ domPolicySet.addPolicyCombinerParameter(DOMPolicySetCombinerParameter
++ .newInstance(child));
+ } else if (XACML3.ELEMENT_OBLIGATIONEXPRESSIONS.equals(childName)) {
- if ((iterator = domPolicySet.getObligationExpressions()) != null && iterator.hasNext() && !bLenient) {
++ if ((iterator = domPolicySet.getObligationExpressions()) != null
++ && iterator.hasNext() && !bLenient) {
+ throw DOMUtil.newUnexpectedElementException(child, nodePolicySet);
+ }
- domPolicySet.setObligationExpressions(DOMObligationExpression.newList(child, null));
++ domPolicySet.setObligationExpressions(DOMObligationExpression.newList(child,
++ null));
+ } else if (XACML3.ELEMENT_ADVICEEXPRESSIONS.equals(childName)) {
- if ((iterator = domPolicySet.getAdviceExpressions()) != null && iterator.hasNext() && !bLenient) {
++ if ((iterator = domPolicySet.getAdviceExpressions()) != null
++ && iterator.hasNext() && !bLenient) {
+ throw DOMUtil.newUnexpectedElementException(child, nodePolicySet);
+ }
+ domPolicySet.setAdviceExpressions(DOMAdviceExpression.newList(child, null));
+ } else if (!bLenient) {
+ throw DOMUtil.newUnexpectedElementException(child, nodePolicySet);
+ }
+ } else if (!bLenient) {
+ throw DOMUtil.newUnexpectedElementException(child, nodePolicySet);
+ }
+ }
+ }
+ }
+ if (domPolicySet.getTarget() == null && !bLenient) {
+ throw DOMUtil.newMissingElementException(nodePolicySet, XACML3.XMLNS, XACML3.ELEMENT_TARGET);
+ }
+
+ /*
+ * Get the attributes
+ */
- domPolicySet.setIdentifier(DOMUtil.getIdentifierAttribute(elementPolicySet, XACML3.ATTRIBUTE_POLICYSETID, !bLenient));
- domPolicySet.setVersion(DOMUtil.getVersionAttribute(elementPolicySet, XACML3.ATTRIBUTE_VERSION, !bLenient));
++ domPolicySet.setIdentifier(DOMUtil
++ .getIdentifierAttribute(elementPolicySet, XACML3.ATTRIBUTE_POLICYSETID, !bLenient));
++ domPolicySet.setVersion(DOMUtil.getVersionAttribute(elementPolicySet, XACML3.ATTRIBUTE_VERSION,
++ !bLenient));
+
- identifier = DOMUtil.getIdentifierAttribute(elementPolicySet, XACML3.ATTRIBUTE_POLICYCOMBININGALGID, !bLenient);
- CombiningAlgorithm<PolicySetChild> combiningAlgorithm = null;
++ identifier = DOMUtil.getIdentifierAttribute(elementPolicySet,
++ XACML3.ATTRIBUTE_POLICYCOMBININGALGID, !bLenient);
++ CombiningAlgorithm<PolicySetChild> combiningAlgorithm = null;
+ try {
- combiningAlgorithm = CombiningAlgorithmFactory.newInstance().getPolicyCombiningAlgorithm(identifier);
++ combiningAlgorithm = CombiningAlgorithmFactory.newInstance()
++ .getPolicyCombiningAlgorithm(identifier);
+ } catch (FactoryException ex) {
+ if (!bLenient) {
+ throw new DOMStructureException("Failed to get CombinginAlgorithm", ex);
+ }
+ }
+ if (combiningAlgorithm == null && !bLenient) {
- throw new DOMStructureException(elementPolicySet, "Unknown policy combining algorithm \"" + identifier.toString() + "\" in \"" + DOMUtil.getNodeLabel(nodePolicySet));
++ throw new DOMStructureException(elementPolicySet, "Unknown policy combining algorithm \""
++ + identifier.toString() + "\" in \""
++ + DOMUtil.getNodeLabel(nodePolicySet));
+ } else {
+ domPolicySet.setPolicyCombiningAlgorithm(combiningAlgorithm);
+ }
+
+ if ((integer = DOMUtil.getIntegerAttribute(elementPolicySet, XACML3.ATTRIBUTE_MAXDELEGATIONDEPTH)) != null) {
+ domPolicySet.setMaxDelegationDepth(integer);
+ }
+ } catch (DOMStructureException ex) {
+ domPolicySet.setStatus(StdStatusCode.STATUS_CODE_SYNTAX_ERROR, ex.getMessage());
+ if (DOMProperties.throwsExceptions()) {
+ throw ex;
+ }
+ }
+
+ return domPolicySet;
+ }
+
+ public static boolean repair(Node nodePolicySet) throws DOMStructureException {
- Element elementPolicySet = DOMUtil.getElement(nodePolicySet);
- boolean result = false;
++ Element elementPolicySet = DOMUtil.getElement(nodePolicySet);
++ boolean result = false;
+
- NodeList children = elementPolicySet.getChildNodes();
++ NodeList children = elementPolicySet.getChildNodes();
+ int numChildren;
- boolean sawDescription = false;
- boolean sawPolicyIssuer = false;
- boolean sawPolicyDefaults = false;
- boolean sawTarget = false;
- boolean sawObligationExprs = false;
- boolean sawAdviceExprs = false;
++ boolean sawDescription = false;
++ boolean sawPolicyIssuer = false;
++ boolean sawPolicyDefaults = false;
++ boolean sawTarget = false;
++ boolean sawObligationExprs = false;
++ boolean sawAdviceExprs = false;
+
+ if (children != null && (numChildren = children.getLength()) > 0) {
+ /*
+ * Now process the other elements so we can pull up the parent policy defaults
+ */
- for (int i = 0 ; i < numChildren ; i++) {
- Node child = children.item(i);
++ for (int i = 0; i < numChildren; i++) {
++ Node child = children.item(i);
+ if (DOMUtil.isElement(child)) {
+ if (DOMUtil.isInNamespace(child, XACML3.XMLNS)) {
- String childName = child.getLocalName();
++ String childName = child.getLocalName();
+ if (XACML3.ELEMENT_DESCRIPTION.equals(childName)) {
+ if (sawDescription) {
+ logger.warn("Unexpected element " + child.getNodeName());
+ elementPolicySet.removeChild(child);
- result = true;
++ result = true;
+ } else {
- sawDescription = true;
++ sawDescription = true;
+ }
+ } else if (XACML3.ELEMENT_POLICYISSUER.equals(childName)) {
+ if (sawPolicyIssuer) {
+ logger.warn("Unexpected element " + child.getNodeName());
+ elementPolicySet.removeChild(child);
- result = true;
++ result = true;
+ } else {
- sawPolicyIssuer = true;
- result = DOMPolicyIssuer.repair(child) || result;
++ sawPolicyIssuer = true;
++ result = DOMPolicyIssuer.repair(child) || result;
+ }
+ } else if (XACML3.ELEMENT_POLICYSETDEFAULTS.equals(childName)) {
+ if (sawPolicyDefaults) {
+ logger.warn("Unexpected element " + child.getNodeName());
+ elementPolicySet.removeChild(child);
- result = true;
++ result = true;
+ } else {
- sawPolicyDefaults = true;
- result = DOMPolicyDefaults.repair(child) || result;
++ sawPolicyDefaults = true;
++ result = DOMPolicyDefaults.repair(child) || result;
+ }
+ } else if (XACML3.ELEMENT_TARGET.equals(childName)) {
+ if (sawTarget) {
+ logger.warn("Unexpected element " + child.getNodeName());
+ elementPolicySet.removeChild(child);
- result = true;
++ result = true;
+ } else {
- sawTarget = true;
- result = DOMTarget.repair(child) || result;
++ sawTarget = true;
++ result = DOMTarget.repair(child) || result;
+ }
+ } else if (XACML3.ELEMENT_POLICYSET.equals(childName)) {
- result = DOMPolicySet.repair(child) || result;
++ result = DOMPolicySet.repair(child) || result;
+ } else if (XACML3.ELEMENT_POLICY.equals(childName)) {
- result = DOMPolicy.repair(child) || result;
++ result = DOMPolicy.repair(child) || result;
+ } else if (XACML3.ELEMENT_POLICYIDREFERENCE.equals(childName)) {
- result = DOMPolicyIdReference.repair(child) || result;
++ result = DOMPolicyIdReference.repair(child) || result;
+ } else if (XACML3.ELEMENT_POLICYSETIDREFERENCE.equals(childName)) {
- result = DOMPolicySetIdReference.repair(child) || result;
++ result = DOMPolicySetIdReference.repair(child) || result;
+ } else if (XACML3.ELEMENT_COMBINERPARAMETERS.equals(childName)) {
- result = DOMCombinerParameter.repair(child) || result;
++ result = DOMCombinerParameter.repair(child) || result;
+ } else if (XACML3.ELEMENT_POLICYCOMBINERPARAMETERS.equals(childName)) {
- result = DOMPolicyCombinerParameter.repair(child) || result;
++ result = DOMPolicyCombinerParameter.repair(child) || result;
+ } else if (XACML3.ELEMENT_POLICYSETCOMBINERPARAMETERS.equals(childName)) {
- result = DOMPolicySetCombinerParameter.repair(child) || result;
++ result = DOMPolicySetCombinerParameter.repair(child) || result;
+ } else if (XACML3.ELEMENT_OBLIGATIONEXPRESSIONS.equals(childName)) {
+ if (sawObligationExprs) {
+ logger.warn("Unexpected element " + child.getNodeName());
+ elementPolicySet.removeChild(child);
- result = true;
++ result = true;
+ } else {
- sawObligationExprs = true;
- result = DOMObligationExpression.repairList(child) || result;
++ sawObligationExprs = true;
++ result = DOMObligationExpression.repairList(child) || result;
+ }
+ } else if (XACML3.ELEMENT_ADVICEEXPRESSIONS.equals(childName)) {
+ if (sawAdviceExprs) {
+ logger.warn("Unexpected element " + child.getNodeName());
+ elementPolicySet.removeChild(child);
- result = true;
++ result = true;
+ } else {
- sawAdviceExprs = true;
- result = DOMAdviceExpression.repairList(child) || result;
++ sawAdviceExprs = true;
++ result = DOMAdviceExpression.repairList(child) || result;
+ }
+ } else {
+ logger.warn("Unexpected element " + child.getNodeName());
+ elementPolicySet.removeChild(child);
- result = true;
++ result = true;
+ }
- } else {
++ } else {
+ logger.warn("Unexpected element " + child.getNodeName());
+ elementPolicySet.removeChild(child);
- result = true;
++ result = true;
+ }
+ }
+ }
+ }
+ if (!sawTarget) {
+ throw DOMUtil.newMissingElementException(nodePolicySet, XACML3.XMLNS, XACML3.ELEMENT_TARGET);
+ }
+
+ /*
+ * Get the attributes
+ */
- result = DOMUtil.repairIdentifierAttribute(elementPolicySet, XACML3.ATTRIBUTE_POLICYSETID, logger) || result;
- result = DOMUtil.repairVersionAttribute(elementPolicySet, XACML3.ATTRIBUTE_VERSION, logger) || result;
- result = DOMUtil.repairIdentifierAttribute(elementPolicySet, XACML3.ATTRIBUTE_POLICYCOMBININGALGID, XACML3.ID_POLICY_DENY_OVERRIDES, logger) || result;
++ result = DOMUtil.repairIdentifierAttribute(elementPolicySet, XACML3.ATTRIBUTE_POLICYSETID, logger)
++ || result;
++ result = DOMUtil.repairVersionAttribute(elementPolicySet, XACML3.ATTRIBUTE_VERSION, logger) || result;
++ result = DOMUtil.repairIdentifierAttribute(elementPolicySet, XACML3.ATTRIBUTE_POLICYCOMBININGALGID,
++ XACML3.ID_POLICY_DENY_OVERRIDES, logger) || result;
+
- Identifier identifier = DOMUtil.getIdentifierAttribute(elementPolicySet, XACML3.ATTRIBUTE_POLICYCOMBININGALGID);
- CombiningAlgorithm<PolicySetChild> combiningAlgorithm = null;
++ Identifier identifier = DOMUtil.getIdentifierAttribute(elementPolicySet,
++ XACML3.ATTRIBUTE_POLICYCOMBININGALGID);
++ CombiningAlgorithm<PolicySetChild> combiningAlgorithm = null;
+ try {
- combiningAlgorithm = CombiningAlgorithmFactory.newInstance().getPolicyCombiningAlgorithm(identifier);
++ combiningAlgorithm = CombiningAlgorithmFactory.newInstance()
++ .getPolicyCombiningAlgorithm(identifier);
+ } catch (FactoryException ex) {
- combiningAlgorithm = null;
++ combiningAlgorithm = null;
+ }
+ if (combiningAlgorithm == null) {
- logger.warn("Setting invalid " + XACML3.ATTRIBUTE_POLICYCOMBININGALGID + " attribute " + identifier.stringValue() + " to " + XACML3.ID_POLICY_DENY_OVERRIDES.stringValue());
- elementPolicySet.setAttribute(XACML3.ATTRIBUTE_POLICYCOMBININGALGID, XACML3.ID_POLICY_DENY_OVERRIDES.stringValue());
- result = true;
++ logger.warn("Setting invalid " + XACML3.ATTRIBUTE_POLICYCOMBININGALGID + " attribute "
++ + identifier.stringValue() + " to " + XACML3.ID_POLICY_DENY_OVERRIDES.stringValue());
++ elementPolicySet.setAttribute(XACML3.ATTRIBUTE_POLICYCOMBININGALGID,
++ XACML3.ID_POLICY_DENY_OVERRIDES.stringValue());
++ result = true;
+ }
+
+ return result;
+ }
+
+ public static void main(String args[]) {
+ try {
- DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
++ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setNamespaceAware(true);
- DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
++ DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+
- for (String fileName: args) {
- File filePolicy = new File(fileName);
++ for (String fileName : args) {
++ File filePolicy = new File(fileName);
+ if (filePolicy.exists() && filePolicy.canRead()) {
+ try {
- Document documentPolicy = documentBuilder.parse(filePolicy);
++ Document documentPolicy = documentBuilder.parse(filePolicy);
+ if (documentPolicy.getFirstChild() == null) {
+ System.err.println(fileName + ": Error: No PolicySet found");
- } else if (!XACML3.ELEMENT_POLICYSET.equals(documentPolicy.getFirstChild().getLocalName())) {
++ } else if (!XACML3.ELEMENT_POLICYSET.equals(documentPolicy.getFirstChild()
++ .getLocalName())) {
+ System.err.println(fileName + ": Error: Not a PolicySet document");
+ } else {
- PolicySet policySet = DOMPolicySet.newInstance(documentPolicy.getFirstChild(), null, null);
++ PolicySet policySet = DOMPolicySet.newInstance(documentPolicy.getFirstChild(),
++ null, null);
+ System.out.println(fileName + ": validate()=" + policySet.validate());
+ System.out.println(StringUtils.prettyPrint(policySet.toString()));
+ }
+ } catch (Exception ex) {
+ System.err.println("Exception processing policy set file \"" + fileName + "\"");
+ ex.printStackTrace(System.err);
+ }
+ } else {
+ System.err.println("Cannot read policy set file \"" + fileName + "\"");
+ }
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace(System.err);
+ System.exit(1);
+ }
+ System.exit(0);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMPolicySetCombinerParameter.java
----------------------------------------------------------------------
diff --cc openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMPolicySetCombinerParameter.java
index e287a47,0000000..621c4b1
mode 100644,000000..100644
--- a/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMPolicySetCombinerParameter.java
+++ b/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMPolicySetCombinerParameter.java
@@@ -1,143 -1,0 +1,158 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+/*
+ * AT&T - PROPRIETARY
+ * THIS FILE CONTAINS PROPRIETARY INFORMATION OF
+ * AT&T AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN
+ * ACCORDANCE WITH APPLICABLE AGREEMENTS.
+ *
+ * Copyright (c) 2013 AT&T Knowledge Ventures
+ * Unpublished and Not for Publication
+ * All Rights Reserved
+ */
+package org.apache.openaz.xacml.pdp.policy.dom;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.openaz.xacml.api.Identifier;
+import org.apache.openaz.xacml.api.XACML3;
+import org.apache.openaz.xacml.pdp.policy.PolicySetChild;
+import org.apache.openaz.xacml.pdp.policy.TargetedCombinerParameter;
+import org.apache.openaz.xacml.std.StdStatusCode;
+import org.apache.openaz.xacml.std.dom.DOMAttributeValue;
+import org.apache.openaz.xacml.std.dom.DOMProperties;
+import org.apache.openaz.xacml.std.dom.DOMStructureException;
+import org.apache.openaz.xacml.std.dom.DOMUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
- * DOMPolicySetCombinerParameter extends {@link org.apache.openaz.xacml.pdp.policy.TargetedCombinerParameter} for
- * {@link org.apache.openaz.xacml.pdp.policy.PolicySet}s with methods for creation from DOM {@link org.w3c.dom.Node}s.
- *
++ * DOMPolicySetCombinerParameter extends
++ * {@link com.att.research.xacmlatt.pdp.policy.TargetedCombinerParameter} for
++ * {@link com.att.research.xacmlatt.pdp.policy.PolicySet}s with methods for creation from DOM
++ * {@link org.w3c.dom.Node}s.
+ */
+public class DOMPolicySetCombinerParameter extends TargetedCombinerParameter<Identifier, PolicySetChild> {
- public static final Log logger = LogFactory.getLog(DOMPolicySetCombinerParameter.class);
++ public static final Log logger = LogFactory.getLog(DOMPolicySetCombinerParameter.class);
+
+ protected DOMPolicySetCombinerParameter() {
+
+ }
+
+ /**
- * Creates a new <code>TargetedCombinerParameter</code> for <code>PolicySet</code>s by parsing the given <code>Node</code>
- * representing a XACML PolicySetCombinerParameter element.
++ * Creates a new <code>TargetedCombinerParameter</code> for <code>PolicySet</code>s by parsing the given
++ * <code>Node</code> representing a XACML PolicySetCombinerParameter element.
+ *
- * @param nodeCombinerParameter the <code>Node</code> representing the XACML PolicySetCombinerParameter element
- * @return a new <code>TargetedCombinerParameter</code> for <code>PolicySet</code>s parsed from the given <code>Node</code>
++ * @param nodeCombinerParameter the <code>Node</code> representing the XACML PolicySetCombinerParameter
++ * element
++ * @return a new <code>TargetedCombinerParameter</code> for <code>PolicySet</code>s parsed from the given
++ * <code>Node</code>
+ * @throws DOMStructureException if there is an error parsing the <code>Node</code>
+ */
- public static TargetedCombinerParameter<Identifier,PolicySetChild> newInstance(Node nodeCombinerParameter) throws DOMStructureException {
- Element elementPolicySetCombinerParameter = DOMUtil.getElement(nodeCombinerParameter);
- boolean bLenient = DOMProperties.isLenient();
++ public static TargetedCombinerParameter<Identifier, PolicySetChild> newInstance(Node nodeCombinerParameter)
++ throws DOMStructureException {
++ Element elementPolicySetCombinerParameter = DOMUtil.getElement(nodeCombinerParameter);
++ boolean bLenient = DOMProperties.isLenient();
+
- DOMPolicySetCombinerParameter domPolicySetCombinerParameter = new DOMPolicySetCombinerParameter();
++ DOMPolicySetCombinerParameter domPolicySetCombinerParameter = new DOMPolicySetCombinerParameter();
+
+ try {
- NodeList children = elementPolicySetCombinerParameter.getChildNodes();
++ NodeList children = elementPolicySetCombinerParameter.getChildNodes();
+ int numChildren;
+ if (children != null && (numChildren = children.getLength()) > 0) {
- for (int i = 0 ; i < numChildren ; i++) {
- Node child = children.item(i);
++ for (int i = 0; i < numChildren; i++) {
++ Node child = children.item(i);
+ if (DOMUtil.isElement(child)) {
- if (DOMUtil.isInNamespace(child, XACML3.XMLNS) && XACML3.ELEMENT_ATTRIBUTEVALUE.equals(child.getLocalName())) {
++ if (DOMUtil.isInNamespace(child, XACML3.XMLNS)
++ && XACML3.ELEMENT_ATTRIBUTEVALUE.equals(child.getLocalName())) {
+ if (domPolicySetCombinerParameter.getAttributeValue() != null && !bLenient) {
+ throw DOMUtil.newUnexpectedElementException(child, nodeCombinerParameter);
+ }
- domPolicySetCombinerParameter.setAttributeValue(DOMAttributeValue.newInstance(child, null));
++ domPolicySetCombinerParameter.setAttributeValue(DOMAttributeValue
++ .newInstance(child, null));
+ } else if (!bLenient) {
+ throw DOMUtil.newUnexpectedElementException(child, nodeCombinerParameter);
+ }
+ }
+ }
+ }
+ if (domPolicySetCombinerParameter.getAttributeValue() == null && !bLenient) {
- throw DOMUtil.newMissingElementException(elementPolicySetCombinerParameter, XACML3.XMLNS, XACML3.ELEMENT_ATTRIBUTEVALUE);
++ throw DOMUtil.newMissingElementException(elementPolicySetCombinerParameter, XACML3.XMLNS,
++ XACML3.ELEMENT_ATTRIBUTEVALUE);
+ }
- domPolicySetCombinerParameter.setName(DOMUtil.getStringAttribute(elementPolicySetCombinerParameter, XACML3.ATTRIBUTE_PARAMETERNAME, !bLenient));
- domPolicySetCombinerParameter.setTargetId(DOMUtil.getIdentifierAttribute(elementPolicySetCombinerParameter, XACML3.ATTRIBUTE_POLICYSETIDREF, !bLenient));
++ domPolicySetCombinerParameter.setName(DOMUtil
++ .getStringAttribute(elementPolicySetCombinerParameter, XACML3.ATTRIBUTE_PARAMETERNAME,
++ !bLenient));
++ domPolicySetCombinerParameter.setTargetId(DOMUtil
++ .getIdentifierAttribute(elementPolicySetCombinerParameter, XACML3.ATTRIBUTE_POLICYSETIDREF,
++ !bLenient));
+ } catch (DOMStructureException ex) {
+ domPolicySetCombinerParameter.setStatus(StdStatusCode.STATUS_CODE_SYNTAX_ERROR, ex.getMessage());
+ if (DOMProperties.throwsExceptions()) {
+ throw ex;
+ }
+ }
+
+ return domPolicySetCombinerParameter;
+
+ }
+
+ public static boolean repair(Node nodeCombinerParameter) throws DOMStructureException {
- Element elementPolicySetCombinerParameter = DOMUtil.getElement(nodeCombinerParameter);
- boolean result = false;
++ Element elementPolicySetCombinerParameter = DOMUtil.getElement(nodeCombinerParameter);
++ boolean result = false;
+
- NodeList children = elementPolicySetCombinerParameter.getChildNodes();
++ NodeList children = elementPolicySetCombinerParameter.getChildNodes();
+ int numChildren;
- boolean sawAttributeValue = false;
++ boolean sawAttributeValue = false;
+ if (children != null && (numChildren = children.getLength()) > 0) {
- for (int i = 0 ; i < numChildren ; i++) {
- Node child = children.item(i);
++ for (int i = 0; i < numChildren; i++) {
++ Node child = children.item(i);
+ if (DOMUtil.isElement(child)) {
- if (DOMUtil.isInNamespace(child, XACML3.XMLNS) && XACML3.ELEMENT_ATTRIBUTEVALUE.equals(child.getLocalName())) {
++ if (DOMUtil.isInNamespace(child, XACML3.XMLNS)
++ && XACML3.ELEMENT_ATTRIBUTEVALUE.equals(child.getLocalName())) {
+ if (sawAttributeValue) {
+ logger.warn("Unexpected element " + child.getNodeName());
+ elementPolicySetCombinerParameter.removeChild(child);
- result = true;
++ result = true;
+ } else {
- sawAttributeValue = true;
- result = DOMAttributeValue.repair(child) || result;
++ sawAttributeValue = true;
++ result = DOMAttributeValue.repair(child) || result;
+ }
+ } else {
+ logger.warn("Unexpected element " + child.getNodeName());
+ elementPolicySetCombinerParameter.removeChild(child);
- result = true;
++ result = true;
+ }
+ }
+ }
+ }
+ if (!sawAttributeValue) {
- throw DOMUtil.newMissingElementException(elementPolicySetCombinerParameter, XACML3.XMLNS, XACML3.ELEMENT_ATTRIBUTEVALUE);
++ throw DOMUtil.newMissingElementException(elementPolicySetCombinerParameter, XACML3.XMLNS,
++ XACML3.ELEMENT_ATTRIBUTEVALUE);
+ }
- result = DOMUtil.repairStringAttribute(elementPolicySetCombinerParameter, XACML3.ATTRIBUTE_PARAMETERNAME, "parameter", logger) || result;
- result = DOMUtil.repairIdentifierAttribute(elementPolicySetCombinerParameter, XACML3.ATTRIBUTE_POLICYSETIDREF, logger) || result;
++ result = DOMUtil.repairStringAttribute(elementPolicySetCombinerParameter,
++ XACML3.ATTRIBUTE_PARAMETERNAME, "parameter", logger) || result;
++ result = DOMUtil.repairIdentifierAttribute(elementPolicySetCombinerParameter,
++ XACML3.ATTRIBUTE_POLICYSETIDREF, logger) || result;
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMPolicySetIdReference.java
----------------------------------------------------------------------
diff --cc openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMPolicySetIdReference.java
index 2224f06,0000000..2f8b9cb
mode 100644,000000..100644
--- a/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMPolicySetIdReference.java
+++ b/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMPolicySetIdReference.java
@@@ -1,75 -1,0 +1,78 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+/*
+ * AT&T - PROPRIETARY
+ * THIS FILE CONTAINS PROPRIETARY INFORMATION OF
+ * AT&T AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN
+ * ACCORDANCE WITH APPLICABLE AGREEMENTS.
+ *
+ * Copyright (c) 2013 AT&T Knowledge Ventures
+ * Unpublished and Not for Publication
+ * All Rights Reserved
+ */
+package org.apache.openaz.xacml.pdp.policy.dom;
+
+import org.apache.openaz.xacml.pdp.policy.PolicySet;
+import org.apache.openaz.xacml.pdp.policy.PolicySetIdReference;
+import org.apache.openaz.xacml.std.StdStatusCode;
+import org.apache.openaz.xacml.std.dom.DOMIdReferenceMatch;
+import org.apache.openaz.xacml.std.dom.DOMProperties;
+import org.apache.openaz.xacml.std.dom.DOMStructureException;
+import org.w3c.dom.Node;
+
+/**
- * DOMPolicySetIdReference extends {@link org.apache.openaz.xacml.pdp.policy.PolicySetIdReference} with methods for creation
- * from DOM {@link org.w3c.dom.Node}s.
- *
++ * DOMPolicySetIdReference extends {@link com.att.research.xacmlatt.pdp.policy.PolicySetIdReference} with
++ * methods for creation from DOM {@link org.w3c.dom.Node}s.
+ */
+public class DOMPolicySetIdReference {
+ protected DOMPolicySetIdReference() {
+ }
+
+ /**
- * Creates a new <code>PolicySetIdReference</code> parsed from the given <code>Node</code> representing a XACML PolicySetIdReference element.
++ * Creates a new <code>PolicySetIdReference</code> parsed from the given <code>Node</code> representing a
++ * XACML PolicySetIdReference element.
+ *
- * @param nodePolicySetIdReference the <code>Node</code> representing the XACML PolicySetIdReference element
++ * @param nodePolicySetIdReference the <code>Node</code> representing the XACML PolicySetIdReference
++ * element
+ * @return a new <code>PolicySetIdReference</code> parsed from the given <code>Node</code>
+ * @throws DOMStructureException if there is an error parsing the <code>Node</code>
+ */
- public static PolicySetIdReference newInstance(Node nodePolicySetIdReference, PolicySet policySetParent) throws DOMStructureException {
- PolicySetIdReference domPolicySetIdReference = new PolicySetIdReference(policySetParent);
++ public static PolicySetIdReference newInstance(Node nodePolicySetIdReference, PolicySet policySetParent)
++ throws DOMStructureException {
++ PolicySetIdReference domPolicySetIdReference = new PolicySetIdReference(policySetParent);
+
+ try {
- domPolicySetIdReference.setIdReferenceMatch(DOMIdReferenceMatch.newInstance(nodePolicySetIdReference));
++ domPolicySetIdReference.setIdReferenceMatch(DOMIdReferenceMatch
++ .newInstance(nodePolicySetIdReference));
+ } catch (DOMStructureException ex) {
+ domPolicySetIdReference.setStatus(StdStatusCode.STATUS_CODE_SYNTAX_ERROR, ex.getMessage());
+ if (DOMProperties.throwsExceptions()) {
+ throw ex;
+ }
+ }
+
+ return domPolicySetIdReference;
+ }
+
+ public static boolean repair(Node nodePolicySetIdReference) throws DOMStructureException {
+ return DOMIdReferenceMatch.repair(nodePolicySetIdReference);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMRule.java
----------------------------------------------------------------------
diff --cc openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMRule.java
index c83f0de,0000000..79263b8
mode 100644,000000..100644
--- a/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMRule.java
+++ b/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMRule.java
@@@ -1,238 -1,0 +1,250 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+/*
+ * AT&T - PROPRIETARY
+ * THIS FILE CONTAINS PROPRIETARY INFORMATION OF
+ * AT&T AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN
+ * ACCORDANCE WITH APPLICABLE AGREEMENTS.
+ *
+ * Copyright (c) 2013 AT&T Knowledge Ventures
+ * Unpublished and Not for Publication
+ * All Rights Reserved
+ */
+package org.apache.openaz.xacml.pdp.policy.dom;
+
+import java.util.Iterator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.openaz.xacml.api.XACML3;
+import org.apache.openaz.xacml.pdp.policy.Condition;
+import org.apache.openaz.xacml.pdp.policy.Policy;
+import org.apache.openaz.xacml.pdp.policy.Rule;
+import org.apache.openaz.xacml.pdp.policy.RuleEffect;
+import org.apache.openaz.xacml.std.IdentifierImpl;
+import org.apache.openaz.xacml.std.StdStatusCode;
+import org.apache.openaz.xacml.std.dom.DOMProperties;
+import org.apache.openaz.xacml.std.dom.DOMStructureException;
+import org.apache.openaz.xacml.std.dom.DOMUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
- * DOMRule extends {@link org.apache.openaz.xacml.pdp.policy.Rule} with methods for creation from
- * DOM {@link org.w3c.dom.Node}s.
- *
++ * DOMRule extends {@link com.att.research.xacmlatt.pdp.policy.Rule} with methods for creation from DOM
++ * {@link org.w3c.dom.Node}s.
+ */
+public class DOMRule extends Rule {
- private static final Log logger = LogFactory.getLog(DOMRule.class);
++ private static final Log logger = LogFactory.getLog(DOMRule.class);
+
+ protected DOMRule() {
+ }
+
+ /**
- * Creates a new <code>Rule</code> by parsing the given <code>Node</code> representing a XACML Rule element.
++ * Creates a new <code>Rule</code> by parsing the given <code>Node</code> representing a XACML Rule
++ * element.
+ *
+ * @param nodeRule the <code>Node</code> representing the XACML Rule element
+ * @param policy the {@link org.apache.openaz.xacml.pdp.policy.Policy} encompassing the Rule element
+ * @return a new <code>Rule</code> parsed from the given <code>Node</code>
+ * @throws DOMStructureException if there is an error parsing the <code>Node</code>
+ */
+ public static Rule newInstance(Node nodeRule, Policy policy) throws DOMStructureException {
- Element elementRule = DOMUtil.getElement(nodeRule);
- boolean bLenient = DOMProperties.isLenient();
++ Element elementRule = DOMUtil.getElement(nodeRule);
++ boolean bLenient = DOMProperties.isLenient();
+
- DOMRule domRule = new DOMRule();
++ DOMRule domRule = new DOMRule();
+
+ domRule.setPolicy(policy);
+
+ Iterator<?> iterator;
+
+ try {
- NodeList children = elementRule.getChildNodes();
++ NodeList children = elementRule.getChildNodes();
+ int numChildren;
+ if (children != null && (numChildren = children.getLength()) > 0) {
- for (int i = 0 ; i < numChildren ; i++) {
- Node child = children.item(i);
++ for (int i = 0; i < numChildren; i++) {
++ Node child = children.item(i);
+ if (DOMUtil.isElement(child)) {
+ if (DOMUtil.isInNamespace(child, XACML3.XMLNS)) {
- String childName = child.getLocalName();
++ String childName = child.getLocalName();
+ if (XACML3.ELEMENT_DESCRIPTION.equals(childName)) {
+ if (domRule.getDescription() != null && !bLenient) {
+ throw DOMUtil.newUnexpectedElementException(child, nodeRule);
+ }
+ domRule.setDescription(child.getTextContent());
+ } else if (XACML3.ELEMENT_TARGET.equals(childName)) {
+ if (domRule.getTarget() != null && !bLenient) {
+ throw DOMUtil.newUnexpectedElementException(child, nodeRule);
+ }
+ domRule.setTarget(DOMTarget.newInstance(child));
+ } else if (XACML3.ELEMENT_CONDITION.equals(childName)) {
+ if (domRule.getCondition() != null && !bLenient) {
+ throw DOMUtil.newUnexpectedElementException(child, nodeRule);
+ }
- Node nodeExpression = DOMUtil.getFirstChildElement(child);
++ Node nodeExpression = DOMUtil.getFirstChildElement(child);
+ if (nodeExpression == null && !bLenient) {
- throw DOMUtil.newMissingElementException(child, XACML3.XMLNS, XACML3.ELEMENT_EXPRESSION);
++ throw DOMUtil.newMissingElementException(child, XACML3.XMLNS,
++ XACML3.ELEMENT_EXPRESSION);
+ }
- domRule.setCondition(new Condition(DOMExpression.newInstance(nodeExpression, policy)));
++ domRule.setCondition(new Condition(DOMExpression.newInstance(nodeExpression,
++ policy)));
+ } else if (XACML3.ELEMENT_OBLIGATIONEXPRESSIONS.equals(childName)) {
- if ((iterator = domRule.getObligationExpressions()) != null && iterator.hasNext() && !bLenient) {
++ if ((iterator = domRule.getObligationExpressions()) != null
++ && iterator.hasNext() && !bLenient) {
+ throw DOMUtil.newUnexpectedElementException(child, nodeRule);
+ }
- domRule.setObligationExpressions(DOMObligationExpression.newList(child, policy));
++ domRule.setObligationExpressions(DOMObligationExpression.newList(child,
++ policy));
+ } else if (XACML3.ELEMENT_ADVICEEXPRESSIONS.equals(childName)) {
- if ((iterator = domRule.getAdviceExpressions()) != null && iterator.hasNext() && !bLenient) {
++ if ((iterator = domRule.getAdviceExpressions()) != null && iterator.hasNext()
++ && !bLenient) {
+ throw DOMUtil.newUnexpectedElementException(child, nodeRule);
+ }
+ domRule.setAdviceExpressions(DOMAdviceExpression.newList(child, policy));
+ } else if (!bLenient) {
+ throw DOMUtil.newUnexpectedElementException(child, nodeRule);
+ }
+ } else if (!bLenient) {
+ throw DOMUtil.newUnexpectedElementException(child, nodeRule);
+ }
+ }
+ }
+ }
+
+ domRule.setRuleId(DOMUtil.getStringAttribute(elementRule, XACML3.ATTRIBUTE_RULEID, !bLenient));
- String string = DOMUtil.getStringAttribute(elementRule, XACML3.ATTRIBUTE_EFFECT, !bLenient);
- RuleEffect ruleEffect = RuleEffect.getRuleEffect(string);
++ String string = DOMUtil.getStringAttribute(elementRule, XACML3.ATTRIBUTE_EFFECT, !bLenient);
++ RuleEffect ruleEffect = RuleEffect.getRuleEffect(string);
+ if (ruleEffect == null && !bLenient) {
- throw new DOMStructureException(elementRule, "Unknown RuleEffect \"" + string + "\" in \"" + DOMUtil.getNodeLabel(nodeRule) + "\"");
++ throw new DOMStructureException(elementRule, "Unknown RuleEffect \"" + string + "\" in \""
++ + DOMUtil.getNodeLabel(nodeRule) + "\"");
+ }
+ domRule.setRuleEffect(ruleEffect);
+
+ } catch (DOMStructureException ex) {
+ domRule.setStatus(StdStatusCode.STATUS_CODE_SYNTAX_ERROR, ex.getMessage());
+ if (DOMProperties.throwsExceptions()) {
+ throw ex;
+ }
+ }
+ return domRule;
+ }
+
+ public static boolean repair(Node nodeRule) throws DOMStructureException {
- Element elementRule = DOMUtil.getElement(nodeRule);
- boolean result = false;
++ Element elementRule = DOMUtil.getElement(nodeRule);
++ boolean result = false;
+
- NodeList children = elementRule.getChildNodes();
++ NodeList children = elementRule.getChildNodes();
+ int numChildren;
- boolean sawDescription = false;
- boolean sawTarget = false;
- boolean sawCondition = false;
- boolean sawObligationExpressions = false;
- boolean sawAdviceExpressions = false;
++ boolean sawDescription = false;
++ boolean sawTarget = false;
++ boolean sawCondition = false;
++ boolean sawObligationExpressions = false;
++ boolean sawAdviceExpressions = false;
+
+ if (children != null && (numChildren = children.getLength()) > 0) {
- for (int i = 0 ; i < numChildren ; i++) {
- Node child = children.item(i);
++ for (int i = 0; i < numChildren; i++) {
++ Node child = children.item(i);
+ if (DOMUtil.isElement(child)) {
+ if (DOMUtil.isInNamespace(child, XACML3.XMLNS)) {
- String childName = child.getLocalName();
++ String childName = child.getLocalName();
+ if (XACML3.ELEMENT_DESCRIPTION.equals(childName)) {
+ if (sawDescription) {
+ logger.warn("Unexpected element " + child.getNodeName());
+ elementRule.removeChild(child);
- result = true;
++ result = true;
+ } else {
- sawDescription = true;
++ sawDescription = true;
+ }
+ } else if (XACML3.ELEMENT_TARGET.equals(childName)) {
+ if (sawTarget) {
+ logger.warn("Unexpected element " + child.getNodeName());
+ elementRule.removeChild(child);
- result = true;
++ result = true;
+ } else {
- sawTarget = true;
- result = DOMTarget.repair(child) || result;
++ sawTarget = true;
++ result = DOMTarget.repair(child) || result;
+ }
+ } else if (XACML3.ELEMENT_CONDITION.equals(childName)) {
+ if (sawCondition) {
+ logger.warn("Unexpected element " + child.getNodeName());
+ elementRule.removeChild(child);
- result = true;
++ result = true;
+ } else {
- sawCondition = true;
- Node nodeExpression = DOMUtil.getFirstChildElement(child);
++ sawCondition = true;
++ Node nodeExpression = DOMUtil.getFirstChildElement(child);
+ if (nodeExpression == null) {
- throw DOMUtil.newMissingElementException(child, XACML3.XMLNS, XACML3.ELEMENT_EXPRESSION);
++ throw DOMUtil.newMissingElementException(child, XACML3.XMLNS,
++ XACML3.ELEMENT_EXPRESSION);
+ }
- result = DOMExpression.repair(nodeExpression) || result;
++ result = DOMExpression.repair(nodeExpression) || result;
+ }
+ } else if (XACML3.ELEMENT_OBLIGATIONEXPRESSIONS.equals(childName)) {
+ if (sawObligationExpressions) {
+ logger.warn("Unexpected element " + child.getNodeName());
+ elementRule.removeChild(child);
- result = true;
++ result = true;
+ } else {
- sawObligationExpressions = true;
- result = DOMObligationExpression.repairList(child) || result;
++ sawObligationExpressions = true;
++ result = DOMObligationExpression.repairList(child) || result;
+ }
+ } else if (XACML3.ELEMENT_ADVICEEXPRESSIONS.equals(childName)) {
+ if (sawAdviceExpressions) {
+ logger.warn("Unexpected element " + child.getNodeName());
+ elementRule.removeChild(child);
- result = true;
++ result = true;
+ } else {
- sawAdviceExpressions = true;
- result = DOMAdviceExpression.repairList(child) || result;
++ sawAdviceExpressions = true;
++ result = DOMAdviceExpression.repairList(child) || result;
+ }
+ } else {
+ logger.warn("Unexpected element " + child.getNodeName());
+ elementRule.removeChild(child);
- result = true;
++ result = true;
+ }
+ } else {
+ logger.warn("Unexpected element " + child.getNodeName());
+ elementRule.removeChild(child);
- result = true;
++ result = true;
+ }
+ }
+ }
+ }
+
- result = DOMUtil.repairStringAttribute(elementRule, XACML3.ATTRIBUTE_RULEID, IdentifierImpl.gensym().stringValue(), logger) || result;
- result = DOMUtil.repairStringAttribute(elementRule, XACML3.ATTRIBUTE_EFFECT, RuleEffect.DENY.getName(), logger) || result;
++ result = DOMUtil.repairStringAttribute(elementRule, XACML3.ATTRIBUTE_RULEID, IdentifierImpl.gensym()
++ .stringValue(), logger)
++ || result;
++ result = DOMUtil.repairStringAttribute(elementRule, XACML3.ATTRIBUTE_EFFECT,
++ RuleEffect.DENY.getName(), logger)
++ || result;
+
- String string = DOMUtil.getStringAttribute(elementRule, XACML3.ATTRIBUTE_EFFECT);
- RuleEffect ruleEffect = RuleEffect.getRuleEffect(string);
++ String string = DOMUtil.getStringAttribute(elementRule, XACML3.ATTRIBUTE_EFFECT);
++ RuleEffect ruleEffect = RuleEffect.getRuleEffect(string);
+ if (ruleEffect == null) {
- logger.warn("Setting invalid " + XACML3.ATTRIBUTE_EFFECT + " attribute " + string + " to " + RuleEffect.DENY.getName());
++ logger.warn("Setting invalid " + XACML3.ATTRIBUTE_EFFECT + " attribute " + string + " to "
++ + RuleEffect.DENY.getName());
+ elementRule.setAttribute(XACML3.ATTRIBUTE_EFFECT, RuleEffect.DENY.getName());
- result = true;
++ result = true;
+ }
+
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMRuleCombinerParameters.java
----------------------------------------------------------------------
diff --cc openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMRuleCombinerParameters.java
index f5d0505,0000000..692762a
mode 100644,000000..100644
--- a/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMRuleCombinerParameters.java
+++ b/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMRuleCombinerParameters.java
@@@ -1,140 -1,0 +1,157 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+/*
+ * AT&T - PROPRIETARY
+ * THIS FILE CONTAINS PROPRIETARY INFORMATION OF
+ * AT&T AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN
+ * ACCORDANCE WITH APPLICABLE AGREEMENTS.
+ *
+ * Copyright (c) 2013 AT&T Knowledge Ventures
+ * Unpublished and Not for Publication
+ * All Rights Reserved
+ */
+package org.apache.openaz.xacml.pdp.policy.dom;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.openaz.xacml.api.XACML3;
+import org.apache.openaz.xacml.pdp.policy.Rule;
+import org.apache.openaz.xacml.pdp.policy.TargetedCombinerParameter;
+import org.apache.openaz.xacml.std.StdStatusCode;
+import org.apache.openaz.xacml.std.dom.DOMAttributeValue;
+import org.apache.openaz.xacml.std.dom.DOMProperties;
+import org.apache.openaz.xacml.std.dom.DOMStructureException;
+import org.apache.openaz.xacml.std.dom.DOMUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
- * DOMRuleCombinerParameters extends {@link org.apache.openaz.xacml.pdp.policy.TargetedCombinerParameter} with methods
- * for creation from DOM {@link org.w3c.dom.Node}s.
- *
++ * DOMRuleCombinerParameters extends {@link com.att.research.xacmlatt.pdp.policy.TargetedCombinerParameter}
++ * with methods for creation from DOM {@link org.w3c.dom.Node}s.
+ */
- public class DOMRuleCombinerParameters extends TargetedCombinerParameter<String,Rule> {
- private static final Log logger = LogFactory.getLog(DOMRuleCombinerParameters.class);
++public class DOMRuleCombinerParameters extends TargetedCombinerParameter<String, Rule> {
++ private static final Log logger = LogFactory.getLog(DOMRuleCombinerParameters.class);
+
+ protected DOMRuleCombinerParameters() {
+ }
+
+ /**
- * Creates a new <code>TargetedCombinerParameter</code> for {@link org.apache.openaz.xacml.pdp.policy.Rule}s by parsing the
- * given <code>Node</code> representing a XACML RuleCombinerParameters element.
++ * Creates a new <code>TargetedCombinerParameter</code> for
++ * {@link com.att.research.xacmlatt.pdp.policy.Rule}s by parsing the given <code>Node</code> representing
++ * a XACML RuleCombinerParameters element.
+ *
- * @param nodeRuleCombinerParameters the <code>Node</code> representing the XACML RuleCombinerParameters element.
- * @return a new <code>TargetedCombinerParameter</code> for <code>Rule</code>s parsed from the given <code>Node</code>
++ * @param nodeRuleCombinerParameters the <code>Node</code> representing the XACML RuleCombinerParameters
++ * element.
++ * @return a new <code>TargetedCombinerParameter</code> for <code>Rule</code>s parsed from the given
++ * <code>Node</code>
+ * @throws DOMStructureException if there is an error parsing the <code>Node</code>.
+ */
- public static TargetedCombinerParameter<String,Rule> newInstance(Node nodeRuleCombinerParameters) throws DOMStructureException {
- Element elementRuleCombinerParameters = DOMUtil.getElement(nodeRuleCombinerParameters);
- boolean bLenient = DOMProperties.isLenient();
++ public static TargetedCombinerParameter<String, Rule> newInstance(Node nodeRuleCombinerParameters)
++ throws DOMStructureException {
++ Element elementRuleCombinerParameters = DOMUtil.getElement(nodeRuleCombinerParameters);
++ boolean bLenient = DOMProperties.isLenient();
+
- DOMRuleCombinerParameters domRuleCombinerParameters = new DOMRuleCombinerParameters();
++ DOMRuleCombinerParameters domRuleCombinerParameters = new DOMRuleCombinerParameters();
+
+ try {
- NodeList children = elementRuleCombinerParameters.getChildNodes();
++ NodeList children = elementRuleCombinerParameters.getChildNodes();
+ int numChildren;
+ if (children != null && (numChildren = children.getLength()) > 0) {
- for (int i = 0 ; i < numChildren ; i++) {
- Node child = children.item(i);
++ for (int i = 0; i < numChildren; i++) {
++ Node child = children.item(i);
+ if (DOMUtil.isElement(child)) {
- if (DOMUtil.isInNamespace(child, XACML3.XMLNS) && XACML3.ELEMENT_ATTRIBUTEVALUE.equals(child.getLocalName())) {
++ if (DOMUtil.isInNamespace(child, XACML3.XMLNS)
++ && XACML3.ELEMENT_ATTRIBUTEVALUE.equals(child.getLocalName())) {
+ if (domRuleCombinerParameters.getAttributeValue() != null) {
- throw DOMUtil.newUnexpectedElementException(child, nodeRuleCombinerParameters);
++ throw DOMUtil
++ .newUnexpectedElementException(child, nodeRuleCombinerParameters);
+ }
- domRuleCombinerParameters.setAttributeValue(DOMAttributeValue.newInstance(child, null));
++ domRuleCombinerParameters.setAttributeValue(DOMAttributeValue.newInstance(child,
++ null));
+ } else if (!bLenient) {
+ throw DOMUtil.newUnexpectedElementException(child, nodeRuleCombinerParameters);
+ }
+ }
+ }
+ }
+ if (domRuleCombinerParameters.getAttributeValue() == null && !bLenient) {
- throw DOMUtil.newMissingElementException(nodeRuleCombinerParameters, XACML3.XMLNS, XACML3.ELEMENT_ATTRIBUTEVALUE);
++ throw DOMUtil.newMissingElementException(nodeRuleCombinerParameters, XACML3.XMLNS,
++ XACML3.ELEMENT_ATTRIBUTEVALUE);
+ }
- domRuleCombinerParameters.setName(DOMUtil.getStringAttribute(elementRuleCombinerParameters, XACML3.ATTRIBUTE_PARAMETERNAME, !bLenient));
- domRuleCombinerParameters.setTargetId(DOMUtil.getStringAttribute(elementRuleCombinerParameters, XACML3.ATTRIBUTE_RULEIDREF, !bLenient));
++ domRuleCombinerParameters.setName(DOMUtil.getStringAttribute(elementRuleCombinerParameters,
++ XACML3.ATTRIBUTE_PARAMETERNAME,
++ !bLenient));
++ domRuleCombinerParameters.setTargetId(DOMUtil.getStringAttribute(elementRuleCombinerParameters,
++ XACML3.ATTRIBUTE_RULEIDREF,
++ !bLenient));
+ } catch (DOMStructureException ex) {
+ domRuleCombinerParameters.setStatus(StdStatusCode.STATUS_CODE_SYNTAX_ERROR, ex.getMessage());
+ if (DOMProperties.throwsExceptions()) {
+ throw ex;
+ }
+ }
+ return domRuleCombinerParameters;
+ }
+
+ public static boolean repair(Node nodeRuleCombinerParameters) throws DOMStructureException {
- Element elementRuleCombinerParameters = DOMUtil.getElement(nodeRuleCombinerParameters);
- boolean result = false;
++ Element elementRuleCombinerParameters = DOMUtil.getElement(nodeRuleCombinerParameters);
++ boolean result = false;
+
- NodeList children = elementRuleCombinerParameters.getChildNodes();
++ NodeList children = elementRuleCombinerParameters.getChildNodes();
+ int numChildren;
- boolean sawAttributeValue = false;
++ boolean sawAttributeValue = false;
+ if (children != null && (numChildren = children.getLength()) > 0) {
- for (int i = 0 ; i < numChildren ; i++) {
- Node child = children.item(i);
++ for (int i = 0; i < numChildren; i++) {
++ Node child = children.item(i);
+ if (DOMUtil.isElement(child)) {
- if (DOMUtil.isInNamespace(child, XACML3.XMLNS) && XACML3.ELEMENT_ATTRIBUTEVALUE.equals(child.getLocalName())) {
++ if (DOMUtil.isInNamespace(child, XACML3.XMLNS)
++ && XACML3.ELEMENT_ATTRIBUTEVALUE.equals(child.getLocalName())) {
+ if (sawAttributeValue) {
+ logger.warn("Unexpected element " + child.getNodeName());
+ elementRuleCombinerParameters.removeChild(child);
- result = true;
++ result = true;
+ } else {
- sawAttributeValue = true;
- result = result || DOMAttributeValue.repair(child);
++ sawAttributeValue = true;
++ result = result || DOMAttributeValue.repair(child);
+ }
+ } else {
+ logger.warn("Unexpected element " + child.getNodeName());
+ elementRuleCombinerParameters.removeChild(child);
- result = true;
++ result = true;
+ }
+ }
+ }
+ }
+ if (!sawAttributeValue) {
- throw DOMUtil.newMissingElementException(nodeRuleCombinerParameters, XACML3.XMLNS, XACML3.ELEMENT_ATTRIBUTEVALUE);
++ throw DOMUtil.newMissingElementException(nodeRuleCombinerParameters, XACML3.XMLNS,
++ XACML3.ELEMENT_ATTRIBUTEVALUE);
+ }
- result = result || DOMUtil.repairStringAttribute(elementRuleCombinerParameters, XACML3.ATTRIBUTE_PARAMETERNAME, "parameter", logger);
- result = result || DOMUtil.repairIdentifierAttribute(elementRuleCombinerParameters, XACML3.ATTRIBUTE_RULEIDREF, logger);
++ result = result
++ || DOMUtil.repairStringAttribute(elementRuleCombinerParameters,
++ XACML3.ATTRIBUTE_PARAMETERNAME, "parameter", logger);
++ result = result
++ || DOMUtil.repairIdentifierAttribute(elementRuleCombinerParameters,
++ XACML3.ATTRIBUTE_RULEIDREF, logger);
+
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMTarget.java
----------------------------------------------------------------------
diff --cc openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMTarget.java
index b93712a,0000000..cbd3d5e
mode 100644,000000..100644
--- a/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMTarget.java
+++ b/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMTarget.java
@@@ -1,119 -1,0 +1,121 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+/*
+ * AT&T - PROPRIETARY
+ * THIS FILE CONTAINS PROPRIETARY INFORMATION OF
+ * AT&T AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN
+ * ACCORDANCE WITH APPLICABLE AGREEMENTS.
+ *
+ * Copyright (c) 2013 AT&T Knowledge Ventures
+ * Unpublished and Not for Publication
+ * All Rights Reserved
+ */
+package org.apache.openaz.xacml.pdp.policy.dom;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.openaz.xacml.api.XACML3;
+import org.apache.openaz.xacml.pdp.policy.Target;
+import org.apache.openaz.xacml.std.StdStatusCode;
+import org.apache.openaz.xacml.std.dom.DOMProperties;
+import org.apache.openaz.xacml.std.dom.DOMStructureException;
+import org.apache.openaz.xacml.std.dom.DOMUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
- * DOMTarget extends {@link org.apache.openaz.xacml.pdp.policy.Target} with methods for creation from
- * DOM {@link org.w3c.dom.Node}s.
- *
++ * DOMTarget extends {@link com.att.research.xacmlatt.pdp.policy.Target} with methods for creation from DOM
++ * {@link org.w3c.dom.Node}s.
+ */
+public class DOMTarget extends Target {
- private static final Log logger = LogFactory.getLog(DOMTarget.class);
++ private static final Log logger = LogFactory.getLog(DOMTarget.class);
+
+ /**
+ * Creates an empty <code>DOMTarget</code>.
+ */
+ protected DOMTarget() {
+ }
+
+ /**
- * Creates a new <code>DOMTarget</code> by parsing the given <code>Node</code> representing a XACML Target element.
++ * Creates a new <code>DOMTarget</code> by parsing the given <code>Node</code> representing a XACML Target
++ * element.
+ *
+ * @param nodeTarget the <code>Node</code> representing the XACML Target element
+ * @return a new <code>DOMTarget</code> parsed from the given <code>Node</code>
+ * @throws DOMStructureException if there is an error parsing the <code>Node</code>
+ */
+ public static Target newInstance(Node nodeTarget) throws DOMStructureException {
- Element elementTarget = DOMUtil.getElement(nodeTarget);
- boolean bLenient = DOMProperties.isLenient();
++ Element elementTarget = DOMUtil.getElement(nodeTarget);
++ boolean bLenient = DOMProperties.isLenient();
+
- DOMTarget domTarget = new DOMTarget();
++ DOMTarget domTarget = new DOMTarget();
+ try {
- NodeList children = elementTarget.getChildNodes();
++ NodeList children = elementTarget.getChildNodes();
+ int numChildren;
+ if (children != null && (numChildren = children.getLength()) > 0) {
- for (int i = 0 ; i < numChildren ; i++) {
- Node child = children.item(i);
++ for (int i = 0; i < numChildren; i++) {
++ Node child = children.item(i);
+ if (DOMUtil.isElement(child)) {
- if (DOMUtil.isInNamespace(child, XACML3.XMLNS) && XACML3.ELEMENT_ANYOF.equals(child.getLocalName())) {
++ if (DOMUtil.isInNamespace(child, XACML3.XMLNS)
++ && XACML3.ELEMENT_ANYOF.equals(child.getLocalName())) {
+ domTarget.addAnyOf(DOMAnyOf.newInstance(child));
+ } else if (!bLenient) {
+ throw DOMUtil.newUnexpectedElementException(child, nodeTarget);
+ }
+ }
+ }
+ }
+ } catch (DOMStructureException ex) {
+ domTarget.setStatus(StdStatusCode.STATUS_CODE_SYNTAX_ERROR, ex.getMessage());
+ if (DOMProperties.throwsExceptions()) {
+ throw ex;
+ }
+ }
+
+ return domTarget;
+ }
+
+ public static boolean repair(Node nodeTarget) throws DOMStructureException {
- Element elementTarget = DOMUtil.getElement(nodeTarget);
- boolean result = false;
++ Element elementTarget = DOMUtil.getElement(nodeTarget);
++ boolean result = false;
+
- NodeList children = elementTarget.getChildNodes();
++ NodeList children = elementTarget.getChildNodes();
+ int numChildren;
+ if (children != null && (numChildren = children.getLength()) > 0) {
- for (int i = 0 ; i < numChildren ; i++) {
- Node child = children.item(i);
++ for (int i = 0; i < numChildren; i++) {
++ Node child = children.item(i);
+ if (DOMUtil.isElement(child)) {
- if (DOMUtil.isInNamespace(child, XACML3.XMLNS) && XACML3.ELEMENT_ANYOF.equals(child.getLocalName())) {
- result = DOMAnyOf.repair(child) || result;
++ if (DOMUtil.isInNamespace(child, XACML3.XMLNS)
++ && XACML3.ELEMENT_ANYOF.equals(child.getLocalName())) {
++ result = DOMAnyOf.repair(child) || result;
+ } else {
+ logger.warn("Unexpected element " + child.getNodeName());
+ elementTarget.removeChild(child);
- result = true;
++ result = true;
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+}