Interim patch introducing X500Names

This is an intermediary step to introducing X500Names in all Party instances, which adds:

* Party constructor which accepts X500Name and then converts it to string.
* startNode() function which takes in X500Name instead of String
* Numerous legal name fixes to use full distinguished names
This commit is contained in:
Ross Nicoll 2017-04-26 12:06:37 +01:00
parent cfe5786d2d
commit d65d63e4f6
31 changed files with 134 additions and 63 deletions

View File

@ -8,6 +8,6 @@ webAddress : "localhost:10004"
extraAdvertisedServiceIds : [ "corda.interest_rates" ] extraAdvertisedServiceIds : [ "corda.interest_rates" ]
networkMapService : { networkMapService : {
address : "localhost:10000" address : "localhost:10000"
legalName : "Network Map Service" legalName : "CN=Network Map Service,O=R3,OU=corda,L=London,C=UK"
} }
useHTTPS : false useHTTPS : false

View File

@ -1,4 +1,4 @@
myLegalName : "Bank B" myLegalName : "CN=Bank B,O=Bank A,L=London,C=UK"
nearestCity : "London" nearestCity : "London"
keyStorePassword : "cordacadevpass" keyStorePassword : "cordacadevpass"
trustStorePassword : "trustpass" trustStorePassword : "trustpass"
@ -8,6 +8,6 @@ webAddress : "localhost:10007"
extraAdvertisedServiceIds : [ "corda.interest_rates" ] extraAdvertisedServiceIds : [ "corda.interest_rates" ]
networkMapService : { networkMapService : {
address : "localhost:10000" address : "localhost:10000"
legalName : "Network Map Service" legalName : "CN=Network Map Service,O=R3,OU=corda,L=London,C=UK"
} }
useHTTPS : false useHTTPS : false

View File

