mirror of
https://github.com/corda/corda.git
synced 2025-06-06 01:11:45 +00:00
Create X.500 names for DemoBench nodes. (#674)
This commit is contained in:
parent
e981632184
commit
6bc885fb09
@ -127,7 +127,7 @@ distributions {
|
|||||||
* Bundles the application using JavaPackager,
|
* Bundles the application using JavaPackager,
|
||||||
* using the ZIP distribution as source.
|
* using the ZIP distribution as source.
|
||||||
*/
|
*/
|
||||||
task javapackage(dependsOn: 'distZip') {
|
task javapackage(dependsOn: distZip) {
|
||||||
|
|
||||||
doLast {
|
doLast {
|
||||||
delete([pkg_source, pkg_outDir])
|
delete([pkg_source, pkg_outDir])
|
||||||
|
@ -4,7 +4,6 @@ import com.typesafe.config.*
|
|||||||
import net.corda.core.crypto.location
|
import net.corda.core.crypto.location
|
||||||
import net.corda.nodeapi.User
|
import net.corda.nodeapi.User
|
||||||
import org.bouncycastle.asn1.x500.X500Name
|
import org.bouncycastle.asn1.x500.X500Name
|
||||||
import org.bouncycastle.asn1.x500.style.BCStyle
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
package net.corda.demobench.model
|
package net.corda.demobench.model
|
||||||
|
|
||||||
|
import net.corda.core.crypto.X509Utilities.getX509Name
|
||||||
import net.corda.demobench.plugin.PluginController
|
import net.corda.demobench.plugin.PluginController
|
||||||
import net.corda.demobench.pty.R3Pty
|
import net.corda.demobench.pty.R3Pty
|
||||||
import org.bouncycastle.asn1.x500.X500Name
|
|
||||||
import tornadofx.*
|
import tornadofx.*
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.lang.management.ManagementFactory
|
import java.lang.management.ManagementFactory
|
||||||
import java.net.ServerSocket
|
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
@ -50,9 +49,15 @@ class NodeController(check: atRuntime = ::checkExists) : Controller() {
|
|||||||
* Validate a Node configuration provided by [net.corda.demobench.views.NodeTabView].
|
* Validate a Node configuration provided by [net.corda.demobench.views.NodeTabView].
|
||||||
*/
|
*/
|
||||||
fun validate(nodeData: NodeData): NodeConfig? {
|
fun validate(nodeData: NodeData): NodeConfig? {
|
||||||
|
val location = nodeData.nearestCity.value
|
||||||
val config = NodeConfig(
|
val config = NodeConfig(
|
||||||
baseDir,
|
baseDir,
|
||||||
X500Name(nodeData.legalName.value.trim()),
|
getX509Name(
|
||||||
|
myLegalName = nodeData.legalName.value.trim(),
|
||||||
|
email = "corda@city.${location.countryCode.toLowerCase()}.example",
|
||||||
|
nearestCity = location.description,
|
||||||
|
country = location.countryCode
|
||||||
|
),
|
||||||
nodeData.p2pPort.value,
|
nodeData.p2pPort.value,
|
||||||
nodeData.rpcPort.value,
|
nodeData.rpcPort.value,
|
||||||
nodeData.webPort.value,
|
nodeData.webPort.value,
|
||||||
|
@ -14,6 +14,7 @@ import javafx.scene.layout.Pane
|
|||||||
import javafx.scene.layout.Priority
|
import javafx.scene.layout.Priority
|
||||||
import javafx.stage.FileChooser
|
import javafx.stage.FileChooser
|
||||||
import javafx.util.StringConverter
|
import javafx.util.StringConverter
|
||||||
|
import net.corda.core.crypto.commonName
|
||||||
import net.corda.core.div
|
import net.corda.core.div
|
||||||
import net.corda.core.exists
|
import net.corda.core.exists
|
||||||
import net.corda.core.node.CityDatabase
|
import net.corda.core.node.CityDatabase
|
||||||
@ -24,7 +25,6 @@ import net.corda.core.utilities.validateLegalName
|
|||||||
import net.corda.core.writeLines
|
import net.corda.core.writeLines
|
||||||
import net.corda.demobench.model.*
|
import net.corda.demobench.model.*
|
||||||
import net.corda.demobench.ui.CloseableTab
|
import net.corda.demobench.ui.CloseableTab
|
||||||
import org.bouncycastle.asn1.x500.style.RFC4519Style.name
|
|
||||||
import org.controlsfx.control.CheckListView
|
import org.controlsfx.control.CheckListView
|
||||||
import tornadofx.*
|
import tornadofx.*
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
@ -267,7 +267,7 @@ class NodeTabView : Fragment() {
|
|||||||
if (countryCode != null) {
|
if (countryCode != null) {
|
||||||
nodeTab.graphic = ImageView(flags.get()[countryCode]).apply { fitWidth = 24.0; isPreserveRatio = true }
|
nodeTab.graphic = ImageView(flags.get()[countryCode]).apply { fitWidth = 24.0; isPreserveRatio = true }
|
||||||
}
|
}
|
||||||
nodeTab.text = config.legalName.toString()
|
nodeTab.text = config.legalName.commonName
|
||||||
nodeTerminalView.open(config) { exitCode ->
|
nodeTerminalView.open(config) { exitCode ->
|
||||||
Platform.runLater {
|
Platform.runLater {
|
||||||
if (exitCode == 0)
|
if (exitCode == 0)
|
||||||
|
@ -17,6 +17,7 @@ import javafx.scene.layout.StackPane
|
|||||||
import javafx.scene.layout.HBox
|
import javafx.scene.layout.HBox
|
||||||
import javafx.scene.layout.VBox
|
import javafx.scene.layout.VBox
|
||||||
import javafx.util.Duration
|
import javafx.util.Duration
|
||||||
|
import net.corda.core.crypto.commonName
|
||||||
import net.corda.core.failure
|
import net.corda.core.failure
|
||||||
import net.corda.core.success
|
import net.corda.core.success
|
||||||
import net.corda.core.then
|
import net.corda.core.then
|
||||||
@ -64,7 +65,7 @@ class NodeTerminalView : Fragment() {
|
|||||||
private lateinit var swingTerminal: SwingNode
|
private lateinit var swingTerminal: SwingNode
|
||||||
|
|
||||||
fun open(config: NodeConfig, onExit: (Int) -> Unit) {
|
fun open(config: NodeConfig, onExit: (Int) -> Unit) {
|
||||||
nodeName.text = config.legalName.toString()
|
nodeName.text = config.legalName.commonName
|
||||||
|
|
||||||
swingTerminal = SwingNode()
|
swingTerminal = SwingNode()
|
||||||
swingTerminal.setOnMouseClicked {
|
swingTerminal.setOnMouseClicked {
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package net.corda.demobench.model
|
package net.corda.demobench.model
|
||||||
|
|
||||||
import net.corda.core.crypto.X509Utilities
|
import net.corda.core.crypto.X509Utilities.getX509Name
|
||||||
import net.corda.core.utilities.DUMMY_NOTARY
|
import net.corda.core.utilities.DUMMY_NOTARY
|
||||||
import net.corda.nodeapi.User
|
import net.corda.nodeapi.User
|
||||||
import org.bouncycastle.asn1.x500.X500Name
|
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
@ -13,13 +12,13 @@ class NodeControllerTest {
|
|||||||
|
|
||||||
private val baseDir: Path = Paths.get(".").toAbsolutePath()
|
private val baseDir: Path = Paths.get(".").toAbsolutePath()
|
||||||
private val controller = NodeController({ _, _ -> })
|
private val controller = NodeController({ _, _ -> })
|
||||||
private val node1Name = X500Name("CN=Node 1,OU=Corda QA Department,O=R3 CEV,L=New York,C=US")
|
private val node1Name = "Node 1"
|
||||||
private val node2Name = X500Name("CN=Node 2,OU=Corda QA Department,O=R3 CEV,L=New York,C=US")
|
private val node2Name = "Node 2"
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test unique nodes after validate`() {
|
fun `test unique nodes after validate`() {
|
||||||
val data = NodeData()
|
val data = NodeData()
|
||||||
data.legalName.value = node1Name.toString()
|
data.legalName.value = node1Name
|
||||||
assertNotNull(controller.validate(data))
|
assertNotNull(controller.validate(data))
|
||||||
assertNull(controller.validate(data))
|
assertNull(controller.validate(data))
|
||||||
}
|
}
|
||||||
@ -27,7 +26,7 @@ class NodeControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
fun `test unique key after validate`() {
|
fun `test unique key after validate`() {
|
||||||
val data = NodeData()
|
val data = NodeData()
|
||||||
data.legalName.value = node1Name.toString()
|
data.legalName.value = node1Name
|
||||||
|
|
||||||
assertFalse(controller.keyExists("node1"))
|
assertFalse(controller.keyExists("node1"))
|
||||||
controller.validate(data)
|
controller.validate(data)
|
||||||
@ -37,7 +36,7 @@ class NodeControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
fun `test matching name after validate`() {
|
fun `test matching name after validate`() {
|
||||||
val data = NodeData()
|
val data = NodeData()
|
||||||
data.legalName.value = node1Name.toString()
|
data.legalName.value = node1Name
|
||||||
|
|
||||||
assertFalse(controller.nameExists("Node 1"))
|
assertFalse(controller.nameExists("Node 1"))
|
||||||
assertFalse(controller.nameExists("Node1"))
|
assertFalse(controller.nameExists("Node1"))
|
||||||
@ -51,7 +50,7 @@ class NodeControllerTest {
|
|||||||
@Test
|
@Test
|
||||||
fun `test first validated node becomes network map`() {
|
fun `test first validated node becomes network map`() {
|
||||||
val data = NodeData()
|
val data = NodeData()
|
||||||
data.legalName.value = node1Name.toString()
|
data.legalName.value = node1Name
|
||||||
data.p2pPort.value = 100000
|
data.p2pPort.value = 100000
|
||||||
|
|
||||||
assertFalse(controller.hasNetworkMap())
|
assertFalse(controller.hasNetworkMap())
|
||||||
@ -61,14 +60,14 @@ class NodeControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test register unique nodes`() {
|
fun `test register unique nodes`() {
|
||||||
val config = createConfig(legalName = node2Name)
|
val config = createConfig(commonName = node2Name)
|
||||||
assertTrue(controller.register(config))
|
assertTrue(controller.register(config))
|
||||||
assertFalse(controller.register(config))
|
assertFalse(controller.register(config))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test unique key after register`() {
|
fun `test unique key after register`() {
|
||||||
val config = createConfig(legalName = node2Name)
|
val config = createConfig(commonName = node2Name)
|
||||||
|
|
||||||
assertFalse(controller.keyExists("node2"))
|
assertFalse(controller.keyExists("node2"))
|
||||||
controller.register(config)
|
controller.register(config)
|
||||||
@ -77,7 +76,7 @@ class NodeControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test matching name after register`() {
|
fun `test matching name after register`() {
|
||||||
val config = createConfig(legalName = node2Name)
|
val config = createConfig(commonName = node2Name)
|
||||||
|
|
||||||
assertFalse(controller.nameExists("Node 2"))
|
assertFalse(controller.nameExists("Node 2"))
|
||||||
assertFalse(controller.nameExists("Node2"))
|
assertFalse(controller.nameExists("Node2"))
|
||||||
@ -90,7 +89,7 @@ class NodeControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test register network map node`() {
|
fun `test register network map node`() {
|
||||||
val config = createConfig(legalName = X500Name("CN=Node is Network Map,OU=Corda QA Department,O=R3 CEV,L=New York,C=US"))
|
val config = createConfig(commonName = "Node is Network Map")
|
||||||
assertTrue(config.isNetworkMap())
|
assertTrue(config.isNetworkMap())
|
||||||
|
|
||||||
assertFalse(controller.hasNetworkMap())
|
assertFalse(controller.hasNetworkMap())
|
||||||
@ -100,7 +99,7 @@ class NodeControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `test register non-network-map node`() {
|
fun `test register non-network-map node`() {
|
||||||
val config = createConfig(legalName = X500Name("CN=Node is not Network Map,OU=Corda QA Department,O=R3 CEV,L=New York,C=US"))
|
val config = createConfig(commonName = "Node is not Network Map")
|
||||||
config.networkMap = NetworkMapConfig(DUMMY_NOTARY.name, 10000)
|
config.networkMap = NetworkMapConfig(DUMMY_NOTARY.name, 10000)
|
||||||
assertFalse(config.isNetworkMap())
|
assertFalse(config.isNetworkMap())
|
||||||
|
|
||||||
@ -155,7 +154,7 @@ class NodeControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `dispose node`() {
|
fun `dispose node`() {
|
||||||
val config = createConfig(legalName = X500Name("CN=MyName,OU=Corda QA Department,O=R3 CEV,L=New York,C=US"))
|
val config = createConfig(commonName = "MyName")
|
||||||
controller.register(config)
|
controller.register(config)
|
||||||
|
|
||||||
assertEquals(NodeState.STARTING, config.state)
|
assertEquals(NodeState.STARTING, config.state)
|
||||||
@ -166,7 +165,7 @@ class NodeControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun createConfig(
|
private fun createConfig(
|
||||||
legalName: X500Name = X509Utilities.getDevX509Name("Unknown"),
|
commonName: String = "Unknown",
|
||||||
p2pPort: Int = -1,
|
p2pPort: Int = -1,
|
||||||
rpcPort: Int = -1,
|
rpcPort: Int = -1,
|
||||||
webPort: Int = -1,
|
webPort: Int = -1,
|
||||||
@ -175,7 +174,12 @@ class NodeControllerTest {
|
|||||||
users: List<User> = listOf(user("guest"))
|
users: List<User> = listOf(user("guest"))
|
||||||
) = NodeConfig(
|
) = NodeConfig(
|
||||||
baseDir,
|
baseDir,
|
||||||
legalName = legalName,
|
legalName = getX509Name(
|
||||||
|
myLegalName = commonName,
|
||||||
|
nearestCity = "New York",
|
||||||
|
country = "US",
|
||||||
|
email = "corda@city.us.example"
|
||||||
|
),
|
||||||
p2pPort = p2pPort,
|
p2pPort = p2pPort,
|
||||||
rpcPort = rpcPort,
|
rpcPort = rpcPort,
|
||||||
webPort = webPort,
|
webPort = webPort,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user