aboutsummaryrefslogtreecommitdiffstats
path: root/aai-aaf-auth
diff options
context:
space:
mode:
authorLiard Samuel <samuel.liard@orange.com>2021-06-30 19:06:16 +0200
committerSamuel Liard <samuel.liard@gmail.com>2021-07-02 09:30:45 +0200
commita2f7d11ca0bd58ec6c252111ddd3d5dfac0e4c70 (patch)
tree2c12ab019a9456d928da715198b4bb91b3678b36 /aai-aaf-auth
parentfe71e2611b2bfecc65ef121631360b4c32ca129e (diff)
Fix all blocker sonar issues and some checkstyle
Issue-ID: AAI-3362 Signed-off-by: sliard <samuel.liard@gmail.com> Change-Id: I365be3e8afe75b54f5a65deadb054df73857274e
Diffstat (limited to 'aai-aaf-auth')
-rw-r--r--aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/CertUtil.java30
1 files changed, 18 insertions, 12 deletions
diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/CertUtil.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/CertUtil.java
index 334a3060..26273a6a 100644
--- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/CertUtil.java
+++ b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/CertUtil.java
@@ -20,23 +20,27 @@
package org.onap.aai.aaf.auth;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
-import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.security.cert.X509Certificate;
-import java.util.*;
import java.util.stream.Collectors;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* The Class CertUtil provides cert related utility methods.
*/
public class CertUtil {
- public static final String DEFAULT_CADI_ISSUERS =
- "CN=ATT AAF CADI Test Issuing CA 01, OU=CSO, O=ATT, C=US:CN=ATT AAF CADI Test Issuing CA 02, OU=CSO, O=ATT, C=US";
+ public static final String DEFAULT_CADI_ISSUERS = "CN=ATT AAF CADI Test Issuing " +
+ "CA 01, OU=CSO, O=ATT, C=US:CN=ATT AAF CADI Test Issuing CA 02, OU=CSO, O=ATT, C=US";
public static final String CADI_PROP_FILES = "cadi_prop_files";
public static final String CADI_ISSUERS_PROP_NAME = "cadi_x509_issuers";
public static final String CADI_ISSUERS_SEPARATOR = ":";
@@ -119,11 +123,11 @@ public class CertUtil {
public static List<String> getCadiCertIssuers(Properties cadiProperties) {
- List<String> defaultList = new ArrayList<String>();
+ List<String> defaultList = new ArrayList<>();
List<String> resultList = new ArrayList<String>();
- String[] cIssuers = DEFAULT_CADI_ISSUERS.split(CADI_ISSUERS_SEPARATOR);
- for (String issuer : cIssuers) {
+ String[] cadiIssuers = DEFAULT_CADI_ISSUERS.split(CADI_ISSUERS_SEPARATOR);
+ for (String issuer : cadiIssuers) {
defaultList.add(issuer.replaceAll("\\s+", "").toUpperCase());
}
try {
@@ -131,12 +135,14 @@ public class CertUtil {
String configuredIssuers = DEFAULT_CADI_ISSUERS;
Properties certProperties = new Properties();
if (certPropFileName != null) {
- certProperties.load(new FileInputStream(new File(certPropFileName)));
+ try (FileInputStream fis = new FileInputStream(certPropFileName)) {
+ certProperties.load(fis);
+ }
configuredIssuers = certProperties.getProperty(CADI_ISSUERS_PROP_NAME);
}
if ((configuredIssuers != null) && (!configuredIssuers.isEmpty())) {
- cIssuers = configuredIssuers.split(CADI_ISSUERS_SEPARATOR);
- for (String issuer : cIssuers) {
+ cadiIssuers = configuredIssuers.split(CADI_ISSUERS_SEPARATOR);
+ for (String issuer : cadiIssuers) {
resultList.add(issuer.replaceAll("\\s+", "").toUpperCase());
}
}