summaryrefslogtreecommitdiffstats
path: root/aai-aaf-auth/src
diff options
context:
space:
mode:
authorWilliam Reehil <william.reehil@att.com>2021-07-08 13:34:54 +0000
committerGerrit Code Review <gerrit@onap.org>2021-07-08 13:34:54 +0000
commit03e4a9c48f9fe3ce7ed2ff2d7808eb7e62cbc573 (patch)
treec1f44e44cf9ad4f55d15d6fcae5717eb6dac63d5 /aai-aaf-auth/src
parent89ea55bd33bffeca2a3f3781c0fcacaf18077002 (diff)
parenta2f7d11ca0bd58ec6c252111ddd3d5dfac0e4c70 (diff)
Merge "Fix all blocker sonar issues and some checkstyle"
Diffstat (limited to 'aai-aaf-auth/src')
-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());
}
}