From a1fd215863ad50ac28de68b0ed313ab633456310 Mon Sep 17 00:00:00 2001 From: Ross Nicoll Date: Wed, 3 May 2017 16:58:48 +0100 Subject: [PATCH] Extract common name from legal name to determine path in Driver (#613) Rewrote node name to extract common name to use as the node path for samples, to work around characters being incorrectly treated as separators. --- .../kotlin/net/corda/node/driver/Driver.kt | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/node/src/main/kotlin/net/corda/node/driver/Driver.kt b/node/src/main/kotlin/net/corda/node/driver/Driver.kt index 10acb7253b..e343a6fbab 100644 --- a/node/src/main/kotlin/net/corda/node/driver/Driver.kt +++ b/node/src/main/kotlin/net/corda/node/driver/Driver.kt @@ -74,7 +74,7 @@ interface DriverDSLExposedInterface { * @return The [NodeInfo] of the started up node retrieved from the network map service. */ @Deprecated("To be removed once X500Name is used as legal name everywhere") - fun startNode(providedName: String, + fun startNode(providedName: String?, advertisedServices: Set = emptySet(), rpcUsers: List = emptyList(), verifierType: VerifierType = VerifierType.InMemory, @@ -437,10 +437,6 @@ class DriverDSL( } } - override fun startNode(providedName: String, advertisedServices: Set, rpcUsers: List, verifierType: VerifierType, customOverrides: Map): ListenableFuture { - return startNode(X500Name(providedName), advertisedServices, rpcUsers, verifierType, customOverrides) - } - override fun startNode( providedName: X500Name?, advertisedServices: Set, @@ -448,13 +444,25 @@ class DriverDSL( verifierType: VerifierType, customOverrides: Map ): ListenableFuture { + return startNode(providedName?.toString(), advertisedServices, rpcUsers, verifierType, customOverrides) + } + + override fun startNode(providedName: String?, + advertisedServices: Set, + rpcUsers: List, + verifierType: VerifierType, + customOverrides: Map): ListenableFuture { val p2pAddress = portAllocation.nextHostAndPort() val rpcAddress = portAllocation.nextHostAndPort() val webAddress = portAllocation.nextHostAndPort() val debugPort = if (isDebug) debugPortAllocation.nextPort() else null - val name = providedName ?: X509Utilities.getDevX509Name("${pickA(name).commonName}-${p2pAddress.port}") - - val baseDirectory = driverDirectory / name.toString() + val name = providedName.toString() ?: X509Utilities.getDevX509Name("${pickA(name).commonName}-${p2pAddress.port}").toString() + val commonName = try { + X500Name(name).commonName + } catch(ex: IllegalArgumentException) { + name + } + val baseDirectory = driverDirectory / commonName val configOverrides = mapOf( "myLegalName" to name.toString(), "p2pAddress" to p2pAddress.toString(), @@ -501,7 +509,7 @@ class DriverDSL( verifierType: VerifierType, rpcUsers: List ): ListenableFuture>> { - val nodeNames = (1..clusterSize).map { "${DUMMY_NOTARY.name} $it" } + val nodeNames = (1..clusterSize).map { "Notary Node $it" } val paths = nodeNames.map { driverDirectory / it } ServiceIdentityGenerator.generateToDisk(paths, type.id, notaryName) @@ -559,7 +567,12 @@ class DriverDSL( override fun startNetworkMapService() { val debugPort = if (isDebug) debugPortAllocation.nextPort() else null val apiAddress = portAllocation.nextHostAndPort().toString() - val baseDirectory = driverDirectory / networkMapLegalName + val nodeDirectoryName = try { + X500Name(networkMapLegalName).commonName + } catch(ex: IllegalArgumentException) { + networkMapLegalName + } + val baseDirectory = driverDirectory / nodeDirectoryName val config = ConfigHelper.loadConfig( baseDirectory = baseDirectory, allowMissingConfig = true,