aboutsummaryrefslogtreecommitdiffstats
path: root/POLICY-SDK-APP/src/main/java/org/onap/policy/admin
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2019-10-24 21:33:45 -0400
committerliamfallon <liam.fallon@est.tech>2019-10-24 21:50:19 -0400
commitc2ca6ea5cb44103903e1409e8dd6db80167e61e8 (patch)
treea713b7e2d83a2492d4141881eb886c82a3a10647 /POLICY-SDK-APP/src/main/java/org/onap/policy/admin
parent766f999081e73b301062f1b96bffb9c52d7e9852 (diff)
CHeckstyle and JUnit for base package in ONAP-REST
Added unit tests and fixed checkstyle and SONAR issues in the base package of ONAPE-REST There was a lot of knock-on automatic changes done by Eclipse when I renamed the class XACMLRestProperties to XacmlRestProperties so ignore the changes in all but the ONAP-REST package. I also didn't update the licenses on files on those classes because the changes were automatic. Issue-ID: POLICY-2131 Change-Id: I28823c844b5192f8d56de76a727996b13e7ea4a6 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'POLICY-SDK-APP/src/main/java/org/onap/policy/admin')
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPdpProperties.java4
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java10
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java12
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/RESTfulPAPEngine.java10
4 files changed, 18 insertions, 18 deletions
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPdpProperties.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPdpProperties.java
index 16b6d0979..925344191 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPdpProperties.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPdpProperties.java
@@ -42,7 +42,7 @@ import java.util.Properties;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
-import org.onap.policy.rest.XACMLRestProperties;
+import org.onap.policy.rest.XacmlRestProperties;
import org.onap.policy.utils.PeCryptoUtils;
import org.onap.policy.xacml.api.XACMLErrorConstants;
@@ -101,7 +101,7 @@ public class CheckPdpProperties {
private static void readFile() {
String pdpFile;
try {
- pdpFile = XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_IDFILE);
+ pdpFile = XACMLProperties.getProperty(XacmlRestProperties.PROP_PDP_IDFILE);
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Cannot read the PDP ID File" + e);
return;
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java
index ed1266cfb..224ee0793 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java
@@ -76,8 +76,8 @@ import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.components.HumanPolicyComponent;
import org.onap.policy.controller.PolicyController;
import org.onap.policy.controller.PolicyExportAndImportController;
-import org.onap.policy.rest.XACMLRest;
-import org.onap.policy.rest.XACMLRestProperties;
+import org.onap.policy.rest.XacmlRest;
+import org.onap.policy.rest.XacmlRestProperties;
import org.onap.policy.rest.adapter.PolicyRestAdapter;
import org.onap.policy.rest.jpa.ActionBodyEntity;
import org.onap.policy.rest.jpa.ConfigurationDataEntity;
@@ -192,9 +192,9 @@ public class PolicyManagerServlet extends HttpServlet {
//
// Common initialization
//
- XACMLRest.xacmlInit(servletConfig);
+ XacmlRest.xacmlInit(servletConfig);
// init aes key from prop or env
- PeCryptoUtils.initAesKey(XACMLProperties.getProperty(XACMLRestProperties.PROP_AES_KEY));
+ PeCryptoUtils.initAesKey(XACMLProperties.getProperty(XacmlRestProperties.PROP_AES_KEY));
//
// Initialize ClosedLoop JSON
//
@@ -202,7 +202,7 @@ public class PolicyManagerServlet extends HttpServlet {
}
private static void initializeJsonLoad() {
- Path closedLoopJsonLocation = Paths.get(XACMLProperties.getProperty(XACMLRestProperties.PROP_ADMIN_CLOSEDLOOP));
+ Path closedLoopJsonLocation = Paths.get(XACMLProperties.getProperty(XacmlRestProperties.PROP_ADMIN_CLOSEDLOOP));
String location = closedLoopJsonLocation.toString();
if (!location.endsWith("json")) {
LOGGER.warn("JSONConfig file does not end with extension .json");
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java
index 12d3fc334..76bb04945 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java
@@ -56,7 +56,7 @@ import org.onap.policy.controller.CreateDcaeMicroServiceController;
import org.onap.policy.controller.CreateFirewallController;
import org.onap.policy.controller.CreateOptimizationController;
import org.onap.policy.controller.PolicyController;
-import org.onap.policy.rest.XACMLRestProperties;
+import org.onap.policy.rest.XacmlRestProperties;
import org.onap.policy.rest.adapter.PolicyRestAdapter;
import org.onap.policy.rest.dao.CommonClassDao;
import org.onap.policy.rest.jpa.PolicyVersion;
@@ -234,9 +234,9 @@ public class PolicyRestController extends RestrictedBaseController {
private ResponseEntity<?> sendToPap(String body, String requestUri, HttpMethod method) {
String papUrl = PolicyController.getPapUrl();
- String papPass = PeCryptoUtils.decrypt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_PASS));
+ String papPass = PeCryptoUtils.decrypt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_PASS));
String encoding = Base64.getEncoder().encodeToString(
- (XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_USERID)
+ (XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_USERID)
+ ":" + papPass).getBytes(StandardCharsets.UTF_8));
HttpHeaders headers = new HttpHeaders();
headers.set(AUTHORIZATION, BASIC + encoding);
@@ -284,11 +284,11 @@ public class PolicyRestController extends RestrictedBaseController {
}
private String callPap(HttpServletRequest request, String method, String uriValue) {
- PeCryptoUtils.initAesKey(XACMLProperties.getProperty(XACMLRestProperties.PROP_AES_KEY));
- String papPass = PeCryptoUtils.decrypt((XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_PASS)));
+ PeCryptoUtils.initAesKey(XACMLProperties.getProperty(XacmlRestProperties.PROP_AES_KEY));
+ String papPass = PeCryptoUtils.decrypt((XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_PASS)));
Base64.Encoder encoder = Base64.getEncoder();
- String encoding = encoder.encodeToString((XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_USERID)
+ String encoding = encoder.encodeToString((XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_USERID)
+ ":" + papPass).getBytes(StandardCharsets.UTF_8));
HttpHeaders headers = new HttpHeaders();
headers.set(AUTHORIZATION, BASIC + encoding);
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/RESTfulPAPEngine.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/RESTfulPAPEngine.java
index 142613e93..ff72e0224 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/RESTfulPAPEngine.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/RESTfulPAPEngine.java
@@ -52,7 +52,7 @@ import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
-import org.onap.policy.rest.XACMLRestProperties;
+import org.onap.policy.rest.XacmlRestProperties;
import org.onap.policy.rest.adapter.PolicyRestAdapter;
import org.onap.policy.utils.PeCryptoUtils;
import org.onap.policy.xacml.api.XACMLErrorConstants;
@@ -95,7 +95,7 @@ public class RESTfulPAPEngine extends StdPDPItemSetChangeNotifier implements PAP
//
// Get our URL to the PAP servlet
//
- this.papServletUrlString = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_URL);
+ this.papServletUrlString = XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_URL);
if (StringUtils.isBlank(this.papServletUrlString)) {
String message = "The property 'POLICYENGINE_ADMIN_ACTIVE' was not set during installation. "
+ "Admin Console cannot call PAP.";
@@ -357,11 +357,11 @@ public class RESTfulPAPEngine extends StdPDPItemSetChangeNotifier implements PAP
private Object sendToPap(String method, Object content, Class collectionTypeClass, Class responseContentClass,
String... parameters) throws PAPException {
HttpURLConnection connection = null;
- String papID = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_USERID);
+ String papID = XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_USERID);
LOGGER.info("User Id is " + papID);
- PeCryptoUtils.initAesKey(XACMLProperties.getProperty(XACMLRestProperties.PROP_AES_KEY));
+ PeCryptoUtils.initAesKey(XACMLProperties.getProperty(XacmlRestProperties.PROP_AES_KEY));
String papPass = PeCryptoUtils
- .decrypt(PeCryptoUtils.decrypt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_PASS)));
+ .decrypt(PeCryptoUtils.decrypt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_PASS)));
Base64.Encoder encoder = Base64.getEncoder();
String encoding = encoder.encodeToString((papID + ":" + papPass).getBytes(StandardCharsets.UTF_8));
Object contentObj = content;