diff options
author | liamfallon <liam.fallon@est.tech> | 2019-10-24 21:33:45 -0400 |
---|---|---|
committer | liamfallon <liam.fallon@est.tech> | 2019-10-24 21:50:19 -0400 |
commit | c2ca6ea5cb44103903e1409e8dd6db80167e61e8 (patch) | |
tree | a713b7e2d83a2492d4141881eb886c82a3a10647 | |
parent | 766f999081e73b301062f1b96bffb9c52d7e9852 (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>
41 files changed, 773 insertions, 535 deletions
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/Heartbeat.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/Heartbeat.java index 6b9175885..81e7c6778 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/Heartbeat.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/Heartbeat.java @@ -39,7 +39,7 @@ import org.onap.policy.common.logging.eelf.PolicyLogger; import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.pap.xacml.restAuth.CheckPDP; -import org.onap.policy.rest.XACMLRestProperties; +import org.onap.policy.rest.XacmlRestProperties; import org.onap.policy.xacml.api.pap.OnapPDP; import org.onap.policy.xacml.api.pap.OnapPDPGroup; import org.onap.policy.xacml.api.pap.PAPPolicyEngine; @@ -88,9 +88,9 @@ public class Heartbeat implements Runnable { public Heartbeat(PAPPolicyEngine papEngine2) { papEngine = papEngine2; this.heartbeatInterval = - Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_HEARTBEAT_INTERVAL, "10000")); + Integer.parseInt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_HEARTBEAT_INTERVAL, "10000")); this.heartbeatTimeout = - Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_HEARTBEAT_TIMEOUT, "10000")); + Integer.parseInt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_HEARTBEAT_TIMEOUT, "10000")); } @Override @@ -189,7 +189,7 @@ public class Heartbeat implements Runnable { // Do the connect connection.connect(); if (connection.getResponseCode() == 204) { - newStatus = connection.getHeaderField(XACMLRestProperties.PROP_PDP_HTTP_HEADER_HB); + newStatus = connection.getHeaderField(XacmlRestProperties.PROP_PDP_HTTP_HEADER_HB); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Heartbeat '" + pdp.getId() + "' status='" + newStatus + "'"); } diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/PAPRestConfig.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/PAPRestConfig.java index f34d4739f..2ca87af28 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/PAPRestConfig.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/PAPRestConfig.java @@ -32,7 +32,7 @@ import org.apache.tomcat.dbcp.dbcp2.BasicDataSource; import org.hibernate.SessionFactory; 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.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; @@ -65,7 +65,7 @@ public class PAPRestConfig extends WebMvcConfigurerAdapter { setDbDriver(prop.getProperty("javax.persistence.jdbc.driver")); setDbUrl(prop.getProperty("javax.persistence.jdbc.url")); setDbUserName(prop.getProperty("javax.persistence.jdbc.user")); - PeCryptoUtils.initAesKey(prop.getProperty(XACMLRestProperties.PROP_AES_KEY)); + PeCryptoUtils.initAesKey(prop.getProperty(XacmlRestProperties.PROP_AES_KEY)); setDbPassword(PeCryptoUtils.decrypt(prop.getProperty("javax.persistence.jdbc.password"))); } catch (Exception e) { LOGGER.error("Exception Occured while loading properties file" + e); diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/UpdateOthersPAPS.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/UpdateOthersPAPS.java index a7ccfad7f..2bb4229a6 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/UpdateOthersPAPS.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/UpdateOthersPAPS.java @@ -44,7 +44,7 @@ import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.pap.xacml.rest.adapters.UpdateObjectData; import org.onap.policy.pap.xacml.rest.components.Policy; import org.onap.policy.pap.xacml.rest.util.JsonMessage; -import org.onap.policy.rest.XACMLRestProperties; +import org.onap.policy.rest.XacmlRestProperties; import org.onap.policy.rest.dao.CommonClassDao; import org.onap.policy.rest.jpa.ActionBodyEntity; import org.onap.policy.rest.jpa.ConfigurationDataEntity; @@ -102,7 +102,7 @@ public class UpdateOthersPAPS { body.setNewPolicyName(request.getParameter("newPolicyName")); body.setOldPolicyName(request.getParameter("oldPolicyName")); - String currentPap = XACMLRestProperties.getProperty("xacml.rest.pap.url"); + String currentPap = XacmlRestProperties.getProperty("xacml.rest.pap.url"); List<Object> getPAPUrls = commonClassDao.getData(PolicyDBDaoEntity.class); if (getPAPUrls != null && !getPAPUrls.isEmpty()) { for (int i = 0; i < getPAPUrls.size(); i++) { @@ -114,7 +114,7 @@ public class UpdateOthersPAPS { Base64.Encoder encoder = Base64.getEncoder(); String txt; try { - PeCryptoUtils.initAesKey(XACMLProperties.getProperty(XACMLRestProperties.PROP_AES_KEY)); + PeCryptoUtils.initAesKey(XACMLProperties.getProperty(XacmlRestProperties.PROP_AES_KEY)); txt = PeCryptoUtils.decrypt(password); } catch (Exception e) { policyLogger.debug(e); diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java index 5805420f1..32b1eb770 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java @@ -75,8 +75,8 @@ import org.onap.policy.pap.xacml.rest.handler.APIRequestHandler; import org.onap.policy.pap.xacml.rest.handler.PushPolicyHandler; import org.onap.policy.pap.xacml.rest.handler.SavePolicyHandler; import org.onap.policy.pap.xacml.restAuth.CheckPDP; -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.dao.PolicyDBException; import org.onap.policy.utils.PeCryptoUtils; import org.onap.policy.utils.PolicyUtils; @@ -191,20 +191,20 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList } // Initialize - XACMLRest.xacmlInit(config); + XacmlRest.xacmlInit(config); // Load the properties - XACMLRest.loadXacmlProperties(null, null); + XacmlRest.loadXacmlProperties(null, null); /* * Retrieve the property values */ setCommonProperties(); - String papSiteName = XACMLProperties.getProperty(XACMLRestProperties.PAP_SITE_NAME); + String papSiteName = XACMLProperties.getProperty(XacmlRestProperties.PAP_SITE_NAME); if (papSiteName == null) { PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, "XACMLPapServlet", " ERROR: Bad papSiteName property entry"); throw new PAPException("papSiteName is null"); } - String papNodeType = XACMLProperties.getProperty(XACMLRestProperties.PAP_NODE_TYPE); + String papNodeType = XACMLProperties.getProperty(XacmlRestProperties.PAP_NODE_TYPE); if (papNodeType == null) { PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, "XACMLPapServlet", " ERROR: Bad papNodeType property entry"); @@ -212,18 +212,18 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList } // Integer will throw an exception of anything is missing or // unrecognized - int papTransWait = Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_TRANS_WAIT)); + int papTransWait = Integer.parseInt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_TRANS_WAIT)); int papTransTimeout = - Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_TRANS_TIMEOUT)); + Integer.parseInt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_TRANS_TIMEOUT)); int papAuditTimeout = - Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_AUDIT_TIMEOUT)); + Integer.parseInt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_AUDIT_TIMEOUT)); // Boolean will default to false if anything is missing or // unrecognized boolean papAuditFlag = - Boolean.parseBoolean(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_RUN_AUDIT_FLAG)); + Boolean.parseBoolean(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_RUN_AUDIT_FLAG)); boolean papFileSystemAudit = - Boolean.parseBoolean(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_AUDIT_FLAG)); - String papDependencyGroups = XACMLProperties.getProperty(XACMLRestProperties.PAP_DEPENDENCY_GROUPS); + Boolean.parseBoolean(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_AUDIT_FLAG)); + String papDependencyGroups = XACMLProperties.getProperty(XacmlRestProperties.PAP_DEPENDENCY_GROUPS); if (papDependencyGroups == null) { throw new PAPException("papDependencyGroups is null"); } @@ -272,7 +272,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList // we are about to call the PDPs and give them their configuration. // To do that we need to have the URL of this PAP so we can // construct the Policy file URLs - setPapUrl(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_URL)); + setPapUrl(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_URL)); // Create the policyDBDao setPolicyDbDao(); // Load our PAP engine, first create a factory @@ -284,7 +284,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList createDefaultGroupOnInit(); } policyDbDao.setPapEngine(XACMLPapServlet.papEngine); - if (Boolean.parseBoolean(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_RUN_AUDIT_FLAG))) { + if (Boolean.parseBoolean(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_RUN_AUDIT_FLAG))) { /* * Auditing the local File System groups to be in sync with the Database */ @@ -314,7 +314,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList // Configurable - have the PAP servlet initiate sending the latest // PDP policy/pip configuration // to all its known PDP nodes. - if (Boolean.parseBoolean(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_INITIATE_PDP_CONFIG))) { + if (Boolean.parseBoolean(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_INITIATE_PDP_CONFIG))) { startInitiateThreadService(new Thread(this)); } // After startup, the PAP does Heartbeat's to each of the PDPs @@ -403,9 +403,9 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList papDependencyGroupsFlatArray[i] = papDependencyGroupsFlatArray[i].trim(); } try { - if (XACMLProperties.getProperty(XACMLRestProperties.PAP_INTEGRITY_AUDIT_PERIOD_SECONDS) != null) { + if (XACMLProperties.getProperty(XacmlRestProperties.PAP_INTEGRITY_AUDIT_PERIOD_SECONDS) != null) { papIntegrityAuditPeriodSeconds = Integer.parseInt( - XACMLProperties.getProperty(XACMLRestProperties.PAP_INTEGRITY_AUDIT_PERIOD_SECONDS).trim()); + XACMLProperties.getProperty(XacmlRestProperties.PAP_INTEGRITY_AUDIT_PERIOD_SECONDS).trim()); } } catch (Exception e) { String msg = "integrity_audit_period_seconds "; @@ -423,35 +423,35 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList private static void setCommonProperties() throws PAPException { setConfigHome(); setActionHome(); - papDbDriver = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_DB_DRIVER); + papDbDriver = XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_DB_DRIVER); if (papDbDriver == null) { PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, "XACMLPapServlet", " ERROR: Bad papDbDriver property entry"); throw new PAPException("papDbDriver is null"); } setPapDbDriver(papDbDriver); - papDbUrl = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_DB_URL); + papDbUrl = XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_DB_URL); if (papDbUrl == null) { PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, "XACMLPapServlet", " ERROR: Bad papDbUrl property entry"); throw new PAPException("papDbUrl is null"); } setPapDbUrl(papDbUrl); - papDbUser = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_DB_USER); + papDbUser = XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_DB_USER); if (papDbUser == null) { PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, "XACMLPapServlet", " ERROR: Bad papDbUser property entry"); throw new PAPException("papDbUser is null"); } setPapDbUser(papDbUser); - PeCryptoUtils.initAesKey(XACMLProperties.getProperty(XACMLRestProperties.PROP_AES_KEY)); - papDbPd = PeCryptoUtils.decrypt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_DB_PASSWORD)); + PeCryptoUtils.initAesKey(XACMLProperties.getProperty(XacmlRestProperties.PROP_AES_KEY)); + papDbPd = PeCryptoUtils.decrypt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_DB_PASSWORD)); if (papDbPd == null) { PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, "XACMLPapServlet", " ERROR: Bad papDbPassword property entry"); throw new PAPException("papDbPassword is null"); } setPapDbPassword(papDbPd); - papResourceName = XACMLProperties.getProperty(XACMLRestProperties.PAP_RESOURCE_NAME); + papResourceName = XACMLProperties.getProperty(XacmlRestProperties.PAP_RESOURCE_NAME); if (papResourceName == null) { PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, "XACMLPapServlet", " ERROR: Bad papResourceName property entry"); @@ -464,11 +464,11 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList msPolicyName = XACMLProperties.getProperty("xacml.policy.msPolicyName"); setMsPolicyName(msPolicyName); // PDPId File location - XACMLPapServlet.pdpFile = XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_IDFILE); + XACMLPapServlet.pdpFile = XACMLProperties.getProperty(XacmlRestProperties.PROP_PDP_IDFILE); if (XACMLPapServlet.pdpFile == null) { PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE + " The PDP Id Authentication File Property is not valid: " - + XACMLRestProperties.PROP_PDP_IDFILE); - throw new PAPException("The PDP Id Authentication File Property :" + XACMLRestProperties.PROP_PDP_IDFILE + + XacmlRestProperties.PROP_PDP_IDFILE); + throw new PAPException("The PDP Id Authentication File Property :" + XacmlRestProperties.PROP_PDP_IDFILE + " is not Valid. "); } } @@ -564,7 +564,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList } try { loggingContext.metricStarted(); - XACMLRest.dumpRequest(request); + XacmlRest.dumpRequest(request); loggingContext.metricEnded(); PolicyLogger.metrics("XACMLPapServlet doPost dumpRequest"); // since getParameter reads the content string, explicitly get the @@ -784,7 +784,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList OnapLoggingContext loggingContext = OnapLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext); setLoggingContext(loggingContext, "doGet", "PAP.get"); loggingContext.metricStarted(); - XACMLRest.dumpRequest(request); + XacmlRest.dumpRequest(request); loggingContext.metricEnded(); PolicyLogger.metrics("XACMLPapServlet doGet dumpRequest"); String pathInfo = request.getRequestURI(); @@ -1004,7 +1004,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList String apiflag = request.getParameter("apiflag"); // For Debug purposes if (!"api".equals(apiflag) && PolicyLogger.isDebugEnabled()) { - XACMLRest.dumpRequest(request); + XacmlRest.dumpRequest(request); PolicyLogger.metrics("XACMLPapServlet doPut dumpRequest"); } loggingContext.metricEnded(); @@ -1207,7 +1207,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList return; } loggingContext.metricStarted(); - XACMLRest.dumpRequest(request); + XacmlRest.dumpRequest(request); loggingContext.metricEnded(); PolicyLogger.metrics("XACMLPapServlet doDelete dumpRequest"); String groupId = request.getParameter(GROUPID); @@ -1308,7 +1308,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList } protected String getPDPID(HttpServletRequest request) { - String pdpURL = request.getHeader(XACMLRestProperties.PROP_PDP_HTTP_HEADER_ID); + String pdpURL = request.getHeader(XacmlRestProperties.PROP_PDP_HTTP_HEADER_ID); if (pdpURL == null || pdpURL.isEmpty()) { // Should send back its port for identification LOGGER.warn(XACMLErrorConstants.ERROR_DATA_ISSUE + "PDP did not send custom header"); @@ -1318,7 +1318,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList } protected String getPDPJMX(HttpServletRequest request) { - String pdpJMMX = request.getHeader(XACMLRestProperties.PROP_PDP_HTTP_HEADER_JMX_PORT); + String pdpJMMX = request.getHeader(XacmlRestProperties.PROP_PDP_HTTP_HEADER_JMX_PORT); if (pdpJMMX == null || pdpJMMX.isEmpty()) { // Should send back its port for identification LOGGER.warn(XACMLErrorConstants.ERROR_DATA_ISSUE @@ -1643,12 +1643,12 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList private static void loadWebapps() throws PAPException { if (actionHome == null || configHome == null) { - Path webappsPath = Paths.get(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_WEBAPPS)); + Path webappsPath = Paths.get(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_WEBAPPS)); // Sanity Check if (webappsPath == null) { - PolicyLogger.error("Invalid Webapps Path Location property : " + XACMLRestProperties.PROP_PAP_WEBAPPS); + PolicyLogger.error("Invalid Webapps Path Location property : " + XacmlRestProperties.PROP_PAP_WEBAPPS); throw new PAPException( - "Invalid Webapps Path Location property : " + XACMLRestProperties.PROP_PAP_WEBAPPS); + "Invalid Webapps Path Location property : " + XacmlRestProperties.PROP_PAP_WEBAPPS); } Path webappsPathConfig = Paths.get(webappsPath.toString() + File.separator + "Config"); Path webappsPathAction = Paths.get(webappsPath.toString() + File.separator + "Action"); diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/HandleIncomingNotifications.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/HandleIncomingNotifications.java index f565254f1..aca43510d 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/HandleIncomingNotifications.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/HandleIncomingNotifications.java @@ -47,7 +47,7 @@ import org.onap.policy.common.logging.eelf.PolicyLogger; import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.pap.xacml.rest.XACMLPapServlet; -import org.onap.policy.rest.XACMLRestProperties; +import org.onap.policy.rest.XacmlRestProperties; import org.onap.policy.rest.dao.PolicyDBException; import org.onap.policy.rest.jpa.GroupEntity; import org.onap.policy.rest.jpa.PdpEntity; @@ -92,7 +92,7 @@ public class HandleIncomingNotifications { int retries; try { retries = Integer - .parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_INCOMINGNOTIFICATION_TRIES)); + .parseInt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_INCOMINGNOTIFICATION_TRIES)); } catch (Exception e) { logger.error("xacml.rest.pap.incomingnotification.tries property not set, using a default of 3." + e); retries = 3; @@ -546,7 +546,7 @@ public class HandleIncomingNotifications { subTypeName = policy.getActionBodyEntity().getActionBodyName(); subTypeBody = policy.getActionBodyEntity().getActionBody(); } - Path filePath = Paths.get(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_WEBAPPS).toString(), type); + Path filePath = Paths.get(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_WEBAPPS).toString(), type); if (subTypeBody == null) { subTypeBody = ""; @@ -573,7 +573,7 @@ public class HandleIncomingNotifications { Path getPolicySubFile(String inputFileName, String subFileType) { String filename = inputFileName; logger.info("getPolicySubFile(" + filename + ", " + subFileType + ")"); - Path filePath = Paths.get(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_WEBAPPS), subFileType); + Path filePath = Paths.get(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_WEBAPPS), subFileType); File file = null; filename = FilenameUtils.removeExtension(filename); diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/NotifyOtherPaps.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/NotifyOtherPaps.java index 34dd73c57..b703917c4 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/NotifyOtherPaps.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/NotifyOtherPaps.java @@ -35,7 +35,7 @@ import java.util.UUID; 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.jpa.PolicyDBDaoEntity; import org.onap.policy.utils.PeCryptoUtils; @@ -185,7 +185,7 @@ public class NotifyOtherPaps { int readTimeout; try { readTimeout = - Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_NOTIFY_TIMEOUT)); + Integer.parseInt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_NOTIFY_TIMEOUT)); } catch (Exception e) { LOGGER.error("xacml.rest.pap.notify.timeoutms property not set, using a default.", e); readTimeout = 10000; diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/Policy.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/Policy.java index 278e1e866..4873fc5ce 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/Policy.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/Policy.java @@ -8,9 +8,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. @@ -48,7 +48,7 @@ import org.onap.policy.common.logging.eelf.MessageCodes; import org.onap.policy.common.logging.eelf.PolicyLogger; 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.xacml.util.XACMLPolicyWriter; @@ -144,7 +144,7 @@ public abstract class Policy { /** * Return the data field of the PolicyAdapter that will be used when saving this policy with the savePolicies * method. - * + * * @return Either the PolicyAdapter.getData() or PolicyAdapter.getPolicyData() */ public abstract Object getCorrectPolicyDataObject(); @@ -327,12 +327,12 @@ public abstract class Policy { private static void loadWebapps() throws PAPException { if (actionHome == null || configHome == null) { - Path webappsPath = Paths.get(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_WEBAPPS)); + Path webappsPath = Paths.get(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_WEBAPPS)); // Sanity Check if (webappsPath == null) { - PolicyLogger.error("Invalid Webapps Path Location property : " + XACMLRestProperties.PROP_PAP_WEBAPPS); + PolicyLogger.error("Invalid Webapps Path Location property : " + XacmlRestProperties.PROP_PAP_WEBAPPS); throw new PAPException( - "Invalid Webapps Path Location property : " + XACMLRestProperties.PROP_PAP_WEBAPPS); + "Invalid Webapps Path Location property : " + XacmlRestProperties.PROP_PAP_WEBAPPS); } Path webappsPathConfig; Path webappsPathAction; diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java index 25c900393..87e684380 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java @@ -51,7 +51,7 @@ import org.onap.policy.common.logging.eelf.MessageCodes; import org.onap.policy.common.logging.eelf.PolicyLogger; 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.rest.dao.PolicyDBException; import org.onap.policy.rest.jpa.ActionBodyEntity; @@ -218,9 +218,9 @@ public class PolicyDBDao { public PolicyDBDaoTransaction getNewAuditTransaction() { logger.debug("getNewAuditTransaction() as getNewAuditTransaction() called"); // Use the standard transaction wait time in ms - int auditWaitMs = Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_TRANS_WAIT)); + int auditWaitMs = Integer.parseInt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_TRANS_WAIT)); // Use the (extended) audit timeout time in ms - int auditTimeoutMs = Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_AUDIT_TIMEOUT)); + int auditTimeoutMs = Integer.parseInt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_AUDIT_TIMEOUT)); return new PolicyDbDaoTransactionInstance(auditTimeoutMs, auditWaitMs); } @@ -249,7 +249,7 @@ public class PolicyDBDao { */ public String[] getPapUrlUserPass() { logger.debug("getPapUrl() as getPapUrl() called"); - String url = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_URL); + String url = XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_URL); if (url == null) { return null; } @@ -265,14 +265,14 @@ public class PolicyDBDao { urlUserPass[2] = commaSplit[2]; } if (urlUserPass[1] == null || "".equals(urlUserPass[1])) { - String usernamePropertyValue = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_USERID); + String usernamePropertyValue = XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_USERID); if (usernamePropertyValue != null) { urlUserPass[1] = usernamePropertyValue; } } if (urlUserPass[2] == null || "".equals(urlUserPass[2])) { String passwordPropertyValue = - PeCryptoUtils.decrypt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_PASS)); + PeCryptoUtils.decrypt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_PASS)); if (passwordPropertyValue != null) { urlUserPass[2] = passwordPropertyValue; } @@ -552,7 +552,7 @@ public class PolicyDBDao { final Criteria configDataQuery = session.createCriteria(cl.getName()); @SuppressWarnings("unchecked") final List<T> configDataResult = configDataQuery.list(); - Path webappsPath = Paths.get(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_WEBAPPS), type); + Path webappsPath = Paths.get(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_WEBAPPS), type); for (final T configData : configDataResult) { String configName = null; diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDbDaoTransactionInstance.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDbDaoTransactionInstance.java index 347db92d7..daa2d6b5d 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDbDaoTransactionInstance.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDbDaoTransactionInstance.java @@ -57,7 +57,7 @@ import org.onap.policy.common.logging.eelf.MessageCodes; import org.onap.policy.common.logging.eelf.PolicyLogger; 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.rest.dao.PolicyDBException; import org.onap.policy.rest.jpa.ActionBodyEntity; @@ -102,8 +102,8 @@ public class PolicyDbDaoTransactionInstance implements PolicyDBDaoTransaction { */ public PolicyDbDaoTransactionInstance(String test) { // call the constructor with arguments - this(Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_TRANS_TIMEOUT)), - Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_TRANS_WAIT))); + this(Integer.parseInt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_TRANS_TIMEOUT)), + Integer.parseInt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_TRANS_WAIT))); } public PolicyDbDaoTransactionInstance() { @@ -798,7 +798,7 @@ public class PolicyDbDaoTransactionInstance implements PolicyDBDaoTransaction { private String processConfigPath(String inputConfigPath) { String configPath = inputConfigPath; - String webappsPath = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_WEBAPPS); + String webappsPath = XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_WEBAPPS); if (webappsPath == null) { logger.error("Webapps property does not exist"); throw new IllegalArgumentException("Webapps property does not exist"); diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/util/AbstractPolicyCreation.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/util/AbstractPolicyCreation.java index 2b0bc3a4b..db68fb29f 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/util/AbstractPolicyCreation.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/util/AbstractPolicyCreation.java @@ -25,14 +25,14 @@ import com.google.common.base.Joiner; import java.util.UUID; -import org.onap.policy.rest.XACMLRestProperties; +import org.onap.policy.rest.XacmlRestProperties; import org.springframework.stereotype.Component; @Component public abstract class AbstractPolicyCreation { public static String getDomain() { - return XACMLProperties.getProperty(XACMLRestProperties.PROP_ADMIN_DOMAIN, "urn"); + return XACMLProperties.getProperty(XacmlRestProperties.PROP_ADMIN_DOMAIN, "urn"); } public String newPolicyID() { diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/restAuth/AuthenticationService.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/restAuth/AuthenticationService.java index ff849435e..4e938acff 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/restAuth/AuthenticationService.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/restAuth/AuthenticationService.java @@ -28,11 +28,11 @@ import java.util.StringTokenizer; import org.onap.policy.common.logging.eelf.MessageCodes; import org.onap.policy.common.logging.eelf.PolicyLogger; -import org.onap.policy.rest.XACMLRestProperties; +import org.onap.policy.rest.XacmlRestProperties; import org.onap.policy.utils.PeCryptoUtils; public class AuthenticationService { - private String papId = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_USERID); + private String papId = XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_USERID); private String papPass = null; /** @@ -51,9 +51,9 @@ public class AuthenticationService { String usernameAndPassword = null; try { - String secretKey = XACMLProperties.getProperty(XACMLRestProperties.PROP_AES_KEY); + String secretKey = XACMLProperties.getProperty(XacmlRestProperties.PROP_AES_KEY); PeCryptoUtils.initAesKey(secretKey); - papPass = PeCryptoUtils.decrypt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_PASS)); + papPass = PeCryptoUtils.decrypt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_PASS)); } catch (Exception e) { PolicyLogger.error(e); } diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDaoTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDaoTest.java index 80b546d11..07c30909a 100644 --- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDaoTest.java +++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDaoTest.java @@ -55,7 +55,7 @@ import org.onap.policy.pap.xacml.rest.DataToNotifyPdp; import org.onap.policy.pap.xacml.rest.components.PolicyDBDao.PolicyDBDaoTestClass; import org.onap.policy.pap.xacml.rest.daoimpl.CommonClassDaoImpl; import org.onap.policy.pap.xacml.rest.policycontroller.PolicyCreation; -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.PolicyDBException; import org.onap.policy.rest.jpa.DatabaseLockEntity; @@ -160,10 +160,10 @@ public class PolicyDBDaoTest { private static void setUpAuditDb() { Properties properties = new Properties(); - properties.put(XACMLRestProperties.PROP_PAP_DB_DRIVER, "org.h2.Driver"); - properties.put(XACMLRestProperties.PROP_PAP_DB_URL, "jdbc:h2:file:./sql/xacmlTest"); - properties.put(XACMLRestProperties.PROP_PAP_DB_USER, "sa"); - properties.put(XACMLRestProperties.PROP_PAP_DB_PASSWORD, ""); + properties.put(XacmlRestProperties.PROP_PAP_DB_DRIVER, "org.h2.Driver"); + properties.put(XacmlRestProperties.PROP_PAP_DB_URL, "jdbc:h2:file:./sql/xacmlTest"); + properties.put(XacmlRestProperties.PROP_PAP_DB_USER, "sa"); + properties.put(XacmlRestProperties.PROP_PAP_DB_PASSWORD, ""); // create the DB and then close it Persistence.createEntityManagerFactory("testPapPU", properties).close(); @@ -568,7 +568,7 @@ public class PolicyDBDaoTest { try { // Add 1000 ms to the timeout just to be sure it actually times out int sleepTime = - Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_TRANS_TIMEOUT)) + 1000; + Integer.parseInt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_TRANS_TIMEOUT)) + 1000; if (logger.isDebugEnabled()) { Date date = new java.util.Date(); logger.debug("\n\nPolicyDBDaoTest.threadingStabilityTest() " + "\n sleepTime = " + sleepTime @@ -603,7 +603,7 @@ public class PolicyDBDaoTest { try { // Add 1000 ms to the timeout just to be sure it actually times out int sleepTime = - Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_TRANS_TIMEOUT)) + 1000; + Integer.parseInt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_TRANS_TIMEOUT)) + 1000; if (logger.isDebugEnabled()) { Date date = new java.util.Date(); logger.debug("\n\nPolicyDBDaoTest.threadingStabilityTest() " + "\n sleepTime = " + sleepTime @@ -636,9 +636,9 @@ public class PolicyDBDaoTest { b.close(); // Now let's test the transaction wait time timeout. Shorten the wait time to 1000 ms - System.setProperty(XACMLRestProperties.PROP_PAP_TRANS_WAIT, "1000"); + System.setProperty(XacmlRestProperties.PROP_PAP_TRANS_WAIT, "1000"); // And let's lengthen the transaction timeout to 5000 ms - System.setProperty(XACMLRestProperties.PROP_PAP_TRANS_TIMEOUT, "5000"); + System.setProperty(XacmlRestProperties.PROP_PAP_TRANS_TIMEOUT, "5000"); // get a transacton PolicyDBDaoTransaction t1 = dbd.getNewTransaction(); if (logger.isDebugEnabled()) { diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/jpa/PolicyEntityTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/jpa/PolicyEntityTest.java index 550b1527c..9da3f8b5c 100644 --- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/jpa/PolicyEntityTest.java +++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/jpa/PolicyEntityTest.java @@ -35,7 +35,7 @@ import javax.persistence.Query; import org.junit.*; 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.jpa.ActionBodyEntity; import org.onap.policy.rest.jpa.ConfigurationDataEntity; import org.onap.policy.rest.jpa.PolicyDBDaoEntity; @@ -48,10 +48,10 @@ public class PolicyEntityTest { @Test public void testAllOps() { Properties properties = new Properties(); - properties.put(XACMLRestProperties.PROP_PAP_DB_DRIVER, "org.h2.Driver"); - properties.put(XACMLRestProperties.PROP_PAP_DB_URL, "jdbc:h2:file:./sql/xacmlTest"); - properties.put(XACMLRestProperties.PROP_PAP_DB_USER, "sa"); - properties.put(XACMLRestProperties.PROP_PAP_DB_PASSWORD, ""); + properties.put(XacmlRestProperties.PROP_PAP_DB_DRIVER, "org.h2.Driver"); + properties.put(XacmlRestProperties.PROP_PAP_DB_URL, "jdbc:h2:file:./sql/xacmlTest"); + properties.put(XacmlRestProperties.PROP_PAP_DB_USER, "sa"); + properties.put(XacmlRestProperties.PROP_PAP_DB_PASSWORD, ""); EntityManagerFactory emf = Persistence.createEntityManagerFactory("testPapPU", properties); EntityManager em = emf.createEntityManager(); // Start a transaction diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/PapUrlResolver.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/PapUrlResolver.java index 0fab3db61..237ed9334 100644 --- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/PapUrlResolver.java +++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/PapUrlResolver.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. @@ -31,7 +31,7 @@ import java.util.Objects; 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; public class PapUrlResolver { @@ -96,12 +96,12 @@ public class PapUrlResolver { String papUrlFailedList = failedList; String papUrlSuccessList = succeededList; if (papUrlLists == null) { - papUrlLists = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_URLS); + papUrlLists = XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_URLS); if (papUrlLists == null) { - papUrlLists = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_URL); + papUrlLists = XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_URL); } - papUrlFailedList = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_FAILED_URLS); - papUrlSuccessList = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_SUCCEEDED_URLS); + papUrlFailedList = XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_FAILED_URLS); + papUrlSuccessList = XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_SUCCEEDED_URLS); } String[] urls = papUrlLists.split(","); @@ -116,12 +116,12 @@ public class PapUrlResolver { String userId = null; String pass = null; - userId = XACMLProperties.getProperty(urls[i] + "." + XACMLRestProperties.PROP_PAP_USERID); + userId = XACMLProperties.getProperty(urls[i] + "." + XacmlRestProperties.PROP_PAP_USERID); pass = XACMLProperties.getProperty(urls[i] + "." - + PeCryptoUtils.decrypt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_PASS))); + + PeCryptoUtils.decrypt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_PASS))); if (userId == null || pass == null) { - userId = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_USERID); - pass = PeCryptoUtils.decrypt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_PASS)); + userId = XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_USERID); + pass = PeCryptoUtils.decrypt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_PASS)); } if (userId == null || pass == null) { userId = ""; @@ -216,9 +216,9 @@ public class PapUrlResolver { failedPropertyString = failedPropertyString.substring(1); succeededPropertyString = succeededPropertyString.substring(1); urlPropertyString = urlPropertyString.substring(1); - prop.setProperty(XACMLRestProperties.PROP_PAP_FAILED_URLS, failedPropertyString); - prop.setProperty(XACMLRestProperties.PROP_PAP_URLS, urlPropertyString); - prop.setProperty(XACMLRestProperties.PROP_PAP_SUCCEEDED_URLS, succeededPropertyString); + prop.setProperty(XacmlRestProperties.PROP_PAP_FAILED_URLS, failedPropertyString); + prop.setProperty(XacmlRestProperties.PROP_PAP_URLS, urlPropertyString); + prop.setProperty(XacmlRestProperties.PROP_PAP_SUCCEEDED_URLS, succeededPropertyString); return prop; } @@ -229,12 +229,12 @@ public class PapUrlResolver { } Properties prop = getProperties(); - LOGGER.debug("Failed PAP Url List: " + prop.getProperty(XACMLRestProperties.PROP_PAP_FAILED_URLS)); - LOGGER.debug("Succeeded PAP Url List: " + prop.getProperty(XACMLRestProperties.PROP_PAP_SUCCEEDED_URLS)); - XACMLProperties.setProperty(XACMLRestProperties.PROP_PAP_FAILED_URLS, - prop.getProperty(XACMLRestProperties.PROP_PAP_FAILED_URLS)); - XACMLProperties.setProperty(XACMLRestProperties.PROP_PAP_SUCCEEDED_URLS, - prop.getProperty(XACMLRestProperties.PROP_PAP_SUCCEEDED_URLS)); + LOGGER.debug("Failed PAP Url List: " + prop.getProperty(XacmlRestProperties.PROP_PAP_FAILED_URLS)); + LOGGER.debug("Succeeded PAP Url List: " + prop.getProperty(XacmlRestProperties.PROP_PAP_SUCCEEDED_URLS)); + XACMLProperties.setProperty(XacmlRestProperties.PROP_PAP_FAILED_URLS, + prop.getProperty(XacmlRestProperties.PROP_PAP_FAILED_URLS)); + XACMLProperties.setProperty(XacmlRestProperties.PROP_PAP_SUCCEEDED_URLS, + prop.getProperty(XacmlRestProperties.PROP_PAP_SUCCEEDED_URLS)); } // iterates to the next available PAP url, according to the priority order @@ -333,7 +333,7 @@ public class PapUrlResolver { // property) private Date setHandler(Object time) { if (time instanceof String) { - if ("-1".equals((String) time)) { + if ("-1".equals(time)) { return null; } try { diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpLoader.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpLoader.java index 102d43f0c..52dcd96f3 100644 --- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpLoader.java +++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpLoader.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. @@ -40,8 +40,8 @@ import java.util.Set; import org.apache.commons.io.IOUtils; import org.onap.policy.pdp.rest.notifications.NotificationController; -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.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; @@ -68,8 +68,8 @@ import com.google.common.base.Splitter; /** * Does the work for loading policy and PIP configurations sent from the PAP * servlet. - * - * + * + * * */ public class XACMLPdpLoader { @@ -167,7 +167,7 @@ public class XACMLPdpLoader { // Reset our official properties the PDP factory // uses to configure the PDP engine. // - XACMLRest.loadXacmlProperties(policyProperties, pipProperties); + XacmlRest.loadXacmlProperties(policyProperties, pipProperties); // // Dump ALL our properties that we are trying to load // @@ -195,10 +195,11 @@ public class XACMLPdpLoader { } private static HashMap<String, PolicyDef> policyContainer = null; - + public static synchronized void sendNotification(){ Thread notify = new Thread(){ - public void run(){ + @Override + public void run(){ try{ Thread.sleep(notifyDelay); NotificationController.sendNotification(); @@ -209,7 +210,7 @@ public class XACMLPdpLoader { }; notify.start(); } - + public static synchronized void validatePolicies(Properties properties, StdPDPStatus status) throws PAPException { Set<String> rootPolicies = XACMLProperties.getRootPolicyIDs(properties); @@ -239,13 +240,13 @@ public class XACMLPdpLoader { policyContainer.clear(); } - + public static synchronized void loadPolicy(Properties properties, StdPDPStatus status, String id, boolean isRoot) throws PAPException { PolicyDef policy = null; String location = null; URI locationURI = null; - boolean isFile = false; + boolean isFile = false; boolean rougeFile = false; try { location = properties.getProperty(id + ".file"); @@ -255,7 +256,7 @@ public class XACMLPdpLoader { try (InputStream is = Files.newInputStream(Paths.get(location))) { policy = DOMPolicyDef.load(is); } catch (Exception e){ - // This Happens if a any issue with the error policyFile. Lets remove it. + // This Happens if a any issue with the error policyFile. Lets remove it. try { LOGGER.error("Corrupted policy file, deleting: " + location + e); Files.delete(Paths.get(location)); @@ -296,8 +297,8 @@ public class XACMLPdpLoader { papUrls.getNext(); break; } - urlConnection.setRequestProperty(XACMLRestProperties.PROP_PDP_HTTP_HEADER_ID, - XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_ID)); + urlConnection.setRequestProperty(XacmlRestProperties.PROP_PDP_HTTP_HEADER_ID, + XACMLProperties.getProperty(XacmlRestProperties.PROP_PDP_ID)); urlConnection.setRequestProperty("Authorization", "Basic " + encoding); // // Now construct the output file name @@ -343,7 +344,7 @@ public class XACMLPdpLoader { } }while(error && errorCount>2); } - } + } if (policy != null) { status.addLoadedPolicy(new StdPDPPolicy(id, isRoot, locationURI, properties)); @@ -373,7 +374,7 @@ public class XACMLPdpLoader { try { LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Corrupted policy file, deleting: " + location); Files.delete(Paths.get(location)); - + } catch (IOException e1) { LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e1); } @@ -424,10 +425,10 @@ public class XACMLPdpLoader { * the local directory; if so create a ".file" property for it. - if not, * get the "<PolicyID>.url" property and try to GET the policy from * that location (and set the ".file" property) - * + * * If the ".file" property is created, then true is returned to tell the * caller that the props object changed. - * + * * @param props * @return true/false if anything was changed in the props object * @throws PAPException @@ -524,8 +525,8 @@ public class XACMLPdpLoader { // Open the connection // URLConnection urlConnection = url.openConnection(); - urlConnection.setRequestProperty(XACMLRestProperties.PROP_PDP_HTTP_HEADER_ID, - XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_ID)); + urlConnection.setRequestProperty(XacmlRestProperties.PROP_PDP_HTTP_HEADER_ID, + XACMLProperties.getProperty(XacmlRestProperties.PROP_PDP_ID)); urlConnection.setRequestProperty("Authorization", "Basic " + encoding); // // Copy it to disk @@ -619,7 +620,7 @@ public class XACMLPdpLoader { public static synchronized Path getPDPConfig() throws PAPException { Path config = Paths.get(XACMLProperties - .getProperty(XACMLRestProperties.PROP_PDP_CONFIG)); + .getProperty(XacmlRestProperties.PROP_PDP_CONFIG)); if (Files.notExists(config)) { LOGGER.warn(XACMLErrorConstants.ERROR_PROCESS_FLOW + config.toAbsolutePath().toString() + " does NOT exist."); // diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpRegisterThread.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpRegisterThread.java index 66a74a44f..56d82bd3f 100644 --- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpRegisterThread.java +++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpRegisterThread.java @@ -37,7 +37,7 @@ import java.util.UUID; import org.apache.commons.io.IOUtils; import org.onap.policy.pdp.rest.XACMLPdpServlet.PutRequest; -import org.onap.policy.rest.XACMLRestProperties; +import org.onap.policy.rest.XacmlRestProperties; import org.onap.policy.xacml.api.XACMLErrorConstants; import com.att.research.xacml.util.XACMLProperties; @@ -86,7 +86,7 @@ public class XACMLPdpRegisterThread implements Runnable { /* int seconds; try { - seconds = Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_REGISTER_SLEEP)); + seconds = Integer.parseInt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PDP_REGISTER_SLEEP)); } catch (NumberFormatException e) { LOGGER.error( XACMLErrorConstants.ERROR_SYSTEM_ERROR +"REGISTER_SLEEP: ", e); seconds = 5; @@ -96,7 +96,7 @@ public class XACMLPdpRegisterThread implements Runnable { } int retries; try { - retries = Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_REGISTER_RETRIES)); + retries = Integer.parseInt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PDP_REGISTER_RETRIES)); } catch (NumberFormatException e) { LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR +" REGISTER_SLEEP: ", e); retries = -1; @@ -130,7 +130,7 @@ public class XACMLPdpRegisterThread implements Runnable { // // Get the list of PAP Servlet URLs from the property file // - //String papUrlList = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_URL); + //String papUrlList = XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_URL); //String[] papUrls = papUrlList.split(","); //PapUrlResolver.setPapUrls(papUrls); URL url = new URL(papUrls.getUrl()); @@ -149,8 +149,8 @@ public class XACMLPdpRegisterThread implements Runnable { connection.setRequestProperty("Authorization", "Basic " + encoding); connection.setRequestProperty("Accept", "text/x-java-properties"); connection.setRequestProperty("Content-Type", "text/x-java-properties"); - connection.setRequestProperty(XACMLRestProperties.PROP_PDP_HTTP_HEADER_ID, XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_ID)); - connection.setRequestProperty(XACMLRestProperties.PROP_PDP_HTTP_HEADER_JMX_PORT, XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_JMX_PORT)); + connection.setRequestProperty(XacmlRestProperties.PROP_PDP_HTTP_HEADER_ID, XACMLProperties.getProperty(XacmlRestProperties.PROP_PDP_ID)); + connection.setRequestProperty(XacmlRestProperties.PROP_PDP_HTTP_HEADER_JMX_PORT, XACMLProperties.getProperty(XacmlRestProperties.PROP_PDP_JMX_PORT)); connection.setRequestProperty("X-ECOMP-RequestID", requestID.toString()); connection.setUseCaches(false); // diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpServlet.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpServlet.java index c3f0cac46..cae73ce29 100644 --- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpServlet.java +++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpServlet.java @@ -58,8 +58,8 @@ import org.onap.policy.common.logging.OnapLoggingUtils; import org.onap.policy.common.logging.eelf.MessageCodes; import org.onap.policy.common.logging.eelf.PolicyLogger; import org.onap.policy.pdp.rest.jmx.PdpRestMonitor; -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.utils.PeCryptoUtils; import org.onap.policy.xacml.api.XACMLErrorConstants; import org.onap.policy.xacml.pdp.std.functions.PolicyList; @@ -205,7 +205,7 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable { // // Initialize // - XACMLRest.xacmlInit(config); + XacmlRest.xacmlInit(config); // Load the Notification Delay. setNotificationDelay(); // Load Queue size. Not sure if we really need to have the queue bounded, we should look further into this @@ -243,7 +243,7 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable { "Error loading properties with: XACMLProperties.getProperties()"); throw new ServletException(e.getMessage(), e.getCause()); } - if (properties.getProperty(XACMLRestProperties.PDP_RESOURCE_NAME) == null) { + if (properties.getProperty(XacmlRestProperties.PDP_RESOURCE_NAME) == null) { XACMLProperties.reloadProperties(); try { properties = XACMLProperties.getProperties(); @@ -269,7 +269,7 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable { properties.getProperty("createUpdatePolicy.impl.className", CREATE_UPDATE_POLICY_SERVICE); setCreateUpdatePolicyConstructor(createUpdateResourceName); - PeCryptoUtils.initAesKey(properties.getProperty(XACMLRestProperties.PROP_AES_KEY)); + PeCryptoUtils.initAesKey(properties.getProperty(XacmlRestProperties.PROP_AES_KEY)); // Create an IntegrityMonitor try { @@ -296,7 +296,7 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable { // // Kick off our thread to register with the PAP servlet. // - if (Boolean.parseBoolean(XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_REGISTER))) { + if (Boolean.parseBoolean(XACMLProperties.getProperty(XacmlRestProperties.PROP_PDP_REGISTER))) { XACMLPdpServlet.registerRunnable = new XACMLPdpRegisterThread(baseLoggingContext); XACMLPdpServlet.registerThread = new Thread(XACMLPdpServlet.registerRunnable); XACMLPdpServlet.registerThread.start(); @@ -321,9 +321,9 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable { } private static void setPDPResourceName(Properties properties) throws ServletException { - pdpResourceName = properties.getProperty(XACMLRestProperties.PDP_RESOURCE_NAME); + pdpResourceName = properties.getProperty(XacmlRestProperties.PDP_RESOURCE_NAME); if (pdpResourceName == null) { - PolicyLogger.error(MessageCodes.MISS_PROPERTY_ERROR, XACMLRestProperties.PDP_RESOURCE_NAME, "xacml.pdp"); + PolicyLogger.error(MessageCodes.MISS_PROPERTY_ERROR, XacmlRestProperties.PDP_RESOURCE_NAME, "xacml.pdp"); throw new ServletException("pdpResourceName is null"); } } @@ -335,7 +335,7 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable { private static void setNotificationDelay() { try { XACMLPdpServlet.notificationDelay = - Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_NOTIFICATION_DELAY)); + Integer.parseInt(XACMLProperties.getProperty(XacmlRestProperties.PROP_NOTIFICATION_DELAY)); } catch (NumberFormatException e) { logger.error("Error in notification delay format, Taking the default value.", e); } @@ -445,7 +445,7 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable { // Dump our request out // if (logger.isDebugEnabled()) { - XACMLRest.dumpRequest(request); + XacmlRest.dumpRequest(request); } try { @@ -658,7 +658,7 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable { loggingContext.metricEnded(); PolicyLogger.metrics("Metric example posted here - 2 of 2"); - XACMLRest.dumpRequest(request); + XacmlRest.dumpRequest(request); String pathInfo = request.getRequestURI(); if (pathInfo != null && "/pdp/test".equals(pathInfo)) { @@ -805,7 +805,7 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable { } if (returnHB) { synchronized (pdpStatusLock) { - response.addHeader(XACMLRestProperties.PROP_PDP_HTTP_HEADER_HB, status.getStatus().toString()); + response.addHeader(XacmlRestProperties.PROP_PDP_HTTP_HEADER_HB, status.getStatus().toString()); } } loggingContext.transactionEnded(); @@ -876,7 +876,7 @@ public class XACMLPdpServlet extends HttpServlet implements Runnable { return; } - XACMLRest.dumpRequest(request); + XacmlRest.dumpRequest(request); // // Set our no-cache header // diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/NotificationService.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/NotificationService.java index d61b7c006..1d9e3e13f 100644 --- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/NotificationService.java +++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/NotificationService.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. @@ -39,7 +39,7 @@ import java.util.stream.Stream; import org.onap.policy.api.PolicyException; 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.BusPublisher; import org.onap.policy.xacml.api.XACMLErrorConstants; import org.springframework.http.HttpStatus; @@ -99,7 +99,7 @@ public class NotificationService { private static void init() { if (dmaapServers == null || aafLogin == null || aafPassword == null) { - dmaapServers = XACMLProperties.getProperty(XACMLRestProperties.PROP_NOTIFICATION_SERVERS); + dmaapServers = XACMLProperties.getProperty(XacmlRestProperties.PROP_NOTIFICATION_SERVERS); aafLogin = XACMLProperties.getProperty("DMAAP_AAF_LOGIN"); aafPassword = XACMLProperties.getProperty("DMAAP_AAF_PASSWORD"); interval = diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PAPServices.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PAPServices.java index 822599f13..516d873d4 100644 --- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PAPServices.java +++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PAPServices.java @@ -41,7 +41,7 @@ import org.onap.policy.api.PolicyException; import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.pdp.rest.restauth.AuthenticationService; -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; import org.onap.policy.xacml.std.pap.StdPDPPolicy; @@ -67,9 +67,9 @@ public class PAPServices { environment = AuthenticationService.getEnvironment(); if (paps == null) { synchronized (papResourceLock) { - String urlList = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_URLS); + String urlList = XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_URLS); if (urlList == null) { - urlList = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_URL); + urlList = XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_URL); } paps = Arrays.asList(urlList.split(",")); } @@ -78,8 +78,8 @@ public class PAPServices { private String getPAPEncoding() { if (encoding == null) { - String userID = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_USERID); - String pass = PeCryptoUtils.decrypt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_PASS)); + String userID = XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_USERID); + String pass = PeCryptoUtils.decrypt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_PASS)); Base64.Encoder encoder = Base64.getEncoder(); encoding = encoder.encodeToString((userID + ":" + pass).getBytes(StandardCharsets.UTF_8)); } diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PDPServices.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PDPServices.java index e61bbd3aa..9a5fc5ef2 100644 --- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PDPServices.java +++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PDPServices.java @@ -8,9 +8,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. @@ -70,7 +70,7 @@ import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.pdp.rest.XACMLPdpServlet; import org.onap.policy.pdp.rest.api.models.PDPResponse; -import org.onap.policy.rest.XACMLRestProperties; +import org.onap.policy.rest.XacmlRestProperties; import org.onap.policy.std.Matches; import org.onap.policy.xacml.api.XACMLErrorConstants; import org.w3c.dom.Document; @@ -207,7 +207,7 @@ public class PDPServices { if (uri == 1) { configUrl = attribute.getAttributeValue().getValue().toString(); pdpConfigLocation = configUrl.replace("$URL", - XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_WEBAPPS)); + XACMLProperties.getProperty(XacmlRestProperties.PROP_PDP_WEBAPPS)); } else { if (!("PDP".equalsIgnoreCase(attribute.getIssuer()))) { throw new PolicyException(XACMLErrorConstants.ERROR_DATA_ISSUE @@ -350,7 +350,7 @@ public class PDPServices { /** * Process Decision Result. - * + * * @param result input from Response. * @return pdpResposne based on result. */ @@ -388,7 +388,7 @@ public class PDPServices { /** * Check for Decision for decision based calls. - * + * * @param pdpResponseInput pdpResponse. * @param result result. * @return pdpResponse. @@ -420,7 +420,7 @@ public class PDPServices { /** * Check if there is a configuration. - * + * * @param advice advice. * @param configRetrieved boolean. * @param pdpResponse pdpResposneInput. @@ -431,7 +431,7 @@ public class PDPServices { if (attribute.getDataTypeId().stringValue().endsWith("anyURI")) { String configUrl = attribute.getAttributeValue().getValue().toString(); String pdpConfigLocation = - configUrl.replace("$URL", XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_WEBAPPS)); + configUrl.replace("$URL", XACMLProperties.getProperty(XacmlRestProperties.PROP_PDP_WEBAPPS)); // If there is a configuration. try { LOGGER.debug("processDecisionResult: Configuration Call to : " + configUrl); @@ -615,7 +615,7 @@ public class PDPServices { /** * Returns the requestFormat. - * + * * @return the requestFormat. */ public String getRequestFormat() { @@ -624,7 +624,7 @@ public class PDPServices { /** * Set the Request Format. - * + * * @param requestMode to set requestFormat. */ public void setRequestFormat(String requestMode) { diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/notifications/ManualNotificationUpdateThread.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/notifications/ManualNotificationUpdateThread.java index 9027e27a5..9c75e1e38 100644 --- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/notifications/ManualNotificationUpdateThread.java +++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/notifications/ManualNotificationUpdateThread.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. @@ -31,7 +31,7 @@ import java.util.UUID; 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.BusConsumer; import org.onap.policy.utils.BusPublisher; import org.onap.policy.xacml.api.XACMLErrorConstants; @@ -67,9 +67,9 @@ public class ManualNotificationUpdateThread implements Runnable { } /** - * + * * This is our thread that runs on startup if the system is configured to UEB to accept manual update requests - * + * */ @Override public void run() { @@ -85,7 +85,7 @@ public class ManualNotificationUpdateThread implements Runnable { if ("ueb".equals(propNotificationType)) { try { setCluster(); - String url = XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_ID); + String url = XACMLProperties.getProperty(XacmlRestProperties.PROP_PDP_ID); aURL = new URL(url); topic = aURL.getHost() + aURL.getPort(); } catch (NumberFormatException e) { @@ -129,8 +129,8 @@ public class ManualNotificationUpdateThread implements Runnable { } else if ("dmaap".equals(propNotificationType)) { String dmaapServers = null; try { - dmaapServers = XACMLProperties.getProperty(XACMLRestProperties.PROP_NOTIFICATION_SERVERS); - topic = XACMLProperties.getProperty(XACMLRestProperties.PROP_NOTIFICATION_TOPIC); + dmaapServers = XACMLProperties.getProperty(XacmlRestProperties.PROP_NOTIFICATION_SERVERS); + topic = XACMLProperties.getProperty(XacmlRestProperties.PROP_NOTIFICATION_TOPIC); setAAFCreds(); } catch (Exception e) { LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Unable to get DMaaP servers list:", e); @@ -145,7 +145,7 @@ public class ManualNotificationUpdateThread implements Runnable { dmaapServers = dmaapServers.trim(); topic = topic.trim(); - String consumerTopic = XACMLProperties.getProperty(XACMLRestProperties.PROP_NOTIFICATION_TOPIC).trim(); + String consumerTopic = XACMLProperties.getProperty(XacmlRestProperties.PROP_NOTIFICATION_TOPIC).trim(); sendMessage(consumerTopic, "Starting-Topic"); dmaapList = new ArrayList<>(); for (String u : dmaapServers.split(",")) { @@ -189,14 +189,14 @@ public class ManualNotificationUpdateThread implements Runnable { } private static void setCluster() { - clusterList = XACMLProperties.getProperty(XACMLRestProperties.PROP_NOTIFICATION_SERVERS); + clusterList = XACMLProperties.getProperty(XacmlRestProperties.PROP_NOTIFICATION_SERVERS); if (clusterList != null) { clusterList = clusterList.trim(); } } private static void setPropNotification() { - propNotificationType = XACMLProperties.getProperty(XACMLRestProperties.PROP_NOTIFICATION_TYPE); + propNotificationType = XACMLProperties.getProperty(XacmlRestProperties.PROP_NOTIFICATION_TYPE); } private void sendMessage(String topic, String message) { diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/notifications/NotificationController.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/notifications/NotificationController.java index c62872fbd..974ca5c01 100644 --- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/notifications/NotificationController.java +++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/notifications/NotificationController.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. @@ -44,7 +44,7 @@ import org.onap.policy.api.UpdateType; import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.pdp.rest.PapUrlResolver; -import org.onap.policy.rest.XACMLRestProperties; +import org.onap.policy.rest.XacmlRestProperties; import org.onap.policy.xacml.api.XACMLErrorConstants; import com.att.research.xacml.api.pap.PDPPolicy; @@ -61,7 +61,7 @@ import com.fasterxml.jackson.databind.ObjectWriter; /** * NotificationController Checks for the Updated and Removed policies. It notifies the Server to send Notifications to * the Client. - * + * * @version 0.2 * */ @@ -81,7 +81,7 @@ public class NotificationController { private static Boolean notificationFlag = false; public void check(PDPStatus newStatus, Map<String, PolicyDef> policyContainer) { - + LOGGER.info("NotificationController: checking for updated and removed policies."); boolean isUpdated = false; boolean isRemoved = false; @@ -101,7 +101,7 @@ public class NotificationController { LOGGER.info("There is an Update to the PDP"); LOGGER.debug(oldStatus.getLoadedPolicies()); LOGGER.debug(newStatus.getLoadedPolicies()); - + // Check if there is an Update/additions in the policy. LOGGER.info("NotificationController: check for updated or new policies"); for (PDPPolicy newPolicy : newStatus.getLoadedPolicies()) { @@ -191,8 +191,8 @@ public class NotificationController { } private static void setPropNotification() { - propNotificationType = XACMLProperties.getProperty(XACMLRestProperties.PROP_NOTIFICATION_TYPE); - pdpURL = XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_ID); + propNotificationType = XACMLProperties.getProperty(XacmlRestProperties.PROP_NOTIFICATION_TYPE); + pdpURL = XACMLProperties.getProperty(XacmlRestProperties.PROP_PDP_ID); } public static void sendNotification() { @@ -382,7 +382,7 @@ public class NotificationController { private void removeFile(PDPPolicy oldPolicy) { try { - Path removedPolicyFile = Paths.get(XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_CONFIG) + Path removedPolicyFile = Paths.get(XACMLProperties.getProperty(XacmlRestProperties.PROP_PDP_CONFIG) + File.separator + oldPolicy.getId()); Files.deleteIfExists(removedPolicyFile); boolean delete = false; @@ -390,11 +390,11 @@ public class NotificationController { if (oldPolicy.getName().contains(".Config_")) { delete = true; dir = new File( - XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_WEBAPPS) + File.separator + "Config"); + XACMLProperties.getProperty(XacmlRestProperties.PROP_PDP_WEBAPPS) + File.separator + "Config"); } else if (oldPolicy.getName().contains(".Action_")) { delete = true; dir = new File( - XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_WEBAPPS) + File.separator + "Action"); + XACMLProperties.getProperty(XacmlRestProperties.PROP_PDP_WEBAPPS) + File.separator + "Action"); } if (delete) { FileFilter fileFilter = new WildcardFileFilter( @@ -412,7 +412,7 @@ public class NotificationController { private void callPap(String urlString, String type) { Path configLocation = Paths - .get(XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_WEBAPPS) + File.separator + type); + .get(XACMLProperties.getProperty(XacmlRestProperties.PROP_PDP_WEBAPPS) + File.separator + type); if (Files.notExists(configLocation)) { try { Files.createDirectories(configLocation); diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/notifications/NotificationServer.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/notifications/NotificationServer.java index 4c2d1ef57..8c962192b 100644 --- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/notifications/NotificationServer.java +++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/notifications/NotificationServer.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. @@ -44,7 +44,7 @@ import org.onap.policy.common.logging.eelf.PolicyLogger; import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.pdp.rest.api.services.NotificationService; -import org.onap.policy.rest.XACMLRestProperties; +import org.onap.policy.rest.XacmlRestProperties; import org.onap.policy.utils.BusPublisher; import org.onap.policy.xacml.api.XACMLErrorConstants; @@ -57,8 +57,8 @@ import com.att.research.xacml.util.XACMLProperties; * The NotificationServer sends the Server Notifications to the Clients once there is any Event. * WebSockets is being used as a medium for sending Notifications. * UEB is being used as a medium for sending Notifications. - * DMAAP is being used as a medium for sending Notifications. - * + * DMAAP is being used as a medium for sending Notifications. + * * @version 0.2 * **/ @@ -67,28 +67,28 @@ public class NotificationServer { private static final Logger LOGGER = FlexLogger.getLogger(NotificationServer.class); private static Queue<Session> queue = new ConcurrentLinkedQueue<>(); private static String update = null; - + @OnOpen public void openConnection(Session session) { LOGGER.info("Session Connected: " + session.getId()); queue.add(session); } - + @OnClose public void closeConnection(Session session) { queue.remove(session); } - + @OnError public void error(Session session, Throwable t) { queue.remove(session); LOGGER.info(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Session Error for : " + session.getId() + " Error: " + t.getMessage()); - + } - + @OnMessage public void message(String message, Session session) { - + if(message.equalsIgnoreCase("Manual")) { try { session.getBasicRemote().sendText(update); @@ -96,7 +96,7 @@ public class NotificationServer { } catch (IOException e) { LOGGER.info(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error in sending the Event Notification: "+ e.getMessage() + e); LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error sending Message update"); - } + } } } @@ -115,9 +115,9 @@ public class NotificationServer { LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error in parsing out pdpURL for UEB notfication "); PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e1, "Error in parsing out pdpURL for UEB notfication "); } - String hosts = XACMLProperties.getProperty(XACMLRestProperties.PROP_NOTIFICATION_SERVERS); - String apiKey = XACMLProperties.getProperty(XACMLRestProperties.PROP_UEB_API_KEY); - String apiSecret = XACMLProperties.getProperty(XACMLRestProperties.PROP_UEB_API_SECRET); + String hosts = XACMLProperties.getProperty(XacmlRestProperties.PROP_NOTIFICATION_SERVERS); + String apiKey = XACMLProperties.getProperty(XacmlRestProperties.PROP_UEB_API_KEY); + String apiSecret = XACMLProperties.getProperty(XacmlRestProperties.PROP_UEB_API_SECRET); LOGGER.debug("Creating Publisher for host: " + hosts + " with topic: " + topic); CambriaBatchingPublisher pub = null; @@ -164,24 +164,24 @@ public class NotificationServer { } } } else if (propNotificationType.equals("dmaap")) { - + // Setting up the Publisher for DMaaP MR - String dmaapServers = XACMLProperties.getProperty(XACMLRestProperties.PROP_NOTIFICATION_SERVERS); - String topic = XACMLProperties.getProperty(XACMLRestProperties.PROP_NOTIFICATION_TOPIC); + String dmaapServers = XACMLProperties.getProperty(XacmlRestProperties.PROP_NOTIFICATION_SERVERS); + String topic = XACMLProperties.getProperty(XacmlRestProperties.PROP_NOTIFICATION_TOPIC); String aafLogin = XACMLProperties.getProperty("DMAAP_AAF_LOGIN"); String aafPassword = XACMLProperties.getProperty("DMAAP_AAF_PASSWORD"); - + try { if(dmaapServers==null || topic==null){ LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "DMaaP properties are missing from the property file "); throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "DMaaP properties are missing from the property file "); } - + dmaapServers= dmaapServers.trim(); topic= topic.trim(); aafLogin= aafLogin.trim(); aafPassword= aafPassword.trim(); - + List<String> dmaapList = null; if(dmaapServers.contains(",")) { dmaapList = new ArrayList<>(Arrays.asList(dmaapServers.split("\\s*,\\s*"))); @@ -189,23 +189,23 @@ public class NotificationServer { dmaapList = new ArrayList<>(); dmaapList.add(dmaapServers); } - - BusPublisher publisher = - new BusPublisher.DmaapPublisherWrapper(dmaapList, - topic, - aafLogin, + + BusPublisher publisher = + new BusPublisher.DmaapPublisherWrapper(dmaapList, + topic, + aafLogin, aafPassword); - + // Sending notification through DMaaP Message Router publisher.send( "MyPartitionKey", notification); LOGGER.debug("Message Published on DMaaP :" + dmaapList.get(0) + "for Topic: " + topic); publisher.close(); - + } catch (Exception e) { LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error sending notification update" + e.getMessage() + e); } } - + for(Session session: queue) { try { LOGGER.info("\n Sending Notification: " + notification + " for client session id: " + session.getId() + "\n " @@ -216,12 +216,12 @@ public class NotificationServer { LOGGER.info(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error in sending the Event Notification: "+ e.getMessage() + e); } } - + NotificationService.sendNotification(notification); } public static void setUpdate(String update) { NotificationServer.update = update; } - + } diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/restauth/AuthenticationService.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/restauth/AuthenticationService.java index 87a46aa23..54a5151c4 100644 --- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/restauth/AuthenticationService.java +++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/restauth/AuthenticationService.java @@ -42,7 +42,7 @@ import org.onap.policy.api.PolicyEngineException; import org.onap.policy.common.logging.eelf.MessageCodes; 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.AAFPolicyClient; import org.onap.policy.utils.AAFPolicyException; import org.onap.policy.utils.PeCryptoUtils; @@ -66,7 +66,7 @@ public class AuthenticationService { */ private static void setProperty() { environment = XACMLProperties.getProperty("ENVIRONMENT", "DEVL"); - String clientFile = XACMLProperties.getProperty(XACMLRestProperties.PROP_PEP_IDFILE); + String clientFile = XACMLProperties.getProperty(XacmlRestProperties.PROP_PEP_IDFILE); if (clientFile != null) { clientPath = Paths.get(clientFile); } diff --git a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/PapUrlResolverTest.java b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/PapUrlResolverTest.java index cf3ddb3b2..fb768f7d7 100644 --- a/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/PapUrlResolverTest.java +++ b/ONAP-PDP-REST/src/test/java/org/onap/policy/pdp/rest/PapUrlResolverTest.java @@ -28,7 +28,7 @@ import java.util.Date; import java.util.Properties; import org.junit.Assert; import org.junit.Test; -import org.onap.policy.rest.XACMLRestProperties; +import org.onap.policy.rest.XacmlRestProperties; public class PapUrlResolverTest { @@ -41,7 +41,7 @@ public class PapUrlResolverTest { String failed = "-1,-1,-1,-1"; String succeeded = "-1,-1,-1,-1"; PapUrlResolver rs = PapUrlResolver.getInstance(urls, failed, succeeded); - Assert.assertEquals(rs.getProperties().getProperty(XACMLRestProperties.PROP_PAP_URLS), + Assert.assertEquals(rs.getProperties().getProperty(XacmlRestProperties.PROP_PAP_URLS), urls); rs.failed(); @@ -51,12 +51,12 @@ public class PapUrlResolverTest { Assert.assertFalse(rs.hasMoreUrls()); Properties prop = rs.getProperties(); Assert.assertEquals(df.format(new Date()) + ",-1,-1,-1", - prop.getProperty(XACMLRestProperties.PROP_PAP_FAILED_URLS)); + prop.getProperty(XacmlRestProperties.PROP_PAP_FAILED_URLS)); Assert.assertEquals("-1," + df.format(new Date()) + ",-1,-1", - prop.getProperty(XACMLRestProperties.PROP_PAP_SUCCEEDED_URLS)); + prop.getProperty(XacmlRestProperties.PROP_PAP_SUCCEEDED_URLS)); - failed = prop.getProperty(XACMLRestProperties.PROP_PAP_FAILED_URLS); - succeeded = prop.getProperty(XACMLRestProperties.PROP_PAP_SUCCEEDED_URLS); + failed = prop.getProperty(XacmlRestProperties.PROP_PAP_FAILED_URLS); + succeeded = prop.getProperty(XacmlRestProperties.PROP_PAP_SUCCEEDED_URLS); rs = PapUrlResolver.getInstance(urls, failed, succeeded); Assert.assertTrue(rs.hasMoreUrls()); Assert.assertEquals("http://two.localhost.com", rs.getUrl()); @@ -74,10 +74,10 @@ public class PapUrlResolverTest { Assert.assertFalse(rs.hasMoreUrls()); prop = rs.getProperties(); Assert.assertEquals("-1,-1,-1,-1", - prop.getProperty(XACMLRestProperties.PROP_PAP_FAILED_URLS)); + prop.getProperty(XacmlRestProperties.PROP_PAP_FAILED_URLS)); - failed = prop.getProperty(XACMLRestProperties.PROP_PAP_FAILED_URLS); - succeeded = prop.getProperty(XACMLRestProperties.PROP_PAP_SUCCEEDED_URLS); + failed = prop.getProperty(XacmlRestProperties.PROP_PAP_FAILED_URLS); + succeeded = prop.getProperty(XacmlRestProperties.PROP_PAP_SUCCEEDED_URLS); rs = PapUrlResolver.getInstance(urls, failed, succeeded); Assert.assertTrue(rs.hasMoreUrls()); Assert.assertEquals("http://one.localhost.com", rs.getUrl()); @@ -85,8 +85,8 @@ public class PapUrlResolverTest { rs.getNext(); Assert.assertFalse(rs.hasMoreUrls()); prop = rs.getProperties(); - failed = prop.getProperty(XACMLRestProperties.PROP_PAP_FAILED_URLS); - succeeded = prop.getProperty(XACMLRestProperties.PROP_PAP_SUCCEEDED_URLS); + failed = prop.getProperty(XacmlRestProperties.PROP_PAP_FAILED_URLS); + succeeded = prop.getProperty(XacmlRestProperties.PROP_PAP_SUCCEEDED_URLS); rs = PapUrlResolver.getInstance(urls, failed, succeeded); Assert.assertTrue(rs.hasMoreUrls()); Assert.assertEquals("http://one.localhost.com", rs.getUrl()); @@ -94,8 +94,8 @@ public class PapUrlResolverTest { rs.getNext(); Assert.assertFalse(rs.hasMoreUrls()); prop = rs.getProperties(); - failed = prop.getProperty(XACMLRestProperties.PROP_PAP_FAILED_URLS); - succeeded = prop.getProperty(XACMLRestProperties.PROP_PAP_SUCCEEDED_URLS); + failed = prop.getProperty(XacmlRestProperties.PROP_PAP_FAILED_URLS); + succeeded = prop.getProperty(XacmlRestProperties.PROP_PAP_SUCCEEDED_URLS); rs = PapUrlResolver.getInstance(urls, failed, succeeded); Assert.assertTrue(rs.hasMoreUrls()); Assert.assertEquals("http://one.localhost.com", rs.getUrl()); @@ -104,7 +104,7 @@ public class PapUrlResolverTest { Assert.assertFalse(rs.hasMoreUrls()); prop = rs.getProperties(); - succeeded = prop.getProperty(XACMLRestProperties.PROP_PAP_SUCCEEDED_URLS); + succeeded = prop.getProperty(XacmlRestProperties.PROP_PAP_SUCCEEDED_URLS); } @SuppressWarnings("unused") diff --git a/ONAP-PDP/src/main/java/org/onap/policy/xacml/action/FindAction.java b/ONAP-PDP/src/main/java/org/onap/policy/xacml/action/FindAction.java index c256626e6..f4a196adf 100644 --- a/ONAP-PDP/src/main/java/org/onap/policy/xacml/action/FindAction.java +++ b/ONAP-PDP/src/main/java/org/onap/policy/xacml/action/FindAction.java @@ -60,7 +60,7 @@ import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.DefaultHttpClient; 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; @SuppressWarnings("deprecation") public class FindAction { @@ -159,7 +159,7 @@ public class FindAction { attribute.getAttributeValue().getValue().toString()); afterRemoveAssignments.add(attribute); } else if (attribute.getAttributeId().stringValue().equalsIgnoreCase("body")) { - String papPath = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_URL); + String papPath = XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_URL); papPath = papPath.replace("/pap", ""); matchValues.put("body", attribute.getAttributeValue().getValue().toString().replace("$URL", papPath)); diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/XacmlAdminAuthorization.java b/ONAP-REST/src/main/java/org/onap/policy/rest/XacmlAdminAuthorization.java index 184d1ff60..10b3cbfb4 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/XacmlAdminAuthorization.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/XacmlAdminAuthorization.java @@ -3,13 +3,14 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. @@ -32,9 +33,10 @@ public class XacmlAdminAuthorization { String userRole; - Role(String a) { - this.userRole = a; + Role(String userRole) { + this.userRole = userRole; } + @Override public String toString() { return this.userRole; diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/XACMLRest.java b/ONAP-REST/src/main/java/org/onap/policy/rest/XacmlRest.java index 7cced5667..011fb8868 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/XACMLRest.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/XacmlRest.java @@ -4,13 +4,14 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * 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. @@ -21,6 +22,8 @@ package org.onap.policy.rest; +import com.att.research.xacml.util.XACMLProperties; + import java.io.IOException; import java.util.Enumeration; import java.util.Map; @@ -35,37 +38,31 @@ import org.apache.commons.logging.LogFactory; import org.onap.policy.common.logging.eelf.MessageCodes; import org.onap.policy.common.logging.eelf.PolicyLogger; -import com.att.research.xacml.util.XACMLProperties; - - /** - * This static class is used by both the PDP and PAP servlet's. It contains some common - * static functions and objects used by both the servlet's. - * + * This static class is used by both the PDP and PAP servlet's. It contains some common static functions and objects + * used by both the servlet's. + * * */ -public class XACMLRest { - private static final Log logger = LogFactory.getLog(XACMLRest.class); +public class XacmlRest { + private static final Log logger = LogFactory.getLog(XacmlRest.class); private static Properties restProperties = new Properties(); - private XACMLRest(){ + private XacmlRest() { // Empty constructor } + /** - * This must be called during servlet initialization. It sets up the xacml.?.properties - * file as a system property. If the System property is already set, then it does not - * do anything. This allows the developer to specify their own xacml.properties file to be - * used. They can 1) modify the default properties that comes with the project, or 2) change - * the WebInitParam annotation, or 3) specify an alternative path in the web.xml, or 4) set - * the Java System property to point to their xacml.properties file. - * - * The recommended way of overriding the default xacml.properties file is using a Java System - * property: + * This must be called during servlet initialization. It sets up the xacml.?.properties file as a system property. + * If the System property is already set, then it does not do anything. This allows the developer to specify their + * own xacml.properties file to be used. They can 1) modify the default properties that comes with the project, or + * 2) change the WebInitParam annotation, or 3) specify an alternative path in the web.xml, or 4) set the Java + * System property to point to their xacml.properties file. * + * <p>The recommended way of overriding the default xacml.properties file is using a Java System property: * -Dxacml.properties=/opt/app/xacml/etc/xacml.admin.properties * - * This way one does not change any actual code or files in the project and can leave the - * defaults alone. + * <p>This way one does not change any actual code or files in the project and can leave the defaults alone. * * @param config - The servlet config file passed from the javax servlet init() function */ @@ -100,7 +97,7 @@ public class XACMLRest { Enumeration<String> params = config.getInitParameterNames(); while (params.hasMoreElements()) { String param = params.nextElement(); - if (! "XACML_PROPERTIES_NAME".equals(param)) { + if (!"XACML_PROPERTIES_NAME".equals(param)) { String value = config.getInitParameter(param); PolicyLogger.info(param + "=" + config.getInitParameter(param)); restProperties.setProperty(param, value); @@ -109,15 +106,14 @@ public class XACMLRest { } /** - * Reset's the XACMLProperties internal properties object so we start - * in a fresh environment. Then adds back in our Servlet init properties that were - * passed in the javax Servlet init() call. + * Reset's the XACMLProperties internal properties object so we start in a fresh environment. Then adds back in our + * Servlet init properties that were passed in the javax Servlet init() call. * - * This function is primarily used when a new configuration is passed in and the - * PDP servlet needs to load a new PDP engine instance. + * <p>This function is primarily used when a new configuration is passed in and the PDP servlet needs to load a new + * PDP engine instance. * * @param pipProperties - PIP configuration properties - * @param policyProperties - Policy configuration properties + * @param policyProperties - Policy configuration properties */ public static void loadXacmlProperties(Properties policyProperties, Properties pipProperties) { try { @@ -128,7 +124,7 @@ public class XACMLRest { // // Now load our init properties // - XACMLProperties.getProperties().putAll(XACMLRest.restProperties); + XACMLProperties.getProperties().putAll(XacmlRest.restProperties); // // Load our policy properties // @@ -142,7 +138,8 @@ public class XACMLRest { XACMLProperties.getProperties().putAll(pipProperties); } } catch (IOException e) { - PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "Failed to put init properties into Xacml properties"); + PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, + "Failed to put init properties into Xacml properties"); } // // Dump them @@ -166,12 +163,26 @@ public class XACMLRest { return; } - // special-case for receiving heartbeat - don't need to repeatedly output all of the information in multiple lines - if ("GET".equals(request.getMethod()) && "hb".equals(request.getParameter("type")) ) { + // special-case for receiving heartbeat - don't need to repeatedly output all of the information in multiple + // lines + if ("GET".equals(request.getMethod()) && "hb".equals(request.getParameter("type"))) { PolicyLogger.debug("GET type=hb : heartbeat received"); return; } - logger.debug(request.getMethod() + ":" + request.getRemoteAddr() + " " + request.getRemoteHost() + " " + request.getRemotePort()); + + dumpRequestHeadersAttributesContextPath(request); + + dumpRequestBody(request); + } + + /** + * Dump the headers, attributes, and context path of the request. + * + * @param request the request to dump + */ + private static void dumpRequestHeadersAttributesContextPath(HttpServletRequest request) { + logger.debug(request.getMethod() + ":" + request.getRemoteAddr() + " " + request.getRemoteHost() + " " + + request.getRemotePort()); logger.debug(request.getLocalAddr() + " " + request.getLocalName() + " " + request.getLocalPort()); Enumeration<String> en = request.getHeaderNames(); logger.debug("Headers:"); @@ -190,9 +201,20 @@ public class XACMLRest { logger.debug(element + ":" + request.getAttribute(element)); } logger.debug("ContextPath: " + request.getContextPath()); + } + + + /** + * Dump the body of the request. + * + * @param request the request to act on + */ + private static void dumpRequestBody(HttpServletRequest request) { if ("PUT".equals(request.getMethod()) || "POST".equals(request.getMethod())) { - // POST and PUT are allowed to have parameters in the content, but in our usage the parameters are always in the Query string. - // More importantly, there are cases where the POST and PUT content is NOT parameters (e.g. it might contain a Policy file). + // POST and PUT are allowed to have parameters in the content, but in our usage the parameters are always in + // the Query string. + // More importantly, there are cases where the POST and PUT content is NOT parameters (e.g. it might contain + // a Policy file). // Unfortunately the request.getParameterMap method reads the content to see if there are any parameters, // and once the content is read it cannot be read again. // Thus for PUT and POST we must avoid reading the content here so that the main code can read it. @@ -204,7 +226,7 @@ public class XACMLRest { logger.debug("Content available: " + request.getInputStream().available()); } } catch (Exception e) { - logger.debug("Content: inputStream exception: " + e.getMessage() + "; (May not be relevant)" +e); + logger.debug("Content: inputStream exception: " + e.getMessage() + "; (May not be relevant)" + e); } } else { logger.debug("Parameters:"); diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/XACMLRestProperties.java b/ONAP-REST/src/main/java/org/onap/policy/rest/XacmlRestProperties.java index f7f887cef..f75f80c7c 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/XACMLRestProperties.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/XacmlRestProperties.java @@ -3,6 +3,7 @@ * ONAP-REST * ================================================================================ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,52 +24,48 @@ package org.onap.policy.rest; import com.att.research.xacml.util.XACMLProperties; /** - * These are XACML Properties that are relevant to the RESTful API interface for - * the PDP, PAP and AC interfaces. + * These are XACML Properties that are relevant to the RESTful API interface for the PDP, PAP and AC interfaces. * * */ -public class XACMLRestProperties extends XACMLProperties { +public class XacmlRestProperties extends XACMLProperties { /** - * A unique identifier for the PDP servlet instance. Usually set to the URL - * it is running as in the J2EE container. + * A unique identifier for the PDP servlet instance. Usually set to the URL it is running as in the J2EE container. * - * Eg. http://localhost:8080/pdp/ + * <p>Eg. http://localhost:8080/pdp/ */ public static final String PROP_PDP_ID = "xacml.rest.pdp.id"; /** - * A PDP servlet's configuration directory. Holds the pip and policy - * configuration data as well as the local policy cache. + * A PDP servlet's configuration directory. Holds the pip and policy configuration data as well as the local policy + * cache. * - * Eg: /opt/app/xacml/config + * <p>Eg: /opt/app/xacml/config */ public static final String PROP_PDP_CONFIG = "xacml.rest.pdp.config"; // Resilience feature- public static final String PROP_PDP_WEBAPPS = "xacml.rest.pdp.webapps"; - //Closed Loop JSON table + // Closed Loop JSON table public static final String PROP_ADMIN_CLOSEDLOOP = "xacml.rest.admin.closedLoopJSON"; /** - * Set this property to true or false if the PDP servlet should register - * itself upon startup with the PAP servlet. + * Set this property to true or false if the PDP servlet should register itself upon startup with the PAP servlet. */ public static final String PROP_PDP_REGISTER = "xacml.rest.pdp.register"; /** - * Number of seconds the PDP will sleep while retrying registration with the - * PAP. This value must be greater or equal to 5. + * Number of seconds the PDP will sleep while retrying registration with the PAP. This value must be greater or + * equal to 5. */ public static final String PROP_PDP_REGISTER_SLEEP = "xacml.rest.pdp.register.sleep"; /** - * Number of retry attempts at registration with the PAP. A value of -1 - * indicates infinite retries. + * Number of retry attempts at registration with the PAP. A value of -1 indicates infinite retries. */ public static final String PROP_PDP_REGISTER_RETRIES = "xacml.rest.pdp.register.retries"; /** - * Max content length accepted for an incoming POST XML/JSON request. - * Default is 32767 bytes. + * Max content length accepted for an incoming POST XML/JSON request. Default is 32767 bytes. */ public static final String PROP_PDP_MAX_CONTENT = "xacml.rest.pdp.maxcontent"; + /** - * Custom HTTP header used by PDP to send the value of the PROP_PDP_ID + * Custom HTTP header used by PDP to send the value of the PROP_PDP_ID. */ public static final String PROP_PDP_HTTP_HEADER_ID = "X-XACML-PDP-ID"; /** @@ -76,55 +73,48 @@ public class XACMLRestProperties extends XACMLProperties { */ public static final String PROP_PDP_HTTP_HEADER_HB = "X-XACML-PDP-HB"; /* - * Custom HTTP header used by PDP to send the value of the - * X-XACML-PDP-JMX-PORT + * Custom HTTP header used by PDP to send the value of the X-XACML-PDP-JMX-PORT */ public static final String PROP_PDP_HTTP_HEADER_JMX_PORT = "X-XACML-PDP-JMX-PORT"; /** - * The URL of the PAP servlet. Used by PDP servlet's to communicate. Because - * administrators can set whatever context they want to run the PAP servlet, - * it isn't easy to determine a return URL for the PAP servlet. This is - * especially true upon initialization. + * The URL of the PAP servlet. Used by PDP servlet's to communicate. Because administrators can set whatever context + * they want to run the PAP servlet, it isn't easy to determine a return URL for the PAP servlet. This is especially + * true upon initialization. */ public static final String PROP_PAP_URL = "xacml.rest.pap.url"; /** - * A comma divided list of urls pointing to avaiable PAP urls. - * If one or more fail, the other servers in the list can - * handle the requests. + * A comma divided list of urls pointing to avaiable PAP urls. If one or more fail, the other servers in the list + * can handle the requests. */ public static final String PROP_PAP_URLS = "xacml.rest.pap.urls"; public static final String PROP_PAP_FAILED_URLS = "xacml.rest.pap.failedUrls"; public static final String PROP_PAP_SUCCEEDED_URLS = "xacml.rest.pap.succeededUrls"; /** - * Upon startup, have the PAP servlet send latest configuration information - * to all the PDP nodes it knows about. + * Upon startup, have the PAP servlet send latest configuration information to all the PDP nodes it knows about. */ public static final String PROP_PAP_INITIATE_PDP_CONFIG = "xacml.rest.pap.initiate.pdp"; /** - * The interval the PAP servlet uses to send heartbeat requests to the PDP - * nodes. + * The interval the PAP servlet uses to send heartbeat requests to the PDP nodes. */ public static final String PROP_PAP_HEARTBEAT_INTERVAL = "xacml.rest.pap.heartbeat.interval"; /** - * Timeout value used by the PAP servlet when trying to check the heartbeat - * of a PDP node. + * Timeout value used by the PAP servlet when trying to check the heartbeat of a PDP node. */ public static final String PROP_PAP_HEARTBEAT_TIMEOUT = "xacml.rest.pap.heartbeat.timeout"; /* - * This is the domain you can setup for your organization, it should be a URI. - * Eg. com:sample:foo + * This is the domain you can setup for your organization, it should be a URI. Eg. com:sample:foo */ public static final String PROP_PAP_DOMAIN = "xacml.rest.pap.domain"; /* - * Local path to where user workspaces exist. The user workspace contains temporary files, the - * user's clone of the GIT repository, anything specific to the user, etc. + * Local path to where user workspaces exist. The user workspace contains temporary files, the user's clone of the + * GIT repository, anything specific to the user, etc. */ public static final String PROP_PAP_WORKSPACE = "xacml.rest.pap.workspace"; /* - * Local path to where the GIT repository exists. + * Local path to where the GIT repository exists. * * Eg. /opt/app/xacml/repository */ @@ -166,8 +156,8 @@ public class XACMLRestProperties extends XACMLProperties { public static final String PROP_PAP_AUDIT_TIMEOUT = "xacml.rest.pap.audit.timeoutms"; /* - * Value determines direction of audit. Value=true will synch the file system to contents of the DB. - * Value=false will synch the DB to the contents of the file system. + * Value determines direction of audit. Value=true will synch the file system to contents of the DB. Value=false + * will synch the DB to the contents of the file system. */ public static final String PROP_PAP_AUDIT_FLAG = "xacml.rest.pap.filesystem.audit"; @@ -181,12 +171,12 @@ public class XACMLRestProperties extends XACMLProperties { */ public static final String PROP_PAP_NOTIFY_TIMEOUT = "xacml.rest.pap.notify.timeoutms"; /* - * Value for Enable/Disable of AutoPush Flag. + * Value for Enable/Disable of AutoPush Flag. */ public static final String PROP_PAP_PUSH_FLAG = "xacml.rest.pap.autopush.flag"; /* - * Properties file for the AutoPush Functionality. + * Properties file for the AutoPush Functionality. */ public static final String PROP_PAP_PUSH_FILE = "xacml.rest.pap.autopush.file"; @@ -197,14 +187,12 @@ public class XACMLRestProperties extends XACMLProperties { */ public static final String PROP_ADMIN_REPOSITORY = "xacml.rest.admin.repository"; /* - * Local path to where user workspaces exist. The user workspace contains - * temporary files, the user's clone of the GIT repository, anything - * specific to the user, etc. + * Local path to where user workspaces exist. The user workspace contains temporary files, the user's clone of the + * GIT repository, anything specific to the user, etc. */ public static final String PROP_ADMIN_WORKSPACE = "xacml.rest.admin.workspace"; /* - * This is the domain you can setup for your organization, it should be a - * URI. + * This is the domain you can setup for your organization, it should be a URI. * * Eg. com:sample:foo */ @@ -212,38 +200,33 @@ public class XACMLRestProperties extends XACMLProperties { /** * PROP_ADMIN_USER_NAME is simply a name for the logged in user. * - * AC authentication is out the scope of the web application itself. It is - * up to the developer to setup authentication as they please in the J2EE - * container used to run the web application. Whatever authentication - * mechanism they use, they should then set the attribute into the - * HttpSession object. The Admin Console will be able to read that value - * (default to "guest") in. + * <p>AC authentication is out the scope of the web application itself. It is up to the developer to setup + * authentication as they please in the J2EE container used to run the web application. Whatever authentication + * mechanism they use, they should then set the attribute into the HttpSession object. The Admin Console will be + * able to read that value (default to "guest") in. * - * ((HttpServletRequest) - * request).getSession().setAttribute("xacml.rest.admin.user.name", - * "Homer"); + * <p>((HttpServletRequest) request).getSession().setAttribute("xacml.rest.admin.user.name", "Homer"); * */ public static final String PROP_ADMIN_USER_NAME = "xacml.rest.admin.user.name"; + /** - * * PROP_ADMIN_USER_ID is an id for the logged in user. * - * Eg. hs1234 + * <p>Eg. hs1234 * - * @see #PROP_ADMIN_USER_NAME for more information. + * <p>@see #PROP_ADMIN_USER_NAME for more information. */ + public static final String PROP_ADMIN_USER_ID = "xacml.rest.admin.user.id"; /** - * * PROP_ADMIN_USER_EMAIL is a user's email address. * * @see #PROP_ADMIN_USER_NAME for more information. */ public static final String PROP_ADMIN_USER_EMAIL = "xacml.rest.admin.user.email"; /** - * Directory path containing sub-directories where the Subscriber servlet - * puts files sent through data feeds. + * Directory path containing sub-directories where the Subscriber servlet puts files sent through data feeds. */ public static final String PROP_SUBSCRIBER_INCOMING = "xacml.subscriber.incoming"; /** @@ -251,8 +234,7 @@ public class XACMLRestProperties extends XACMLProperties { */ public static final String PROP_SUBSCRIBER_FEED = "xacml.subscriber.feed"; /** - * Value for the log time frame that is to be stored in the database any - * logs after this time frame will be removed. + * Value for the log time frame that is to be stored in the database any logs after this time frame will be removed. */ public static final String PROP_LOG_TIMEFRAME = "xacml.log.timeframe"; /** @@ -305,7 +287,7 @@ public class XACMLRestProperties extends XACMLProperties { /* * webapps Location of the PAP-REST server */ - public static final String PROP_PAP_WEBAPPS= "xacml.rest.config.webapps"; + public static final String PROP_PAP_WEBAPPS = "xacml.rest.config.webapps"; /* * Value for Notification Option */ @@ -317,27 +299,27 @@ public class XACMLRestProperties extends XACMLProperties { /* * Value for Notification Delay */ - public static final String PROP_NOTIFICATION_DELAY= "NOTIFICATION_DELAY"; + public static final String PROP_NOTIFICATION_DELAY = "NOTIFICATION_DELAY"; /* * Value for Notification Topic */ - public static final String PROP_NOTIFICATION_TOPIC= "NOTIFICATION_TOPIC"; + public static final String PROP_NOTIFICATION_TOPIC = "NOTIFICATION_TOPIC"; /* * Value for Notification Topic */ - public static final String PROP_UEB_API_KEY= "UEB_API_KEY"; + public static final String PROP_UEB_API_KEY = "UEB_API_KEY"; /* * Value for Notification Topic */ - public static final String PROP_UEB_API_SECRET= "UEB_API_SECRET"; + public static final String PROP_UEB_API_SECRET = "UEB_API_SECRET"; /* * Closedloop Fault Policy Template Version */ - public static final String TemplateVersion_Fault= "xacml.rest.closedLoopFault"; + public static final String TEMPLATE_VERSION_FAULT = "xacml.rest.closedLoopFault"; /* * Closedloop PM Policy Template Version */ - public static final String TemplateVersion_PM= "xacml.rest.closedLoopPM"; + public static final String TEMPLATE_VERSION_PM = "xacml.rest.closedLoopPM"; /* * Value for model properties file */ @@ -345,89 +327,88 @@ public class XACMLRestProperties extends XACMLProperties { /* * MicroService Policy Template Version */ - public static final String TemplateVersion_MS= "xacml.rest.microServices"; + public static final String TEMPLATE_VERSION_MS = "xacml.rest.microServices"; /* * Optimization Policy Template Version */ - public static final String TemplateVersion_OOF= "xacml.rest.optimization"; + public static final String TEMPLATE_VERSION_OOF = "xacml.rest.optimization"; /* * Firewall Policy Template Version */ - public static final String TemplateVersion_FW= "xacml.rest.firewallPolicy"; + public static final String TEMPLATE_VERSION_FW = "xacml.rest.firewallPolicy"; /* - * Size of SelectList for Users in MS + * Size of SelectList for Users in MS * - */ - public static final String PROP_USER_SELECTLIST_WINDOW_SIZE= "xacml.user.column.count"; + */ + public static final String PROP_USER_SELECTLIST_WINDOW_SIZE = "xacml.user.column.count"; /* * Audit function in pap admin to Update userinfo table to syncronize with Roles table */ - public static final String PROP_ROLES_USERINFO_AUDIT= "xacml.audit.userInfo"; + public static final String PROP_ROLES_USERINFO_AUDIT = "xacml.audit.userInfo"; /* * test Environment LoginId */ - public static final String PROP_TEST_ENVIRONMENT_LOGINID= "xacml.testEnvironment.loginId"; + public static final String PROP_TEST_ENVIRONMENT_LOGINID = "xacml.testEnvironment.loginId"; /* - * Size of of the page length for sqlcontainer + * Size of of the page length for sqlcontainer * - */ - public static final String PROP_SQLCONTAINER_PAGE_LENGTH= "xacml.sqlcontainer.page.length"; + */ + public static final String PROP_SQLCONTAINER_PAGE_LENGTH = "xacml.sqlcontainer.page.length"; /* - * add values used to connect to restful api + * add values used to connect to restful api * - */ - public static final String PROP_RESTFUL_INTERFACE= "xacm.restful.interface.file"; + */ + public static final String PROP_RESTFUL_INTERFACE = "xacm.restful.interface.file"; /* - * add pattern to identify what values are designed as required + * add pattern to identify what values are designed as required * - */ - public static final String PROP_XCORE_REQUIRED_PATTERN= "xacm.xcor.required.pattern"; + */ + public static final String PROP_XCORE_REQUIRED_PATTERN = "xacm.xcor.required.pattern"; /* - * Time before a cache value is evicted + * Time before a cache value is evicted * - */ - public static final String PROP_CACHE_LIVE_TIME= "xacm.cache.live.time"; + */ + public static final String PROP_CACHE_LIVE_TIME = "xacm.cache.live.time"; /* - * Highest value allowed in priority + * Highest value allowed in priority * - */ - public static final String PROP_PRIORITY_COUNT= "xacml.max.priority.count"; + */ + public static final String PROP_PRIORITY_COUNT = "xacml.max.priority.count"; /* - * The name of the PAP. Must be unique across the system + * The name of the PAP. Must be unique across the system */ - public static final String PAP_RESOURCE_NAME="xacml.rest.pap.resource.name"; + public static final String PAP_RESOURCE_NAME = "xacml.rest.pap.resource.name"; /* * The name of the site in which the PAP resides */ - public static final String PAP_SITE_NAME="site_name"; + public static final String PAP_SITE_NAME = "site_name"; /* * The node type of the PAP - really a no-op since it's value is pap */ - public static final String PAP_NODE_TYPE="node_type"; + public static final String PAP_NODE_TYPE = "node_type"; /* - * A list of the groups of resources/nodes on which the PAP is dependent. The members of a - * group are comma-separated and the groups are separated with semicolons. + * A list of the groups of resources/nodes on which the PAP is dependent. The members of a group are comma-separated + * and the groups are separated with semicolons. */ - public static final String PAP_DEPENDENCY_GROUPS="dependency_groups"; + public static final String PAP_DEPENDENCY_GROUPS = "dependency_groups"; /* - * The (optional) period of time in seconds between executions of the integrity audit. - * Value < 0 : Audit does not run (default value if property is not present = -1) - * Value = 0 : Audit runs continuously - * Value > 0 : The period of time in seconds between execution of the audit on a particular node + * The (optional) period of time in seconds between executions of the integrity audit. Value < 0 : Audit does not + * run (default value if property is not present = -1) Value = 0 : Audit runs continuously Value > 0 : The period of + * time in seconds between execution of the audit on a particular node */ public static final String PAP_INTEGRITY_AUDIT_PERIOD_SECONDS = "integrity_audit_period_seconds"; /* - * The name of the Admin. Must be unique across the system + * The name of the Admin. Must be unique across the system */ - public static final String ADMIN_RESOURCE_NAME="xacml.rest.admin.resource.name"; + public static final String ADMIN_RESOURCE_NAME = "xacml.rest.admin.resource.name"; /* - * The name of the PDP. Must be unique across the system + * The name of the PDP. Must be unique across the system */ - public static final String PDP_RESOURCE_NAME="xacml.rest.pdp.resource.name"; + public static final String PDP_RESOURCE_NAME = "xacml.rest.pdp.resource.name"; /* * Audit function in pap admin to Update userinfo table to syncronize with Roles table */ - public static final String PROP_AUTOMATIC_POLICYPUSH= "xacml.automatic.push"; + public static final String PROP_AUTOMATIC_POLICYPUSH = "xacml.automatic.push"; /* * Add Limit for Onap Portal Dashboard tab data */ @@ -444,7 +425,7 @@ public class XACMLRestProperties extends XACMLProperties { /* * The number of Risk Levels allowed */ - public static final String ADMIN_RISK_LEVEL_COUNT="xacml.risk.level.count"; + public static final String ADMIN_RISK_LEVEL_COUNT = "xacml.risk.level.count"; /* * The maxium Level displayed on the UI for Micro Services */ @@ -453,7 +434,7 @@ public class XACMLRestProperties extends XACMLProperties { /* * Value for Incoming Notification tries * - * */ + */ public static final String PROP_PAP_INCOMINGNOTIFICATION_TRIES = "xacml.rest.pap.incomingnotification.tries"; /* @@ -463,7 +444,7 @@ public class XACMLRestProperties extends XACMLProperties { // Static class, hide constructor - private XACMLRestProperties() { + private XacmlRestProperties() { super(); } } diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java b/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java index 56e110019..29fb635b2 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java @@ -4,6 +4,7 @@ * ================================================================================ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd. + * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,7 +64,7 @@ import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; import org.json.JSONObject; -import org.onap.policy.rest.XACMLRestProperties; +import org.onap.policy.rest.XacmlRestProperties; import org.onap.policy.rest.dao.CommonClassDao; import org.onap.policy.rest.jpa.DictionaryData; import org.yaml.snakeyaml.Yaml; @@ -409,7 +410,7 @@ public class MSModelUtils { } public String checkRequiredPattern(int upper, int lower) { - String pattern = XACMLProperties.getProperty(XACMLRestProperties.PROP_XCORE_REQUIRED_PATTERN); + String pattern = XACMLProperties.getProperty(XacmlRestProperties.PROP_XCORE_REQUIRED_PATTERN); if (pattern != null && upper == Integer.parseInt(pattern.split(",")[1]) && lower == Integer.parseInt(pattern.split(",")[0])) { return REQUIREDTRUE; diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/XACMLRestTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/XACMLRestTest.java deleted file mode 100644 index 5b8513823..000000000 --- a/ONAP-REST/src/test/java/org/onap/policy/rest/XACMLRestTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP-REST - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.rest; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.IOException; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import javax.servlet.ServletConfig; -import javax.servlet.ServletOutputStream; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.springframework.mock.web.MockHttpServletResponse; -import org.springframework.mock.web.MockServletConfig; - -public class XACMLRestTest extends Mockito{ - private static Log logger = LogFactory.getLog(XACMLRestTest.class); - - private List<String> headers = new ArrayList<>(); - - private HttpServletRequest httpServletRequest; - private HttpServletResponse httpServletResponse; - private ServletOutputStream mockOutput; - private ServletConfig servletConfig; - - - @Before - public void setUp(){ - httpServletRequest = Mockito.mock(HttpServletRequest.class); - Mockito.when(httpServletRequest.getMethod()).thenReturn("POST"); - Mockito.when(httpServletRequest.getHeaderNames()).thenReturn(Collections.enumeration(headers)); - Mockito.when(httpServletRequest.getAttributeNames()).thenReturn(Collections.enumeration(headers)); - - mockOutput = Mockito.mock(ServletOutputStream.class); - - httpServletResponse = Mockito.mock(MockHttpServletResponse.class); - - try { - Mockito.when(httpServletResponse.getOutputStream()).thenReturn(mockOutput); - } catch (IOException e) { - fail(); - } - - servletConfig = Mockito.mock(MockServletConfig.class); - Mockito.when(servletConfig.getInitParameterNames()).thenReturn(Collections.enumeration(headers)); - Mockito.when(servletConfig.getInitParameter("XACML_PROPERTIES_NAME")).thenReturn("xacml.pdp.properties"); - - System.setProperty("xacml.properties", "xacml.pdp.properties"); - System.setProperty("xacml.rest.pdp.config", "config_testing"); - System.setProperty("xacml.rest.pep.idfile", "testclient.properties"); - System.setProperty("xacml.rest.pdp.webapps", "/webapps"); - System.setProperty("xacml.rootPolicies", "test_PolicyEngine.xml"); - System.setProperty("xacml.referencedPolicies", "test_PolicyEngine.xml"); - System.setProperty("test_PolicyEngine.xml.file", "config_testing\\test_PolicyEngine.xml"); - System.setProperty("xacml.rest.pdp.register", "false"); - } - - @Test - public void testXacmlInit(){ - logger.info("XACMLRestTest - testInit"); - try { - XACMLRest.xacmlInit(servletConfig); - Logger.getRootLogger().setLevel(Level.DEBUG); - XACMLRest.dumpRequest(httpServletRequest); - XACMLRest.loadXacmlProperties(null, null); - } catch (Exception e) { - fail(); - } - } - - @Test - public void testConstructorIsPrivate() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { - Constructor<XACMLRestProperties> constructor = XACMLRestProperties.class.getDeclaredConstructor(); - assertTrue(Modifier.isPrivate(constructor.getModifiers())); - constructor.setAccessible(true); - constructor.newInstance(); - } -}
\ No newline at end of file diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/XacmlAdminAuthorizationTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/XacmlAdminAuthorizationTest.java new file mode 100644 index 000000000..75abb4f53 --- /dev/null +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/XacmlAdminAuthorizationTest.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.rest; + +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; + +/** + * Test the XacmlAdminAuthorizaiton class. + * + * @author Liam Fallon (liam.fallon@est.tech) + */ +public class XacmlAdminAuthorizationTest { + + @Test + public void test() { + assertNotNull(new XacmlAdminAuthorization()); + } +} diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/XacmlRestTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/XacmlRestTest.java new file mode 100644 index 000000000..19800b42e --- /dev/null +++ b/ONAP-REST/src/test/java/org/onap/policy/rest/XacmlRestTest.java @@ -0,0 +1,304 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP-REST + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.rest; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import com.att.research.xacml.util.XACMLProperties; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import javax.servlet.ReadListener; +import javax.servlet.ServletConfig; +import javax.servlet.ServletInputStream; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.springframework.mock.web.MockHttpServletResponse; +import org.springframework.mock.web.MockServletConfig; + +public class XacmlRestTest extends Mockito { + private static Log logger = LogFactory.getLog(XacmlRestTest.class); + + private List<String> headers = new ArrayList<>(); + + private HttpServletRequest httpServletRequest; + private HttpServletResponse httpServletResponse; + private ServletOutputStream mockOutput; + private ServletConfig servletConfig; + private ServletInputStream servletInputStream; + + /** + * Prepare for the test. + */ + @Before + public void setUp() { + httpServletRequest = Mockito.mock(HttpServletRequest.class); + Mockito.when(httpServletRequest.getMethod()).thenReturn("POST"); + Mockito.when(httpServletRequest.getHeaderNames()).thenReturn(Collections.enumeration(headers)); + Mockito.when(httpServletRequest.getAttributeNames()).thenReturn(Collections.enumeration(headers)); + + mockOutput = Mockito.mock(ServletOutputStream.class); + + httpServletResponse = Mockito.mock(MockHttpServletResponse.class); + + try { + Mockito.when(httpServletResponse.getOutputStream()).thenReturn(mockOutput); + } catch (IOException e) { + fail(); + } + + servletConfig = Mockito.mock(MockServletConfig.class); + Mockito.when(servletConfig.getInitParameterNames()).thenReturn(Collections.enumeration(headers)); + Mockito.when(servletConfig.getInitParameter("XACML_PROPERTIES_NAME")).thenReturn("xacml.pdp.properties"); + + System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "xacml.pdp.properties"); + System.setProperty("xacml.rest.pdp.config", "config_testing"); + System.setProperty("xacml.rest.pep.idfile", "testclient.properties"); + System.setProperty("xacml.rest.pdp.webapps", "/webapps"); + System.setProperty("xacml.rootPolicies", "test_PolicyEngine.xml"); + System.setProperty("xacml.referencedPolicies", "test_PolicyEngine.xml"); + System.setProperty("test_PolicyEngine.xml.file", "config_testing\\test_PolicyEngine.xml"); + System.setProperty("xacml.rest.pdp.register", "false"); + + servletInputStream = Mockito.mock(ServletInputStream.class); + } + + @Test + public void testXacmlInit() { + logger.info("XACMLRestTest - testInit"); + + try { + XacmlRest.xacmlInit(servletConfig); + Logger.getRootLogger().setLevel(Level.DEBUG); + XacmlRest.dumpRequest(httpServletRequest); + XacmlRest.loadXacmlProperties(null, null); + } catch (Exception e) { + fail("Normal case of initiation of XACML REST failed"); + } + + System.clearProperty(XACMLProperties.XACML_PROPERTIES_NAME); + try { + XacmlRest.xacmlInit(servletConfig); + Logger.getRootLogger().setLevel(Level.DEBUG); + XacmlRest.dumpRequest(httpServletRequest); + XacmlRest.loadXacmlProperties(null, null); + } catch (Exception e) { + fail("Normal case of initiation of XACML REST failed"); + } + + System.clearProperty(XACMLProperties.XACML_PROPERTIES_NAME); + try { + Logger.getRootLogger().setLevel(Level.INFO); + XacmlRest.xacmlInit(servletConfig); + Logger.getRootLogger().setLevel(Level.DEBUG); + XacmlRest.dumpRequest(httpServletRequest); + XacmlRest.loadXacmlProperties(null, null); + } catch (Exception e) { + fail("Normal case of initiation of XACML REST failed"); + } + + System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "xacml.pdp.properties"); + + try { + Logger.getRootLogger().setLevel(Level.DEBUG); + XacmlRest.xacmlInit(servletConfig); + XacmlRest.dumpRequest(httpServletRequest); + XacmlRest.loadXacmlProperties(null, null); + } catch (Exception e) { + fail("Normal case of initiation of XACML REST failed"); + } + + Mockito.when(servletConfig.getInitParameter("XACML_PROPERTIES_NAME")).thenReturn(null); + try { + XacmlRest.xacmlInit(servletConfig); + Logger.getRootLogger().setLevel(Level.DEBUG); + XacmlRest.dumpRequest(httpServletRequest); + XacmlRest.loadXacmlProperties(null, null); + } catch (Exception e) { + fail("Normal case of initiation of XACML REST failed"); + } + + try { + Logger.getRootLogger().setLevel(Level.INFO); + XacmlRest.xacmlInit(servletConfig); + Logger.getRootLogger().setLevel(Level.DEBUG); + XacmlRest.dumpRequest(httpServletRequest); + XacmlRest.loadXacmlProperties(null, null); + } catch (Exception e) { + fail("Normal case of initiation of XACML REST failed"); + } + + Mockito.when(servletConfig.getInitParameter("XACML_PROPERTIES_NAME")).thenReturn("xacml.pdp.properties"); + + List<String> parNameList = new ArrayList<String>() { + private static final long serialVersionUID = 1L; + + { + add("Name0"); + add("Name1"); + add("Name2"); + add("XACML_PROPERTIES_NAME"); + } + }; + + Mockito.when(servletConfig.getInitParameterNames()).thenReturn(Collections.enumeration(parNameList)); + Mockito.when(servletConfig.getInitParameter("Name0")).thenReturn("Value0"); + Mockito.when(servletConfig.getInitParameter("Name1")).thenReturn("Value1"); + Mockito.when(servletConfig.getInitParameter("Name2")).thenReturn("Value2"); + try { + XacmlRest.xacmlInit(servletConfig); + Logger.getRootLogger().setLevel(Level.DEBUG); + XacmlRest.dumpRequest(httpServletRequest); + XacmlRest.loadXacmlProperties(null, null); + } catch (Exception e) { + e.printStackTrace(); + fail("Normal case of initiation of XACML REST failed"); + } + + } + + @Test + public void testConstructorIsPrivate() + throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { + Constructor<XacmlRestProperties> constructor = XacmlRestProperties.class.getDeclaredConstructor(); + assertTrue(Modifier.isPrivate(constructor.getModifiers())); + constructor.setAccessible(true); + constructor.newInstance(); + } + + @Test + public void testLoadXacmlProperties() { + XacmlRest.xacmlInit(servletConfig); + XacmlRest.loadXacmlProperties(null, null); + + XacmlRest.loadXacmlProperties(new Properties(), new Properties()); + + Logger.getRootLogger().setLevel(Level.INFO); + XacmlRest.loadXacmlProperties(new Properties(), new Properties()); + } + + @Test + public void testDumpRequest() throws IOException { + XacmlRest.xacmlInit(servletConfig); + + Logger.getRootLogger().setLevel(Level.INFO); + XacmlRest.dumpRequest(httpServletRequest); + Logger.getRootLogger().setLevel(Level.DEBUG); + + Mockito.when(httpServletRequest.getMethod()).thenReturn("GET"); + XacmlRest.dumpRequest(httpServletRequest); + Mockito.when(httpServletRequest.getParameter("type")).thenReturn("hb"); + XacmlRest.dumpRequest(httpServletRequest); + Mockito.when(httpServletRequest.getMethod()).thenReturn("POST"); + + List<String> headerNameList = new ArrayList<String>() { + private static final long serialVersionUID = 1L; + + { + add("Name0"); + add("Name1"); + } + }; + + List<String> header0List = new ArrayList<String>() { + private static final long serialVersionUID = 1L; + + { + add("Name0H0"); + add("Name0H1"); + add("Name0H2"); + } + }; + + List<String> header1List = new ArrayList<String>() { + private static final long serialVersionUID = 1L; + + { + add("Name1H0"); + add("Name1H1"); + add("Name1H2"); + } + }; + + Mockito.when(httpServletRequest.getHeaderNames()).thenReturn(Collections.enumeration(headerNameList)); + Mockito.when(httpServletRequest.getHeaders("Name0")).thenReturn(Collections.enumeration(header0List)); + Mockito.when(httpServletRequest.getHeaders("Name1")).thenReturn(Collections.enumeration(header1List)); + XacmlRest.dumpRequest(httpServletRequest); + + List<String> attributeList = new ArrayList<String>() { + private static final long serialVersionUID = 1L; + + { + add("Attribute0"); + add("Attribute1"); + } + }; + Mockito.when(httpServletRequest.getAttributeNames()).thenReturn(Collections.enumeration(attributeList)); + Mockito.when(httpServletRequest.getAttribute("Attribute0")).thenReturn("AttributeValue0"); + Mockito.when(httpServletRequest.getAttribute("Attribute1")).thenReturn("AttributeValue1"); + XacmlRest.dumpRequest(httpServletRequest); + + Mockito.when(httpServletRequest.getInputStream()).thenReturn(servletInputStream); + XacmlRest.dumpRequest(httpServletRequest); + + Mockito.when(httpServletRequest.getInputStream()).thenThrow(new IOException()); + XacmlRest.dumpRequest(httpServletRequest); + + Mockito.when(httpServletRequest.getMethod()).thenReturn("PUT"); + XacmlRest.dumpRequest(httpServletRequest); + + Map<String, String[]> parameterMap = new LinkedHashMap<>(); + String[] mapValue0 = {"MapValue0"}; + String[] mapValue1 = {"MapValue0"}; + String[] mapValue2 = {}; + parameterMap.put("Key0", mapValue0); + parameterMap.put("Key1", mapValue1); + parameterMap.put("Key2", mapValue2); + + Mockito.when(httpServletRequest.getMethod()).thenReturn("DELETE"); + Mockito.when(httpServletRequest.getParameterMap()).thenReturn(parameterMap); + XacmlRest.dumpRequest(httpServletRequest); + Mockito.when(httpServletRequest.getMethod()).thenReturn("POST"); + } +} 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; diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java index f0b3313a6..1cc41f97b 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateDcaeMicroServiceController.java @@ -87,7 +87,7 @@ import org.json.JSONArray; import org.json.JSONObject; 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.rest.dao.CommonClassDao; import org.onap.policy.rest.jpa.GroupPolicyScopeList; @@ -268,7 +268,7 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController { String json = ""; DCAEMicroServiceObject microServiceObject = new DCAEMicroServiceObject(); MicroServiceModels returnModel = new MicroServiceModels(); - microServiceObject.setTemplateVersion(XACMLProperties.getProperty(XACMLRestProperties.TemplateVersion_MS)); + microServiceObject.setTemplateVersion(XACMLProperties.getProperty(XacmlRestProperties.TEMPLATE_VERSION_MS)); if (policyAdapter.getServiceType() != null) { microServiceObject.setService(policyAdapter.getServiceType()); microServiceObject.setVersion(policyAdapter.getVersion()); diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateOptimizationController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateOptimizationController.java index eb3b3246a..0e42c78ce 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateOptimizationController.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/CreateOptimizationController.java @@ -69,7 +69,7 @@ import org.json.JSONArray; import org.json.JSONObject; 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.rest.dao.CommonClassDao; import org.onap.policy.rest.jpa.MicroserviceHeaderdeFaults; @@ -850,7 +850,7 @@ public class CreateOptimizationController extends RestrictedBaseController { private OptimizationObject setOptimizationObjectValues(PolicyRestAdapter policyAdapter) { OptimizationObject optimizationObject = new OptimizationObject(); - optimizationObject.setTemplateVersion(XACMLProperties.getProperty(XACMLRestProperties.TemplateVersion_OOF)); + optimizationObject.setTemplateVersion(XACMLProperties.getProperty(XacmlRestProperties.TEMPLATE_VERSION_OOF)); if (policyAdapter.getServiceType() != null) { optimizationObject.setService(policyAdapter.getServiceType()); diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/DashboardController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/DashboardController.java index dee92925a..0ca315bf1 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/DashboardController.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/DashboardController.java @@ -61,7 +61,7 @@ import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.dao.SystemLogDbDao; import org.onap.policy.model.PDPGroupContainer; -import org.onap.policy.rest.XACMLRestProperties; +import org.onap.policy.rest.XacmlRestProperties; import org.onap.policy.rest.dao.CommonClassDao; import org.onap.policy.rest.jpa.PolicyEntity; import org.onap.policy.utils.PolicyUtils; @@ -351,7 +351,7 @@ public class DashboardController extends RestrictedBaseController { papStatus = "CANNOT_CONNECT"; policyLogger.error("Error getting PAP status, PAP not responding to requests", e1); } - String papUrl = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_URL); + String papUrl = XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_URL); JSONObject object = new JSONObject(); object.put("system", papUrl); object.put("status", papStatus); diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java index 5e957c40c..dbf744829 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java @@ -56,7 +56,7 @@ import org.onap.policy.common.logging.flexlogger.FlexLogger; import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.model.PDPGroupContainer; import org.onap.policy.model.Roles; -import org.onap.policy.rest.XACMLRestProperties; +import org.onap.policy.rest.XacmlRestProperties; import org.onap.policy.rest.dao.CommonClassDao; import org.onap.policy.rest.jpa.Datatype; import org.onap.policy.rest.jpa.FunctionDefinition; @@ -104,7 +104,7 @@ public class PolicyController extends RestrictedBaseController { } public static String getDomain() { - return XACMLProperties.getProperty(XACMLRestProperties.PROP_ADMIN_DOMAIN, "urn"); + return XACMLProperties.getProperty(XacmlRestProperties.PROP_ADMIN_DOMAIN, "urn"); } private static final Object mapAccess = new Object(); |