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:54 UTC
[32/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/std/StdPolicyFinder.java
----------------------------------------------------------------------
diff --cc openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/StdPolicyFinder.java
index fd6765b,0000000..f0084a1
mode 100644,000000..100644
--- a/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/StdPolicyFinder.java
+++ b/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/StdPolicyFinder.java
@@@ -1,390 -1,0 +1,421 @@@
+/*
+ * 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.std;
+
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.openaz.xacml.api.IdReferenceMatch;
+import org.apache.openaz.xacml.api.Identifier;
+import org.apache.openaz.xacml.api.Version;
+import org.apache.openaz.xacml.pdp.eval.EvaluationContext;
+import org.apache.openaz.xacml.pdp.eval.EvaluationException;
+import org.apache.openaz.xacml.pdp.eval.MatchResult;
+import org.apache.openaz.xacml.pdp.policy.Policy;
+import org.apache.openaz.xacml.pdp.policy.PolicyDef;
+import org.apache.openaz.xacml.pdp.policy.PolicyFinder;
+import org.apache.openaz.xacml.pdp.policy.PolicyFinderResult;
+import org.apache.openaz.xacml.pdp.policy.PolicySet;
+import org.apache.openaz.xacml.pdp.policy.PolicySetChild;
+import org.apache.openaz.xacml.pdp.policy.dom.DOMPolicyDef;
+import org.apache.openaz.xacml.std.StdStatus;
+import org.apache.openaz.xacml.std.StdStatusCode;
+
+/**
- * StdPolicyFinder implements the {@link org.apache.openaz.xacml.pdp.policy.PolicyFinder} interface to look up policies
- * by their internal ID or an externally visible ID.
- *
++ * StdPolicyFinder implements the {@link com.att.research.xacmlatt.pdp.policy.PolicyFinder} interface to look
++ * up policies by their internal ID or an externally visible ID.
+ */
+public class StdPolicyFinder implements PolicyFinder {
- private static final PolicyFinderResult<PolicyDef> PFR_MULTIPLE = new StdPolicyFinderResult<PolicyDef>(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, "Multiple applicable root policies"));
- private static final PolicyFinderResult<PolicyDef> PFR_NOT_FOUND = new StdPolicyFinderResult<PolicyDef>(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, "No matching root policy found"));
++ private static final PolicyFinderResult<PolicyDef> PFR_MULTIPLE = new StdPolicyFinderResult<PolicyDef>(
++ new StdStatus(
++ StdStatusCode.STATUS_CODE_PROCESSING_ERROR,
++ "Multiple applicable root policies"));
++ private static final PolicyFinderResult<PolicyDef> PFR_NOT_FOUND = new StdPolicyFinderResult<PolicyDef>(
++ new StdStatus(
++ StdStatusCode.STATUS_CODE_PROCESSING_ERROR,
++ "No matching root policy found"));
+
- private static final PolicyFinderResult<Policy> PFR_POLICY_NOT_FOUND = new StdPolicyFinderResult<Policy>(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, "No matching policy found"));
- private static final PolicyFinderResult<Policy> PFR_NOT_A_POLICY = new StdPolicyFinderResult<Policy>(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, "Not a policy"));
- private static final PolicyFinderResult<PolicySet> PFR_POLICYSET_NOT_FOUND = new StdPolicyFinderResult<PolicySet>(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, "No matching policy set found"));
- private static final PolicyFinderResult<PolicySet> PFR_NOT_A_POLICYSET = new StdPolicyFinderResult<PolicySet>(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, "Not a policy set"));
++ private static final PolicyFinderResult<Policy> PFR_POLICY_NOT_FOUND = new StdPolicyFinderResult<Policy>(
++ new StdStatus(
++ StdStatusCode.STATUS_CODE_PROCESSING_ERROR,
++ "No matching policy found"));
++ private static final PolicyFinderResult<Policy> PFR_NOT_A_POLICY = new StdPolicyFinderResult<Policy>(
++ new StdStatus(
++ StdStatusCode.STATUS_CODE_PROCESSING_ERROR,
++ "Not a policy"));
++ private static final PolicyFinderResult<PolicySet> PFR_POLICYSET_NOT_FOUND = new StdPolicyFinderResult<PolicySet>(
++ new StdStatus(
++ StdStatusCode.STATUS_CODE_PROCESSING_ERROR,
++ "No matching policy set found"));
++ private static final PolicyFinderResult<PolicySet> PFR_NOT_A_POLICYSET = new StdPolicyFinderResult<PolicySet>(
++ new StdStatus(
++ StdStatusCode.STATUS_CODE_PROCESSING_ERROR,
++ "Not a policy set"));
+
- private Log logger = LogFactory.getLog(this.getClass());
- private List<PolicyDef> listRoots = new ArrayList<PolicyDef>();
- private Map<Identifier,List<PolicyDef>> mapPolicies = new HashMap<Identifier,List<PolicyDef>>();
++ private Log logger = LogFactory.getLog(this.getClass());
++ private List<PolicyDef> listRoots = new ArrayList<PolicyDef>();
++ private Map<Identifier, List<PolicyDef>> mapPolicies = new HashMap<Identifier, List<PolicyDef>>();
+
+ public static class StdPolicyFinderException extends Exception {
+ private static final long serialVersionUID = -8969282995787463288L;
++
+ public StdPolicyFinderException(String msg) {
+ super(msg);
+ }
++
+ public StdPolicyFinderException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+ }
+
+ private void storeInPolicyMap(PolicyDef policyDef) {
- List<PolicyDef> listPolicyDefs = this.mapPolicies.get(policyDef.getIdentifier());
++ List<PolicyDef> listPolicyDefs = this.mapPolicies.get(policyDef.getIdentifier());
+ if (listPolicyDefs == null) {
- listPolicyDefs = new ArrayList<PolicyDef>();
++ listPolicyDefs = new ArrayList<PolicyDef>();
+ this.mapPolicies.put(policyDef.getIdentifier(), listPolicyDefs);
+ }
+ listPolicyDefs.add(policyDef);
+ }
+
- private <T extends PolicyDef> List<T> getFromPolicyMap(IdReferenceMatch idReferenceMatch, Class<T> classPolicyDef) {
++ private <T extends PolicyDef> List<T> getFromPolicyMap(IdReferenceMatch idReferenceMatch,
++ Class<T> classPolicyDef) {
+ /*
+ * Get all of the PolicyDefs for the Identifier in the reference match
+ */
- List<PolicyDef> listPolicyDefForId = this.mapPolicies.get(idReferenceMatch.getId());
++ List<PolicyDef> listPolicyDefForId = this.mapPolicies.get(idReferenceMatch.getId());
+ if (listPolicyDefForId == null) {
+ return null;
+ }
+
+ /*
- * Iterate over all of the PolicyDefs that were found and select only the ones that match
- * the version request and the isPolicySet
++ * Iterate over all of the PolicyDefs that were found and select only the ones that match the version
++ * request and the isPolicySet
+ */
- List<T> listPolicyDefMatches = null;
- Iterator<PolicyDef> iterPolicyDefs = listPolicyDefForId.iterator();
++ List<T> listPolicyDefMatches = null;
++ Iterator<PolicyDef> iterPolicyDefs = listPolicyDefForId.iterator();
+ while (iterPolicyDefs.hasNext()) {
- PolicyDef policyDef = iterPolicyDefs.next();
++ PolicyDef policyDef = iterPolicyDefs.next();
+ if (classPolicyDef.isInstance(policyDef) && policyDef.matches(idReferenceMatch)) {
+ if (listPolicyDefMatches == null) {
- listPolicyDefMatches = new ArrayList<T>();
++ listPolicyDefMatches = new ArrayList<T>();
+ }
+ listPolicyDefMatches.add(classPolicyDef.cast(policyDef));
+ }
+ }
+
+ return listPolicyDefMatches;
+ }
+
+ private <T extends PolicyDef> T getBestMatchN(List<T> matches) {
- T bestMatch = null;
- Version bestVersion = null;
- Iterator<T> iterMatches = matches.iterator();
++ T bestMatch = null;
++ Version bestVersion = null;
++ Iterator<T> iterMatches = matches.iterator();
+
+ while (iterMatches.hasNext()) {
- T match = iterMatches.next();
++ T match = iterMatches.next();
+ if (bestMatch == null) {
- bestMatch = match;
- bestVersion = match.getVersion();
++ bestMatch = match;
++ bestVersion = match.getVersion();
+ } else {
- Version matchVersion = match.getVersion();
- if (matchVersion != null) {
- if (matchVersion.compareTo(bestVersion) > 0) {
- bestMatch = match;
- bestVersion = matchVersion;
- }
++ Version matchVersion = match.getVersion();
++ if (matchVersion != null && matchVersion.compareTo(bestVersion) > 0) {
++ bestMatch = match;
++ bestVersion = matchVersion;
+ }
+ }
+ }
+ return bestMatch;
+ }
+
+ private <T extends PolicyDef> T getBestMatch(List<T> matches) {
- switch(matches.size()) {
++ switch (matches.size()) {
+ case 0:
+ return null;
+ case 1:
+ return matches.get(0);
+ default:
+ return this.getBestMatchN(matches);
+ }
+ }
+
+ private PolicyDef loadPolicyDefFromURI(URI uri) throws StdPolicyFinderException {
- PolicyDef policyDef = null;
- InputStream inputStream = null;
++ PolicyDef policyDef = null;
++ InputStream inputStream = null;
+ try {
+ this.logger.info("Loading policy from URI " + uri.toString());
- URL url = uri.toURL();
++ URL url = uri.toURL();
+ this.logger.debug("Loading policy from URL " + url.toString());
+
- inputStream = url.openStream();
- policyDef = DOMPolicyDef.load(inputStream);
++ inputStream = url.openStream();
++ policyDef = DOMPolicyDef.load(inputStream);
+ } catch (MalformedURLException ex) {
+ this.logger.debug("Unknown protocol for URI " + uri.toString());
+ return null;
+ } catch (Exception ex) {
+ this.logger.error("Exception loading policy definition", ex);
- throw new StdPolicyFinderException("Exception loading policy def from \"" + uri.toString() + "\": " + ex.getMessage(), ex);
++ throw new StdPolicyFinderException("Exception loading policy def from \"" + uri.toString()
++ + "\": " + ex.getMessage(), ex);
+ } finally {
+ if (inputStream != null) {
+ try {
+ inputStream.close();
- } catch (Exception ex) {
-
++ } catch (Exception ex) { //NOPMD
++ // TODO
+ }
+ }
+ }
+ return policyDef;
+ }
+
+ /**
- * Looks up the given {@link org.apache.openaz.xacml.api.Identifier} in the map first. If not found, and the <code>Identifier</code> contains
- * a URL, then attempts to retrieve the document from the URL and caches it.
++ * Looks up the given {@link com.att.research.xacml.api.Identifier} in the map first. If not found, and
++ * the <code>Identifier</code> contains a URL, then attempts to retrieve the document from the URL and
++ * caches it.
+ *
+ * @param idReferenceMatch the <code>IdReferenceMatch</code> to look up
+ * @return a <code>PolicyFinderResult</code> with the requested <code>Policy</code> or an error status
+ */
+ private PolicyFinderResult<Policy> lookupPolicyByIdentifier(IdReferenceMatch idReferenceMatch) {
- List<Policy> listCachedPolicies = this.getFromPolicyMap(idReferenceMatch, Policy.class);
++ List<Policy> listCachedPolicies = this.getFromPolicyMap(idReferenceMatch, Policy.class);
+ if (listCachedPolicies == null) {
- Identifier id = idReferenceMatch.getId();
++ Identifier id = idReferenceMatch.getId();
+ if (id != null) {
- URI uri = id.getUri();
++ URI uri = id.getUri();
+ if (uri != null && uri.isAbsolute()) {
- PolicyDef policyDef = null;
++ PolicyDef policyDef = null;
+ try {
- policyDef = this.loadPolicyDefFromURI(uri);
++ policyDef = this.loadPolicyDefFromURI(uri);
+ } catch (StdPolicyFinderException ex) {
- return new StdPolicyFinderResult<Policy>(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, ex.getMessage()));
++ return new StdPolicyFinderResult<Policy>(
++ new StdStatus(
++ StdStatusCode.STATUS_CODE_PROCESSING_ERROR,
++ ex.getMessage()));
+ }
+ if (policyDef != null) {
+ if (policyDef instanceof Policy) {
- List<PolicyDef> listPolicyDefs = new ArrayList<PolicyDef>();
++ List<PolicyDef> listPolicyDefs = new ArrayList<PolicyDef>();
+ listPolicyDefs.add(policyDef);
+ this.mapPolicies.put(id, listPolicyDefs);
+ this.mapPolicies.put(policyDef.getIdentifier(), listPolicyDefs);
+ return new StdPolicyFinderResult<Policy>((Policy)policyDef);
+ } else {
+ return PFR_NOT_A_POLICY;
+ }
+ } else {
+ return PFR_POLICY_NOT_FOUND;
+ }
+ }
+ }
+ }
+ if (listCachedPolicies != null) {
+ return new StdPolicyFinderResult<Policy>(this.getBestMatch(listCachedPolicies));
+ } else {
+ return PFR_POLICY_NOT_FOUND;
+ }
+ }
+
+ /**
- * Looks up the given {@link org.apache.openaz.xacml.api.Identifier} in the map first. If not found, and the <code>Identifier</code> contains
- * a URL, then attempts to retrieve the document from the URL and caches it.
++ * Looks up the given {@link com.att.research.xacml.api.Identifier} in the map first. If not found, and
++ * the <code>Identifier</code> contains a URL, then attempts to retrieve the document from the URL and
++ * caches it.
+ *
+ * @param idReferenceMatch the <code>IdReferenceMatch</code> to look up
+ * @return a <code>PolicyFinderResult</code> with the requested <code>PolicySet</code> or an error status
+ */
+ private PolicyFinderResult<PolicySet> lookupPolicySetByIdentifier(IdReferenceMatch idReferenceMatch) {
- List<PolicySet> listCachedPolicySets = this.getFromPolicyMap(idReferenceMatch, PolicySet.class);
++ List<PolicySet> listCachedPolicySets = this.getFromPolicyMap(idReferenceMatch, PolicySet.class);
+ if (listCachedPolicySets == null) {
- Identifier id = idReferenceMatch.getId();
++ Identifier id = idReferenceMatch.getId();
+ if (id != null) {
- URI uri = id.getUri();
++ URI uri = id.getUri();
+ if (uri != null && uri.isAbsolute()) {
- PolicyDef policyDef = null;
++ PolicyDef policyDef = null;
+ try {
- policyDef = this.loadPolicyDefFromURI(uri);
++ policyDef = this.loadPolicyDefFromURI(uri);
+ } catch (StdPolicyFinderException ex) {
- return new StdPolicyFinderResult<PolicySet>(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, ex.getMessage()));
++ return new StdPolicyFinderResult<PolicySet>(
++ new StdStatus(
++ StdStatusCode.STATUS_CODE_PROCESSING_ERROR,
++ ex.getMessage()));
+ }
+ if (policyDef != null) {
+ if (policyDef instanceof PolicySet) {
- List<PolicyDef> listPolicyDefs = new ArrayList<PolicyDef>();
++ List<PolicyDef> listPolicyDefs = new ArrayList<PolicyDef>();
+ listPolicyDefs.add(policyDef);
+ this.mapPolicies.put(id, listPolicyDefs);
+ this.mapPolicies.put(policyDef.getIdentifier(), listPolicyDefs);
+ return new StdPolicyFinderResult<PolicySet>((PolicySet)policyDef);
+ } else {
+ return PFR_NOT_A_POLICYSET;
+ }
+ } else {
+ return PFR_POLICYSET_NOT_FOUND;
+ }
+ }
+ }
+ }
+ if (listCachedPolicySets != null) {
+ return new StdPolicyFinderResult<PolicySet>(this.getBestMatch(listCachedPolicySets));
+ } else {
+ return PFR_POLICYSET_NOT_FOUND;
+ }
+ }
+
+ /**
- * Adds the given <code>PolicyDef</code> to the map of loaded <code>PolicyDef</code>s and adds
- * its child <code>PolicyDef</code>s recursively.
++ * Adds the given <code>PolicyDef</code> to the map of loaded <code>PolicyDef</code>s and adds its child
++ * <code>PolicyDef</code>s recursively.
+ *
+ * @param policyDef the <code>PolicyDef</code> to add
+ */
+ private void updatePolicyMap(PolicyDef policyDef) {
+ this.storeInPolicyMap(policyDef);
+ if (policyDef instanceof PolicySet) {
- Iterator<PolicySetChild> iterChildren = ((PolicySet)policyDef).getChildren();
++ Iterator<PolicySetChild> iterChildren = ((PolicySet)policyDef).getChildren();
+ if (iterChildren != null) {
+ while (iterChildren.hasNext()) {
- PolicySetChild policySetChild = iterChildren.next();
++ PolicySetChild policySetChild = iterChildren.next();
+ if (policySetChild instanceof PolicyDef) {
+ this.updatePolicyMap((PolicyDef)policySetChild);
+ }
+ }
+ }
+ }
+ }
+
+ public StdPolicyFinder(Collection<PolicyDef> listRootPolicies, Collection<PolicyDef> referencedPolicyDefs) {
+ if (listRootPolicies != null) {
- for (PolicyDef policyDef: listRootPolicies) {
++ for (PolicyDef policyDef : listRootPolicies) {
+ this.listRoots.add(policyDef);
+ this.updatePolicyMap(policyDef);
+ }
+ }
+ if (referencedPolicyDefs != null) {
- for (PolicyDef policyDef: referencedPolicyDefs) {
++ for (PolicyDef policyDef : referencedPolicyDefs) {
+ this.storeInPolicyMap(policyDef);
+ }
+ }
+ }
+
+ /**
+ * Creates a new <code>StdPolicyFinder</code> with the given <code>PolicyDef</code> as the root element.
+ *
+ * @param rootPolicyDef the <code>PolicyDef</code> acting as the root element
+ */
+ public StdPolicyFinder(PolicyDef rootPolicyDef, Collection<PolicyDef> referencedPolicyDefs) {
+ if (rootPolicyDef != null) {
+ this.listRoots.add(rootPolicyDef);
+ this.updatePolicyMap(rootPolicyDef);
+ }
+
+ if (referencedPolicyDefs != null) {
- for (PolicyDef policyDef: referencedPolicyDefs) {
++ for (PolicyDef policyDef : referencedPolicyDefs) {
+ this.storeInPolicyMap(policyDef);
+ }
+ }
+ }
+
- public StdPolicyFinder(List<PolicyDef> rootPolicies, List<PolicyDef> referencedPolicies, Properties properties) {
++ public StdPolicyFinder(List<PolicyDef> rootPolicies, List<PolicyDef> referencedPolicies,
++ Properties properties) {
+ this(rootPolicies, referencedPolicies);
+ }
+
+ @Override
+ public PolicyFinderResult<PolicyDef> getRootPolicyDef(EvaluationContext evaluationContext) {
- PolicyDef policyDefFirstMatch = null;
- Iterator<PolicyDef> iterRootPolicies = this.listRoots.iterator();
- PolicyFinderResult<PolicyDef> firstIndeterminate = null;
++ PolicyDef policyDefFirstMatch = null;
++ Iterator<PolicyDef> iterRootPolicies = this.listRoots.iterator();
++ PolicyFinderResult<PolicyDef> firstIndeterminate = null;
+ while (iterRootPolicies.hasNext()) {
- PolicyDef policyDef = iterRootPolicies.next();
- MatchResult matchResult = null;
++ PolicyDef policyDef = iterRootPolicies.next();
++ MatchResult matchResult = null;
+ try {
- matchResult = policyDef.match(evaluationContext);
- switch(matchResult.getMatchCode()) {
++ matchResult = policyDef.match(evaluationContext);
++ switch (matchResult.getMatchCode()) {
+ case INDETERMINATE:
+ if (firstIndeterminate == null) {
- firstIndeterminate = new StdPolicyFinderResult<PolicyDef>(matchResult.getStatus());
++ firstIndeterminate = new StdPolicyFinderResult<PolicyDef>(matchResult.getStatus());
+ }
+ break;
+ case MATCH:
+ if (policyDefFirstMatch == null) {
- policyDefFirstMatch = policyDef;
++ policyDefFirstMatch = policyDef;
+ } else {
+ return PFR_MULTIPLE;
+ }
+ break;
+ case NOMATCH:
+ break;
+ }
+ } catch (EvaluationException ex) {
+ if (firstIndeterminate == null) {
- firstIndeterminate = new StdPolicyFinderResult<PolicyDef>(new StdStatus(StdStatusCode.STATUS_CODE_PROCESSING_ERROR, ex.getMessage()));
++ firstIndeterminate = new StdPolicyFinderResult<PolicyDef>(
++ new StdStatus(
++ StdStatusCode.STATUS_CODE_PROCESSING_ERROR,
++ ex.getMessage()));
+ }
+ }
+ }
+
+ if (policyDefFirstMatch == null) {
+ if (firstIndeterminate != null) {
+ return firstIndeterminate;
+ } else {
+ return PFR_NOT_FOUND;
+ }
+ } else {
+ return new StdPolicyFinderResult<PolicyDef>(policyDefFirstMatch);
+ }
+ }
+
+ @Override
+ public PolicyFinderResult<Policy> getPolicy(IdReferenceMatch idReferenceMatch) {
+ return this.lookupPolicyByIdentifier(idReferenceMatch);
+ }
+
+ @Override
+ public PolicyFinderResult<PolicySet> getPolicySet(IdReferenceMatch idReferenceMatch) {
+ return this.lookupPolicySetByIdentifier(idReferenceMatch);
+ }
+
+ public void addReferencedPolicy(PolicyDef policyDef) {
+ this.updatePolicyMap(policyDef);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/StdPolicyFinderFactory.java
----------------------------------------------------------------------
diff --cc openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/StdPolicyFinderFactory.java
index e651ed7,0000000..092e952
mode 100644,000000..100644
--- a/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/StdPolicyFinderFactory.java
+++ b/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/StdPolicyFinderFactory.java
@@@ -1,242 -1,0 +1,246 @@@
+/*
+ * 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.std;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.UUID;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.openaz.xacml.pdp.policy.CombiningAlgorithm;
+import org.apache.openaz.xacml.pdp.policy.CombiningAlgorithmFactory;
+import org.apache.openaz.xacml.pdp.policy.Policy;
+import org.apache.openaz.xacml.pdp.policy.PolicyDef;
+import org.apache.openaz.xacml.pdp.policy.PolicyFinder;
+import org.apache.openaz.xacml.pdp.policy.PolicyFinderFactory;
+import org.apache.openaz.xacml.pdp.policy.PolicySet;
+import org.apache.openaz.xacml.pdp.policy.PolicySetChild;
+import org.apache.openaz.xacml.pdp.policy.Target;
+import org.apache.openaz.xacml.pdp.policy.dom.DOMPolicyDef;
+import org.apache.openaz.xacml.pdp.util.OpenAZPDPProperties;
+import org.apache.openaz.xacml.std.IdentifierImpl;
+import org.apache.openaz.xacml.std.StdStatusCode;
+import org.apache.openaz.xacml.std.StdVersion;
+import org.apache.openaz.xacml.std.dom.DOMStructureException;
+import org.apache.openaz.xacml.util.FactoryException;
+import org.apache.openaz.xacml.util.XACMLProperties;
+
+import com.google.common.base.Splitter;
+
+/**
- * StdPolicyFinderFactory extends {@link org.apache.openaz.xacml.pdp.policy.PolicyFinderFactory} with the
- * <code>getPolicyFinder</code> method to get a single instance of the {@link StdPolicyFinder}. The
- * root {@link org.apache.openaz.xacml.pdp.policy.PolicyDef} is loaded from a file whose name is specified as a system property or
- * in the $java.home/lib/xacml.properties property set.
- *
++ * StdPolicyFinderFactory extends {@link com.att.research.xacmlatt.pdp.policy.PolicyFinderFactory} with the
++ * <code>getPolicyFinder</code> method to get a single instance of the {@link StdPolicyFinder}. The root
++ * {@link com.att.research.xacmlatt.pdp.policy.PolicyDef} is loaded from a file whose name is specified as a
++ * system property or in the $java.home/lib/xacml.properties property set.
+ */
+public class StdPolicyFinderFactory extends PolicyFinderFactory {
- public static final String PROP_FILE = ".file";
- public static final String PROP_URL = ".url";
++ public static final String PROP_FILE = ".file";
++ public static final String PROP_URL = ".url";
+
- private Log logger = LogFactory.getLog(this.getClass());
++ private Log logger = LogFactory.getLog(this.getClass());
+ private List<PolicyDef> rootPolicies;
+ private List<PolicyDef> referencedPolicies;
- private boolean needsInit = true;
++ private boolean needsInit = true;
+
+ /**
- * Loads the <code>PolicyDef</code> for the given <code>String</code> identifier by looking first
- * for a ".file" property associated with the ID and using that to load from a <code>File</code> and
- * looking for a ".url" property associated with the ID and using that to load from a <code>URL</code>.
++ * Loads the <code>PolicyDef</code> for the given <code>String</code> identifier by looking first for a
++ * ".file" property associated with the ID and using that to load from a <code>File</code> and looking for
++ * a ".url" property associated with the ID and using that to load from a <code>URL</code>.
+ *
+ * @param policyId the <code>String</code> identifier for the policy
+ * @return a <code>PolicyDef</code> loaded from the given identifier
+ */
+ protected PolicyDef loadPolicyDef(String policyId, Properties properties) {
- String propLocation = properties.getProperty(policyId + PROP_FILE);
++ String propLocation = properties.getProperty(policyId + PROP_FILE);
+ if (propLocation != null) {
- File fileLocation = new File(propLocation);
++ File fileLocation = new File(propLocation);
+ if (!fileLocation.exists()) {
+ this.logger.error("Policy file " + fileLocation.getAbsolutePath() + " does not exist.");
+ } else if (!fileLocation.canRead()) {
+ this.logger.error("Policy file " + fileLocation.getAbsolutePath() + " cannot be read.");
+ } else {
+ try {
+ this.logger.info("Loading policy file " + fileLocation);
- PolicyDef policyDef = DOMPolicyDef.load(fileLocation);
++ PolicyDef policyDef = DOMPolicyDef.load(fileLocation);
+ if (policyDef != null) {
+ return policyDef;
+ }
+ } catch (DOMStructureException ex) {
- this.logger.error("Error loading policy file " + fileLocation.getAbsolutePath() + ": " + ex.getMessage(), ex);
++ this.logger.error("Error loading policy file " + fileLocation.getAbsolutePath() + ": "
++ + ex.getMessage(), ex);
+ return new Policy(StdStatusCode.STATUS_CODE_SYNTAX_ERROR, ex.getMessage());
+ }
+ }
+ }
+
+ if ((propLocation = properties.getProperty(policyId + PROP_URL)) != null) {
+ InputStream is = null;
+ try {
- URL url = new URL(propLocation);
- URLConnection urlConnection = url.openConnection();
++ URL url = new URL(propLocation);
++ URLConnection urlConnection = url.openConnection();
+ this.logger.info("Loading policy file " + url.toString());
+ is = urlConnection.getInputStream();
- PolicyDef policyDef = DOMPolicyDef.load(is);
++ PolicyDef policyDef = DOMPolicyDef.load(is);
+ if (policyDef != null) {
+ return policyDef;
+ }
+ } catch (MalformedURLException ex) {
+ this.logger.error("Invalid URL " + propLocation + ": " + ex.getMessage(), ex);
+ } catch (IOException ex) {
+ this.logger.error("IOException opening URL " + propLocation + ": " + ex.getMessage(), ex);
+ } catch (DOMStructureException ex) {
+ this.logger.error("Invalid Policy " + propLocation + ": " + ex.getMessage(), ex);
+ return new Policy(StdStatusCode.STATUS_CODE_SYNTAX_ERROR, ex.getMessage());
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {
- this.logger.error("Exception closing InputStream for GET of url " + propLocation + " : " + e.getMessage() + " (May be memory leak)", e);
++ this.logger.error("Exception closing InputStream for GET of url " + propLocation
++ + " : " + e.getMessage() + " (May be memory leak)", e);
+ }
+ }
+ }
+ }
+
+ this.logger.error("No known location for Policy " + policyId);
+ return null;
+ }
+
+ /**
+ * Finds the identifiers for all of the policies referenced by the given property name in the
+ * <code>XACMLProperties</code> and loads them using the requested loading method.
+ *
- * @param propertyName the <code>String</code> name of the property containing the list of policy identifiers
++ * @param propertyName the <code>String</code> name of the property containing the list of policy
++ * identifiers
+ * @return a <code>List</code> of <code>PolicyDef</code>s loaded from the given property name
+ */
+ protected List<PolicyDef> getPolicyDefs(String propertyName, Properties properties) {
- String policyIds = properties.getProperty(propertyName);
++ String policyIds = properties.getProperty(propertyName);
+ if (policyIds == null || policyIds.length() == 0) {
+ return null;
+ }
+
- Iterable<String> policyIdArray = Splitter.on(',').trimResults().omitEmptyStrings().split(policyIds);
++ Iterable<String> policyIdArray = Splitter.on(',').trimResults().omitEmptyStrings().split(policyIds);
+ if (policyIdArray == null) {
+ return null;
+ }
+
- List<PolicyDef> listPolicyDefs = new ArrayList<PolicyDef>();
++ List<PolicyDef> listPolicyDefs = new ArrayList<PolicyDef>();
+ for (String policyId : policyIdArray) {
- PolicyDef policyDef = this.loadPolicyDef(policyId, properties);
++ PolicyDef policyDef = this.loadPolicyDef(policyId, properties);
+ if (policyDef != null) {
+ listPolicyDefs.add(policyDef);
+ }
+ }
+ return listPolicyDefs;
+ }
+
+ protected synchronized void init(Properties properties) {
+ if (this.needsInit) {
+ //
+ // Check for property that combines root policies into one policyset
+ //
- String combiningAlgorithm = properties.getProperty(OpenAZPDPProperties.PROP_POLICYFINDERFACTORY_COMBINEROOTPOLICIES);
++ String combiningAlgorithm = properties
++ .getProperty(OpenAZPDPProperties.PROP_POLICYFINDERFACTORY_COMBINEROOTPOLICIES);
+ if (combiningAlgorithm != null) {
+ try {
+ logger.info("Combining root policies with " + combiningAlgorithm);
+ //
+ // Find the combining algorithm
+ //
- CombiningAlgorithm<PolicySetChild> algorithm = CombiningAlgorithmFactory.newInstance().getPolicyCombiningAlgorithm(new IdentifierImpl(combiningAlgorithm));
++ CombiningAlgorithm<PolicySetChild> algorithm = CombiningAlgorithmFactory.newInstance()
++ .getPolicyCombiningAlgorithm(new IdentifierImpl(combiningAlgorithm));
+ //
+ // Create our root policy
+ //
+ PolicySet root = new PolicySet();
+ root.setIdentifier(new IdentifierImpl(UUID.randomUUID().toString()));
+ root.setVersion(StdVersion.newInstance("1.0"));
+ root.setTarget(new Target());
+ //
+ // Set the algorithm
+ //
+ root.setPolicyCombiningAlgorithm(algorithm);
+ //
+ // Load all our root policies
+ //
+ for (PolicyDef policy : this.getPolicyDefs(XACMLProperties.PROP_ROOTPOLICIES, properties)) {
+ root.addChild(policy);
+ }
+ //
+ // Set this policy as the root
+ //
+ this.rootPolicies = new ArrayList<>();
+ this.rootPolicies.add(root);
+ } catch (FactoryException | ParseException e) {
+ logger.error("Failed to load Combining Algorithm Factory: " + e.getLocalizedMessage());
+ }
+ } else {
- this.rootPolicies = this.getPolicyDefs(XACMLProperties.PROP_ROOTPOLICIES, properties);
++ this.rootPolicies = this.getPolicyDefs(XACMLProperties.PROP_ROOTPOLICIES, properties);
+ }
+
- this.referencedPolicies = this.getPolicyDefs(XACMLProperties.PROP_REFERENCEDPOLICIES, properties);
- this.needsInit = false;
++ this.referencedPolicies = this.getPolicyDefs(XACMLProperties.PROP_REFERENCEDPOLICIES, properties);
++ this.needsInit = false;
+ }
+ }
+
+ public StdPolicyFinderFactory() {
+ }
+
+ public StdPolicyFinderFactory(Properties properties) {
+ }
+
+ @Override
+ public PolicyFinder getPolicyFinder() throws FactoryException {
+ try {
+ this.init(XACMLProperties.getProperties());
+ } catch (IOException e) {
+ throw new FactoryException(e);
+ }
+ return new StdPolicyFinder(this.rootPolicies, this.referencedPolicies);
+ }
+
+ @Override
+ public PolicyFinder getPolicyFinder(Properties properties) throws FactoryException {
+ this.init(properties);
+ return new StdPolicyFinder(this.rootPolicies, this.referencedPolicies, properties);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/StdPolicyFinderResult.java
----------------------------------------------------------------------
diff --cc openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/StdPolicyFinderResult.java
index a5cadae,0000000..0fb98e0
mode 100644,000000..100644
--- a/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/StdPolicyFinderResult.java
+++ b/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/StdPolicyFinderResult.java
@@@ -1,70 -1,0 +1,72 @@@
+/*
+ * 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.std;
+
+import org.apache.openaz.xacml.api.Status;
+import org.apache.openaz.xacml.pdp.policy.PolicyDef;
+import org.apache.openaz.xacml.pdp.policy.PolicyFinderResult;
+import org.apache.openaz.xacml.std.StdStatus;
+
+/**
- * StdPolicyFinderResult implements the {@link org.apache.openaz.xacml.pdp.policy.PolicyFinderResult} interface.
++ * StdPolicyFinderResult implements the {@link com.att.research.xacmlatt.pdp.policy.PolicyFinderResult}
++ * interface.
+ *
- * @param <T> the java class extending {@link org.apache.openaz.xacml.pdp.policy.PolicyDef} held by the <code>StdPolicyFinderResult</code>
++ * @param <T> the java class extending {@link com.att.research.xacmlatt.pdp.policy.PolicyDef} held by the
++ * <code>StdPolicyFinderResult</code>
+ */
+public class StdPolicyFinderResult<T extends PolicyDef> implements PolicyFinderResult<T> {
+ private Status status;
+ private T policyDef;
+
+ public StdPolicyFinderResult(Status statusIn, T policyDefIn) {
- this.status = (statusIn == null ? StdStatus.STATUS_OK : statusIn);
- this.policyDef = policyDefIn;
++ this.status = (statusIn == null ? StdStatus.STATUS_OK : statusIn);
++ this.policyDef = policyDefIn;
+ }
+
+ public StdPolicyFinderResult(Status statusIn) {
+ this(statusIn, null);
+ }
+
+ public StdPolicyFinderResult(T policyDefIn) {
+ this(null, policyDefIn);
+ }
+
+ @Override
+ public Status getStatus() {
+ return this.status;
+ }
+
+ @Override
+ public T getPolicyDef() {
+ return this.policyDef;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/combiners/CombinedPermitOverrides.java
----------------------------------------------------------------------
diff --cc openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/combiners/CombinedPermitOverrides.java
index 937b588,0000000..b3ea464
mode 100644,000000..100644
--- a/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/combiners/CombinedPermitOverrides.java
+++ b/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/combiners/CombinedPermitOverrides.java
@@@ -1,136 -1,0 +1,136 @@@
+/*
+ * 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) 2015 AT&T Knowledge Ventures
+ * Unpublished and Not for Publication
+ * All Rights Reserved
+ */
+package org.apache.openaz.xacml.pdp.std.combiners;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.openaz.xacml.api.Decision;
+import org.apache.openaz.xacml.api.Identifier;
+import org.apache.openaz.xacml.pdp.eval.EvaluationContext;
+import org.apache.openaz.xacml.pdp.eval.EvaluationException;
+import org.apache.openaz.xacml.pdp.eval.EvaluationResult;
+import org.apache.openaz.xacml.pdp.policy.CombinerParameter;
+import org.apache.openaz.xacml.pdp.policy.CombiningElement;
+
+/**
- *
- * This algorithm was created to support combining a collection of policies in which the permit's are combined into one decision. PermitOverrides
- * itself will stop once a Permit is found. However, some policy makers want every policy in a policy set to be visited by the PDP engine.
- * The result of all the Permits that were found are then combined and returned. If no Permits were found then the result is the same semantics as
- * the PermitOverrides combining algorithm.
++ * This algorithm was created to support combining a collection of policies in which the permit's are combined
++ * into one decision. PermitOverrides itself will stop once a Permit is found. However, some policy makers
++ * want every policy in a policy set to be visited by the PDP engine. The result of all the Permits that were
++ * found are then combined and returned. If no Permits were found then the result is the same semantics as the
++ * PermitOverrides combining algorithm.
+ *
+ * @param <T>
+ */
- public class CombinedPermitOverrides<T extends org.apache.openaz.xacml.pdp.eval.Evaluatable> extends CombiningAlgorithmBase<T> {
++public class CombinedPermitOverrides<T extends org.apache.openaz.xacml.pdp.eval.Evaluatable> extends
++ CombiningAlgorithmBase<T> {
+
+ public CombinedPermitOverrides(Identifier identifierIn) {
+ super(identifierIn);
+ }
+
+ @Override
- public EvaluationResult combine(EvaluationContext evaluationContext,
- List<CombiningElement<T>> elements,
- List<CombinerParameter> combinerParameters)
- throws EvaluationException {
- boolean atLeastOneDeny = false;
- boolean atLeastOnePermit = false;
++ public EvaluationResult combine(EvaluationContext evaluationContext, List<CombiningElement<T>> elements,
++ List<CombinerParameter> combinerParameters) throws EvaluationException {
++ boolean atLeastOneDeny = false;
++ boolean atLeastOnePermit = false;
+
- EvaluationResult combinedResultDeny = new EvaluationResult(Decision.DENY);
- EvaluationResult combinedResultPermit = new EvaluationResult(Decision.PERMIT);
++ EvaluationResult combinedResultDeny = new EvaluationResult(Decision.DENY);
++ EvaluationResult combinedResultPermit = new EvaluationResult(Decision.PERMIT);
+
- EvaluationResult firstIndeterminateD = null;
- EvaluationResult firstIndeterminateP = null;
- EvaluationResult firstIndeterminateDP = null;
++ EvaluationResult firstIndeterminateD = null;
++ EvaluationResult firstIndeterminateP = null;
++ EvaluationResult firstIndeterminateDP = null;
+
- Iterator<CombiningElement<T>> iterElements = elements.iterator();
++ Iterator<CombiningElement<T>> iterElements = elements.iterator();
+ while (iterElements.hasNext()) {
- CombiningElement<T> combiningElement = iterElements.next();
- EvaluationResult evaluationResultElement = combiningElement.evaluate(evaluationContext);
++ CombiningElement<T> combiningElement = iterElements.next();
++ EvaluationResult evaluationResultElement = combiningElement.evaluate(evaluationContext);
+
- assert(evaluationResultElement != null);
- switch(evaluationResultElement.getDecision()) {
++ assert evaluationResultElement != null;
++ switch (evaluationResultElement.getDecision()) {
+ case DENY:
- atLeastOneDeny = true;
++ atLeastOneDeny = true;
+ combinedResultDeny.merge(evaluationResultElement);
+ break;
+ case INDETERMINATE:
+ case INDETERMINATE_DENYPERMIT:
+ if (firstIndeterminateDP == null) {
- firstIndeterminateDP = evaluationResultElement;
++ firstIndeterminateDP = evaluationResultElement;
+ } else {
+ firstIndeterminateDP.merge(evaluationResultElement);
+ }
+ break;
+ case INDETERMINATE_DENY:
+ if (firstIndeterminateD == null) {
- firstIndeterminateD = evaluationResultElement;
++ firstIndeterminateD = evaluationResultElement;
+ } else {
+ firstIndeterminateD.merge(evaluationResultElement);
+ }
+ break;
+ case INDETERMINATE_PERMIT:
+ if (firstIndeterminateP == null) {
- firstIndeterminateP = evaluationResultElement;
++ firstIndeterminateP = evaluationResultElement;
+ } else {
+ firstIndeterminateP.merge(evaluationResultElement);
+ }
+ break;
+ case NOTAPPLICABLE:
+ break;
+ case PERMIT:
+ atLeastOnePermit = true;
+ combinedResultPermit.merge(evaluationResultElement);
+ break;
+ default:
- throw new EvaluationException("Illegal Decision: \"" + evaluationResultElement.getDecision().toString());
++ throw new EvaluationException("Illegal Decision: \""
++ + evaluationResultElement.getDecision().toString());
+ }
+ }
+
+ if (atLeastOnePermit) {
+ return combinedResultPermit;
+ }
+ if (firstIndeterminateDP != null) {
+ return firstIndeterminateDP;
+ } else if (firstIndeterminateP != null && (firstIndeterminateD != null || atLeastOneDeny)) {
+ return new EvaluationResult(Decision.INDETERMINATE_DENYPERMIT, firstIndeterminateD.getStatus());
+ } else if (firstIndeterminateP != null) {
+ return firstIndeterminateP;
+ } else if (atLeastOneDeny) {
+ return combinedResultDeny;
+ } else if (firstIndeterminateD != null) {
+ return firstIndeterminateD;
+ } else {
+ return new EvaluationResult(Decision.NOTAPPLICABLE);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/combiners/CombiningAlgorithmBase.java
----------------------------------------------------------------------
diff --cc openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/combiners/CombiningAlgorithmBase.java
index 148f5a4,0000000..d0c29c5
mode 100644,000000..100644
--- a/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/combiners/CombiningAlgorithmBase.java
+++ b/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/combiners/CombiningAlgorithmBase.java
@@@ -1,60 -1,0 +1,62 @@@
+/*
+ * 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.std.combiners;
+
+import org.apache.openaz.xacml.api.Identifier;
+import org.apache.openaz.xacml.pdp.policy.CombiningAlgorithm;
+
- public abstract class CombiningAlgorithmBase<T extends org.apache.openaz.xacml.pdp.eval.Evaluatable> implements CombiningAlgorithm<T> {
++public abstract class CombiningAlgorithmBase<T extends org.apache.openaz.xacml.pdp.eval.Evaluatable> implements
++ CombiningAlgorithm<T> {
++
+ private Identifier id;
+
+ public CombiningAlgorithmBase(Identifier identifierIn) {
- this.id = identifierIn;
++ this.id = identifierIn;
+ }
+
+ @Override
+ public Identifier getId() {
+ return this.id;
+ }
+
+ @Override
+ public String toString() {
- StringBuilder stringBuilder = new StringBuilder("{");
++ StringBuilder stringBuilder = new StringBuilder("{");
+
+ Object objectToDump;
+ if ((objectToDump = this.getId()) != null) {
+ stringBuilder.append("id=");
+ stringBuilder.append(objectToDump.toString());
+ }
+ stringBuilder.append('}');
+ return stringBuilder.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/combiners/DenyOverrides.java
----------------------------------------------------------------------
diff --cc openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/combiners/DenyOverrides.java
index b690de1,0000000..6782499
mode 100644,000000..100644
--- a/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/combiners/DenyOverrides.java
+++ b/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/combiners/DenyOverrides.java
@@@ -1,124 -1,0 +1,127 @@@
+/*
+ * 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.std.combiners;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.openaz.xacml.api.Decision;
+import org.apache.openaz.xacml.api.Identifier;
+import org.apache.openaz.xacml.pdp.eval.EvaluationContext;
+import org.apache.openaz.xacml.pdp.eval.EvaluationException;
+import org.apache.openaz.xacml.pdp.eval.EvaluationResult;
+import org.apache.openaz.xacml.pdp.policy.CombinerParameter;
+import org.apache.openaz.xacml.pdp.policy.CombiningElement;
+
+/**
+ * DenyOverrides implements the XACML 3.0 "deny-overrides" combining algorithm for both policies and rules.
+ *
+ *
+ * @param <T> the java class for the {@link org.apache.openaz.xacml.pdp.eval.Evaluatable}
+ * @param <U> the java class for the identifier
+ */
- public class DenyOverrides<T extends org.apache.openaz.xacml.pdp.eval.Evaluatable> extends CombiningAlgorithmBase<T> {
++public class DenyOverrides<T extends org.apache.openaz.xacml.pdp.eval.Evaluatable> extends
++ CombiningAlgorithmBase<T> {
+
+ public DenyOverrides(Identifier identifierIn) {
+ super(identifierIn);
+ }
+
+ @Override
- public EvaluationResult combine(EvaluationContext evaluationContext, List<CombiningElement<T>> elements, List<CombinerParameter> combinerParameters) throws EvaluationException {
- boolean atLeastOnePermit = false;
++ public EvaluationResult combine(EvaluationContext evaluationContext, List<CombiningElement<T>> elements,
++ List<CombinerParameter> combinerParameters) throws EvaluationException {
++ boolean atLeastOnePermit = false;
+
- EvaluationResult combinedResult = new EvaluationResult(Decision.PERMIT);
++ EvaluationResult combinedResult = new EvaluationResult(Decision.PERMIT);
+
- EvaluationResult firstIndeterminateD = null;
- EvaluationResult firstIndeterminateP = null;
- EvaluationResult firstIndeterminateDP = null;
++ EvaluationResult firstIndeterminateD = null;
++ EvaluationResult firstIndeterminateP = null;
++ EvaluationResult firstIndeterminateDP = null;
+
- Iterator<CombiningElement<T>> iterElements = elements.iterator();
++ Iterator<CombiningElement<T>> iterElements = elements.iterator();
+ while (iterElements.hasNext()) {
- CombiningElement<T> combiningElement = iterElements.next();
- EvaluationResult evaluationResultElement = combiningElement.evaluate(evaluationContext);
++ CombiningElement<T> combiningElement = iterElements.next();
++ EvaluationResult evaluationResultElement = combiningElement.evaluate(evaluationContext);
+
- assert(evaluationResultElement != null);
- switch(evaluationResultElement.getDecision()) {
++ assert evaluationResultElement != null;
++ switch (evaluationResultElement.getDecision()) {
+ case DENY:
+ return evaluationResultElement;
+ case INDETERMINATE:
+ case INDETERMINATE_DENYPERMIT:
+ if (firstIndeterminateDP == null) {
- firstIndeterminateDP = evaluationResultElement;
++ firstIndeterminateDP = evaluationResultElement;
+ } else {
+ firstIndeterminateDP.merge(evaluationResultElement);
+ }
+ break;
+ case INDETERMINATE_DENY:
+ if (firstIndeterminateD == null) {
- firstIndeterminateD = evaluationResultElement;
++ firstIndeterminateD = evaluationResultElement;
+ } else {
+ firstIndeterminateD.merge(evaluationResultElement);
+ }
+ break;
+ case INDETERMINATE_PERMIT:
+ if (firstIndeterminateP == null) {
- firstIndeterminateP = evaluationResultElement;
++ firstIndeterminateP = evaluationResultElement;
+ } else {
+ firstIndeterminateP.merge(evaluationResultElement);
+ }
+ break;
+ case NOTAPPLICABLE:
+ break;
+ case PERMIT:
- atLeastOnePermit = true;
++ atLeastOnePermit = true;
+ combinedResult.merge(evaluationResultElement);
+ break;
+ default:
- throw new EvaluationException("Illegal Decision: \"" + evaluationResultElement.getDecision().toString());
++ throw new EvaluationException("Illegal Decision: \""
++ + evaluationResultElement.getDecision().toString());
+ }
+ }
+
+ if (firstIndeterminateDP != null) {
+ return firstIndeterminateDP;
+ } else if (firstIndeterminateD != null && (firstIndeterminateP != null || atLeastOnePermit)) {
+ return new EvaluationResult(Decision.INDETERMINATE_DENYPERMIT, firstIndeterminateD.getStatus());
+ } else if (firstIndeterminateD != null) {
+ return firstIndeterminateD;
+ } else if (atLeastOnePermit) {
+ return combinedResult;
+ } else if (firstIndeterminateP != null) {
+ return firstIndeterminateP;
+ } else {
+ return new EvaluationResult(Decision.NOTAPPLICABLE);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/combiners/DenyUnlessPermit.java
----------------------------------------------------------------------
diff --cc openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/combiners/DenyUnlessPermit.java
index b826b18,0000000..58ac491
mode 100644,000000..100644
--- a/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/combiners/DenyUnlessPermit.java
+++ b/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/combiners/DenyUnlessPermit.java
@@@ -1,87 -1,0 +1,90 @@@
+/*
+ * 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.std.combiners;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.openaz.xacml.api.Decision;
+import org.apache.openaz.xacml.api.Identifier;
+import org.apache.openaz.xacml.pdp.eval.EvaluationContext;
+import org.apache.openaz.xacml.pdp.eval.EvaluationException;
+import org.apache.openaz.xacml.pdp.eval.EvaluationResult;
+import org.apache.openaz.xacml.pdp.policy.CombinerParameter;
+import org.apache.openaz.xacml.pdp.policy.CombiningElement;
+
+/**
- * DenyUnlessPermit implements the XACML 3.0 "deny-unless-permit" combining algorithm for both policies and rules.
- *
++ * DenyUnlessPermit implements the XACML 3.0 "deny-unless-permit" combining algorithm for both policies and
++ * rules.
+ *
+ * @param <T> the java class for the {@link org.apache.openaz.xacml.pdp.eval.Evaluatable}
+ * @param <U> the java class for the identifier
+ */
- public class DenyUnlessPermit<T extends org.apache.openaz.xacml.pdp.eval.Evaluatable> extends CombiningAlgorithmBase<T> {
++public class DenyUnlessPermit<T extends org.apache.openaz.xacml.pdp.eval.Evaluatable> extends
++ CombiningAlgorithmBase<T> {
+
+ public DenyUnlessPermit(Identifier identifierIn) {
+ super(identifierIn);
+ }
+
+ @Override
- public EvaluationResult combine(EvaluationContext evaluationContext, List<CombiningElement<T>> elements, List<CombinerParameter> combinerParameters) throws EvaluationException {
- EvaluationResult combinedResult = new EvaluationResult(Decision.DENY);
++ public EvaluationResult combine(EvaluationContext evaluationContext, List<CombiningElement<T>> elements,
++ List<CombinerParameter> combinerParameters) throws EvaluationException {
++ EvaluationResult combinedResult = new EvaluationResult(Decision.DENY);
+
- Iterator<CombiningElement<T>> iterElements = elements.iterator();
++ Iterator<CombiningElement<T>> iterElements = elements.iterator();
+ while (iterElements.hasNext()) {
- CombiningElement<T> combiningElement = iterElements.next();
- EvaluationResult evaluationResultElement = combiningElement.evaluate(evaluationContext);
++ CombiningElement<T> combiningElement = iterElements.next();
++ EvaluationResult evaluationResultElement = combiningElement.evaluate(evaluationContext);
+
- assert(evaluationResultElement != null);
- switch(evaluationResultElement.getDecision()) {
++ assert evaluationResultElement != null;
++ switch (evaluationResultElement.getDecision()) {
+ case DENY:
+ combinedResult.merge(evaluationResultElement);
+ break;
+ case INDETERMINATE:
+ case INDETERMINATE_DENYPERMIT:
+ case INDETERMINATE_DENY:
+ case INDETERMINATE_PERMIT:
+ case NOTAPPLICABLE:
+ break;
+ case PERMIT:
+ return evaluationResultElement;
+ default:
- throw new EvaluationException("Illegal Decision: \"" + evaluationResultElement.getDecision().toString());
++ throw new EvaluationException("Illegal Decision: \""
++ + evaluationResultElement.getDecision().toString());
+ }
+ }
+
+ return combinedResult;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/combiners/FirstApplicable.java
----------------------------------------------------------------------
diff --cc openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/combiners/FirstApplicable.java
index 5ae3094,0000000..41251ea
mode 100644,000000..100644
--- a/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/combiners/FirstApplicable.java
+++ b/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/combiners/FirstApplicable.java
@@@ -1,76 -1,0 +1,75 @@@
+/*
+ * 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.std.combiners;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.openaz.xacml.api.Decision;
+import org.apache.openaz.xacml.api.Identifier;
+import org.apache.openaz.xacml.pdp.eval.EvaluationContext;
+import org.apache.openaz.xacml.pdp.eval.EvaluationException;
+import org.apache.openaz.xacml.pdp.eval.EvaluationResult;
+import org.apache.openaz.xacml.pdp.policy.CombinerParameter;
+import org.apache.openaz.xacml.pdp.policy.CombiningElement;
+
+/**
+ * PermitOverrides extends {@link org.apache.openaz.xacml.pdp.std.combiners.CombiningAlgorithmBase} to implement the
+ * XACML 1.0 "first-applicable" combining algorithm for policies and rules.
+ *
+ *
+ * @param <T> the java class of the object to be combined
+ */
- public class FirstApplicable<T extends org.apache.openaz.xacml.pdp.eval.Evaluatable> extends CombiningAlgorithmBase<T> {
++public class FirstApplicable<T extends org.apache.openaz.xacml.pdp.eval.Evaluatable> extends
++ CombiningAlgorithmBase<T> {
+
+ public FirstApplicable(Identifier identifierIn) {
+ super(identifierIn);
+ }
+
+ @Override
- public EvaluationResult combine(EvaluationContext evaluationContext,
- List<CombiningElement<T>> elements,
- List<CombinerParameter> combinerParameters)
- throws EvaluationException {
- Iterator<CombiningElement<T>> iterElements = elements.iterator();
++ public EvaluationResult combine(EvaluationContext evaluationContext, List<CombiningElement<T>> elements,
++ List<CombinerParameter> combinerParameters) throws EvaluationException {
++ Iterator<CombiningElement<T>> iterElements = elements.iterator();
+ while (iterElements.hasNext()) {
- CombiningElement<T> combiningElement = iterElements.next();
- EvaluationResult evaluationResultElement = combiningElement.evaluate(evaluationContext);
++ CombiningElement<T> combiningElement = iterElements.next();
++ EvaluationResult evaluationResultElement = combiningElement.evaluate(evaluationContext);
+
- assert(evaluationResultElement != null);
++ assert evaluationResultElement != null;
+ if (evaluationResultElement.getDecision() != Decision.NOTAPPLICABLE) {
+ return evaluationResultElement;
+ }
+ }
+
+ return new EvaluationResult(Decision.NOTAPPLICABLE);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/combiners/LegacyDenyOverridesPolicy.java
----------------------------------------------------------------------
diff --cc openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/combiners/LegacyDenyOverridesPolicy.java
index 667b8f3,0000000..40e85f9
mode 100644,000000..100644
--- a/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/combiners/LegacyDenyOverridesPolicy.java
+++ b/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/combiners/LegacyDenyOverridesPolicy.java
@@@ -1,97 -1,0 +1,99 @@@
+/*
+ * 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.std.combiners;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.openaz.xacml.api.Decision;
+import org.apache.openaz.xacml.api.Identifier;
+import org.apache.openaz.xacml.pdp.eval.EvaluationContext;
+import org.apache.openaz.xacml.pdp.eval.EvaluationException;
+import org.apache.openaz.xacml.pdp.eval.EvaluationResult;
+import org.apache.openaz.xacml.pdp.policy.CombinerParameter;
+import org.apache.openaz.xacml.pdp.policy.CombiningElement;
+import org.apache.openaz.xacml.pdp.policy.PolicySetChild;
+import org.apache.openaz.xacml.std.StdStatus;
+
+/**
+ * DenyOverrides implements the XACML 1.0 "deny-overrides" combining algorithm for policies and policy sets.
+ *
- *
- * @param <T> the java class for the {@link org.apache.openaz.xacml.pdp.eval.Evaluatable}
++ * @param <T> the java class for the {@link com.att.research.xacmlatt.pdp.eval.Evaluatable}
+ * @param <U> the java class for the identifier
+ */
+public class LegacyDenyOverridesPolicy extends CombiningAlgorithmBase<PolicySetChild> {
+
+ public LegacyDenyOverridesPolicy(Identifier identifierIn) {
+ super(identifierIn);
+ }
+
+ @Override
- public EvaluationResult combine(EvaluationContext evaluationContext, List<CombiningElement<PolicySetChild>> elements, List<CombinerParameter> combinerParameters) throws EvaluationException {
- boolean atLeastOnePermit = false;
++ public EvaluationResult combine(EvaluationContext evaluationContext,
++ List<CombiningElement<PolicySetChild>> elements,
++ List<CombinerParameter> combinerParameters) throws EvaluationException {
++ boolean atLeastOnePermit = false;
+
- EvaluationResult combinedResult = new EvaluationResult(Decision.PERMIT);
++ EvaluationResult combinedResult = new EvaluationResult(Decision.PERMIT);
+
- Iterator<CombiningElement<PolicySetChild>> iterElements = elements.iterator();
++ Iterator<CombiningElement<PolicySetChild>> iterElements = elements.iterator();
+ while (iterElements.hasNext()) {
- CombiningElement<PolicySetChild> combiningElement = iterElements.next();
- EvaluationResult evaluationResultElement = combiningElement.evaluate(evaluationContext);
++ CombiningElement<PolicySetChild> combiningElement = iterElements.next();
++ EvaluationResult evaluationResultElement = combiningElement.evaluate(evaluationContext);
+
- assert(evaluationResultElement != null);
- switch(evaluationResultElement.getDecision()) {
++ assert evaluationResultElement != null;
++ switch (evaluationResultElement.getDecision()) {
+ case DENY:
+ return evaluationResultElement;
+ case INDETERMINATE:
+ case INDETERMINATE_DENYPERMIT:
+ case INDETERMINATE_DENY:
+ case INDETERMINATE_PERMIT:
+ return new EvaluationResult(Decision.DENY, StdStatus.STATUS_OK);
+ case NOTAPPLICABLE:
+ break;
+ case PERMIT:
- atLeastOnePermit = true;
++ atLeastOnePermit = true;
+ combinedResult.merge(evaluationResultElement);
+ break;
+ default:
- throw new EvaluationException("Illegal Decision: \"" + evaluationResultElement.getDecision().toString());
++ throw new EvaluationException("Illegal Decision: \""
++ + evaluationResultElement.getDecision().toString());
+ }
+ }
+
+ if (atLeastOnePermit) {
+ return combinedResult;
+ } else {
+ return new EvaluationResult(Decision.NOTAPPLICABLE);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/combiners/LegacyDenyOverridesRule.java
----------------------------------------------------------------------
diff --cc openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/combiners/LegacyDenyOverridesRule.java
index 02300d4,0000000..cc166e5
mode 100644,000000..100644
--- a/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/combiners/LegacyDenyOverridesRule.java
+++ b/openaz-xacml-pdp/src/main/java/org/apache/openaz/xacml/pdp/std/combiners/LegacyDenyOverridesRule.java
@@@ -1,110 -1,0 +1,112 @@@
+/*
+ * 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.std.combiners;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.openaz.xacml.api.Decision;
+import org.apache.openaz.xacml.api.Identifier;
+import org.apache.openaz.xacml.pdp.eval.EvaluationContext;
+import org.apache.openaz.xacml.pdp.eval.EvaluationException;
+import org.apache.openaz.xacml.pdp.eval.EvaluationResult;
+import org.apache.openaz.xacml.pdp.policy.CombinerParameter;
+import org.apache.openaz.xacml.pdp.policy.CombiningElement;
+import org.apache.openaz.xacml.pdp.policy.Rule;
+import org.apache.openaz.xacml.pdp.policy.RuleEffect;
+
+/**
+ * DenyOverrides implements the XACML 1.0 "deny-overrides" combining algorithm for rules.
+ *
- *
- * @param <T> the java class for the {@link org.apache.openaz.xacml.pdp.eval.Evaluatable}
++ * @param <T> the java class for the {@link com.att.research.xacmlatt.pdp.eval.Evaluatable}
+ * @param <U> the java class for the identifier
+ */
+public class LegacyDenyOverridesRule extends CombiningAlgorithmBase<Rule> {
+
+ public LegacyDenyOverridesRule(Identifier identifierIn) {
+ super(identifierIn);
+ }
+
+ @Override
- public EvaluationResult combine(EvaluationContext evaluationContext, List<CombiningElement<Rule>> elements, List<CombinerParameter> combinerParameters) throws EvaluationException {
- boolean atLeastOnePermit = false;
- boolean potentialDeny = false;
++ public EvaluationResult combine(EvaluationContext evaluationContext,
++ List<CombiningElement<Rule>> elements,
++ List<CombinerParameter> combinerParameters) throws EvaluationException {
++ boolean atLeastOnePermit = false;
++ boolean potentialDeny = false;
+
- EvaluationResult combinedResult = new EvaluationResult(Decision.PERMIT);
- EvaluationResult evaluationResultIndeterminate = null;
++ EvaluationResult combinedResult = new EvaluationResult(Decision.PERMIT);
++ EvaluationResult evaluationResultIndeterminate = null;
+
- Iterator<CombiningElement<Rule>> iterElements = elements.iterator();
++ Iterator<CombiningElement<Rule>> iterElements = elements.iterator();
+ while (iterElements.hasNext()) {
- CombiningElement<Rule> combiningElement = iterElements.next();
- EvaluationResult evaluationResultElement = combiningElement.evaluate(evaluationContext);
++ CombiningElement<Rule> combiningElement = iterElements.next();
++ EvaluationResult evaluationResultElement = combiningElement.evaluate(evaluationContext);
+
- assert(evaluationResultElement != null);
- switch(evaluationResultElement.getDecision()) {
++ assert evaluationResultElement != null;
++ switch (evaluationResultElement.getDecision()) {
+ case DENY:
+ return evaluationResultElement;
+ case INDETERMINATE:
+ case INDETERMINATE_DENYPERMIT:
+ case INDETERMINATE_DENY:
+ case INDETERMINATE_PERMIT:
+ if (evaluationResultIndeterminate == null) {
- evaluationResultIndeterminate = evaluationResultElement;
++ evaluationResultIndeterminate = evaluationResultElement;
+ } else {
+ evaluationResultIndeterminate.merge(evaluationResultElement);
+ }
+ if (combiningElement.getEvaluatable().getRuleEffect() == RuleEffect.DENY) {
- potentialDeny = true;
++ potentialDeny = true;
+ }
+ case NOTAPPLICABLE:
+ break;
+ case PERMIT:
- atLeastOnePermit = true;
++ atLeastOnePermit = true;
+ combinedResult.merge(evaluationResultElement);
+ break;
+ default:
- throw new EvaluationException("Illegal Decision: \"" + evaluationResultElement.getDecision().toString());
++ throw new EvaluationException("Illegal Decision: \""
++ + evaluationResultElement.getDecision().toString());
+ }
+ }
+
+ if (potentialDeny) {
+ return evaluationResultIndeterminate;
+ } else if (atLeastOnePermit) {
+ return combinedResult;
+ } else if (evaluationResultIndeterminate != null) {
+ return evaluationResultIndeterminate;
+ } else {
+ return new EvaluationResult(Decision.NOTAPPLICABLE);
+ }
+ }
+
+}