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