diff options
Diffstat (limited to 'certServiceClient/src/main/java')
-rw-r--r-- | certServiceClient/src/main/java/org/onap/aaf/certservice/client/configuration/factory/AbstractConfigurationFactory.java | 13 |
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); + } } |