Format java POLICY-SDK-APP
[policy/engine.git] / POLICY-SDK-APP / src / main / java / org / onap / policy / admin / CheckPDP.java
index f918159..0965ee6 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
  * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * Modifications Copyright (C) 2019 Bell Canada
  * ================================================================================
@@ -22,6 +22,7 @@
 
 package org.onap.policy.admin;
 
+import com.att.research.xacml.util.XACMLProperties;
 
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -42,10 +43,9 @@ 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.utils.PeCryptoUtils;
 import org.onap.policy.xacml.api.XACMLErrorConstants;
 
-import com.att.research.xacml.util.XACMLProperties;
-
 /**
  * What is not good about this class is that once a value has been set for pdpProperties path you cannot change it. That
  * may be ok for a highly controlled production environment in which nothing changes, but not a very good
@@ -64,7 +64,7 @@ public class CheckPDP {
     private static final Logger LOGGER = FlexLogger.getLogger(CheckPDP.class);
 
     private CheckPDP() {
-        //default constructor
+        // default constructor
     }
 
     public static Map<String, String> getPdpMap() {
@@ -105,9 +105,8 @@ public class CheckPDP {
         } else if (pdpPath == null) {
             pdpPath = Paths.get(pdpFile);
             if (!pdpPath.toString().endsWith(".properties") || !pdpPath.toFile().exists()) {
-                LOGGER.error(
-                    XACMLErrorConstants.ERROR_SYSTEM_ERROR + "File doesn't exist in the specified Path : " + pdpPath
-                        .toString());
+                LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "File doesn't exist in the specified Path : "
+                        + pdpPath.toString());
                 CheckPDP.reset();
                 return;
             }
@@ -170,11 +169,11 @@ public class CheckPDP {
             if (pdpValues.size() == 3) {
                 // 1:2 will be UserID:Password
                 String userID = pdpValues.get(1);
-                String pass = pdpValues.get(2);
+                String pass = PeCryptoUtils.decrypt(pdpValues.get(2));
                 Base64.Encoder encoder = Base64.getEncoder();
                 // 0 - PDPURL
                 pdpMap.put(pdpValues.get(0),
-                    encoder.encodeToString((userID + ":" + pass).getBytes(StandardCharsets.UTF_8)));
+                        encoder.encodeToString((userID + ":" + pass).getBytes(StandardCharsets.UTF_8)));
             } else {
                 LOGGER.error(XACMLErrorConstants.ERROR_PERMISSIONS + "No Credentials to send Request: " + pdpValues);
             }