aboutsummaryrefslogtreecommitdiffstats
path: root/certServiceClient/src/main/java
diff options
context:
space:
mode:
authorpwielebs <piotr.wielebski@nokia.com>2020-03-18 07:59:14 +0100
committerBogumil Zebek <bogumil.zebek@nokia.com>2020-03-18 11:41:56 +0000
commit0d4320e07d220219876e77f5faf301be3a8a8a49 (patch)
tree1aa87db719864a79597eb181267fcd6c74efa6a3 /certServiceClient/src/main/java
parentc16d738408ceef496be1d8bb1b22f6c0d868e6fc (diff)
Improve validation of country code
Issue-ID: AAF-1107 Signed-off-by: pwielebs <piotr.wielebski@nokia.com> Change-Id: Id8c1ca149fd65746a02ee480cfc8abbb6b9f7b5c
Diffstat (limited to 'certServiceClient/src/main/java')
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactory.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactory.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactory.java
index a914891f..092cd3c3 100644
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactory.java
+++ b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactory.java
@@ -24,6 +24,10 @@ import org.onap.aaf.certservice.client.configuration.exception.ClientConfigurati
import org.onap.aaf.certservice.client.configuration.exception.CsrConfigurationException;
import org.onap.aaf.certservice.client.configuration.model.ConfigurationModel;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
import java.util.regex.Pattern;
public abstract class AbstractConfigurationFactory<T extends ConfigurationModel> {
@@ -38,10 +42,6 @@ public abstract class AbstractConfigurationFactory<T extends ConfigurationModel>
return caName.matches("^[a-zA-Z0-9]*$");
}
- public boolean isCountryValid(String country) {
- return country.matches("^([A-Z][A-Z])$");
- }
-
public boolean isCommonNameValid(String commonName) {
return !isSpecialCharsPresent(commonName) &&
!isHttpProtocolsPresent(commonName) &&
@@ -64,4 +64,9 @@ public abstract class AbstractConfigurationFactory<T extends ConfigurationModel>
private boolean isHttpProtocolsPresent(String stringToCheck) {
return Pattern.compile("[h][t][t][p][:][/][/]|[h][t][t][p][s][:][/][/]").matcher(stringToCheck).find();
}
+
+ public boolean isCountryValid(String country) {
+ Set<String> countryNames = new HashSet<>(Arrays.asList(Locale.getISOCountries()));
+ return countryNames.contains(country);
+ }
}