Legal name validation for X500Name (#983)

* * Legal name validation for X500Name while loading from config file.

* * Removed unintended changes.
This commit is contained in:
Patrick Kuo
2017-07-11 12:09:30 +01:00
committed by GitHub
parent d52b0e5db9
commit 7e8de79848
5 changed files with 15 additions and 8 deletions

View File

@ -3,6 +3,7 @@ package net.corda.nodeapi.config
import com.typesafe.config.Config
import com.typesafe.config.ConfigUtil
import net.corda.core.noneOrSingle
import net.corda.core.utilities.validateX500Name
import net.corda.core.utilities.NetworkHostAndPort
import net.corda.core.utilities.parseNetworkHostAndPort
import org.bouncycastle.asn1.x500.X500Name
@ -72,7 +73,7 @@ private fun Config.getSingleValue(path: String, type: KType): Any? {
Path::class -> Paths.get(getString(path))
URL::class -> URL(getString(path))
Properties::class -> getConfig(path).toProperties()
X500Name::class -> X500Name(getString(path))
X500Name::class -> X500Name(getString(path)).apply(::validateX500Name)
else -> if (typeClass.java.isEnum) {
parseEnum(typeClass.java, getString(path))
} else {

View File

@ -112,7 +112,7 @@ class ConfigParsingTest {
@Test
fun x500Name() {
testPropertyType<X500NameData, X500NameListData, X500Name>(getTestX509Name("Mock Node"), getTestX509Name("Mock Node 2"), valuesToString = true)
testPropertyType<X500NameData, X500NameListData, X500Name>(getTestX509Name("Mock Party"), getTestX509Name("Mock Party 2"), valuesToString = true)
}
@Test