From 7186c63f4d7e0ffea202f793c5c5d769e0e08af2 Mon Sep 17 00:00:00 2001 From: pwielebs Date: Wed, 18 Mar 2020 15:40:44 +0100 Subject: Improve validation of country code (2) Issue-ID: AAF-1107 Signed-off-by: pwielebs Change-Id: I2de9d1ddb01212d6953699c82556a342ab8c70cd --- .../configuration/factory/AbstractConfigurationFactory.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'certServiceClient/src') 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 { @@ -53,6 +51,10 @@ public abstract class AbstractConfigurationFactory 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 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 countryNames = new HashSet<>(Arrays.asList(Locale.getISOCountries())); - return countryNames.contains(country); - } } -- cgit 1.2.3-korg