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:03:00 UTC
[38/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/DOMCombinerParameter.java
----------------------------------------------------------------------
diff --cc openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMCombinerParameter.java
index 12d1204,0000000..cf60930
mode 100644,000000..100644
--- a/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMCombinerParameter.java
+++ b/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMCombinerParameter.java
@@@ -1,200 -1,0 +1,209 @@@
+/*
+ * 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.ArrayList;
+import java.util.List;
+
+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.CombinerParameter;
+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;
+
+/**
- * DOMCombinerParameter extends {@link org.apache.openaz.xacml.pdp.policy.CombinerParameter} with methods for
- * creation from DOM {@link org.w3c.dom.Node}s.
- *
++ * DOMCombinerParameter extends {@link com.att.research.xacmlatt.pdp.policy.CombinerParameter} with methods
++ * for creation from DOM {@link org.w3c.dom.Node}s.
+ */
+public class DOMCombinerParameter extends CombinerParameter {
- private static final Log logger = LogFactory.getLog(DOMCombinerParameter.class);
++ private static final Log logger = LogFactory.getLog(DOMCombinerParameter.class);
+
+ protected DOMCombinerParameter() {
+
+ }
+
+ /**
- * Creates a new <code>CombinerParameter</code> by parsing the given <code>Node</code> representing a XACML CombinerParameter element.
++ * Creates a new <code>CombinerParameter</code> by parsing the given <code>Node</code> representing a
++ * XACML CombinerParameter element.
+ *
+ * @param nodeCombinerParameter the <code>Node</code> representing the XACML CombinerParameter element
+ * @return a new <code>CombinerParameter</code> parsed from the given <code>Node</code>
+ * @throws DOMStructureException if there is an error parsing the <code>Node</code>
+ */
+ public static CombinerParameter newInstance(Node nodeCombinerParameter) throws DOMStructureException {
- Element elementCombinerParameter = DOMUtil.getElement(nodeCombinerParameter);
- boolean bLenient = DOMProperties.isLenient();
++ Element elementCombinerParameter = DOMUtil.getElement(nodeCombinerParameter);
++ boolean bLenient = DOMProperties.isLenient();
+
- DOMCombinerParameter combinerParameter = new DOMCombinerParameter();
++ DOMCombinerParameter combinerParameter = new DOMCombinerParameter();
+
+ try {
- NodeList children = elementCombinerParameter.getChildNodes();
++ NodeList children = elementCombinerParameter.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 (combinerParameter.getAttributeValue() != null && !bLenient) {
+ throw DOMUtil.newUnexpectedElementException(child, elementCombinerParameter);
+ } else {
- combinerParameter.setAttributeValue(DOMAttributeValue.newInstance(child, null));
++ combinerParameter.setAttributeValue(DOMAttributeValue
++ .newInstance(child, null));
+ }
+ } else if (!bLenient) {
+ throw DOMUtil.newUnexpectedElementException(child, elementCombinerParameter);
+ }
+ }
+ }
+ }
+
+ if (combinerParameter.getAttributeValue() == null && !bLenient) {
- throw DOMUtil.newMissingElementException(elementCombinerParameter, XACML3.XMLNS, XACML3.ELEMENT_ATTRIBUTEVALUE);
++ throw DOMUtil.newMissingElementException(elementCombinerParameter, XACML3.XMLNS,
++ XACML3.ELEMENT_ATTRIBUTEVALUE);
+ }
- combinerParameter.setName(DOMUtil.getStringAttribute(elementCombinerParameter, XACML3.ATTRIBUTE_PARAMETERNAME, !bLenient));
++ combinerParameter.setName(DOMUtil.getStringAttribute(elementCombinerParameter,
++ XACML3.ATTRIBUTE_PARAMETERNAME, !bLenient));
+ } catch (DOMStructureException ex) {
+ combinerParameter.setStatus(StdStatusCode.STATUS_CODE_SYNTAX_ERROR, ex.getMessage());
+ if (DOMProperties.throwsExceptions()) {
+ throw ex;
+ }
+ }
+
+ return combinerParameter;
+ }
+
+ public static boolean repair(Node nodeCombinerParameter) throws DOMStructureException {
- Element elementCombinerParameter = DOMUtil.getElement(nodeCombinerParameter);
- boolean result = false;
++ Element elementCombinerParameter = DOMUtil.getElement(nodeCombinerParameter);
++ boolean result = false;
+
- NodeList children = elementCombinerParameter.getChildNodes();
++ NodeList children = elementCombinerParameter.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());
+ elementCombinerParameter.removeChild(child);
- result = true;
++ result = true;
+ } else {
- result = DOMAttributeValue.repair(child) || result;
- sawAttributeValue = true;
++ result = DOMAttributeValue.repair(child) || result;
++ sawAttributeValue = true;
+ }
+ } else {
+ logger.warn("Unexpected element " + child.getNodeName());
+ elementCombinerParameter.removeChild(child);
- result = true;
++ result = true;
+ }
+ }
+ }
+ }
+
+ if (!sawAttributeValue) {
- throw DOMUtil.newMissingElementException(elementCombinerParameter, XACML3.XMLNS, XACML3.ELEMENT_ATTRIBUTEVALUE);
++ throw DOMUtil.newMissingElementException(elementCombinerParameter, XACML3.XMLNS,
++ XACML3.ELEMENT_ATTRIBUTEVALUE);
+ }
+
- result = DOMUtil.repairStringAttribute(elementCombinerParameter, XACML3.ATTRIBUTE_PARAMETERNAME, "parameter", logger) || result;
++ result = DOMUtil.repairStringAttribute(elementCombinerParameter, XACML3.ATTRIBUTE_PARAMETERNAME,
++ "parameter", logger) || result;
+
+ return result;
+ }
+
+ /**
- * Creates a <code>List</code> of <code>CombinerParameter</code>s by parsing the given <code>Node</code> representing a
- * XACML CombinerParameters element.
++ * Creates a <code>List</code> of <code>CombinerParameter</code>s by parsing the given <code>Node</code>
++ * representing a XACML CombinerParameters element.
+ *
+ * @param nodeCombinerParameters the <code>Node</code> representing the XACML CombinerParameters element
+ * @return a <code>List</code> of <code>CombinerParameter</code>s parsed from the given <code>Node</code>.
+ * @throws DOMStructureException if there is an error parsing the <code>Node</code>
+ */
+ public static List<CombinerParameter> newList(Node nodeCombinerParameters) throws DOMStructureException {
- Element elementCombinerParameters = DOMUtil.getElement(nodeCombinerParameters);
- boolean bLenient = DOMProperties.isLenient();
++ Element elementCombinerParameters = DOMUtil.getElement(nodeCombinerParameters);
++ boolean bLenient = DOMProperties.isLenient();
+
- List<CombinerParameter> listCombinerParameters = new ArrayList<CombinerParameter>();
++ List<CombinerParameter> listCombinerParameters = new ArrayList<CombinerParameter>();
+
- NodeList children = elementCombinerParameters.getChildNodes();
++ NodeList children = elementCombinerParameters.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_COMBINERPARAMETER.equals(child.getLocalName())) {
++ if (DOMUtil.isInNamespace(child, XACML3.XMLNS)
++ && XACML3.ELEMENT_COMBINERPARAMETER.equals(child.getLocalName())) {
+ listCombinerParameters.add(DOMCombinerParameter.newInstance(child));
+ } else if (!bLenient) {
+ throw DOMUtil.newUnexpectedElementException(child, elementCombinerParameters);
+ }
+ }
+ }
+ }
+ return listCombinerParameters;
+ }
+
+ public static boolean repairList(Node nodeCombinerParameters) throws DOMStructureException {
- Element elementCombinerParameters = DOMUtil.getElement(nodeCombinerParameters);
- boolean result = false;
++ Element elementCombinerParameters = DOMUtil.getElement(nodeCombinerParameters);
++ boolean result = false;
+
- NodeList children = elementCombinerParameters.getChildNodes();
++ NodeList children = elementCombinerParameters.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_COMBINERPARAMETER.equals(child.getLocalName())) {
- result = DOMCombinerParameter.repair(child) || result;
++ if (DOMUtil.isInNamespace(child, XACML3.XMLNS)
++ && XACML3.ELEMENT_COMBINERPARAMETER.equals(child.getLocalName())) {
++ result = DOMCombinerParameter.repair(child) || result;
+ } else {
+ logger.warn("Unexpected element " + child.getNodeName());
+ elementCombinerParameters.removeChild(child);
- 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/DOMDocumentRepair.java
----------------------------------------------------------------------
diff --cc openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMDocumentRepair.java
index c48e181,0000000..57f7e84
mode 100644,000000..100644
--- a/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMDocumentRepair.java
+++ b/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMDocumentRepair.java
@@@ -1,87 -1,0 +1,89 @@@
+/*
+ * 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.api.XACML3;
+import org.apache.openaz.xacml.std.dom.DOMStructureException;
+import org.apache.openaz.xacml.std.dom.DOMUtil;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+/**
- * DOMDocumentRepair extends {@link org.apache.openaz.xacml.std.dom.DOMDocumentRepair} to repair Policy documents as well as
- * Request and Response documents.
- *
++ * DOMDocumentRepair extends {@link com.att.research.xacml.std.dom.DOMDocumentRepair} to repair Policy
++ * documents as well as Request and Response documents.
+ */
+public class DOMDocumentRepair extends org.apache.openaz.xacml.std.dom.DOMDocumentRepair {
+ protected boolean repairPolicy(Node nodePolicy) throws DOMStructureException {
+ return DOMPolicy.repair(nodePolicy);
+ }
+
+ protected boolean repairPolicySet(Node nodePolicySet) throws DOMStructureException {
+ return DOMPolicySet.repair(nodePolicySet);
+ }
+
+ public DOMDocumentRepair() {
+ }
+
+ /**
- * Determines what kind of XACML document is represented by the given <code>Document</code> and
- * attempts to repair it.
++ * Determines what kind of XACML document is represented by the given <code>Document</code> and attempts
++ * to repair it.
+ *
+ * @param document the <code>Document</code> to check
+ * @return true if any repairs were made in the <code>Document</code>, else false
+ * @throws DOMStructureException if there were unrecoverable errors found
+ * @throws UnsupportedDocumentTypeException if the root element is not a XACML Request or Response.
+ */
++ @Override
+ public boolean repair(Document document) throws DOMStructureException, UnsupportedDocumentTypeException {
- Node firstChild = DOMUtil.getFirstChildElement(document);
++ Node firstChild = DOMUtil.getFirstChildElement(document);
+ if (firstChild == null || !DOMUtil.isElement(firstChild)) {
+ return false;
+ }
+
+ if (!DOMUtil.isInNamespace(firstChild, XACML3.XMLNS)) {
- throw new UnsupportedDocumentTypeException("Not a XACML document: " + DOMUtil.getNodeLabel(firstChild));
++ throw new UnsupportedDocumentTypeException("Not a XACML document: "
++ + DOMUtil.getNodeLabel(firstChild));
+ }
+ if (XACML3.ELEMENT_REQUEST.equals(firstChild.getLocalName())) {
+ return this.repairRequest(firstChild);
+ } else if (XACML3.ELEMENT_RESPONSE.equals(firstChild.getLocalName())) {
+ return this.repairResponse(firstChild);
+ } else if (XACML3.ELEMENT_POLICY.equals(firstChild.getLocalName())) {
+ return this.repairPolicy(firstChild);
+ } else if (XACML3.ELEMENT_POLICYSET.equals(firstChild.getLocalName())) {
+ return this.repairPolicySet(firstChild);
+ } else {
- throw new UnsupportedDocumentTypeException("Not a XACML Request or Response: " + DOMUtil.getNodeLabel(firstChild));
++ throw new UnsupportedDocumentTypeException("Not a XACML Request or Response: "
++ + DOMUtil.getNodeLabel(firstChild));
+ }
+ }
+
+}
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/DOMExpression.java
----------------------------------------------------------------------
diff --cc openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMExpression.java
index 8fab00d,0000000..0e462ec
mode 100644,000000..100644
--- a/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMExpression.java
+++ b/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMExpression.java
@@@ -1,137 -1,0 +1,139 @@@
+/*
+ * 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.AttributeValue;
+import org.apache.openaz.xacml.api.XACML3;
+import org.apache.openaz.xacml.pdp.policy.Expression;
+import org.apache.openaz.xacml.pdp.policy.Policy;
+import org.apache.openaz.xacml.pdp.policy.expressions.AttributeValueExpression;
+import org.apache.openaz.xacml.pdp.policy.expressions.Function;
+import org.apache.openaz.xacml.pdp.policy.expressions.VariableReference;
+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;
+
+/**
+ * DOMExpression extends {@link org.apache.openaz.xacml.pdp.policy.Expression} with methods for creation
+ * from DOM {@link org.w3c.dom.Node}s.
- *
+ */
+public abstract class DOMExpression extends Expression {
- private static final Log logger = LogFactory.getLog(DOMExpression.class);
++ private static final Log logger = LogFactory.getLog(DOMExpression.class);
+
+ protected DOMExpression() {
+ }
+
+ public static boolean isExpression(Node nodeExpression) {
- String nodeName = nodeExpression.getLocalName();
- return (XACML3.ELEMENT_APPLY.equals(nodeName) ||
- XACML3.ELEMENT_ATTRIBUTEDESIGNATOR.equals(nodeName) ||
- XACML3.ELEMENT_ATTRIBUTESELECTOR.equals(nodeName) ||
- XACML3.ELEMENT_ATTRIBUTEVALUE.equals(nodeName) ||
- XACML3.ELEMENT_FUNCTION.equals(nodeName) ||
- XACML3.ELEMENT_VARIABLEREFERENCE.equals(nodeName)
- );
++ String nodeName = nodeExpression.getLocalName();
++ return XACML3.ELEMENT_APPLY.equals(nodeName) || XACML3.ELEMENT_ATTRIBUTEDESIGNATOR.equals(nodeName)
++ || XACML3.ELEMENT_ATTRIBUTESELECTOR.equals(nodeName)
++ || XACML3.ELEMENT_ATTRIBUTEVALUE.equals(nodeName) || XACML3.ELEMENT_FUNCTION.equals(nodeName) || XACML3.ELEMENT_VARIABLEREFERENCE
++ .equals(nodeName);
+ }
+
+ /**
- * Creates a new <code>Expression</code> of the appropriate sub-type based on the name of the given <code>Node</code>.
++ * Creates a new <code>Expression</code> of the appropriate sub-type based on the name of the given
++ * <code>Node</code>.
+ *
+ * @param nodeExpression the <code>Node</code> to parse
+ * @param policy the {@link org.apache.openaz.xacml.pdp.policy.Policy} containing the Expression element
+ * @return a new <code>Expression</code> parsed from the given <code>Node</code>
+ * @throws DOMStructureException if there is an error parsing the <code>Node</code>
+ */
+ public static Expression newInstance(Node nodeExpression, Policy policy) throws DOMStructureException {
- Element elementExpression = DOMUtil.getElement(nodeExpression);
- boolean bLenient = DOMProperties.isLenient();
++ Element elementExpression = DOMUtil.getElement(nodeExpression);
++ boolean bLenient = DOMProperties.isLenient();
+
+ if (DOMUtil.isInNamespace(elementExpression, XACML3.XMLNS)) {
+ if (elementExpression.getLocalName().equals(XACML3.ELEMENT_APPLY)) {
+ return DOMApply.newInstance(elementExpression, policy);
+ } else if (elementExpression.getLocalName().equals(XACML3.ELEMENT_ATTRIBUTEDESIGNATOR)) {
+ return DOMAttributeDesignator.newInstance(elementExpression);
+ } else if (elementExpression.getLocalName().equals(XACML3.ELEMENT_ATTRIBUTESELECTOR)) {
+ return DOMAttributeSelector.newInstance(elementExpression);
+ } else if (elementExpression.getLocalName().equals(XACML3.ELEMENT_ATTRIBUTEVALUE)) {
- AttributeValue<?> attributeValue = null;
++ AttributeValue<?> attributeValue = null;
+ try {
- attributeValue = DOMAttributeValue.newInstance(elementExpression, null);
++ attributeValue = DOMAttributeValue.newInstance(elementExpression, null);
+ } catch (DOMStructureException ex) {
- return new AttributeValueExpression(StdStatusCode.STATUS_CODE_SYNTAX_ERROR, ex.getMessage());
++ return new AttributeValueExpression(StdStatusCode.STATUS_CODE_SYNTAX_ERROR,
++ ex.getMessage());
+ }
+ return new AttributeValueExpression(attributeValue);
+ } else if (elementExpression.getLocalName().equals(XACML3.ELEMENT_FUNCTION)) {
- return new Function(DOMUtil.getIdentifierAttribute(elementExpression, XACML3.ATTRIBUTE_FUNCTIONID));
++ return new Function(DOMUtil.getIdentifierAttribute(elementExpression,
++ XACML3.ATTRIBUTE_FUNCTIONID));
+ } else if (elementExpression.getLocalName().equals(XACML3.ELEMENT_VARIABLEREFERENCE)) {
- return new VariableReference(policy, DOMUtil.getStringAttribute(elementExpression, XACML3.ATTRIBUTE_VARIABLEID));
++ return new VariableReference(policy, DOMUtil.getStringAttribute(elementExpression,
++ XACML3.ATTRIBUTE_VARIABLEID));
+ } else if (!bLenient) {
+ throw DOMUtil.newUnexpectedElementException(nodeExpression);
+ } else {
+ return null;
+ }
+ } else if (!bLenient) {
+ throw DOMUtil.newUnexpectedElementException(nodeExpression);
+ } else {
+ return null;
+ }
+ }
+
+ public static boolean repair(Node nodeExpression) throws DOMStructureException {
- Element elementExpression = DOMUtil.getElement(nodeExpression);
++ Element elementExpression = DOMUtil.getElement(nodeExpression);
+ if (DOMUtil.isInNamespace(elementExpression, XACML3.XMLNS)) {
+ if (elementExpression.getLocalName().equals(XACML3.ELEMENT_APPLY)) {
+ return DOMApply.repair(elementExpression);
+ } else if (elementExpression.getLocalName().equals(XACML3.ELEMENT_ATTRIBUTEDESIGNATOR)) {
+ return DOMAttributeDesignator.repair(elementExpression);
+ } else if (elementExpression.getLocalName().equals(XACML3.ELEMENT_ATTRIBUTESELECTOR)) {
+ return DOMAttributeSelector.repair(elementExpression);
+ } else if (elementExpression.getLocalName().equals(XACML3.ELEMENT_ATTRIBUTEVALUE)) {
+ return DOMAttributeValue.repair(elementExpression);
+ } else if (elementExpression.getLocalName().equals(XACML3.ELEMENT_FUNCTION)) {
- return DOMUtil.repairIdentifierAttribute(elementExpression, XACML3.ATTRIBUTE_FUNCTIONID, XACML3.ID_FUNCTION_STRING_EQUAL, logger);
++ return DOMUtil.repairIdentifierAttribute(elementExpression, XACML3.ATTRIBUTE_FUNCTIONID,
++ XACML3.ID_FUNCTION_STRING_EQUAL, logger);
+ } else if (elementExpression.getLocalName().equals(XACML3.ELEMENT_VARIABLEREFERENCE)) {
- return DOMUtil.repairStringAttribute(elementExpression, XACML3.ATTRIBUTE_VARIABLEID, "variableId", logger);
++ return DOMUtil.repairStringAttribute(elementExpression, XACML3.ATTRIBUTE_VARIABLEID,
++ "variableId", logger);
+ } else {
+ throw DOMUtil.newUnexpectedElementException(nodeExpression);
+ }
+ } else {
+ throw DOMUtil.newUnexpectedElementException(nodeExpression);
+ }
+ }
+}
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/DOMMatch.java
----------------------------------------------------------------------
diff --cc openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMMatch.java
index cee77ce,0000000..5819cfa
mode 100644,000000..100644
--- a/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMMatch.java
+++ b/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMMatch.java
@@@ -1,190 -1,0 +1,196 @@@
+/*
+ * 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.Match;
+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;
+
+/**
- * DOMMatch extends {@link org.apache.openaz.xacml.pdp.policy.Match} with methods for creation from
- * DOM {@link org.w3c.dom.Node}s.
- *
++ * DOMMatch extends {@link com.att.research.xacmlatt.pdp.policy.Match} with methods for creation from DOM
++ * {@link org.w3c.dom.Node}s.
+ */
+public class DOMMatch extends Match {
- private static Log logger = LogFactory.getLog(DOMMatch.class);
++ private static Log logger = LogFactory.getLog(DOMMatch.class);
+
+ protected DOMMatch() {
+ }
+
+ /**
- * Creates a new <code>DOMMatch</code> by parsing the given <code>Node</code> representing a XACML Match element.
++ * Creates a new <code>DOMMatch</code> by parsing the given <code>Node</code> representing a XACML Match
++ * element.
+ *
+ * @param nodeMatch the <code>Node</code> representing the XACML Match element
+ * @return a new <code>DOMMatch</code> parsed from the given <code>Node</code>
+ * @throws DOMStructureException if there is an error parsing the given <code>Node</code>
+ */
+ public static Match newInstance(Node nodeMatch) throws DOMStructureException {
- Element elementMatch = DOMUtil.getElement(nodeMatch);
- boolean bLenient = DOMProperties.isLenient();
++ Element elementMatch = DOMUtil.getElement(nodeMatch);
++ boolean bLenient = DOMProperties.isLenient();
+
- DOMMatch domMatch = new DOMMatch();
++ DOMMatch domMatch = new DOMMatch();
+
+ try {
- NodeList children = elementMatch.getChildNodes();
++ NodeList children = elementMatch.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_ATTRIBUTEVALUE.equals(childName)) {
+ domMatch.setAttributeValue(DOMAttributeValue.newInstance(child, null));
+ } else if (XACML3.ELEMENT_ATTRIBUTEDESIGNATOR.equals(childName)) {
+ if (domMatch.getAttributeRetrievalBase() != null && !bLenient) {
+ throw DOMUtil.newUnexpectedElementException(child, nodeMatch);
+ }
+ domMatch.setAttributeRetrievalBase(DOMAttributeDesignator.newInstance(child));
+ } else if (XACML3.ELEMENT_ATTRIBUTESELECTOR.equals(childName)) {
+ if (domMatch.getAttributeRetrievalBase() != null) {
+ throw DOMUtil.newUnexpectedElementException(child, nodeMatch);
+ }
+ domMatch.setAttributeRetrievalBase(DOMAttributeSelector.newInstance(child));
+ } else if (!bLenient) {
+ throw DOMUtil.newUnexpectedElementException(child, nodeMatch);
+ }
+ } else if (!bLenient) {
+ throw DOMUtil.newUnexpectedElementException(child, nodeMatch);
+ }
+ }
+ }
+ }
+
+ /*
+ * We have to see exactly one of these
+ */
+ if (domMatch.getAttributeRetrievalBase() == null && !bLenient) {
- throw DOMUtil.newMissingElementException(nodeMatch, XACML3.XMLNS, XACML3.ELEMENT_ATTRIBUTEDESIGNATOR + " or " + XACML3.ELEMENT_ATTRIBUTESELECTOR);
++ throw DOMUtil.newMissingElementException(nodeMatch, XACML3.XMLNS,
++ XACML3.ELEMENT_ATTRIBUTEDESIGNATOR + " or "
++ + XACML3.ELEMENT_ATTRIBUTESELECTOR);
+ } else if (domMatch.getAttributeValue() == null && !bLenient) {
- throw DOMUtil.newMissingElementException(nodeMatch, XACML3.XMLNS, XACML3.ELEMENT_ATTRIBUTEVALUE);
++ throw DOMUtil.newMissingElementException(nodeMatch, XACML3.XMLNS,
++ XACML3.ELEMENT_ATTRIBUTEVALUE);
+ }
+
- domMatch.setMatchId(DOMUtil.getIdentifierAttribute(elementMatch, XACML3.ATTRIBUTE_MATCHID, !bLenient));
++ domMatch.setMatchId(DOMUtil.getIdentifierAttribute(elementMatch, XACML3.ATTRIBUTE_MATCHID,
++ !bLenient));
+
+ } catch (DOMStructureException ex) {
+ domMatch.setStatus(StdStatusCode.STATUS_CODE_SYNTAX_ERROR, ex.getMessage());
+ if (DOMProperties.throwsExceptions()) {
+ throw ex;
+ }
+ }
+ return domMatch;
+ }
+
+ public static boolean repair(Node nodeMatch) throws DOMStructureException {
- Element elementMatch = DOMUtil.getElement(nodeMatch);
- boolean result = false;
++ Element elementMatch = DOMUtil.getElement(nodeMatch);
++ boolean result = false;
+
- NodeList children = elementMatch.getChildNodes();
++ NodeList children = elementMatch.getChildNodes();
+ int numChildren;
- boolean sawAttributeRetrievalBase = false;
- boolean sawAttributeValue = false;
++ boolean sawAttributeRetrievalBase = 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)) {
- String childName = child.getLocalName();
++ String childName = child.getLocalName();
+ if (XACML3.ELEMENT_ATTRIBUTEVALUE.equals(childName)) {
+ if (sawAttributeValue) {
+ logger.warn("Unexpected element " + child.getNodeName());
+ elementMatch.removeChild(child);
- result = true;
++ result = true;
+ } else {
- result = DOMAttributeValue.repair(child) || result;
- sawAttributeValue = true;
++ result = DOMAttributeValue.repair(child) || result;
++ sawAttributeValue = true;
+ }
+ } else if (XACML3.ELEMENT_ATTRIBUTEDESIGNATOR.equals(childName)) {
+ if (sawAttributeRetrievalBase) {
+ logger.warn("Unexpected element " + child.getNodeName());
+ elementMatch.removeChild(child);
- result = true;
++ result = true;
+ } else {
- result = DOMAttributeDesignator.repair(child) || result;
- sawAttributeRetrievalBase = true;
++ result = DOMAttributeDesignator.repair(child) || result;
++ sawAttributeRetrievalBase = true;
+ }
+ } else if (XACML3.ELEMENT_ATTRIBUTESELECTOR.equals(childName)) {
+ if (sawAttributeRetrievalBase) {
+ logger.warn("Unexpected element " + child.getNodeName());
+ elementMatch.removeChild(child);
- result = true;
++ result = true;
+ } else {
- result = DOMAttributeSelector.repair(child) || result;
- sawAttributeRetrievalBase = true;
++ result = DOMAttributeSelector.repair(child) || result;
++ sawAttributeRetrievalBase = true;
+ }
+ } else {
+ logger.warn("Unexpected element " + child.getNodeName());
+ elementMatch.removeChild(child);
- result = true;
++ result = true;
+ }
+ } else {
+ logger.warn("Unexpected element " + child.getNodeName());
+ elementMatch.removeChild(child);
- result = true;
++ result = true;
+ }
+ }
+ }
+ }
+
+ /*
+ * We have to see exactly one of these
+ */
+ if (!sawAttributeRetrievalBase) {
- throw DOMUtil.newMissingElementException(nodeMatch, XACML3.XMLNS, XACML3.ELEMENT_ATTRIBUTEDESIGNATOR + " or " + XACML3.ELEMENT_ATTRIBUTESELECTOR);
++ throw DOMUtil.newMissingElementException(nodeMatch, XACML3.XMLNS,
++ XACML3.ELEMENT_ATTRIBUTEDESIGNATOR + " or "
++ + XACML3.ELEMENT_ATTRIBUTESELECTOR);
+ } else if (!sawAttributeValue) {
+ throw DOMUtil.newMissingElementException(nodeMatch, XACML3.XMLNS, XACML3.ELEMENT_ATTRIBUTEVALUE);
+ }
- result = DOMUtil.repairIdentifierAttribute(elementMatch, XACML3.ATTRIBUTE_MATCHID, logger) || result;
++ result = DOMUtil.repairIdentifierAttribute(elementMatch, XACML3.ATTRIBUTE_MATCHID, 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/DOMObligationExpression.java
----------------------------------------------------------------------
diff --cc openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMObligationExpression.java
index 6c1731d,0000000..34063b6
mode 100644,000000..100644
--- a/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMObligationExpression.java
+++ b/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/policy/dom/DOMObligationExpression.java
@@@ -1,212 -1,0 +1,234 @@@
+/*
+ * 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.ArrayList;
+import java.util.List;
+
+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.ObligationExpression;
+import org.apache.openaz.xacml.pdp.policy.Policy;
+import org.apache.openaz.xacml.pdp.policy.RuleEffect;
+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;
+
+/**
- * DOMObligationExpression extends {@link org.apache.openaz.xacml.pdp.policy.ObligationExpression} with methods
- * for creation from {@link org.w3c.dom.Node}s.
- *
++ * DOMObligationExpression extends {@link com.att.research.xacmlatt.pdp.policy.ObligationExpression} with
++ * methods for creation from {@link org.w3c.dom.Node}s.
+ */
+public class DOMObligationExpression extends ObligationExpression {
- private static final Log logger = LogFactory.getLog(DOMObligationExpression.class);
++ private static final Log logger = LogFactory.getLog(DOMObligationExpression.class);
+
+ protected DOMObligationExpression() {
+ }
+
+ /**
- * Creates a new <code>ObligationExpression</code> by parsing the given <code>Node</code> representing a XACML ObligationExpression element.
++ * Creates a new <code>ObligationExpression</code> by parsing the given <code>Node</code> representing a
++ * XACML ObligationExpression element.
+ *
- * @param nodeObligationExpression the <code>Node</code> representing the XACML ObligationExpression element
- * @param policy the {@link org.apache.openaz.xacml.pdp.policy.Policy} encompassing the ObligationExpression element
++ * @param nodeObligationExpression the <code>Node</code> representing the XACML ObligationExpression
++ * element
++ * @param policy the {@link com.att.research.xacmlatt.pdp.policy.Policy} encompassing the
++ * ObligationExpression element
+ * @return a new <code>ObligationExpression</code> parsed from the given <code>Node</code>
+ * @throws DOMStructureException if there is an error parsing the <code>Node</code>
+ */
- public static ObligationExpression newInstance(Node nodeObligationExpression, Policy policy) throws DOMStructureException {
- Element elementObligationExpression = DOMUtil.getElement(nodeObligationExpression);
- boolean bLenient = DOMProperties.isLenient();
++ public static ObligationExpression newInstance(Node nodeObligationExpression, Policy policy)
++ throws DOMStructureException {
++ Element elementObligationExpression = DOMUtil.getElement(nodeObligationExpression);
++ boolean bLenient = DOMProperties.isLenient();
+
- DOMObligationExpression domObligationExpression = new DOMObligationExpression();
++ DOMObligationExpression domObligationExpression = new DOMObligationExpression();
+
+ try {
- NodeList children = elementObligationExpression.getChildNodes();
++ NodeList children = elementObligationExpression.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_ATTRIBUTEASSIGNMENTEXPRESSION.equals(child.getLocalName())) {
- domObligationExpression.addAttributeAssignmentExpression(DOMAttributeAssignmentExpression.newInstance(child, policy));
++ if (DOMUtil.isInNamespace(child, XACML3.XMLNS)
++ && XACML3.ELEMENT_ATTRIBUTEASSIGNMENTEXPRESSION.equals(child.getLocalName())) {
++ domObligationExpression
++ .addAttributeAssignmentExpression(DOMAttributeAssignmentExpression
++ .newInstance(child, policy));
+ } else if (!bLenient) {
+ throw DOMUtil.newUnexpectedElementException(child, nodeObligationExpression);
+ }
+ }
+ }
+ }
+
- domObligationExpression.setObligationId(DOMUtil.getIdentifierAttribute(elementObligationExpression, XACML3.ATTRIBUTE_OBLIGATIONID, !bLenient));
++ domObligationExpression
++ .setObligationId(DOMUtil.getIdentifierAttribute(elementObligationExpression,
++ XACML3.ATTRIBUTE_OBLIGATIONID, !bLenient));
+
- String string = DOMUtil.getStringAttribute(elementObligationExpression, XACML3.ATTRIBUTE_FULFILLON, !bLenient);
- RuleEffect ruleEffectType = RuleEffect.getRuleEffect(string);
++ String string = DOMUtil.getStringAttribute(elementObligationExpression,
++ XACML3.ATTRIBUTE_FULFILLON, !bLenient);
++ RuleEffect ruleEffectType = RuleEffect.getRuleEffect(string);
+ if (ruleEffectType == null) {
+ if (!bLenient) {
- throw new DOMStructureException(nodeObligationExpression, "Invalid EffectType \"" + string + "\" in \"" + DOMUtil.getNodeLabel(nodeObligationExpression) + "\"");
++ throw new DOMStructureException(nodeObligationExpression,
++ "Invalid EffectType \"" + string + "\" in \""
++ + DOMUtil.getNodeLabel(nodeObligationExpression)
++ + "\"");
+ }
+ } else {
+ domObligationExpression.setRuleEffect(ruleEffectType);
+ }
+ } catch (DOMStructureException ex) {
+ domObligationExpression.setStatus(StdStatusCode.STATUS_CODE_SYNTAX_ERROR, ex.getMessage());
+ if (DOMProperties.throwsExceptions()) {
+ throw ex;
+ }
+ }
+ return domObligationExpression;
+ }
+
+ public static boolean repair(Node nodeObligationExpression) throws DOMStructureException {
- Element elementObligationExpression = DOMUtil.getElement(nodeObligationExpression);
- boolean result = false;
++ Element elementObligationExpression = DOMUtil.getElement(nodeObligationExpression);
++ boolean result = false;
+
- NodeList children = elementObligationExpression.getChildNodes();
++ NodeList children = elementObligationExpression.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_ATTRIBUTEASSIGNMENTEXPRESSION.equals(child.getLocalName())) {
- result = DOMAttributeAssignmentExpression.repair(child) || result;
++ if (DOMUtil.isInNamespace(child, XACML3.XMLNS)
++ && XACML3.ELEMENT_ATTRIBUTEASSIGNMENTEXPRESSION.equals(child.getLocalName())) {
++ result = DOMAttributeAssignmentExpression.repair(child) || result;
+ } else {
+ logger.warn("Unexpected element " + child.getNodeName());
+ elementObligationExpression.removeChild(child);
- result = true;
++ result = true;
+ }
+ }
+ }
+ }
+
- result = DOMUtil.repairIdentifierAttribute(elementObligationExpression, XACML3.ATTRIBUTE_OBLIGATIONID, logger) || result;
- result = DOMUtil.repairStringAttribute(elementObligationExpression, XACML3.ATTRIBUTE_FULFILLON, RuleEffect.DENY.getName(), logger) || result;
++ result = DOMUtil.repairIdentifierAttribute(elementObligationExpression,
++ XACML3.ATTRIBUTE_OBLIGATIONID, logger) || result;
++ result = DOMUtil.repairStringAttribute(elementObligationExpression, XACML3.ATTRIBUTE_FULFILLON,
++ RuleEffect.DENY.getName(), logger) || result;
+
- String string = DOMUtil.getStringAttribute(elementObligationExpression, XACML3.ATTRIBUTE_FULFILLON);
- RuleEffect ruleEffectType = RuleEffect.getRuleEffect(string);
++ String string = DOMUtil.getStringAttribute(elementObligationExpression, XACML3.ATTRIBUTE_FULFILLON);
++ RuleEffect ruleEffectType = RuleEffect.getRuleEffect(string);
+ if (ruleEffectType == null) {
+ logger.warn("Setting invalid RuleEffect " + string + " to " + RuleEffect.DENY.getName());
+ elementObligationExpression.setAttribute(XACML3.ATTRIBUTE_FULFILLON, RuleEffect.DENY.getName());
- result = true;
++ result = true;
+ }
+
+ return result;
+ }
+
+ /**
- * Creates a <code>List</code> of <code>ObligationExpression</code>s by parsing the given <code>Node</code>
- * representing a XACML ObligationExpressions element.
++ * Creates a <code>List</code> of <code>ObligationExpression</code>s by parsing the given
++ * <code>Node</code> representing a XACML ObligationExpressions element.
+ *
- * @param nodeObligationExpressions the <code>Node</code> representing the XACML ObligationExpressions element
++ * @param nodeObligationExpressions the <code>Node</code> representing the XACML ObligationExpressions
++ * element
+ * @param policy the <code>Policy</code> encompassing the ObligationExpressions element
- * @return a new <code>List</code> of <code>ObligationExpression</code>s parsed from the given <code>Node</code>
++ * @return a new <code>List</code> of <code>ObligationExpression</code>s parsed from the given
++ * <code>Node</code>
+ * @throws DOMStructureException if there is an error parsing the <code>Node</code>
+ */
- public static List<ObligationExpression> newList(Node nodeObligationExpressions, Policy policy) throws DOMStructureException {
- Element elementObligationExpressions = DOMUtil.getElement(nodeObligationExpressions);
- boolean bLenient = DOMProperties.isLenient();
++ public static List<ObligationExpression> newList(Node nodeObligationExpressions, Policy policy)
++ throws DOMStructureException {
++ Element elementObligationExpressions = DOMUtil.getElement(nodeObligationExpressions);
++ boolean bLenient = DOMProperties.isLenient();
+
- List<ObligationExpression> listObligationExpressions = new ArrayList<ObligationExpression>();
++ List<ObligationExpression> listObligationExpressions = new ArrayList<ObligationExpression>();
+
- NodeList children = elementObligationExpressions.getChildNodes();
++ NodeList children = elementObligationExpressions.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_OBLIGATIONEXPRESSION.equals(child.getLocalName())) {
++ if (DOMUtil.isInNamespace(child, XACML3.XMLNS)
++ && XACML3.ELEMENT_OBLIGATIONEXPRESSION.equals(child.getLocalName())) {
+ listObligationExpressions.add(DOMObligationExpression.newInstance(child, policy));
+ } else if (!bLenient) {
+ throw DOMUtil.newUnexpectedElementException(child, elementObligationExpressions);
+ }
+ }
+ }
+ }
+
+ if (listObligationExpressions.size() == 0 && !bLenient) {
- throw DOMUtil.newMissingElementException(elementObligationExpressions, XACML3.XMLNS, XACML3.ELEMENT_OBLIGATIONEXPRESSION);
++ throw DOMUtil.newMissingElementException(elementObligationExpressions, XACML3.XMLNS,
++ XACML3.ELEMENT_OBLIGATIONEXPRESSION);
+ }
+
+ return listObligationExpressions;
+ }
+
+ public static boolean repairList(Node nodeObligationExpressions) throws DOMStructureException {
- Element elementObligationExpressions = DOMUtil.getElement(nodeObligationExpressions);
- boolean result = false;
++ Element elementObligationExpressions = DOMUtil.getElement(nodeObligationExpressions);
++ boolean result = false;
+
- boolean sawObligationExpression = false;
- NodeList children = elementObligationExpressions.getChildNodes();
++ boolean sawObligationExpression = false;
++ NodeList children = elementObligationExpressions.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_OBLIGATIONEXPRESSION.equals(child.getLocalName())) {
- result = DOMObligationExpression.repair(child) || result;
- sawObligationExpression = true;
++ if (DOMUtil.isInNamespace(child, XACML3.XMLNS)
++ && XACML3.ELEMENT_OBLIGATIONEXPRESSION.equals(child.getLocalName())) {
++ result = DOMObligationExpression.repair(child) || result;
++ sawObligationExpression = true;
+ } else {
+ logger.warn("Unexpected element " + child.getNodeName());
+ elementObligationExpressions.removeChild(child);
- result = true;
++ result = true;
+ }
+ }
+ }
+ }
+ if (!sawObligationExpression) {
- throw DOMUtil.newMissingElementException(elementObligationExpressions, XACML3.XMLNS, XACML3.ELEMENT_OBLIGATIONEXPRESSION);
++ throw DOMUtil.newMissingElementException(elementObligationExpressions, XACML3.XMLNS,
++ XACML3.ELEMENT_OBLIGATIONEXPRESSION);
+ }
+
+ return result;
+ }
+
+}