From 8bab2ae9a180bd8fa41074297334b2c4999274bd Mon Sep 17 00:00:00 2001 From: Viktor Kolomeyko Date: Tue, 26 Sep 2017 08:57:28 +0100 Subject: [PATCH] Derive list of countries from JDK (#1558) --- .../net/corda/core/identity/CordaX500Name.kt | 7 +- .../net/corda/core/internal/CountryCode.kt | 255 ------------------ 2 files changed, 4 insertions(+), 258 deletions(-) delete mode 100644 core/src/main/kotlin/net/corda/core/internal/CountryCode.kt diff --git a/core/src/main/kotlin/net/corda/core/identity/CordaX500Name.kt b/core/src/main/kotlin/net/corda/core/identity/CordaX500Name.kt index b662f6f1cf..a563ebb1ca 100644 --- a/core/src/main/kotlin/net/corda/core/identity/CordaX500Name.kt +++ b/core/src/main/kotlin/net/corda/core/identity/CordaX500Name.kt @@ -1,7 +1,7 @@ package net.corda.core.identity +import com.google.common.collect.ImmutableSet import net.corda.core.internal.LegalNameValidator -import net.corda.core.internal.countryCodes import net.corda.core.internal.x500Name import net.corda.core.serialization.CordaSerializable import org.bouncycastle.asn1.ASN1Encodable @@ -9,12 +9,12 @@ import org.bouncycastle.asn1.ASN1ObjectIdentifier import org.bouncycastle.asn1.x500.AttributeTypeAndValue import org.bouncycastle.asn1.x500.X500Name import org.bouncycastle.asn1.x500.style.BCStyle -import java.security.Principal +import java.util.Locale import javax.security.auth.x500.X500Principal /** * X.500 distinguished name data type customised to how Corda uses names. This restricts the attributes to those Corda - * supports, and requires that organsation, locality and country attributes are specified. See also RFC 4519 for + * supports, and requires that organisation, locality and country attributes are specified. See also RFC 4519 for * the underlying attribute type definitions * * @property commonName optional name by the which the entity is usually known. Used only for services (for @@ -78,6 +78,7 @@ data class CordaX500Name(val commonName: String?, const val MAX_LENGTH_ORGANISATION_UNIT = 64 const val MAX_LENGTH_COMMON_NAME = 64 private val supportedAttributes = setOf(BCStyle.O, BCStyle.C, BCStyle.L, BCStyle.CN, BCStyle.ST, BCStyle.OU) + private val countryCodes: Set = ImmutableSet.copyOf(Locale.getISOCountries()) @JvmStatic fun build(principal: X500Principal) : CordaX500Name { diff --git a/core/src/main/kotlin/net/corda/core/internal/CountryCode.kt b/core/src/main/kotlin/net/corda/core/internal/CountryCode.kt deleted file mode 100644 index 7e5f1ae54f..0000000000 --- a/core/src/main/kotlin/net/corda/core/internal/CountryCode.kt +++ /dev/null @@ -1,255 +0,0 @@ -package net.corda.core.internal - -import com.google.common.collect.ImmutableSet - -val countryCodes: Set = ImmutableSet.of( - "AF", - "AX", - "AL", - "DZ", - "AS", - "AD", - "AO", - "AI", - "AQ", - "AG", - "AR", - "AM", - "AW", - "AU", - "AT", - "AZ", - "BS", - "BH", - "BD", - "BB", - "BY", - "BE", - "BZ", - "BJ", - "BM", - "BT", - "BO", - "BQ", - "BA", - "BW", - "BV", - "BR", - "IO", - "BN", - "BG", - "BF", - "BI", - "KH", - "CM", - "CA", - "CV", - "KY", - "CF", - "TD", - "CL", - "CN", - "CX", - "CC", - "CO", - "KM", - "CG", - "CD", - "CK", - "CR", - "CI", - "HR", - "CU", - "CW", - "CY", - "CZ", - "DK", - "DJ", - "DM", - "DO", - "EC", - "EG", - "SV", - "GQ", - "ER", - "EE", - "ET", - "FK", - "FO", - "FJ", - "FI", - "FR", - "GF", - "PF", - "TF", - "GA", - "GM", - "GE", - "DE", - "GH", - "GI", - "GR", - "GL", - "GD", - "GP", - "GU", - "GT", - "GG", - "GN", - "GW", - "GY", - "HT", - "HM", - "VA", - "HN", - "HK", - "HU", - "IS", - "IN", - "ID", - "IR", - "IQ", - "IE", - "IM", - "IL", - "IT", - "JM", - "JP", - "JE", - "JO", - "KZ", - "KE", - "KI", - "KP", - "KR", - "KW", - "KG", - "LA", - "LV", - "LB", - "LS", - "LR", - "LY", - "LI", - "LT", - "LU", - "MO", - "MK", - "MG", - "MW", - "MY", - "MV", - "ML", - "MT", - "MH", - "MQ", - "MR", - "MU", - "YT", - "MX", - "FM", - "MD", - "MC", - "MN", - "ME", - "MS", - "MA", - "MZ", - "MM", - "NA", - "NR", - "NP", - "NL", - "NC", - "NZ", - "NI", - "NE", - "NG", - "NU", - "NF", - "MP", - "NO", - "OM", - "PK", - "PW", - "PS", - "PA", - "PG", - "PY", - "PE", - "PH", - "PN", - "PL", - "PT", - "PR", - "QA", - "RE", - "RO", - "RU", - "RW", - "BL", - "SH", - "KN", - "LC", - "MF", - "PM", - "VC", - "WS", - "SM", - "ST", - "SA", - "SN", - "RS", - "SC", - "SL", - "SG", - "SX", - "SK", - "SI", - "SB", - "SO", - "ZA", - "GS", - "SS", - "ES", - "LK", - "SD", - "SR", - "SJ", - "SZ", - "SE", - "CH", - "SY", - "TW", - "TJ", - "TZ", - "TH", - "TL", - "TG", - "TK", - "TO", - "TT", - "TN", - "TR", - "TM", - "TC", - "TV", - "UG", - "UA", - "AE", - "GB", - "US", - "UM", - "UY", - "UZ", - "VU", - "VE", - "VN", - "VG", - "VI", - "WF", - "EH", - "YE", - "ZM", - "ZW" -) \ No newline at end of file