summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authork.kedron <k.kedron@partner.samsung.com>2019-04-29 11:37:25 +0200
committerk.kedron <k.kedron@partner.samsung.com>2019-05-06 15:49:32 +0200
commit5e60216d030f45267124e94b82c0ab8fac3b2958 (patch)
tree2c2174becd776e4ea2d8e1bfa7445df50d386a9f /src/main/java
parentb9a405eca2343594a07f6a7f8bfb5c268c95119e (diff)
Improve unit tests and sonar fixes
Add more test to CryptoUtilsTest and JsonUtilsTest. Correct sonar issue in CldsServiceItCase test - checking if stream is not null. Remove unused import in CldsHealthcheckServiceItCase. Remove unused field in DocumentBuilderTest. Add private constructor in PrincipalUtils and XmlTools. Add FEATURE_SECURE_PROCESSING feature to TransformerFactory. Change-Id: Ieeb561352697c131ebf11bc43162f63ea7096e81 Issue-ID: CLAMP-355 Signed-off-by: Krystian Kedron <k.kedron@partner.samsung.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/onap/clamp/clds/util/CryptoUtils.java2
-rw-r--r--src/main/java/org/onap/clamp/clds/util/XmlTools.java8
-rw-r--r--src/main/java/org/onap/clamp/util/PrincipalUtils.java6
3 files changed, 15 insertions, 1 deletions
diff --git a/src/main/java/org/onap/clamp/clds/util/CryptoUtils.java b/src/main/java/org/onap/clamp/clds/util/CryptoUtils.java
index f08bf7b28..85aae0a5d 100644
--- a/src/main/java/org/onap/clamp/clds/util/CryptoUtils.java
+++ b/src/main/java/org/onap/clamp/clds/util/CryptoUtils.java
@@ -162,7 +162,7 @@ public final class CryptoUtils {
private static SecretKeySpec readSecretKeySpec(String propertiesFileName) {
Properties props = new Properties();
try {
- //Workaround fix to make encryption key configurable
+ // Workaround fix to make encryption key configurable
// System environment variable takes precedence for over clds/key.properties
String encryptionKey = System.getenv(AES_ENCRYPTION_KEY);
if(encryptionKey != null && encryptionKey.trim().length() > 0) {
diff --git a/src/main/java/org/onap/clamp/clds/util/XmlTools.java b/src/main/java/org/onap/clamp/clds/util/XmlTools.java
index a812fa127..a7d4ed9fb 100644
--- a/src/main/java/org/onap/clamp/clds/util/XmlTools.java
+++ b/src/main/java/org/onap/clamp/clds/util/XmlTools.java
@@ -24,6 +24,7 @@
package org.onap.clamp.clds.util;
import java.io.StringWriter;
+import javax.xml.XMLConstants;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
@@ -39,6 +40,12 @@ import org.w3c.dom.Document;
public class XmlTools {
/**
+ * Private constructor to avoid creating instances of util class.
+ */
+ private XmlTools(){
+ }
+
+ /**
* Transforms document to XML string.
*
* @param doc XML document
@@ -47,6 +54,7 @@ public class XmlTools {
public static String exportXmlDocumentAsString(Document doc) {
try {
TransformerFactory tf = TransformerFactory.newInstance();
+ tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
Transformer transformer = tf.newTransformer();
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
StringWriter writer = new StringWriter();
diff --git a/src/main/java/org/onap/clamp/util/PrincipalUtils.java b/src/main/java/org/onap/clamp/util/PrincipalUtils.java
index d6b20f30b..d6dfacbdb 100644
--- a/src/main/java/org/onap/clamp/util/PrincipalUtils.java
+++ b/src/main/java/org/onap/clamp/util/PrincipalUtils.java
@@ -38,6 +38,12 @@ public class PrincipalUtils {
private static SecurityContext securityContext = SecurityContextHolder.getContext();
/**
+ * Private constructor to avoid creating instances of util class.
+ */
+ private PrincipalUtils(){
+ }
+
+ /**
* Get the Full name.
*
* @return The user name