diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2019-10-22 07:51:12 -0400 |
---|---|---|
committer | Pamela Dragosh <pdragosh@research.att.com> | 2019-10-22 07:52:42 -0400 |
commit | f18fbfc026de9cf02126f57844c37abfee607394 (patch) | |
tree | 86df38a6a75bf4dd268a959ac2ec15269a1c4351 /ONAP-XACML | |
parent | 18998fee10abecb2ff1b2cdc3b99a3115d7de77c (diff) |
Remove useless imports and vars
Some formatting and javadoc cleanup also.
Issue-ID: POLICY-2133
Change-Id: Icb0f76c7e69df87918b4bc5a02a013f9d2bfae89
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'ONAP-XACML')
-rw-r--r-- | ONAP-XACML/src/main/java/org/onap/policy/xacml/util/XACMLPolicyScanner.java | 96 |
1 files changed, 47 insertions, 49 deletions
diff --git a/ONAP-XACML/src/main/java/org/onap/policy/xacml/util/XACMLPolicyScanner.java b/ONAP-XACML/src/main/java/org/onap/policy/xacml/util/XACMLPolicyScanner.java index 0003e12c6..e0ee60ade 100644 --- a/ONAP-XACML/src/main/java/org/onap/policy/xacml/util/XACMLPolicyScanner.java +++ b/ONAP-XACML/src/main/java/org/onap/policy/xacml/util/XACMLPolicyScanner.java @@ -7,9 +7,9 @@ * Licensed 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. @@ -37,8 +37,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; import org.onap.policy.common.logging.eelf.MessageCodes; import org.onap.policy.common.logging.eelf.PolicyLogger; @@ -73,18 +71,18 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.VariableDefinitionType; /** * class XACMLPolicyScanner - * + * * This class traverses the hierarchy of a XACML 3.0 policy. You can optionally pass a Callback class - * and override any desired methods to retrieve information from a policy. - * + * and override any desired methods to retrieve information from a policy. + * * */ public class XACMLPolicyScanner { - + private static final Log logger = LogFactory.getLog(XACMLPolicyScanner.class); private Object policyObject = null; private Callback callback = null; - + public XACMLPolicyScanner(Path filename, Callback callback) { try (InputStream is = Files.newInputStream(filename)) { this.policyObject = XACMLPolicyScanner.readPolicy(is); @@ -93,7 +91,7 @@ public class XACMLPolicyScanner { } this.callback = callback; } - + public XACMLPolicyScanner(InputStream filename, Callback callback) { try (InputStream is = filename) { this.policyObject = XACMLPolicyScanner.readPolicy(is); @@ -102,37 +100,37 @@ public class XACMLPolicyScanner { } this.callback = callback; } - + public XACMLPolicyScanner(PolicySetType policySet, Callback callback) { this.policyObject = policySet; this.callback = callback; } - + public XACMLPolicyScanner(PolicySetType policySet) { this(policySet, null); } - + public XACMLPolicyScanner(PolicyType policy, Callback callback) { this.policyObject = policy; this.callback = callback; } - + public XACMLPolicyScanner(PolicyType policy) { this(policy, null); } - + /** * Sets the callback interface to be used. - * + * * @param cb */ public void setCallback(Callback cb) { this.callback = cb; } - + /** * Saves the given callback object then calls the scan() method. - * + * * @param cb * @return */ @@ -140,11 +138,11 @@ public class XACMLPolicyScanner { this.callback = cb; return this.scan(); } - + /** - * + * * This begins the scanning of the contained object. - * + * * @return - The PolicySet/Policy that was scanned. */ public Object scan() { @@ -166,10 +164,10 @@ public class XACMLPolicyScanner { } return this.policyObject; } - + /** * This performs the scan of a PolicySet - * + * * @param parent - Its parent PolicySet. Can be null if this is the root. * @param policySet - The PolicySet object. * @return CallbackResult - CONTINUE to continue, STOP to terminate scanning. @@ -203,7 +201,7 @@ public class XACMLPolicyScanner { // List<JAXBElement<?>> list = policySet.getPolicySetOrPolicyOrPolicySetIdReference(); for (JAXBElement<?> element: list) { - if ("PolicySet".equals(element.getName().getLocalPart()) && + if ("PolicySet".equals(element.getName().getLocalPart()) && this.scanPolicySet(policySet, (PolicySetType)element.getValue()) == CallbackResult.STOP) { return CallbackResult.STOP; } else if ("Policy".equals(element.getName().getLocalPart()) && @@ -218,11 +216,11 @@ public class XACMLPolicyScanner { } return CallbackResult.CONTINUE; } - + /** - * + * * This performs scanning of the Policy object. - * + * * @param parent - The parent PolicySet of the policy. This can be null if this is a root Policy. * @param policy - The policy being scanned. * @return CallbackResult - CONTINUE to continue, STOP to terminate scanning. @@ -292,10 +290,10 @@ public class XACMLPolicyScanner { } return CallbackResult.CONTINUE; } - + /** * Scans the given target for attributes. Its sole purpose is to return attributes found. - * + * * @param parent - The parent PolicySet/Policy/Rule for the target. * @param target - The target. * @return CallbackResult - CONTINUE to continue, STOP to terminate scanning. @@ -355,10 +353,10 @@ public class XACMLPolicyScanner { } return CallbackResult.CONTINUE; } - + /** * Scan the list of obligations. - * + * * @param parent - The parent PolicySet/Policy/Rule for the obligation. * @param obligationExpressionsType - All the obligation expressions. * @return CallbackResult - CONTINUE to continue, STOP to terminate scanning. @@ -398,9 +396,9 @@ public class XACMLPolicyScanner { } /** - * + * * Scans the list of advice expressions returning each individually. - * + * * @param parent - The parent PolicySet/Policy/Rule for the advice. * @param adviceExpressionstype - The list of advice expressions. * @return CallbackResult - CONTINUE to continue, STOP to terminate scanning. @@ -437,10 +435,10 @@ public class XACMLPolicyScanner { } return CallbackResult.CONTINUE; } - + /** * Scans the list of variable definitions. - * + * * @param policy - Policy object containing the variable definition. * @param list - List of variable definitions. * @return CallbackResult - CONTINUE to continue, STOP to terminate scanning. @@ -454,13 +452,13 @@ public class XACMLPolicyScanner { return CallbackResult.STOP; } } - + return CallbackResult.CONTINUE; } - + /** * Scans the list of conditions. - * + * * @param rule * @param condition * @return @@ -471,13 +469,13 @@ public class XACMLPolicyScanner { } return CallbackResult.CONTINUE; } - + /** * Reads the XACML XML policy file in and returns the version contained in the root Policy/PolicySet element. - * + * * @param policy - The policy file. * @return - The version string from the file (uninterpreted) - * @throws IOException + * @throws IOException */ public static String getVersion(Path policy) throws IOException { Object data = null; @@ -493,10 +491,10 @@ public class XACMLPolicyScanner { } return getVersion(data); } - + /** * Reads the Policy/PolicySet element object and returns its current version. - * + * * @param data - Either a PolicySet or Policy XACML type object. * @return - The integer version value. -1 if it doesn't exist or was un-parsable. */ @@ -524,10 +522,10 @@ public class XACMLPolicyScanner { } return null; } - + /** * Returns the Policy or PolicySet ID. - * + * * @param data - A XACML 3.0 Policy or PolicySet element object. * @return The policy/policyset's policy ID */ @@ -541,7 +539,7 @@ public class XACMLPolicyScanner { return null; } } - + public static List<String> getCreatedByModifiedBy(Path policyPath) throws IOException{ String createdBy = ""; String modifiedBy= ""; @@ -560,7 +558,7 @@ public class XACMLPolicyScanner { } return Arrays.asList(createdBy, modifiedBy); } - + //get the Created Name of the User on reading the Xml file public static String getCreatedBy(Path policyPath) throws IOException{ String userId = ""; @@ -577,7 +575,7 @@ public class XACMLPolicyScanner { } return userId; } - + //get the Modified Name of the User on reading the Xml file public static String getModifiedBy(Path policyPath) throws IOException{ String modifiedBy = ""; @@ -597,7 +595,7 @@ public class XACMLPolicyScanner { /** * readPolicy - does the work to read in policy data from a file. - * + * * @param policy - The path to the policy file. * @return - The policy data object. This *should* be either a PolicySet or a Policy. */ |