Change to fix SQLInvalidAuthorizationSpecException 93/87793/6
authorMichael Mokry <michael.mokry@att.com>
Wed, 15 May 2019 17:54:25 +0000 (12:54 -0500)
committerMichael Mokry <michael.mokry@att.com>
Thu, 16 May 2019 11:44:41 +0000 (06:44 -0500)
Added code to decode password and set property

Change-Id: Ied806fcceeaa44d53ca39af636da620fb824e41d
Issue-ID: POLICY-1760
Signed-off-by: Michael Mokry <michael.mokry@att.com>
applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/CountRecentOperationsPip.java
applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/operationshistory/GetOperationOutcomePip.java
applications/guard/src/test/resources/xacml.properties

index 00f7680..7304dfc 100644 (file)
@@ -33,6 +33,7 @@ import java.sql.Timestamp;
 import java.time.Instant;
 import java.time.temporal.ChronoUnit;
 import java.util.Arrays;
+import java.util.Base64;
 import java.util.Collection;
 import java.util.Properties;
 
@@ -70,6 +71,14 @@ public class CountRecentOperationsPip extends StdOnapPip {
             //
             Properties emProperties = new Properties();
             emProperties.putAll(properties);
+
+            //
+            // Need to decode the password before creating the EntityManager
+            //
+            String decodedPassword = new String(Base64.getDecoder()
+                    .decode(emProperties.getProperty("javax.persistence.jdbc.password")));
+            emProperties.setProperty("javax.persistence.jdbc.password", decodedPassword);
+
             //
             // Create the entity manager factory
             //
index 4f327cf..f2339b1 100644 (file)
@@ -29,6 +29,7 @@ import com.att.research.xacml.std.pip.StdPIPResponse;
 import com.google.common.base.Strings;
 
 import java.util.Arrays;
+import java.util.Base64;
 import java.util.Collection;
 import java.util.Properties;
 
@@ -66,6 +67,14 @@ public class GetOperationOutcomePip extends StdOnapPip {
             //
             Properties emProperties = new Properties();
             emProperties.putAll(properties);
+
+            //
+            // Need to decode the password before creating the EntityManager
+            //
+            String decodedPassword = new String(Base64.getDecoder()
+                    .decode(emProperties.getProperty("javax.persistence.jdbc.password")));
+            emProperties.setProperty("javax.persistence.jdbc.password", decodedPassword);
+
             //
             // Create the entity manager factory
             //
index 3d4d025..252143e 100644 (file)
@@ -50,4 +50,4 @@ xacml.pip.engines=count-recent-operations,get-operation-outcome
 javax.persistence.jdbc.driver=org.h2.Driver
 javax.persistence.jdbc.url=jdbc:h2:mem:testdb;DATABASE_TO_UPPER=FALSE
 javax.persistence.jdbc.user=policy
-javax.persistence.jdbc.password=P01icY
+javax.persistence.jdbc.password=UDAxaWNZ