@ -2,6 +2,7 @@ package net.corda.core.crypto
import net.corda.core.contracts.PartyAndReference import net.corda.core.contracts.PartyAndReference
import net.corda.core.serialization.OpaqueBytes import net.corda.core.serialization.OpaqueBytes
import org.bouncycastle.asn1.x500.X500Name
import java.security.PublicKey import java.security.PublicKey
/** /**
@ -23,6 +24,7 @@ import java.security.PublicKey
* @see CompositeKey * @see CompositeKey
*/ */
class Party(val name: String, owningKey: PublicKey) : AbstractParty(owningKey) { class Party(val name: String, owningKey: PublicKey) : AbstractParty(owningKey) {
constructor(name: X500Name, owningKey: PublicKey) : this(name.toString(), owningKey)
override fun toAnonymous(): AnonymousParty = AnonymousParty(owningKey) override fun toAnonymous(): AnonymousParty = AnonymousParty(owningKey)
override fun toString() = "${owningKey.toBase58String()} ($name)" override fun toString() = "${owningKey.toBase58String()} ($name)"
override fun nameOrNull(): String? = name override fun nameOrNull(): String? = name

View File

@ -1,6 +1,7 @@
package net.corda.core.node.services package net.corda.core.node.services
import net.corda.core.serialization.CordaSerializable import net.corda.core.serialization.CordaSerializable
import org.bouncycastle.asn1.x500.X500Name
/** /**
* A container for additional information for an advertised service. * A container for additional information for an advertised service.
@ -11,6 +12,7 @@ import net.corda.core.serialization.CordaSerializable
*/ */
@CordaSerializable @CordaSerializable
data class ServiceInfo(val type: ServiceType, val name: String? = null) { data class ServiceInfo(val type: ServiceType, val name: String? = null) {
constructor(type: ServiceType, name: X500Name?) : this(type, name?.toString())
companion object { companion object {
fun parse(encoded: String): ServiceInfo { fun parse(encoded: String): ServiceInfo {
val parts = encoded.split("|") val parts = encoded.split("|")

View File

@ -20,34 +20,32 @@ val DUMMY_KEY_2: KeyPair by lazy { generateKeyPair() }
val DUMMY_NOTARY_KEY: KeyPair by lazy { entropyToKeyPair(BigInteger.valueOf(20)) } val DUMMY_NOTARY_KEY: KeyPair by lazy { entropyToKeyPair(BigInteger.valueOf(20)) }
/** Dummy notary identity for tests and simulations */ /** Dummy notary identity for tests and simulations */
val DUMMY_NOTARY: Party get() = Party("CN=Notary Service,O=R3,OU=corda,L=London,C=UK", DUMMY_NOTARY_KEY.public) val DUMMY_NOTARY: Party get() = Party(X500Name("CN=Notary Service,O=R3,OU=corda,L=London,C=UK"), DUMMY_NOTARY_KEY.public)
val DUMMY_MAP_KEY: KeyPair by lazy { entropyToKeyPair(BigInteger.valueOf(30)) } val DUMMY_MAP_KEY: KeyPair by lazy { entropyToKeyPair(BigInteger.valueOf(30)) }
/** Dummy network map service identity for tests and simulations */ /** Dummy network map service identity for tests and simulations */
val DUMMY_MAP: Party get() = Party("CN=Network Map Service,O=R3,OU=corda,L=London,C=UK", DUMMY_MAP_KEY.public) val DUMMY_MAP: Party get() = Party(X500Name("CN=Network Map Service,O=R3,OU=corda,L=London,C=UK"), DUMMY_MAP_KEY.public)
val DUMMY_BANK_A_KEY: KeyPair by lazy { entropyToKeyPair(BigInteger.valueOf(40)) } val DUMMY_BANK_A_KEY: KeyPair by lazy { entropyToKeyPair(BigInteger.valueOf(40)) }
/** Dummy bank identity for tests and simulations */ /** Dummy bank identity for tests and simulations */
val DUMMY_BANK_A: Party get() = Party("CN=Bank A,O=Bank A,L=London,C=UK", DUMMY_BANK_A_KEY.public) val DUMMY_BANK_A: Party get() = Party(X500Name("CN=Bank A,O=Bank A,L=London,C=UK"), DUMMY_BANK_A_KEY.public)
val DUMMY_BANK_B_KEY: KeyPair by lazy { entropyToKeyPair(BigInteger.valueOf(50)) } val DUMMY_BANK_B_KEY: KeyPair by lazy { entropyToKeyPair(BigInteger.valueOf(50)) }
/** Dummy bank identity for tests and simulations */ /** Dummy bank identity for tests and simulations */
val DUMMY_BANK_B: Party get() = Party("CN=Bank B,O=Bank B,L=New York,C=USA", DUMMY_BANK_B_KEY.public) val DUMMY_BANK_B: Party get() = Party(X500Name("CN=Bank B,O=Bank B,L=New York,C=USA"), DUMMY_BANK_B_KEY.public)
val DUMMY_BANK_C_KEY: KeyPair by lazy { entropyToKeyPair(BigInteger.valueOf(60)) } val DUMMY_BANK_C_KEY: KeyPair by lazy { entropyToKeyPair(BigInteger.valueOf(60)) }
/** Dummy bank identity for tests and simulations */ /** Dummy bank identity for tests and simulations */
val DUMMY_BANK_C: Party get() = Party("CN=Bank C,O=Bank C,L=Tokyo,C=Japan", DUMMY_BANK_C_KEY.public) val DUMMY_BANK_C: Party get() = Party(X500Name("CN=Bank C,O=Bank C,L=Tokyo,C=Japan"), DUMMY_BANK_C_KEY.public)
val ALICE_KEY: KeyPair by lazy { entropyToKeyPair(BigInteger.valueOf(70)) } val ALICE_KEY: KeyPair by lazy { entropyToKeyPair(BigInteger.valueOf(70)) }
/** Dummy individual identity for tests and simulations */ /** Dummy individual identity for tests and simulations */
val ALICE: Party get() = Party("CN=Alice Corp,O=Alice Corp,L=London,C=UK", ALICE_KEY.public) val ALICE: Party get() = Party(X500Name("CN=Alice Corp,O=Alice Corp,L=London,C=UK"), ALICE_KEY.public)
val BOB_KEY: KeyPair by lazy { entropyToKeyPair(BigInteger.valueOf(80)) } val BOB_KEY: KeyPair by lazy { entropyToKeyPair(BigInteger.valueOf(80)) }
/** Dummy individual identity for tests and simulations */ /** Dummy individual identity for tests and simulations */
val BOB: Party get() = Party("CN=Bob Plc,O=Bob Plc,L=London,C=UK", BOB_KEY.public) val BOB: Party get() = Party(X500Name("CN=Bob Plc,O=Bob Plc,L=London,C=UK"), BOB_KEY.public)
val CHARLIE_KEY: KeyPair by lazy { entropyToKeyPair(BigInteger.valueOf(90)) } val CHARLIE_KEY: KeyPair by lazy { entropyToKeyPair(BigInteger.valueOf(90)) }
/** Dummy individual identity for tests and simulations */ /** Dummy individual identity for tests and simulations */
val CHARLIE: Party get() = Party("CN=Charlie Ltd,O=Charlie Ltd,L=London,C=UK", CHARLIE_KEY.public) val CHARLIE: Party get() = Party(X500Name("CN=Charlie Ltd,O=Charlie Ltd,L=London,C=UK"), CHARLIE_KEY.public)

View File

@ -3,13 +3,14 @@ package net.corda.core.node
import net.corda.core.crypto.X509Utilities import net.corda.core.crypto.X509Utilities
import net.corda.core.node.services.ServiceInfo import net.corda.core.node.services.ServiceInfo
import net.corda.core.node.services.ServiceType import net.corda.core.node.services.ServiceType
import org.bouncycastle.asn1.x500.X500Name
import org.junit.Test import org.junit.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith import kotlin.test.assertFailsWith
class ServiceInfoTests { class ServiceInfoTests {
val serviceType = ServiceType.getServiceType("test", "service").getSubType("subservice") val serviceType = ServiceType.getServiceType("test", "service").getSubType("subservice")
val name = "CN=service.name,O=R3,OU=corda,L=London,C=UK" val name = X500Name("CN=service.name,O=R3,OU=corda,L=London,C=UK")
@Test @Test
fun `type and name encodes correctly`() { fun `type and name encodes correctly`() {

View File

@ -16,6 +16,7 @@ import net.corda.core.serialization.CordaSerializable
import net.corda.core.transactions.TransactionBuilder import net.corda.core.transactions.TransactionBuilder
import net.corda.core.utilities.Emoji import net.corda.core.utilities.Emoji
import net.corda.schemas.CashSchemaV1 import net.corda.schemas.CashSchemaV1
import org.bouncycastle.asn1.x500.X500Name
import java.math.BigInteger import java.math.BigInteger
import java.security.PublicKey import java.security.PublicKey
import java.util.* import java.util.*
@ -203,7 +204,7 @@ infix fun Cash.State.`with deposit`(deposit: PartyAndReference): Cash.State = wi
/** A randomly generated key. */ /** A randomly generated key. */
val DUMMY_CASH_ISSUER_KEY by lazy { entropyToKeyPair(BigInteger.valueOf(10)) } val DUMMY_CASH_ISSUER_KEY by lazy { entropyToKeyPair(BigInteger.valueOf(10)) }
/** A dummy, randomly generated issuer party by the name of "Snake Oil Issuer" */ /** A dummy, randomly generated issuer party by the name of "Snake Oil Issuer" */
val DUMMY_CASH_ISSUER by lazy { Party("CN=Snake Oil Issuer,O=R3,OU=corda,L=London,C=UK", DUMMY_CASH_ISSUER_KEY.public).ref(1) } val DUMMY_CASH_ISSUER by lazy { Party(X500Name("CN=Snake Oil Issuer,O=R3,OU=corda,L=London,C=UK"), DUMMY_CASH_ISSUER_KEY.public).ref(1) }
/** An extension property that lets you write 100.DOLLARS.CASH */ /** An extension property that lets you write 100.DOLLARS.CASH */
val Amount<Currency>.CASH: Cash.State get() = Cash.State(Amount(quantity, Issued(DUMMY_CASH_ISSUER, token)), NullPublicKey) val Amount<Currency>.CASH: Cash.State get() = Cash.State(Amount(quantity, Issued(DUMMY_CASH_ISSUER, token)), NullPublicKey)
/** An extension property that lets you get a cash state from an issued token, under the [NullPublicKey] */ /** An extension property that lets you get a cash state from an issued token, under the [NullPublicKey] */

View File

@ -13,6 +13,7 @@ import net.corda.core.utilities.Emoji
import net.corda.core.utilities.NonEmptySet import net.corda.core.utilities.NonEmptySet
import net.corda.core.utilities.TEST_TX_TIME import net.corda.core.utilities.TEST_TX_TIME
import net.corda.core.utilities.nonEmptySetOf import net.corda.core.utilities.nonEmptySetOf
import org.bouncycastle.asn1.x500.X500Name
import java.math.BigInteger import java.math.BigInteger
import java.security.PublicKey import java.security.PublicKey
import java.time.Duration import java.time.Duration
@ -719,7 +720,7 @@ infix fun <T : Any> Obligation.State<T>.`issued by`(party: AbstractParty) = copy
/** A randomly generated key. */ /** A randomly generated key. */
val DUMMY_OBLIGATION_ISSUER_KEY by lazy { entropyToKeyPair(BigInteger.valueOf(10)) } val DUMMY_OBLIGATION_ISSUER_KEY by lazy { entropyToKeyPair(BigInteger.valueOf(10)) }
/** A dummy, randomly generated issuer party by the name of "Snake Oil Issuer" */ /** A dummy, randomly generated issuer party by the name of "Snake Oil Issuer" */
val DUMMY_OBLIGATION_ISSUER by lazy { Party("CN=Snake Oil Issuer,O=R3,OU=corda,L=London,C=UK", DUMMY_OBLIGATION_ISSUER_KEY.public) } val DUMMY_OBLIGATION_ISSUER by lazy { Party(X500Name("CN=Snake Oil Issuer,O=R3,OU=corda,L=London,C=UK"), DUMMY_OBLIGATION_ISSUER_KEY.public) }
val Issued<Currency>.OBLIGATION_DEF: Obligation.Terms<Currency> val Issued<Currency>.OBLIGATION_DEF: Obligation.Terms<Currency>
get() = Obligation.Terms(nonEmptySetOf(Cash().legalContractReference), nonEmptySetOf(this), TEST_TX_TIME) get() = Obligation.Terms(nonEmptySetOf(Cash().legalContractReference), nonEmptySetOf(this), TEST_TX_TIME)

View File

@ -27,15 +27,15 @@ import kotlin.test.assertFailsWith
class BFTNotaryServiceTests : NodeBasedTest() { class BFTNotaryServiceTests : NodeBasedTest() {
private companion object { private companion object {
val notaryName = "BFT Notary Server" val notaryCommonName = "BFT Notary Server"
} }
@Test @Test
fun `detect double spend`() { fun `detect double spend`() {
val masterNode = startBFTNotaryCluster(notaryName, 4, BFTNonValidatingNotaryService.type).first() val masterNode = startBFTNotaryCluster(notaryCommonName, 4, BFTNonValidatingNotaryService.type).first()
val alice = startNode(ALICE.name).getOrThrow() val alice = startNode(ALICE.name).getOrThrow()
val notaryParty = alice.netMapCache.getNotary(notaryName)!! val notaryParty = alice.netMapCache.getNotary(notaryCommonName)!!
val notaryNodeKeyPair = with(masterNode) { database.transaction { services.notaryIdentityKey } } val notaryNodeKeyPair = with(masterNode) { database.transaction { services.notaryIdentityKey } }
val aliceKey = with(alice) { database.transaction { services.legalIdentityKey } } val aliceKey = with(alice) { database.transaction { services.legalIdentityKey } }

View File

@ -9,6 +9,8 @@ import com.typesafe.config.ConfigRenderOptions
import net.corda.client.rpc.CordaRPCClient import net.corda.client.rpc.CordaRPCClient
import net.corda.core.ThreadBox import net.corda.core.ThreadBox
import net.corda.core.crypto.Party import net.corda.core.crypto.Party
import net.corda.core.crypto.X509Utilities
import net.corda.core.crypto.commonName
import net.corda.core.div import net.corda.core.div
import net.corda.core.flatMap import net.corda.core.flatMap
import net.corda.core.map import net.corda.core.map
@ -30,6 +32,9 @@ import net.corda.nodeapi.config.SSLConfiguration
import net.corda.nodeapi.config.parseAs import net.corda.nodeapi.config.parseAs
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
import org.bouncycastle.asn1.x500.X500Name
import org.bouncycastle.asn1.x500.X500NameBuilder
import org.bouncycastle.asn1.x500.style.BCStyle
import org.slf4j.Logger import org.slf4j.Logger
import java.io.File import java.io.File
import java.net.* import java.net.*
@ -58,6 +63,23 @@ private val log: Logger = loggerFor<DriverDSL>()
* This is the interface that's exposed to DSL users. * This is the interface that's exposed to DSL users.
*/ */
interface DriverDSLExposedInterface { interface DriverDSLExposedInterface {
/**
* Starts a [net.corda.node.internal.Node] in a separate process.
*
* @param providedName Name of the node, which will be its legal name in [Party].
* Note that this must be unique as the driver uses it as a primary key!
* @param advertisedServices The set of services to be advertised by the node. Defaults to empty set.
* @param verifierType The type of transaction verifier to use. See: [VerifierType]
* @param rpcUsers List of users who are authorised to use the RPC system. Defaults to empty list.
* @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,
advertisedServices: Set<ServiceInfo> = emptySet(),
rpcUsers: List<User> = emptyList(),
verifierType: VerifierType = VerifierType.InMemory,
customOverrides: Map<String, Any?> = emptyMap()): ListenableFuture<NodeHandle>
/** /**
* Starts a [net.corda.node.internal.Node] in a separate process. * Starts a [net.corda.node.internal.Node] in a separate process.
* *
@ -68,7 +90,7 @@ interface DriverDSLExposedInterface {
* @param rpcUsers List of users who are authorised to use the RPC system. Defaults to empty list. * @param rpcUsers List of users who are authorised to use the RPC system. Defaults to empty list.
* @return The [NodeInfo] of the started up node retrieved from the network map service. * @return The [NodeInfo] of the started up node retrieved from the network map service.
*/ */
fun startNode(providedName: String? = null, fun startNode(providedName: X500Name? = null,
advertisedServices: Set<ServiceInfo> = emptySet(), advertisedServices: Set<ServiceInfo> = emptySet(),
rpcUsers: List<User> = emptyList(), rpcUsers: List<User> = emptyList(),
verifierType: VerifierType = VerifierType.InMemory, verifierType: VerifierType = VerifierType.InMemory,
@ -415,8 +437,12 @@ class DriverDSL(
} }
} }
override fun startNode(providedName: String, advertisedServices: Set<ServiceInfo>, rpcUsers: List<User>, verifierType: VerifierType, customOverrides: Map<String, Any?>): ListenableFuture<NodeHandle> {
return startNode(X500Name(providedName), advertisedServices, rpcUsers, verifierType, customOverrides)
}
override fun startNode( override fun startNode(
providedName: String?, providedName: X500Name?,
advertisedServices: Set<ServiceInfo>, advertisedServices: Set<ServiceInfo>,
rpcUsers: List<User>, rpcUsers: List<User>,
verifierType: VerifierType, verifierType: VerifierType,
@ -426,11 +452,11 @@ class DriverDSL(
val rpcAddress = portAllocation.nextHostAndPort() val rpcAddress = portAllocation.nextHostAndPort()
val webAddress = portAllocation.nextHostAndPort() val webAddress = portAllocation.nextHostAndPort()
val debugPort = if (isDebug) debugPortAllocation.nextPort() else null val debugPort = if (isDebug) debugPortAllocation.nextPort() else null
val name = providedName ?: "${pickA(name)}-${p2pAddress.port}" val name = providedName ?: X509Utilities.getDevX509Name("${pickA(name).commonName}-${p2pAddress.port}")
val baseDirectory = driverDirectory / name val baseDirectory = driverDirectory / name.toString()
val configOverrides = mapOf( val configOverrides = mapOf(
"myLegalName" to name, "myLegalName" to name.toString(),
"p2pAddress" to p2pAddress.toString(), "p2pAddress" to p2pAddress.toString(),
"rpcAddress" to rpcAddress.toString(), "rpcAddress" to rpcAddress.toString(),
"webAddress" to webAddress.toString(), "webAddress" to webAddress.toString(),
@ -554,9 +580,9 @@ class DriverDSL(
companion object { companion object {
val name = arrayOf( val name = arrayOf(
ALICE.name, X500Name(ALICE.name),
BOB.name, X500Name(BOB.name),
DUMMY_BANK_A.name X500Name(DUMMY_BANK_A.name)
) )
fun <A> pickA(array: Array<A>): A = array[Math.abs(Random().nextInt()) % array.size] fun <A> pickA(array: Array<A>): A = array[Math.abs(Random().nextInt()) % array.size]

View File

@ -9,6 +9,7 @@ import net.corda.core.node.services.UniquenessProvider
import net.corda.core.serialization.SingletonSerializeAsToken import net.corda.core.serialization.SingletonSerializeAsToken
import net.corda.core.utilities.loggerFor import net.corda.core.utilities.loggerFor
import net.corda.node.utilities.* import net.corda.node.utilities.*
import org.bouncycastle.asn1.x500.X500Name
import org.jetbrains.exposed.sql.ResultRow import org.jetbrains.exposed.sql.ResultRow
import org.jetbrains.exposed.sql.statements.InsertStatement import org.jetbrains.exposed.sql.statements.InsertStatement
import java.util.* import java.util.*
@ -38,7 +39,7 @@ class PersistentUniquenessProvider : UniquenessProvider, SingletonSerializeAsTok
override fun valueFromRow(row: ResultRow): UniquenessProvider.ConsumingTx = UniquenessProvider.ConsumingTx( override fun valueFromRow(row: ResultRow): UniquenessProvider.ConsumingTx = UniquenessProvider.ConsumingTx(
row[table.consumingTxHash], row[table.consumingTxHash],
row[table.consumingIndex], row[table.consumingIndex],
Party(row[table.requestingParty.name], row[table.requestingParty.owningKey]) Party(X500Name(row[table.requestingParty.name]), row[table.requestingParty.owningKey])
) )
override fun addKeyToInsert(insert: InsertStatement, override fun addKeyToInsert(insert: InsertStatement,

View File

@ -69,7 +69,7 @@ class InteractiveShellTest {
fun flowTooManyParams() = check("b: 12, c: Yo, d: Bar", "") fun flowTooManyParams() = check("b: 12, c: Yo, d: Bar", "")
@Test @Test
fun party() = check("party: \"${someCorpLegalName}\"", someCorpLegalName) fun party() = check("party: \"${someCorpLegalName}\"", someCorpLegalName.toString())
class DummyFSM(val logic: FlowA) : FlowStateMachine<Any?> { class DummyFSM(val logic: FlowA) : FlowStateMachine<Any?> {
override fun <T : Any> sendAndReceive(receiveType: Class<T>, otherParty: Party, payload: Any, sessionFlow: FlowLogic<*>): UntrustworthyData<T> { override fun <T : Any> sendAndReceive(receiveType: Class<T>, otherParty: Party, payload: Any, sessionFlow: FlowLogic<*>): UntrustworthyData<T> {

View File

@ -31,6 +31,7 @@ import net.corda.testing.*
import net.corda.testing.node.InMemoryMessagingNetwork import net.corda.testing.node.InMemoryMessagingNetwork
import net.corda.testing.node.MockNetwork import net.corda.testing.node.MockNetwork
import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThat
import org.bouncycastle.asn1.x500.X500Name
import org.jetbrains.exposed.sql.Database import org.jetbrains.exposed.sql.Database
import org.junit.After import org.junit.After
import org.junit.Before import org.junit.Before

View File

@ -16,6 +16,7 @@ import net.corda.node.services.network.NetworkMapService
import net.corda.node.services.transactions.SimpleNotaryService import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.testing.node.MockNetwork import net.corda.testing.node.MockNetwork
import org.assertj.core.api.Assertions.assertThatExceptionOfType import org.assertj.core.api.Assertions.assertThatExceptionOfType
import org.bouncycastle.asn1.x500.X500Name
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import java.time.Instant import java.time.Instant
@ -75,7 +76,7 @@ class NotaryChangeTests {
@Test @Test
fun `should throw when a participant refuses to change Notary`() { fun `should throw when a participant refuses to change Notary`() {
val state = issueMultiPartyState(clientNodeA, clientNodeB, oldNotaryNode) val state = issueMultiPartyState(clientNodeA, clientNodeB, oldNotaryNode)
val newEvilNotary = Party("CN=Evil Notary,O=Evil R3,OU=corda,L=London,C=UK", generateKeyPair().public) val newEvilNotary = Party(X500Name("CN=Evil Notary,O=Evil R3,OU=corda,L=London,C=UK"), generateKeyPair().public)
val flow = Instigator(state, newEvilNotary) val flow = Instigator(state, newEvilNotary)
val future = clientNodeA.services.startFlow(flow) val future = clientNodeA.services.startFlow(flow)

View File

@ -1,6 +1,7 @@
package net.corda.node.services.network package net.corda.node.services.network
import com.google.common.util.concurrent.ListenableFuture import com.google.common.util.concurrent.ListenableFuture
import net.corda.core.crypto.X509Utilities
import net.corda.core.getOrThrow import net.corda.core.getOrThrow
import net.corda.core.messaging.SingleMessageRecipient import net.corda.core.messaging.SingleMessageRecipient
import net.corda.core.messaging.send import net.corda.core.messaging.send
@ -8,9 +9,6 @@ import net.corda.core.node.NodeInfo
import net.corda.core.node.services.DEFAULT_SESSION_ID import net.corda.core.node.services.DEFAULT_SESSION_ID
import net.corda.core.node.services.ServiceInfo import net.corda.core.node.services.ServiceInfo
import net.corda.core.serialization.deserialize import net.corda.core.serialization.deserialize
import net.corda.core.utilities.ALICE
import net.corda.core.utilities.BOB
import net.corda.core.utilities.CHARLIE
import net.corda.flows.sendRequest import net.corda.flows.sendRequest
import net.corda.node.services.config.NodeConfiguration import net.corda.node.services.config.NodeConfiguration
import net.corda.node.services.network.AbstractNetworkMapServiceTest.Changed.Added import net.corda.node.services.network.AbstractNetworkMapServiceTest.Changed.Added
@ -22,12 +20,18 @@ import net.corda.node.services.network.NetworkMapService.Companion.PUSH_TOPIC
import net.corda.node.services.network.NetworkMapService.Companion.QUERY_TOPIC import net.corda.node.services.network.NetworkMapService.Companion.QUERY_TOPIC
import net.corda.node.services.network.NetworkMapService.Companion.REGISTER_TOPIC import net.corda.node.services.network.NetworkMapService.Companion.REGISTER_TOPIC
import net.corda.node.services.network.NetworkMapService.Companion.SUBSCRIPTION_TOPIC import net.corda.node.services.network.NetworkMapService.Companion.SUBSCRIPTION_TOPIC
import net.corda.node.services.network.NodeRegistration
import net.corda.core.utilities.ALICE
import net.corda.core.utilities.BOB
import net.corda.core.utilities.CHARLIE
import net.corda.core.utilities.DUMMY_MAP
import net.corda.node.utilities.AddOrRemove import net.corda.node.utilities.AddOrRemove
import net.corda.node.utilities.AddOrRemove.ADD import net.corda.node.utilities.AddOrRemove.ADD
import net.corda.node.utilities.AddOrRemove.REMOVE import net.corda.node.utilities.AddOrRemove.REMOVE
import net.corda.testing.node.MockNetwork import net.corda.testing.node.MockNetwork
import net.corda.testing.node.MockNetwork.MockNode import net.corda.testing.node.MockNetwork.MockNode
import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThat
import org.bouncycastle.asn1.x500.X500Name
import org.eclipse.jetty.util.BlockingArrayQueue import org.eclipse.jetty.util.BlockingArrayQueue
import org.junit.After import org.junit.After
import org.junit.Before import org.junit.Before
@ -41,10 +45,14 @@ abstract class AbstractNetworkMapServiceTest<out S : AbstractNetworkMapService>
lateinit var mapServiceNode: MockNode lateinit var mapServiceNode: MockNode
lateinit var alice: MockNode lateinit var alice: MockNode
companion object {
val subscriberLegalName = "CN=Subscriber,OU=Corda QA Department,O=R3 CEV,L=New York,C=US"
}
@Before @Before
fun setup() { fun setup() {
network = MockNetwork(defaultFactory = nodeFactory) network = MockNetwork(defaultFactory = nodeFactory)
network.createTwoNodes(firstNodeName = "map service", secondNodeName = ALICE.name).apply { network.createTwoNodes(firstNodeName = DUMMY_MAP.name, secondNodeName = ALICE.name).apply {
mapServiceNode = first mapServiceNode = first
alice = second alice = second
} }
@ -149,7 +157,7 @@ abstract class AbstractNetworkMapServiceTest<out S : AbstractNetworkMapService>
@Test @Test
fun `surpass unacknowledged update limit`() { fun `surpass unacknowledged update limit`() {
val subscriber = newNodeSeparateFromNetworkMap("Subscriber") val subscriber = newNodeSeparateFromNetworkMap(subscriberLegalName)
val updates = subscriber.subscribe() val updates = subscriber.subscribe()
val bob = addNewNodeToNetworkMap(BOB.name) val bob = addNewNodeToNetworkMap(BOB.name)
var serial = updates.first().wireReg.verified().serial var serial = updates.first().wireReg.verified().serial
@ -163,7 +171,7 @@ abstract class AbstractNetworkMapServiceTest<out S : AbstractNetworkMapService>
@Test @Test
fun `delay sending update ack until just before unacknowledged update limit`() { fun `delay sending update ack until just before unacknowledged update limit`() {
val subscriber = newNodeSeparateFromNetworkMap("Subscriber") val subscriber = newNodeSeparateFromNetworkMap(subscriberLegalName)
val updates = subscriber.subscribe() val updates = subscriber.subscribe()
val bob = addNewNodeToNetworkMap(BOB.name) val bob = addNewNodeToNetworkMap(BOB.name)
var serial = updates.first().wireReg.verified().serial var serial = updates.first().wireReg.verified().serial

View File

@ -8,6 +8,7 @@ import net.corda.core.utilities.ALICE
import net.corda.core.utilities.BOB import net.corda.core.utilities.BOB
import net.corda.testing.ALICE_PUBKEY import net.corda.testing.ALICE_PUBKEY
import net.corda.testing.BOB_PUBKEY import net.corda.testing.BOB_PUBKEY
import org.bouncycastle.asn1.x500.X500Name
import org.junit.Test import org.junit.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertNull import kotlin.test.assertNull
@ -52,7 +53,7 @@ class InMemoryIdentityServiceTests {
fun `get identity by name`() { fun `get identity by name`() {
val service = InMemoryIdentityService() val service = InMemoryIdentityService()
val identities = listOf("Node A", "Node B", "Node C") val identities = listOf("Node A", "Node B", "Node C")
.map { Party("CN=$it,O=R3,OU=corda,L=London,C=UK", generateKeyPair().public) } .map { Party(X500Name("CN=$it,O=R3,OU=corda,L=London,C=UK"), generateKeyPair().public) }
assertNull(service.partyFromName(identities.first().name)) assertNull(service.partyFromName(identities.first().name))
identities.forEach { service.registerIdentity(it) } identities.forEach { service.registerIdentity(it) }
identities.forEach { assertEquals(it, service.partyFromName(it.name)) } identities.forEach { assertEquals(it, service.partyFromName(it.name)) }

View File

@ -43,6 +43,7 @@ import net.corda.testing.sequence
import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThat
import org.assertj.core.api.Assertions.assertThatThrownBy import org.assertj.core.api.Assertions.assertThatThrownBy
import org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType import org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType
import org.bouncycastle.asn1.x500.X500Name
import org.junit.After import org.junit.After
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test

View File

@ -8,6 +8,7 @@ import net.corda.core.crypto.X509Utilities
import net.corda.core.exists import net.corda.core.exists
import net.corda.core.utilities.ALICE import net.corda.core.utilities.ALICE
import net.corda.testing.TestNodeConfiguration import net.corda.testing.TestNodeConfiguration
import org.bouncycastle.asn1.x500.X500Name
import org.junit.Rule import org.junit.Rule
import org.junit.Test import org.junit.Test
import org.junit.rules.TemporaryFolder import org.junit.rules.TemporaryFolder
@ -24,9 +25,12 @@ class NetworkRegistrationHelperTest {
fun buildKeyStore() { fun buildKeyStore() {
val id = SecureHash.randomSHA256().toString() val id = SecureHash.randomSHA256().toString()
val certs = arrayOf(X509Utilities.createSelfSignedCACert("CORDA_CLIENT_CA").certificate, val identities = listOf("CORDA_CLIENT_CA",
X509Utilities.createSelfSignedCACert("CORDA_INTERMEDIATE_CA").certificate, "CORDA_INTERMEDIATE_CA",
X509Utilities.createSelfSignedCACert("CORDA_ROOT_CA").certificate) "CORDA_ROOT_CA")
.map { X500Name("CN=${it},O=R3,OU=corda,L=London,C=UK") }
val certs = identities.map { X509Utilities.createSelfSignedCACert(it).certificate }
.toTypedArray()
val certService: NetworkRegistrationService = mock { val certService: NetworkRegistrationService = mock {
on { submitRequest(any()) }.then { id } on { submitRequest(any()) }.then { id }

View File

@ -8,6 +8,7 @@ import net.corda.core.node.services.ServiceInfo
import net.corda.node.driver.driver import net.corda.node.driver.driver
import net.corda.node.services.transactions.SimpleNotaryService import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.testing.BOC import net.corda.testing.BOC
import org.bouncycastle.asn1.x500.X500Name
import org.junit.Test import org.junit.Test
class BankOfCordaHttpAPITest { class BankOfCordaHttpAPITest {
@ -19,7 +20,7 @@ class BankOfCordaHttpAPITest {
startNode(BIGCORP_LEGAL_NAME) startNode(BIGCORP_LEGAL_NAME)
).getOrThrow() ).getOrThrow()
val nodeBankOfCordaApiAddr = startWebserver(nodeBankOfCorda).getOrThrow().listenAddress val nodeBankOfCordaApiAddr = startWebserver(nodeBankOfCorda).getOrThrow().listenAddress
assert(BankOfCordaClientApi(nodeBankOfCordaApiAddr).requestWebIssue(IssueRequestParams(1000, "USD", BIGCORP_LEGAL_NAME, "1", BOC.name))) assert(BankOfCordaClientApi(nodeBankOfCordaApiAddr).requestWebIssue(IssueRequestParams(1000, "USD", BIGCORP_LEGAL_NAME, "1", X500Name(BOC.name))))
}, isDebug = true) }, isDebug = true)
} }
} }

View File

@ -16,6 +16,7 @@ import net.corda.node.services.startFlowPermission
import net.corda.node.services.transactions.SimpleNotaryService import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.nodeapi.User import net.corda.nodeapi.User
import net.corda.testing.BOC import net.corda.testing.BOC
import org.bouncycastle.asn1.x500.X500Name
import kotlin.system.exitProcess import kotlin.system.exitProcess
/** /**
@ -28,7 +29,7 @@ fun main(args: Array<String>) {
val BANK_USERNAME = "bankUser" val BANK_USERNAME = "bankUser"
val BIGCORP_USERNAME = "bigCorpUser" val BIGCORP_USERNAME = "bigCorpUser"
val BIGCORP_LEGAL_NAME = "CN=BigCorporation,O=R3,OU=corda,L=London,C=UK" val BIGCORP_LEGAL_NAME = X500Name("CN=BigCorporation,O=R3,OU=corda,L=London,C=UK")
private class BankOfCordaDriver { private class BankOfCordaDriver {
enum class Role { enum class Role {
@ -66,7 +67,7 @@ private class BankOfCordaDriver {
}, isDebug = true) }, isDebug = true)
} else { } else {
try { try {
val requestParams = IssueRequestParams(options.valueOf(quantity), options.valueOf(currency), BIGCORP_LEGAL_NAME, "1", BOC.name) val requestParams = IssueRequestParams(options.valueOf(quantity), options.valueOf(currency), BIGCORP_LEGAL_NAME, "1", X500Name(BOC.name))
when (role) { when (role) {
Role.ISSUE_CASH_RPC -> { Role.ISSUE_CASH_RPC -> {
println("Requesting Cash via RPC ...") println("Requesting Cash via RPC ...")

View File

@ -9,6 +9,7 @@ import net.corda.core.messaging.startFlow
import net.corda.core.serialization.OpaqueBytes import net.corda.core.serialization.OpaqueBytes
import net.corda.core.utilities.loggerFor import net.corda.core.utilities.loggerFor
import net.corda.flows.IssuerFlow.IssuanceRequester import net.corda.flows.IssuerFlow.IssuanceRequester
import org.bouncycastle.asn1.x500.X500Name
import java.time.LocalDateTime import java.time.LocalDateTime
import javax.ws.rs.* import javax.ws.rs.*
import javax.ws.rs.core.MediaType import javax.ws.rs.core.MediaType
@ -19,7 +20,13 @@ import javax.ws.rs.core.Response
class BankOfCordaWebApi(val rpc: CordaRPCOps) { class BankOfCordaWebApi(val rpc: CordaRPCOps) {
data class IssueRequestParams(val amount: Long, val currency: String, data class IssueRequestParams(val amount: Long, val currency: String,
val issueToPartyName: String, val issueToPartyRefAsString: String, val issueToPartyName: String, val issueToPartyRefAsString: String,
val issuerBankName: String) val issuerBankName: String) {
constructor(amount: Long, currency: String,
issueToPartyName: X500Name, issueToPartyRefAsString: String,
issuerBankName: X500Name) : this(amount, currency,
issueToPartyName.toString(), issueToPartyRefAsString,
issuerBankName.toString())
}
private companion object { private companion object {
val logger = loggerFor<BankOfCordaWebApi>() val logger = loggerFor<BankOfCordaWebApi>()

View File

@ -25,6 +25,7 @@ import net.corda.testing.MEGA_CORP
import net.corda.testing.MEGA_CORP_KEY import net.corda.testing.MEGA_CORP_KEY
import net.corda.testing.node.MockNetwork import net.corda.testing.node.MockNetwork
import net.corda.testing.node.makeTestDataSourceProperties import net.corda.testing.node.makeTestDataSourceProperties
import org.bouncycastle.asn1.x500.X500Name
import org.jetbrains.exposed.sql.Database import org.jetbrains.exposed.sql.Database
import org.junit.After import org.junit.After
import org.junit.Assert import org.junit.Assert
@ -48,7 +49,7 @@ class NodeInterestRatesTest {
""".trimIndent()) """.trimIndent())
val DUMMY_CASH_ISSUER_KEY = generateKeyPair() val DUMMY_CASH_ISSUER_KEY = generateKeyPair()
val DUMMY_CASH_ISSUER = Party("CN=Cash issuer,O=R3,OU=corda,L=London,C=UK", DUMMY_CASH_ISSUER_KEY.public) val DUMMY_CASH_ISSUER = Party(X500Name("CN=Cash issuer,O=R3,OU=corda,L=London,C=UK"), DUMMY_CASH_ISSUER_KEY.public)
val clock = Clock.systemUTC() val clock = Clock.systemUTC()
lateinit var oracle: NodeInterestRates.Oracle lateinit var oracle: NodeInterestRates.Oracle

View File

@ -7,6 +7,7 @@ import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.node.driver.driver import net.corda.node.driver.driver
import net.corda.node.services.transactions.RaftValidatingNotaryService import net.corda.node.services.transactions.RaftValidatingNotaryService
import net.corda.nodeapi.User import net.corda.nodeapi.User
import org.bouncycastle.asn1.x500.X500Name
import java.nio.file.Paths import java.nio.file.Paths
/** Creates and starts all nodes required for the demo. */ /** Creates and starts all nodes required for the demo. */

View File

@ -1,6 +1,7 @@
package net.corda.vega package net.corda.vega
import com.google.common.util.concurrent.Futures import com.google.common.util.concurrent.Futures
import net.corda.core.crypto.X509Utilities
import net.corda.core.getOrThrow import net.corda.core.getOrThrow
import net.corda.core.node.services.ServiceInfo import net.corda.core.node.services.ServiceInfo
import net.corda.core.utilities.DUMMY_BANK_A import net.corda.core.utilities.DUMMY_BANK_A
@ -16,7 +17,7 @@ import net.corda.node.services.transactions.SimpleNotaryService
*/ */
fun main(args: Array<String>) { fun main(args: Array<String>) {
driver(dsl = { driver(dsl = {
startNode("Controller", setOf(ServiceInfo(SimpleNotaryService.type))) startNode(X509Utilities.getDevX509Name("Controller"), setOf(ServiceInfo(SimpleNotaryService.type)))
val (nodeA, nodeB, nodeC) = Futures.allAsList( val (nodeA, nodeB, nodeC) = Futures.allAsList(
startNode(DUMMY_BANK_A.name), startNode(DUMMY_BANK_A.name),
startNode(DUMMY_BANK_B.name), startNode(DUMMY_BANK_B.name),

View File

@ -2,6 +2,8 @@ package net.corda.traderdemo
import net.corda.core.div import net.corda.core.div
import net.corda.core.node.services.ServiceInfo import net.corda.core.node.services.ServiceInfo
import net.corda.core.utilities.DUMMY_BANK_A
import net.corda.core.utilities.DUMMY_BANK_B
import net.corda.core.utilities.DUMMY_NOTARY import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.flows.IssuerFlow import net.corda.flows.IssuerFlow
import net.corda.node.driver.driver import net.corda.node.driver.driver
@ -10,9 +12,6 @@ import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.nodeapi.User import net.corda.nodeapi.User
import net.corda.testing.BOC import net.corda.testing.BOC
import java.nio.file.Paths import java.nio.file.Paths
import net.corda.core.utilities.DUMMY_BANK_A
import net.corda.core.utilities.DUMMY_BANK_B
import net.corda.core.utilities.DUMMY_NOTARY
/** /**
* This file is exclusively for being able to run your nodes through an IDE (as opposed to running deployNodes) * This file is exclusively for being able to run your nodes through an IDE (as opposed to running deployNodes)

View File

@ -4,7 +4,10 @@ import com.google.common.net.HostAndPort
import joptsimple.OptionParser import joptsimple.OptionParser
import net.corda.client.rpc.CordaRPCClient import net.corda.client.rpc.CordaRPCClient
import net.corda.core.contracts.DOLLARS import net.corda.core.contracts.DOLLARS
import net.corda.core.crypto.X509Utilities
import net.corda.core.utilities.DUMMY_BANK_A
import net.corda.core.utilities.loggerFor import net.corda.core.utilities.loggerFor
import org.bouncycastle.asn1.x500.X500Name
import org.slf4j.Logger import org.slf4j.Logger
import kotlin.system.exitProcess import kotlin.system.exitProcess
@ -48,7 +51,7 @@ private class TraderDemo {
} else { } else {
val host = HostAndPort.fromString("localhost:10009") val host = HostAndPort.fromString("localhost:10009")
CordaRPCClient(host).use("demo", "demo") { CordaRPCClient(host).use("demo", "demo") {
TraderDemoClientApi(this).runSeller(1000.DOLLARS, "CN=Bank A,O=Bank A,L=London,C=UK") TraderDemoClientApi(this).runSeller(1000.DOLLARS, DUMMY_BANK_A.name)
} }
} }
} }

View File

@ -16,6 +16,7 @@ import net.corda.core.utilities.DUMMY_BANK_C
import net.corda.core.utilities.ProgressTracker import net.corda.core.utilities.ProgressTracker
import net.corda.flows.NotaryFlow import net.corda.flows.NotaryFlow
import net.corda.flows.TwoPartyTradeFlow import net.corda.flows.TwoPartyTradeFlow
import net.corda.testing.BOC
import java.security.PublicKey import java.security.PublicKey
import java.time.Instant import java.time.Instant
import java.util.* import java.util.*
@ -66,7 +67,7 @@ class SellerFlow(val otherParty: Party,
fun selfIssueSomeCommercialPaper(ownedBy: PublicKey, notaryNode: NodeInfo): StateAndRef<CommercialPaper.State> { fun selfIssueSomeCommercialPaper(ownedBy: PublicKey, notaryNode: NodeInfo): StateAndRef<CommercialPaper.State> {
// Make a fake company that's issued its own paper. // Make a fake company that's issued its own paper.
val keyPair = generateKeyPair() val keyPair = generateKeyPair()
val party = Party(DUMMY_BANK_C.name, keyPair.public) val party = Party(BOC.name, keyPair.public)
val issuance: SignedTransaction = run { val issuance: SignedTransaction = run {
val tx = CommercialPaper().generateIssue(party.ref(1, 2, 3), 1100.DOLLARS `issued by` DUMMY_CASH_ISSUER, val tx = CommercialPaper().generateIssue(party.ref(1, 2, 3), 1100.DOLLARS `issued by` DUMMY_CASH_ISSUER,

View File

@ -8,6 +8,7 @@ import com.google.common.util.concurrent.ListenableFuture
import net.corda.core.contracts.StateRef import net.corda.core.contracts.StateRef
import net.corda.core.crypto.Party import net.corda.core.crypto.Party
import net.corda.core.crypto.SecureHash import net.corda.core.crypto.SecureHash
import net.corda.core.crypto.X509Utilities
import net.corda.core.crypto.generateKeyPair import net.corda.core.crypto.generateKeyPair
import net.corda.core.flows.FlowLogic import net.corda.core.flows.FlowLogic
import net.corda.core.node.ServiceHub import net.corda.core.node.ServiceHub
@ -26,6 +27,7 @@ import net.corda.nodeapi.config.SSLConfiguration
import net.corda.testing.node.MockIdentityService import net.corda.testing.node.MockIdentityService
import net.corda.testing.node.MockServices import net.corda.testing.node.MockServices
import net.corda.testing.node.makeTestDataSourceProperties import net.corda.testing.node.makeTestDataSourceProperties
import org.bouncycastle.asn1.x500.X500Name
import java.net.ServerSocket import java.net.ServerSocket
import java.net.URL import java.net.URL
import java.nio.file.Files import java.nio.file.Files
@ -67,17 +69,17 @@ val ALICE_PUBKEY: PublicKey get() = ALICE_KEY.public
val BOB_PUBKEY: PublicKey get() = BOB_KEY.public val BOB_PUBKEY: PublicKey get() = BOB_KEY.public
val CHARLIE_PUBKEY: PublicKey get() = CHARLIE_KEY.public val CHARLIE_PUBKEY: PublicKey get() = CHARLIE_KEY.public
val MEGA_CORP: Party get() = Party("MegaCorp", MEGA_CORP_PUBKEY) val MEGA_CORP: Party get() = Party(X509Utilities.getDevX509Name("MegaCorp"), MEGA_CORP_PUBKEY)
val MINI_CORP: Party get() = Party("MiniCorp", MINI_CORP_PUBKEY) val MINI_CORP: Party get() = Party(X509Utilities.getDevX509Name("MiniCorp"), MINI_CORP_PUBKEY)
val BOC_KEY: KeyPair by lazy { generateKeyPair() } val BOC_KEY: KeyPair by lazy { generateKeyPair() }
val BOC_PUBKEY: PublicKey get() = BOC_KEY.public val BOC_PUBKEY: PublicKey get() = BOC_KEY.public
val BOC: Party get() = Party("CN=BankOfCorda,O=R3,OU=corda,L=New York,C=USA", BOC_PUBKEY) val BOC: Party get() = Party(X500Name("CN=BankOfCorda,O=R3,OU=corda,L=New York,C=USA"), BOC_PUBKEY)
val BOC_PARTY_REF = BOC.ref(OpaqueBytes.of(1)).reference val BOC_PARTY_REF = BOC.ref(OpaqueBytes.of(1)).reference
val BIG_CORP_KEY: KeyPair by lazy { generateKeyPair() } val BIG_CORP_KEY: KeyPair by lazy { generateKeyPair() }
val BIG_CORP_PUBKEY: PublicKey get() = BIG_CORP_KEY.public val BIG_CORP_PUBKEY: PublicKey get() = BIG_CORP_KEY.public
val BIG_CORP: Party get() = Party("BigCorporation", BIG_CORP_PUBKEY) val BIG_CORP: Party get() = Party(X509Utilities.getDevX509Name("BigCorporation"), BIG_CORP_PUBKEY)
val BIG_CORP_PARTY_REF = BIG_CORP.ref(OpaqueBytes.of(1)).reference val BIG_CORP_PARTY_REF = BIG_CORP.ref(OpaqueBytes.of(1)).reference
val ALL_TEST_KEYS: List<KeyPair> get() = listOf(MEGA_CORP_KEY, MINI_CORP_KEY, ALICE_KEY, BOB_KEY, DUMMY_NOTARY_KEY) val ALL_TEST_KEYS: List<KeyPair> get() = listOf(MEGA_CORP_KEY, MINI_CORP_KEY, ALICE_KEY, BOB_KEY, DUMMY_NOTARY_KEY)

View File

@ -3,11 +3,13 @@ package net.corda.testing.node
import co.paralleluniverse.common.util.VisibleForTesting import co.paralleluniverse.common.util.VisibleForTesting
import net.corda.core.crypto.DummyPublicKey import net.corda.core.crypto.DummyPublicKey
import net.corda.core.crypto.Party import net.corda.core.crypto.Party
import net.corda.core.crypto.X509Utilities
import net.corda.core.messaging.SingleMessageRecipient import net.corda.core.messaging.SingleMessageRecipient
import net.corda.core.node.NodeInfo import net.corda.core.node.NodeInfo
import net.corda.core.node.services.NetworkMapCache import net.corda.core.node.services.NetworkMapCache
import net.corda.node.services.network.InMemoryNetworkMapCache import net.corda.node.services.network.InMemoryNetworkMapCache
import net.corda.testing.MOCK_VERSION_INFO import net.corda.testing.MOCK_VERSION_INFO
import org.bouncycastle.asn1.x500.X500Name
import rx.Observable import rx.Observable
import rx.subjects.PublishSubject import rx.subjects.PublishSubject
@ -15,13 +17,18 @@ import rx.subjects.PublishSubject
* Network map cache with no backing map service. * Network map cache with no backing map service.
*/ */
class MockNetworkMapCache : InMemoryNetworkMapCache() { class MockNetworkMapCache : InMemoryNetworkMapCache() {
private companion object {
val BANK_C = Party(X500Name("CN=Bank C,OU=Corda QA Department,O=R3 CEV,L=New York,C=US"), DummyPublicKey("Bank C"))
val BANK_D = Party(X500Name("CN=Bank D,OU=Corda QA Department,O=R3 CEV,L=New York,C=US"), DummyPublicKey("Bank D"))
}
override val changed: Observable<NetworkMapCache.MapChange> = PublishSubject.create<NetworkMapCache.MapChange>() override val changed: Observable<NetworkMapCache.MapChange> = PublishSubject.create<NetworkMapCache.MapChange>()
data class MockAddress(val id: String) : SingleMessageRecipient data class MockAddress(val id: String) : SingleMessageRecipient
init { init {
val mockNodeA = NodeInfo(MockAddress("bankC:8080"), Party("Bank C", DummyPublicKey("Bank C")), MOCK_VERSION_INFO.platformVersion) val mockNodeA = NodeInfo(MockAddress("bankC:8080"), BANK_C, MOCK_VERSION_INFO.platformVersion)
val mockNodeB = NodeInfo(MockAddress("bankD:8080"), Party("Bank D", DummyPublicKey("Bank D")), MOCK_VERSION_INFO.platformVersion) val mockNodeB = NodeInfo(MockAddress("bankD:8080"), BANK_D, MOCK_VERSION_INFO.platformVersion)
registeredNodes[mockNodeA.legalIdentity.owningKey] = mockNodeA registeredNodes[mockNodeA.legalIdentity.owningKey] = mockNodeA
registeredNodes[mockNodeB.legalIdentity.owningKey] = mockNodeB registeredNodes[mockNodeB.legalIdentity.owningKey] = mockNodeB
runWithoutMapService() runWithoutMapService()

View File

@ -3,9 +3,6 @@ package net.corda.testing.node
import net.corda.core.contracts.Attachment import net.corda.core.contracts.Attachment
import net.corda.core.contracts.PartyAndReference import net.corda.core.contracts.PartyAndReference
import net.corda.core.crypto.* import net.corda.core.crypto.*
import net.corda.core.flows.FlowInitiator
import net.corda.core.flows.FlowLogic
import net.corda.core.flows.FlowStateMachine
import net.corda.core.flows.StateMachineRunId import net.corda.core.flows.StateMachineRunId
import net.corda.core.messaging.MessagingService import net.corda.core.messaging.MessagingService
import net.corda.core.messaging.SingleMessageRecipient import net.corda.core.messaging.SingleMessageRecipient
@ -65,7 +62,7 @@ open class MockServices(val key: KeyPair = generateKeyPair()) : ServiceHub {
override val networkMapCache: NetworkMapCache get() = throw UnsupportedOperationException() override val networkMapCache: NetworkMapCache get() = throw UnsupportedOperationException()
override val clock: Clock get() = Clock.systemUTC() override val clock: Clock get() = Clock.systemUTC()
override val schedulerService: SchedulerService get() = throw UnsupportedOperationException() override val schedulerService: SchedulerService get() = throw UnsupportedOperationException()
override val myInfo: NodeInfo get() = NodeInfo(object : SingleMessageRecipient {}, Party("MegaCorp", key.public), MOCK_VERSION_INFO.platformVersion) override val myInfo: NodeInfo get() = NodeInfo(object : SingleMessageRecipient {}, Party(MEGA_CORP.name, key.public), MOCK_VERSION_INFO.platformVersion)
override val transactionVerifierService: TransactionVerifierService get() = InMemoryTransactionVerifierService(2) override val transactionVerifierService: TransactionVerifierService get() = InMemoryTransactionVerifierService(2)
fun makeVaultService(dataSourceProps: Properties): VaultService { fun makeVaultService(dataSourceProps: Properties): VaultService {

View File

@ -18,6 +18,7 @@ import net.corda.contracts.asset.Cash
import net.corda.core.contracts.Amount import net.corda.core.contracts.Amount
import net.corda.core.contracts.GBP import net.corda.core.contracts.GBP
import net.corda.core.contracts.USD import net.corda.core.contracts.USD
import net.corda.core.crypto.X509Utilities
import net.corda.core.failure import net.corda.core.failure
import net.corda.core.messaging.FlowHandle import net.corda.core.messaging.FlowHandle
import net.corda.core.node.services.ServiceInfo import net.corda.core.node.services.ServiceInfo
@ -44,6 +45,7 @@ import net.corda.node.services.startFlowPermission
import net.corda.node.services.transactions.SimpleNotaryService import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.nodeapi.User import net.corda.nodeapi.User
import org.apache.commons.lang.SystemUtils import org.apache.commons.lang.SystemUtils
import org.bouncycastle.asn1.x500.X500Name
import org.controlsfx.dialog.ExceptionDialog import org.controlsfx.dialog.ExceptionDialog
import tornadofx.* import tornadofx.*
import java.time.Instant import java.time.Instant
@ -172,10 +174,10 @@ fun main(args: Array<String>) {
val bob = startNode(BOB.name, rpcUsers = arrayListOf(user), val bob = startNode(BOB.name, rpcUsers = arrayListOf(user),
advertisedServices = setOf(ServiceInfo(ServiceType.corda.getSubType("cash"))), advertisedServices = setOf(ServiceInfo(ServiceType.corda.getSubType("cash"))),
customOverrides = mapOf("nearestCity" to "Madrid")) customOverrides = mapOf("nearestCity" to "Madrid"))
val issuerGBP = startNode("UK Bank Plc", rpcUsers = arrayListOf(manager), val issuerGBP = startNode(X500Name("CN=UK Bank Plc,O=UK Bank Plc,L=London,C=UK"), rpcUsers = arrayListOf(manager),
advertisedServices = setOf(ServiceInfo(ServiceType.corda.getSubType("issuer.GBP"))), advertisedServices = setOf(ServiceInfo(ServiceType.corda.getSubType("issuer.GBP"))),
customOverrides = mapOf("nearestCity" to "London")) customOverrides = mapOf("nearestCity" to "London"))
val issuerUSD = startNode("USA Bank Corp", rpcUsers = arrayListOf(manager), val issuerUSD = startNode(X500Name("CN=USA Bank Corp,O=USA Bank Corp,L=New York,C=USA"), rpcUsers = arrayListOf(manager),
advertisedServices = setOf(ServiceInfo(ServiceType.corda.getSubType("issuer.USD"))), advertisedServices = setOf(ServiceInfo(ServiceType.corda.getSubType("issuer.USD"))),
customOverrides = mapOf("nearestCity" to "New York")) customOverrides = mapOf("nearestCity" to "New York"))