aboutsummaryrefslogtreecommitdiffstats
path: root/certServiceClient/src/main
diff options
context:
space:
mode:
authorpwielebs <piotr.wielebski@nokia.com>2020-03-18 15:40:44 +0100
committerPiotr Wielebski <piotr.wielebski@nokia.com>2020-03-19 10:43:48 +0000
commit7186c63f4d7e0ffea202f793c5c5d769e0e08af2 (patch)
treebdafe4e52803be731070b02b2a1632cd204b67b2 /certServiceClient/src/main
parent0d4320e07d220219876e77f5faf301be3a8a8a49 (diff)
Improve validation of country code (2)
Issue-ID: AAF-1107 Signed-off-by: pwielebs <piotr.wielebski@nokia.com> Change-Id: I2de9d1ddb01212d6953699c82556a342ab8c70cd
Diffstat (limited to 'certServiceClient/src/main')
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactory.java11
1 files changed, 4 insertions, 7 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 092cd3c3..b72ef7a1 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
@@ -25,9 +25,7 @@ import org.onap.aaf.certservice.client.configuration.exception.CsrConfigurationE
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> {
@@ -53,6 +51,10 @@ public abstract class AbstractConfigurationFactory<T extends ConfigurationModel>
return Pattern.compile("[~#@*$+%!()?/{}<>\\|_^]").matcher(stringToCheck).find();
}
+ public boolean isCountryValid(String country) {
+ return Arrays.asList(Locale.getISOCountries()).contains(country);
+ }
+
private boolean isPortNumberPresent(String stringToCheck) {
return Pattern.compile(":[0-9]{1,5}").matcher(stringToCheck).find();
}
@@ -64,9 +66,4 @@ 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);
- }
}