From 98266da41cd5d5d71ae46a765f8dde038fcbd088 Mon Sep 17 00:00:00 2001 From: Chris Rankin Date: Wed, 22 Mar 2017 15:52:54 +0000 Subject: [PATCH] Refactor CordaRPCClient into new :client:rpc Gradle module. (#405) * CORDA-305: Refactor CordaRPCClient into :client:rpc module * CORDA-305: Remove the Kotlin test framework from the artifacts. * CORDA-305: Migrate serialisation whitelist into node-api module. * CORDA-305: Clean up unused RPC observables. * CORDA-305: Add :client:rpc module to documentation tasks. * CORDA-305: Include :finance into :client:rpc for its serialisable classes. * CORDA-305: Move test classes into the correct directory. * CORDA-305: Migrate :finance dependency from :client:rpc into DemoBench. * CORDA-305: Update wording of TODO about handling Observables. --- build.gradle | 10 +-- client/jackson/build.gradle | 1 + client/jfx/build.gradle | 5 +- .../corda/client/jfx/CordaRPCClientTest.kt | 4 +- .../corda/client/jfx/NodeMonitorModelTest.kt | 2 +- .../client/jfx/model/NetworkIdentityModel.kt | 3 +- .../client/jfx/model/NodeMonitorModel.kt | 2 +- .../corda/client/jfx/utils/FlattenedList.kt | 3 +- client/mock/build.gradle | 3 +- client/rpc/build.gradle | 64 +++++++++++++++++++ .../net/corda/client/rpc}/CordaRPCClient.kt | 5 +- .../corda/client/rpc}/CordaRPCClientImpl.kt | 19 +++++- .../corda/client/rpc}/AbstractClientRPC.kt | 3 +- .../rpc}/ClientRPCInfrastructureTests.kt | 2 +- .../corda/client/rpc}/RPCPermissionsTest.kt | 2 +- core/build.gradle | 4 +- .../corda/core/node/services/ServiceType.kt | 4 +- .../core/flows/ContractUpgradeFlowTest.kt | 4 +- docs/source/example-code/build.gradle | 1 + .../corda/docs/IntegrationTestingTutorial.kt | 2 +- .../net/corda/docs/ClientRpcTutorial.kt | 2 +- node-api/build.gradle | 6 +- .../nodeapi}/ArtemisMessagingComponent.kt | 2 +- .../net/corda/nodeapi}/RPCStructures.kt | 49 ++------------ .../serialization/DefaultWhitelist.kt | 4 +- .../net.corda.core.node.CordaPluginRegistry | 2 + node-schemas/build.gradle | 1 + node/build.gradle | 7 +- .../net/corda/node/driver/DriverTests.kt | 2 +- .../node/services/DistributedServiceTests.kt | 1 + .../messaging/MQSecurityAsNodeTest.kt | 6 +- .../services/messaging/MQSecurityAsRPCTest.kt | 2 +- .../services/messaging/MQSecurityTest.kt | 20 +++--- node/src/main/kotlin/net/corda/node/Corda.kt | 2 +- .../kotlin/net/corda/node/driver/Driver.kt | 6 +- .../kotlin/net/corda/node/internal/Node.kt | 3 +- .../net/corda/node/services/RPCUserService.kt | 5 +- .../node/services/config/NodeConfiguration.kt | 2 +- .../messaging/ArtemisMessagingServer.kt | 13 ++-- .../services/messaging/NodeMessagingClient.kt | 1 + .../node/services/messaging/RPCDispatcher.kt | 22 +++++-- .../services/messaging/RPCServerStructures.kt | 17 +++++ .../services/network/NetworkMapService.kt | 2 +- .../net.corda.core.node.CordaPluginRegistry | 3 +- .../net/corda/node/CordaRPCOpsImplTest.kt | 6 +- .../node/services/RPCUserServiceImplTest.kt | 1 + node/webserver/build.gradle | 2 +- .../corda/webserver/internal/NodeWebServer.kt | 5 +- .../attachmentdemo/AttachmentDemoTest.kt | 2 +- .../corda/attachmentdemo/AttachmentDemo.kt | 2 +- .../kotlin/net/corda/attachmentdemo/Main.kt | 2 +- samples/bank-of-corda-demo/build.gradle | 2 +- .../net/corda/bank/BankOfCordaHttpAPITest.kt | 1 - .../corda/bank/BankOfCordaRPCClientTest.kt | 2 +- .../net/corda/bank/BankOfCordaDriver.kt | 2 +- .../corda/bank/api/BankOfCordaClientApi.kt | 2 +- .../kotlin/net/corda/irs/IRSDemoTest.kt | 4 +- samples/raft-notary-demo/build.gradle | 2 +- .../main/kotlin/net/corda/notarydemo/Main.kt | 2 +- .../kotlin/net/corda/notarydemo/NotaryDemo.kt | 2 +- .../notarydemo/flows/DummyIssueAndMove.kt | 1 - .../notarydemo/plugin/NotaryDemoPlugin.kt | 1 - .../net/corda/traderdemo/TraderDemoTest.kt | 4 +- .../main/kotlin/net/corda/traderdemo/Main.kt | 2 +- .../kotlin/net/corda/traderdemo/TraderDemo.kt | 6 +- .../traderdemo/plugin/TraderDemoPlugin.kt | 2 - settings.gradle | 1 + .../corda/testing/messaging/SimpleMQClient.kt | 2 +- .../net/corda/testing/node/NodeBasedTest.kt | 2 +- tools/demobench/build.gradle | 7 +- .../kotlin/net/corda/demobench/rpc/NodeRPC.kt | 2 +- .../corda/demobench/views/NodeTerminalView.kt | 11 +++- tools/explorer/build.gradle | 1 + .../main/kotlin/net/corda/explorer/Main.kt | 2 +- tools/loadtest/build.gradle | 2 + .../net/corda/loadtest/ConnectionManager.kt | 5 +- 76 files changed, 248 insertions(+), 165 deletions(-) create mode 100644 client/rpc/build.gradle rename {node/src/main/kotlin/net/corda/node/services/messaging => client/rpc/src/main/kotlin/net/corda/client/rpc}/CordaRPCClient.kt (98%) rename {node/src/main/kotlin/net/corda/node/services/messaging => client/rpc/src/main/kotlin/net/corda/client/rpc}/CordaRPCClientImpl.kt (96%) rename {node/src/test/kotlin/net/corda/node/messaging => client/rpc/src/test/net/corda/client/rpc}/AbstractClientRPC.kt (97%) rename {node/src/test/kotlin/net/corda/node/messaging => client/rpc/src/test/net/corda/client/rpc}/ClientRPCInfrastructureTests.kt (99%) rename {node/src/test/kotlin/net/corda/node/messaging => client/rpc/src/test/net/corda/client/rpc}/RPCPermissionsTest.kt (98%) rename {node/src/main/kotlin/net/corda/node/services/messaging => node-api/src/main/kotlin/net/corda/nodeapi}/ArtemisMessagingComponent.kt (99%) rename {node/src/main/kotlin/net/corda/node/services/messaging => node-api/src/main/kotlin/net/corda/nodeapi}/RPCStructures.kt (72%) rename {node/src/main/kotlin/net/corda/node => node-api/src/main/kotlin/net/corda/nodeapi}/serialization/DefaultWhitelist.kt (98%) create mode 100644 node-api/src/main/resources/META-INF/services/net.corda.core.node.CordaPluginRegistry create mode 100644 node/src/main/kotlin/net/corda/node/services/messaging/RPCServerStructures.kt diff --git a/build.gradle b/build.gradle index 0a1402b5e4..4fbc368912 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ buildscript { ext.jersey_version = '2.25' ext.jolokia_version = '2.0.0-M3' ext.assertj_version = '3.6.1' - ext.slf4j_version = '1.7.22' + ext.slf4j_version = '1.7.24' ext.log4j_version = '2.7' ext.bouncycastle_version = '1.56' ext.guava_version = '19.0' @@ -27,6 +27,7 @@ buildscript { ext.okhttp_version = '3.5.0' ext.netty_version = '4.1.5.Final' ext.typesafe_config_version = '1.3.1' + ext.fileupload_version = '1.3.2' ext.junit_version = '4.12' ext.jopt_simple_version = '5.0.2' ext.jansi_version = '1.14' @@ -127,6 +128,7 @@ dependencies { // For the buildCordappDependenciesJar task runtime project(':client:jfx') runtime project(':client:mock') + runtime project(':client:rpc') runtime project(':core') runtime project(':finance') runtime project(':node:webserver') @@ -198,7 +200,7 @@ bintrayConfig { projectUrl = 'https://github.com/corda/corda' gpgSign = true gpgPassphrase = System.getenv('CORDA_BINTRAY_GPG_PASSPHRASE') - publications = ['jfx', 'mock', 'core', 'corda', 'corda-webserver', 'finance', 'node', 'node-api', 'node-schemas', 'test-utils', 'jackson', 'webserver'] + publications = ['jfx', 'mock', 'rpc', 'core', 'corda', 'corda-webserver', 'finance', 'node', 'node-api', 'node-schemas', 'test-utils', 'jackson', 'webserver'] license { name = 'Apache-2.0' url = 'https://www.apache.org/licenses/LICENSE-2.0' @@ -217,7 +219,7 @@ dokka { moduleName = 'corda' outputDirectory = 'docs/build/html/api/kotlin' processConfigurations = ['compile'] - sourceDirs = files('core/src/main/kotlin', 'client/jfx/src/main/kotlin', 'client/mock/src/main/kotlin', 'node/src/main/kotlin', 'finance/src/main/kotlin', 'client/jackson/src/main/kotlin') + sourceDirs = files('core/src/main/kotlin', 'client/jfx/src/main/kotlin', 'client/mock/src/main/kotlin', 'client/rpc/src/main/kotlin', 'node/src/main/kotlin', 'finance/src/main/kotlin', 'client/jackson/src/main/kotlin') } task dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaTask) { @@ -225,7 +227,7 @@ task dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaTask) { outputFormat = "javadoc" outputDirectory = 'docs/build/html/api/javadoc' processConfigurations = ['compile'] - sourceDirs = files('core/src/main/kotlin', 'client/jfx/src/main/kotlin', 'client/mock/src/main/kotlin', 'node/src/main/kotlin', 'finance/src/main/kotlin', 'client/jackson/src/main/kotlin') + sourceDirs = files('core/src/main/kotlin', 'client/jfx/src/main/kotlin', 'client/mock/src/main/kotlin', 'client/rpc/src/main/kotlin', 'node/src/main/kotlin', 'finance/src/main/kotlin', 'client/jackson/src/main/kotlin') } task apidocs(dependsOn: ['dokka', 'dokkaJavadoc']) diff --git a/client/jackson/build.gradle b/client/jackson/build.gradle index a895476683..b92adbd7ad 100644 --- a/client/jackson/build.gradle +++ b/client/jackson/build.gradle @@ -14,6 +14,7 @@ repositories { dependencies { compile project(':core') compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" // Jackson and its plugins: parsing to/from JSON and other textual formats. compile "com.fasterxml.jackson.module:jackson-module-kotlin:${jackson_version}" diff --git a/client/jfx/build.gradle b/client/jfx/build.gradle index 90b36527e0..6279c489c1 100644 --- a/client/jfx/build.gradle +++ b/client/jfx/build.gradle @@ -44,8 +44,9 @@ sourceSets { // build/reports/project/dependencies/index.html for green highlighted parts of the tree. dependencies { - compile project(":core") - compile project(':node') + compile project(':core') + compile project(':finance') + compile project(':client:rpc') compile "com.google.guava:guava:$guava_version" diff --git a/client/jfx/src/integration-test/kotlin/net/corda/client/jfx/CordaRPCClientTest.kt b/client/jfx/src/integration-test/kotlin/net/corda/client/jfx/CordaRPCClientTest.kt index 37b99d0c79..b6dc1572c3 100644 --- a/client/jfx/src/integration-test/kotlin/net/corda/client/jfx/CordaRPCClientTest.kt +++ b/client/jfx/src/integration-test/kotlin/net/corda/client/jfx/CordaRPCClientTest.kt @@ -1,5 +1,6 @@ package net.corda.client.jfx +import net.corda.client.rpc.CordaRPCClient import net.corda.core.contracts.DOLLARS import net.corda.core.flows.FlowException import net.corda.core.getOrThrow @@ -10,10 +11,9 @@ import net.corda.core.serialization.OpaqueBytes import net.corda.flows.CashIssueFlow import net.corda.flows.CashPaymentFlow import net.corda.node.internal.Node -import net.corda.node.services.User -import net.corda.node.services.messaging.CordaRPCClient import net.corda.node.services.startFlowPermission import net.corda.node.services.transactions.ValidatingNotaryService +import net.corda.nodeapi.User import net.corda.testing.node.NodeBasedTest import org.apache.activemq.artemis.api.core.ActiveMQSecurityException import org.assertj.core.api.Assertions.assertThatExceptionOfType diff --git a/client/jfx/src/integration-test/kotlin/net/corda/client/jfx/NodeMonitorModelTest.kt b/client/jfx/src/integration-test/kotlin/net/corda/client/jfx/NodeMonitorModelTest.kt index fff3c09523..48df7516b1 100644 --- a/client/jfx/src/integration-test/kotlin/net/corda/client/jfx/NodeMonitorModelTest.kt +++ b/client/jfx/src/integration-test/kotlin/net/corda/client/jfx/NodeMonitorModelTest.kt @@ -22,10 +22,10 @@ import net.corda.flows.CashExitFlow import net.corda.flows.CashIssueFlow import net.corda.flows.CashPaymentFlow import net.corda.node.driver.driver -import net.corda.node.services.User import net.corda.node.services.network.NetworkMapService import net.corda.node.services.startFlowPermission import net.corda.node.services.transactions.SimpleNotaryService +import net.corda.nodeapi.User import net.corda.testing.expect import net.corda.testing.expectEvents import net.corda.testing.node.DriverBasedTest diff --git a/client/jfx/src/main/kotlin/net/corda/client/jfx/model/NetworkIdentityModel.kt b/client/jfx/src/main/kotlin/net/corda/client/jfx/model/NetworkIdentityModel.kt index 9c3b1d408b..bbf7a2f42d 100644 --- a/client/jfx/src/main/kotlin/net/corda/client/jfx/model/NetworkIdentityModel.kt +++ b/client/jfx/src/main/kotlin/net/corda/client/jfx/model/NetworkIdentityModel.kt @@ -11,7 +11,6 @@ import net.corda.client.jfx.utils.map import net.corda.core.crypto.CompositeKey import net.corda.core.node.NodeInfo import net.corda.core.node.services.NetworkMapCache.MapChange -import net.corda.node.services.network.NetworkMapService import java.security.PublicKey class NetworkIdentityModel { @@ -37,7 +36,7 @@ class NetworkIdentityModel { private fun NodeInfo.isCordaService(): Boolean { // TODO: better way to identify Corda service? - return advertisedServices.any { it.info.type == NetworkMapService.type || it.info.type.isNotary() } + return advertisedServices.any { it.info.type.isNetworkMap() || it.info.type.isNotary() } } // TODO: Use Identity Service in service hub instead? diff --git a/client/jfx/src/main/kotlin/net/corda/client/jfx/model/NodeMonitorModel.kt b/client/jfx/src/main/kotlin/net/corda/client/jfx/model/NodeMonitorModel.kt index 24b5611752..a6ed4a7cf7 100644 --- a/client/jfx/src/main/kotlin/net/corda/client/jfx/model/NodeMonitorModel.kt +++ b/client/jfx/src/main/kotlin/net/corda/client/jfx/model/NodeMonitorModel.kt @@ -2,6 +2,7 @@ package net.corda.client.jfx.model import com.google.common.net.HostAndPort import javafx.beans.property.SimpleObjectProperty +import net.corda.client.rpc.CordaRPCClient import net.corda.core.flows.StateMachineRunId import net.corda.core.messaging.CordaRPCOps import net.corda.core.messaging.StateMachineInfo @@ -11,7 +12,6 @@ import net.corda.core.node.services.StateMachineTransactionMapping import net.corda.core.node.services.Vault import net.corda.core.seconds import net.corda.core.transactions.SignedTransaction -import net.corda.node.services.messaging.CordaRPCClient import rx.Observable import rx.subjects.PublishSubject diff --git a/client/jfx/src/main/kotlin/net/corda/client/jfx/utils/FlattenedList.kt b/client/jfx/src/main/kotlin/net/corda/client/jfx/utils/FlattenedList.kt index 8e9bcf7d98..4e2153c905 100644 --- a/client/jfx/src/main/kotlin/net/corda/client/jfx/utils/FlattenedList.kt +++ b/client/jfx/src/main/kotlin/net/corda/client/jfx/utils/FlattenedList.kt @@ -6,7 +6,6 @@ import javafx.collections.ListChangeListener import javafx.collections.ObservableList import javafx.collections.transformation.TransformationList import java.util.* -import kotlin.test.assertEquals /** * [FlattenedList] flattens the passed in list of [ObservableValue]s so that changes in individual updates to the values @@ -107,7 +106,7 @@ class FlattenedList(val sourceList: ObservableList } } endChange() - assertEquals(sourceList.size, indexMap.size) + assert(sourceList.size == indexMap.size) } override fun get(index: Int) = sourceList.get(index).value diff --git a/client/mock/build.gradle b/client/mock/build.gradle index ec64233971..1a08e05b38 100644 --- a/client/mock/build.gradle +++ b/client/mock/build.gradle @@ -34,7 +34,8 @@ sourceSets { // build/reports/project/dependencies/index.html for green highlighted parts of the tree. dependencies { - compile project(":node") + compile project(":core") + compile project(':finance') // Unit testing helpers. testCompile "junit:junit:$junit_version" diff --git a/client/rpc/build.gradle b/client/rpc/build.gradle new file mode 100644 index 0000000000..eaeb7a81ef --- /dev/null +++ b/client/rpc/build.gradle @@ -0,0 +1,64 @@ +apply plugin: 'kotlin' +apply plugin: 'net.corda.plugins.quasar-utils' +apply plugin: 'net.corda.plugins.publish-utils' + +description 'Corda client RPC modules' + +repositories { + mavenLocal() + mavenCentral() + maven { + url 'http://oss.sonatype.org/content/repositories/snapshots' + } + jcenter() + maven { + url 'https://dl.bintray.com/kotlin/exposed' + } +} + +//noinspection GroovyAssignabilityCheck +configurations { + // we don't want isolated.jar in classPath, since we want to test jar being dynamically loaded as an attachment + runtime.exclude module: 'isolated' + + integrationTestCompile.extendsFrom testCompile + integrationTestRuntime.extendsFrom testRuntime +} + +sourceSets { + integrationTest { + kotlin { + compileClasspath += main.output + test.output + runtimeClasspath += main.output + test.output + srcDir file('src/integration-test/kotlin') + } + } + test { + resources { + srcDir "../../config/test" + } + } +} + +// To find potential version conflicts, run "gradle htmlDependencyReport" and then look in +// build/reports/project/dependencies/index.html for green highlighted parts of the tree. + +dependencies { + compile project(':core') + compile project(':node-api') + + // Unit testing helpers. + testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" + testCompile "junit:junit:$junit_version" + testCompile "org.assertj:assertj-core:${assertj_version}" + + testCompile project(':test-utils') + + // Integration test helpers + integrationTestCompile "junit:junit:$junit_version" +} + +task integrationTest(type: Test) { + testClassesDir = sourceSets.integrationTest.output.classesDir + classpath = sourceSets.integrationTest.runtimeClasspath +} diff --git a/node/src/main/kotlin/net/corda/node/services/messaging/CordaRPCClient.kt b/client/rpc/src/main/kotlin/net/corda/client/rpc/CordaRPCClient.kt similarity index 98% rename from node/src/main/kotlin/net/corda/node/services/messaging/CordaRPCClient.kt rename to client/rpc/src/main/kotlin/net/corda/client/rpc/CordaRPCClient.kt index 1d51c03f9f..15c290400f 100644 --- a/node/src/main/kotlin/net/corda/node/services/messaging/CordaRPCClient.kt +++ b/client/rpc/src/main/kotlin/net/corda/client/rpc/CordaRPCClient.kt @@ -1,4 +1,4 @@ -package net.corda.node.services.messaging +package net.corda.client.rpc import com.google.common.net.HostAndPort import net.corda.nodeapi.config.SSLConfiguration @@ -8,8 +8,11 @@ import net.corda.core.messaging.CordaRPCOps import net.corda.core.minutes import net.corda.core.seconds import net.corda.core.utilities.loggerFor +import net.corda.nodeapi.ArtemisMessagingComponent import net.corda.nodeapi.ArtemisTcpTransport.Companion.tcpTransport import net.corda.nodeapi.ConnectionDirection +import net.corda.nodeapi.RPCException +import net.corda.nodeapi.rpcLog import org.apache.activemq.artemis.api.core.ActiveMQException import org.apache.activemq.artemis.api.core.client.ActiveMQClient import org.apache.activemq.artemis.api.core.client.ClientSession diff --git a/node/src/main/kotlin/net/corda/node/services/messaging/CordaRPCClientImpl.kt b/client/rpc/src/main/kotlin/net/corda/client/rpc/CordaRPCClientImpl.kt similarity index 96% rename from node/src/main/kotlin/net/corda/node/services/messaging/CordaRPCClientImpl.kt rename to client/rpc/src/main/kotlin/net/corda/client/rpc/CordaRPCClientImpl.kt index 5307f14861..e5771beb54 100644 --- a/node/src/main/kotlin/net/corda/node/services/messaging/CordaRPCClientImpl.kt +++ b/client/rpc/src/main/kotlin/net/corda/client/rpc/CordaRPCClientImpl.kt @@ -1,10 +1,11 @@ -package net.corda.node.services.messaging +package net.corda.client.rpc import com.esotericsoftware.kryo.Kryo import com.esotericsoftware.kryo.KryoException import com.esotericsoftware.kryo.Serializer import com.esotericsoftware.kryo.io.Input import com.esotericsoftware.kryo.io.Output +import com.esotericsoftware.kryo.pool.KryoPool import com.google.common.cache.CacheBuilder import net.corda.core.ErrorOr import net.corda.core.bufferUntilSubscribed @@ -14,6 +15,7 @@ import net.corda.core.random63BitValue import net.corda.core.serialization.deserialize import net.corda.core.serialization.serialize import net.corda.core.utilities.debug +import net.corda.nodeapi.* import org.apache.activemq.artemis.api.core.ActiveMQObjectClosedException import org.apache.activemq.artemis.api.core.Message.HDR_DUPLICATE_DETECTION_ID import org.apache.activemq.artemis.api.core.SimpleString @@ -383,3 +385,18 @@ class CordaRPCClientImpl(private val session: ClientSession, } //endregion } + +private val rpcDesKryoPool = KryoPool.Builder { RPCKryo(CordaRPCClientImpl.ObservableDeserializer()) }.build() + +fun createRPCKryoForDeserialization(rpcClient: CordaRPCClientImpl, qName: String? = null, rpcName: String? = null, rpcLocation: Throwable? = null): Kryo { + val kryo = rpcDesKryoPool.borrow() + kryo.context.put(RPCKryoClientKey, rpcClient) + kryo.context.put(RPCKryoQNameKey, qName) + kryo.context.put(RPCKryoMethodNameKey, rpcName) + kryo.context.put(RPCKryoLocationKey, rpcLocation) + return kryo +} + +fun releaseRPCKryoForDeserialization(kryo: Kryo) { + rpcDesKryoPool.release(kryo) +} diff --git a/node/src/test/kotlin/net/corda/node/messaging/AbstractClientRPC.kt b/client/rpc/src/test/net/corda/client/rpc/AbstractClientRPC.kt similarity index 97% rename from node/src/test/kotlin/net/corda/node/messaging/AbstractClientRPC.kt rename to client/rpc/src/test/net/corda/client/rpc/AbstractClientRPC.kt index 8f1a4ddead..7431ce3e1f 100644 --- a/node/src/test/kotlin/net/corda/node/messaging/AbstractClientRPC.kt +++ b/client/rpc/src/test/net/corda/client/rpc/AbstractClientRPC.kt @@ -1,4 +1,4 @@ -package net.corda.node.messaging +package net.corda.client.rpc import net.corda.core.messaging.RPCOps import net.corda.core.serialization.SerializedBytes @@ -6,7 +6,6 @@ import net.corda.core.utilities.LogHelper import net.corda.node.services.RPCUserService import net.corda.node.services.User import net.corda.node.services.messaging.ArtemisMessagingComponent -import net.corda.node.services.messaging.CordaRPCClientImpl import net.corda.node.services.messaging.RPCDispatcher import net.corda.node.utilities.AffinityExecutor import org.apache.activemq.artemis.api.core.Message diff --git a/node/src/test/kotlin/net/corda/node/messaging/ClientRPCInfrastructureTests.kt b/client/rpc/src/test/net/corda/client/rpc/ClientRPCInfrastructureTests.kt similarity index 99% rename from node/src/test/kotlin/net/corda/node/messaging/ClientRPCInfrastructureTests.kt rename to client/rpc/src/test/net/corda/client/rpc/ClientRPCInfrastructureTests.kt index cf06874d52..9eb28a474d 100644 --- a/node/src/test/kotlin/net/corda/node/messaging/ClientRPCInfrastructureTests.kt +++ b/client/rpc/src/test/net/corda/client/rpc/ClientRPCInfrastructureTests.kt @@ -1,4 +1,4 @@ -package net.corda.node.messaging +package net.corda.client.rpc import com.google.common.util.concurrent.Futures import com.google.common.util.concurrent.ListenableFuture diff --git a/node/src/test/kotlin/net/corda/node/messaging/RPCPermissionsTest.kt b/client/rpc/src/test/net/corda/client/rpc/RPCPermissionsTest.kt similarity index 98% rename from node/src/test/kotlin/net/corda/node/messaging/RPCPermissionsTest.kt rename to client/rpc/src/test/net/corda/client/rpc/RPCPermissionsTest.kt index 1eff060ef0..2729ae8f86 100644 --- a/node/src/test/kotlin/net/corda/node/messaging/RPCPermissionsTest.kt +++ b/client/rpc/src/test/net/corda/client/rpc/RPCPermissionsTest.kt @@ -1,4 +1,4 @@ -package net.corda.node.messaging +package net.corda.client.rpc import net.corda.core.messaging.RPCOps import net.corda.node.services.User diff --git a/core/build.gradle b/core/build.gradle index b9241e4a47..6c94a4a196 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -33,7 +33,7 @@ sourceSets { dependencies { testCompile "junit:junit:$junit_version" - testCompile "commons-fileupload:commons-fileupload:1.3.2" + testCompile "commons-fileupload:commons-fileupload:$fileupload_version" // Guava: Google test library (collections test suite) testCompile "com.google.guava:guava-testlib:$guava_version" @@ -45,7 +45,7 @@ dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" compile "org.jetbrains.kotlinx:kotlinx-support-jdk8:0.3" - compile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" + testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" // Thread safety annotations compile "com.google.code.findbugs:jsr305:3.0.1" diff --git a/core/src/main/kotlin/net/corda/core/node/services/ServiceType.kt b/core/src/main/kotlin/net/corda/core/node/services/ServiceType.kt index dc7e35102b..fc89811657 100644 --- a/core/src/main/kotlin/net/corda/core/node/services/ServiceType.kt +++ b/core/src/main/kotlin/net/corda/core/node/services/ServiceType.kt @@ -31,6 +31,7 @@ sealed class ServiceType(val id: String) { val notary: ServiceType = corda.getSubType("notary") val regulator: ServiceType = corda.getSubType("regulator") + val networkMap: ServiceType = corda.getSubType("network_map") fun getServiceType(namespace: String, typeId: String): ServiceType { require(!namespace.startsWith("corda")) { "Corda namespace is protected" } @@ -47,7 +48,8 @@ sealed class ServiceType(val id: String) { fun isSubTypeOf(superType: ServiceType) = (id == superType.id) || id.startsWith(superType.id + ".") fun isNotary() = isSubTypeOf(notary) fun isValidatingNotary() = isNotary() && id.contains(".validating") + fun isNetworkMap() = id == networkMap.id override fun hashCode(): Int = id.hashCode() - override fun toString(): String = id.toString() + override fun toString(): String = id } diff --git a/core/src/test/kotlin/net/corda/core/flows/ContractUpgradeFlowTest.kt b/core/src/test/kotlin/net/corda/core/flows/ContractUpgradeFlowTest.kt index 962459612f..7529269fca 100644 --- a/core/src/test/kotlin/net/corda/core/flows/ContractUpgradeFlowTest.kt +++ b/core/src/test/kotlin/net/corda/core/flows/ContractUpgradeFlowTest.kt @@ -14,10 +14,10 @@ import net.corda.flows.CashIssueFlow import net.corda.flows.ContractUpgradeFlow import net.corda.flows.FinalityFlow import net.corda.node.internal.CordaRPCOpsImpl -import net.corda.node.services.User -import net.corda.node.services.messaging.CURRENT_RPC_USER import net.corda.node.services.startFlowPermission import net.corda.node.utilities.databaseTransaction +import net.corda.nodeapi.CURRENT_RPC_USER +import net.corda.nodeapi.User import net.corda.testing.node.MockNetwork import org.junit.After import org.junit.Before diff --git a/docs/source/example-code/build.gradle b/docs/source/example-code/build.gradle index be45ebc6d9..9d0f556482 100644 --- a/docs/source/example-code/build.gradle +++ b/docs/source/example-code/build.gradle @@ -41,6 +41,7 @@ compileTestJava.dependsOn tasks.getByPath(':node:capsule:buildCordaJAR') dependencies { compile project(':core') compile project(':client:jfx') + compile project(':node') testCompile project(':test-utils') compile "org.graphstream:gs-core:1.3" diff --git a/docs/source/example-code/src/integration-test/kotlin/net/corda/docs/IntegrationTestingTutorial.kt b/docs/source/example-code/src/integration-test/kotlin/net/corda/docs/IntegrationTestingTutorial.kt index 2be6b47c58..489e1eb6b5 100644 --- a/docs/source/example-code/src/integration-test/kotlin/net/corda/docs/IntegrationTestingTutorial.kt +++ b/docs/source/example-code/src/integration-test/kotlin/net/corda/docs/IntegrationTestingTutorial.kt @@ -12,9 +12,9 @@ import net.corda.core.serialization.OpaqueBytes import net.corda.flows.CashIssueFlow import net.corda.flows.CashPaymentFlow import net.corda.node.driver.driver -import net.corda.node.services.User import net.corda.node.services.startFlowPermission import net.corda.node.services.transactions.ValidatingNotaryService +import net.corda.nodeapi.User import net.corda.testing.expect import net.corda.testing.expectEvents import net.corda.testing.parallel diff --git a/docs/source/example-code/src/main/kotlin/net/corda/docs/ClientRpcTutorial.kt b/docs/source/example-code/src/main/kotlin/net/corda/docs/ClientRpcTutorial.kt index 2f26d671ee..09cea98ba2 100644 --- a/docs/source/example-code/src/main/kotlin/net/corda/docs/ClientRpcTutorial.kt +++ b/docs/source/example-code/src/main/kotlin/net/corda/docs/ClientRpcTutorial.kt @@ -17,9 +17,9 @@ import net.corda.flows.CashExitFlow import net.corda.flows.CashIssueFlow import net.corda.flows.CashPaymentFlow import net.corda.node.driver.driver -import net.corda.node.services.User import net.corda.node.services.startFlowPermission import net.corda.node.services.transactions.ValidatingNotaryService +import net.corda.nodeapi.User import org.graphstream.graph.Edge import org.graphstream.graph.Node import org.graphstream.graph.implementations.MultiGraph diff --git a/node-api/build.gradle b/node-api/build.gradle index 5e2e748f1c..0c7f81735a 100644 --- a/node-api/build.gradle +++ b/node-api/build.gradle @@ -41,10 +41,14 @@ dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" compile "org.jetbrains.kotlinx:kotlinx-support-jdk8:0.3" - compile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" + testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" compile "org.apache.activemq:artemis-core-client:${artemis_version}" compile "org.apache.activemq:artemis-commons:${artemis_version}" + // For adding serialisation of file upload streams to RPC + // TODO: Remove this dependency and the code that requires it + compile "commons-fileupload:commons-fileupload:$fileupload_version" + // TypeSafe Config: for simple and human friendly config files. compile "com.typesafe:config:$typesafe_config_version" } diff --git a/node/src/main/kotlin/net/corda/node/services/messaging/ArtemisMessagingComponent.kt b/node-api/src/main/kotlin/net/corda/nodeapi/ArtemisMessagingComponent.kt similarity index 99% rename from node/src/main/kotlin/net/corda/node/services/messaging/ArtemisMessagingComponent.kt rename to node-api/src/main/kotlin/net/corda/nodeapi/ArtemisMessagingComponent.kt index 7de69c26d9..77a5b1c087 100644 --- a/node/src/main/kotlin/net/corda/node/services/messaging/ArtemisMessagingComponent.kt +++ b/node-api/src/main/kotlin/net/corda/nodeapi/ArtemisMessagingComponent.kt @@ -1,4 +1,4 @@ -package net.corda.node.services.messaging +package net.corda.nodeapi import com.google.common.annotations.VisibleForTesting import com.google.common.net.HostAndPort diff --git a/node/src/main/kotlin/net/corda/node/services/messaging/RPCStructures.kt b/node-api/src/main/kotlin/net/corda/nodeapi/RPCStructures.kt similarity index 72% rename from node/src/main/kotlin/net/corda/node/services/messaging/RPCStructures.kt rename to node-api/src/main/kotlin/net/corda/nodeapi/RPCStructures.kt index 5662b8d295..21dc8c2917 100644 --- a/node/src/main/kotlin/net/corda/node/services/messaging/RPCStructures.kt +++ b/node-api/src/main/kotlin/net/corda/nodeapi/RPCStructures.kt @@ -1,20 +1,17 @@ @file:JvmName("RPCStructures") -package net.corda.node.services.messaging +package net.corda.nodeapi import com.esotericsoftware.kryo.Kryo import com.esotericsoftware.kryo.Registration import com.esotericsoftware.kryo.Serializer import com.esotericsoftware.kryo.io.Input import com.esotericsoftware.kryo.io.Output -import com.esotericsoftware.kryo.pool.KryoPool import com.google.common.util.concurrent.ListenableFuture import net.corda.core.flows.FlowException import net.corda.core.serialization.* import net.corda.core.toFuture import net.corda.core.toObservable -import net.corda.node.services.User -import net.corda.node.services.messaging.ArtemisMessagingComponent.Companion.NODE_USER import org.apache.commons.fileupload.MultipartStream import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -27,6 +24,10 @@ val rpcLog: Logger by lazy { LoggerFactory.getLogger("net.corda.rpc") } /** Used in the RPC wire protocol to wrap an observation with the handle of the observable it's intended for. */ data class MarshalledObservation(val forHandle: Int, val what: Notification<*>) +data class User(val username: String, val password: String, val permissions: Set) { + override fun toString(): String = "${javaClass.simpleName}($username, permissions=$permissions)" +} + /** Records the protocol version in which this RPC was added. */ @Target(AnnotationTarget.FUNCTION) @MustBeDocumented @@ -54,16 +55,6 @@ data class ClientRPCRequestMessage( @JvmField val CURRENT_RPC_USER: ThreadLocal = ThreadLocal() -/** Helper method which checks that the current RPC user is entitled for the given permission. Throws a [PermissionException] otherwise. */ -fun requirePermission(permission: String) { - // TODO remove the NODE_USER condition once webserver doesn't need it - val currentUser = CURRENT_RPC_USER.get() - val currentUserPermissions = currentUser.permissions - if (currentUser.username != NODE_USER && currentUserPermissions.intersect(listOf(permission, "ALL")).isEmpty()) { - throw PermissionException("User not permissioned for $permission, permissions are $currentUserPermissions") - } -} - /** * Thrown to indicate a fatal error in the RPC system itself, as opposed to an error generated by the invoked * method. @@ -98,7 +89,7 @@ object RPCKryoLocationKey // The Kryo used for the RPC wire protocol. Every type in the wire protocol is listed here explicitly. // This is annoying to write out, but will make it easier to formalise the wire protocol when the time comes, // because we can see everything we're using in one place. -private class RPCKryo(observableSerializer: Serializer>) : CordaKryo(makeStandardClassResolver()) { +class RPCKryo(observableSerializer: Serializer>) : CordaKryo(makeStandardClassResolver()) { init { DefaultKryoCustomizer.customize(this) @@ -143,31 +134,3 @@ private class RPCKryo(observableSerializer: Serializer>) : Corda return super.getRegistration(type) } } - -private val rpcSerKryoPool = KryoPool.Builder { RPCKryo(RPCDispatcher.ObservableSerializer()) }.build() - -fun createRPCKryoForSerialization(qName: String? = null, dispatcher: RPCDispatcher? = null): Kryo { - val kryo = rpcSerKryoPool.borrow() - kryo.context.put(RPCKryoQNameKey, qName) - kryo.context.put(RPCKryoDispatcherKey, dispatcher) - return kryo -} - -fun releaseRPCKryoForSerialization(kryo: Kryo) { - rpcSerKryoPool.release(kryo) -} - -private val rpcDesKryoPool = KryoPool.Builder { RPCKryo(CordaRPCClientImpl.ObservableDeserializer()) }.build() - -fun createRPCKryoForDeserialization(rpcClient: CordaRPCClientImpl, qName: String? = null, rpcName: String? = null, rpcLocation: Throwable? = null): Kryo { - val kryo = rpcDesKryoPool.borrow() - kryo.context.put(RPCKryoClientKey, rpcClient) - kryo.context.put(RPCKryoQNameKey, qName) - kryo.context.put(RPCKryoMethodNameKey, rpcName) - kryo.context.put(RPCKryoLocationKey, rpcLocation) - return kryo -} - -fun releaseRPCKryoForDeserialization(kryo: Kryo) { - rpcDesKryoPool.release(kryo) -} \ No newline at end of file diff --git a/node/src/main/kotlin/net/corda/node/serialization/DefaultWhitelist.kt b/node-api/src/main/kotlin/net/corda/nodeapi/serialization/DefaultWhitelist.kt similarity index 98% rename from node/src/main/kotlin/net/corda/node/serialization/DefaultWhitelist.kt rename to node-api/src/main/kotlin/net/corda/nodeapi/serialization/DefaultWhitelist.kt index 17be5f1aef..0df1ea3e89 100644 --- a/node/src/main/kotlin/net/corda/node/serialization/DefaultWhitelist.kt +++ b/node-api/src/main/kotlin/net/corda/nodeapi/serialization/DefaultWhitelist.kt @@ -1,4 +1,4 @@ -package net.corda.node.serialization +package net.corda.nodeapi.serialization import com.esotericsoftware.kryo.KryoException import com.google.common.net.HostAndPort @@ -54,4 +54,4 @@ class DefaultWhitelist : CordaPluginRegistry() { } return true } -} \ No newline at end of file +} diff --git a/node-api/src/main/resources/META-INF/services/net.corda.core.node.CordaPluginRegistry b/node-api/src/main/resources/META-INF/services/net.corda.core.node.CordaPluginRegistry new file mode 100644 index 0000000000..afc9681edf --- /dev/null +++ b/node-api/src/main/resources/META-INF/services/net.corda.core.node.CordaPluginRegistry @@ -0,0 +1,2 @@ +# Register a ServiceLoader service extending from net.corda.core.node.CordaPluginRegistry +net.corda.nodeapi.serialization.DefaultWhitelist \ No newline at end of file diff --git a/node-schemas/build.gradle b/node-schemas/build.gradle index bf5b2edabc..afd9f84721 100644 --- a/node-schemas/build.gradle +++ b/node-schemas/build.gradle @@ -43,6 +43,7 @@ sourceSets { dependencies { compile project(':core') + testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" // Requery: SQL based query & persistence for Kotlin kapt "io.requery:requery-processor:$requery_version" diff --git a/node/build.gradle b/node/build.gradle index d9adff9781..f4a528bd88 100644 --- a/node/build.gradle +++ b/node/build.gradle @@ -69,6 +69,7 @@ dependencies { exclude group: 'javassist', module: 'javassist' } compile project(':node-api') + compile project(':client:rpc') compile "com.google.code.findbugs:jsr305:3.0.1" @@ -78,7 +79,7 @@ dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" - compile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" + testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" compile "com.google.guava:guava:$guava_version" @@ -105,10 +106,6 @@ dependencies { exclude group: "asm" } - // For adding serialisation of file upload streams to RPC - // TODO: Remove this dependency and the code that requires it - compile "commons-fileupload:commons-fileupload:1.3.2" - compile "com.fasterxml.jackson.core:jackson-annotations:${jackson_version}" // Coda Hale's Metrics: for monitoring of key statistics diff --git a/node/src/integration-test/kotlin/net/corda/node/driver/DriverTests.kt b/node/src/integration-test/kotlin/net/corda/node/driver/DriverTests.kt index c4c61ffed7..4b1b49cb11 100644 --- a/node/src/integration-test/kotlin/net/corda/node/driver/DriverTests.kt +++ b/node/src/integration-test/kotlin/net/corda/node/driver/DriverTests.kt @@ -8,9 +8,9 @@ import net.corda.core.node.services.ServiceInfo import net.corda.core.readLines import net.corda.node.LOGS_DIRECTORY_NAME import net.corda.node.services.api.RegulatorService -import net.corda.node.services.messaging.ArtemisMessagingComponent import net.corda.node.services.transactions.SimpleNotaryService import org.assertj.core.api.Assertions.assertThat +import net.corda.nodeapi.ArtemisMessagingComponent import org.junit.Test import java.nio.file.Paths import java.util.concurrent.Executors diff --git a/node/src/integration-test/kotlin/net/corda/node/services/DistributedServiceTests.kt b/node/src/integration-test/kotlin/net/corda/node/services/DistributedServiceTests.kt index 7e199238ce..9fe2594ba9 100644 --- a/node/src/integration-test/kotlin/net/corda/node/services/DistributedServiceTests.kt +++ b/node/src/integration-test/kotlin/net/corda/node/services/DistributedServiceTests.kt @@ -16,6 +16,7 @@ import net.corda.flows.CashPaymentFlow import net.corda.node.driver.NodeHandle import net.corda.node.driver.driver import net.corda.node.services.transactions.RaftValidatingNotaryService +import net.corda.nodeapi.User import net.corda.testing.expect import net.corda.testing.expectEvents import net.corda.testing.node.DriverBasedTest diff --git a/node/src/integration-test/kotlin/net/corda/services/messaging/MQSecurityAsNodeTest.kt b/node/src/integration-test/kotlin/net/corda/services/messaging/MQSecurityAsNodeTest.kt index 76a82f56ba..5c5ac2edac 100644 --- a/node/src/integration-test/kotlin/net/corda/services/messaging/MQSecurityAsNodeTest.kt +++ b/node/src/integration-test/kotlin/net/corda/services/messaging/MQSecurityAsNodeTest.kt @@ -1,8 +1,8 @@ package net.corda.services.messaging -import net.corda.node.services.messaging.ArtemisMessagingComponent.Companion.NODE_USER -import net.corda.node.services.messaging.ArtemisMessagingComponent.Companion.PEER_USER -import net.corda.node.services.messaging.ArtemisMessagingComponent.Companion.RPC_REQUESTS_QUEUE +import net.corda.nodeapi.ArtemisMessagingComponent.Companion.NODE_USER +import net.corda.nodeapi.ArtemisMessagingComponent.Companion.PEER_USER +import net.corda.nodeapi.ArtemisMessagingComponent.Companion.RPC_REQUESTS_QUEUE import net.corda.testing.messaging.SimpleMQClient import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration import org.apache.activemq.artemis.api.core.ActiveMQClusterSecurityException diff --git a/node/src/integration-test/kotlin/net/corda/services/messaging/MQSecurityAsRPCTest.kt b/node/src/integration-test/kotlin/net/corda/services/messaging/MQSecurityAsRPCTest.kt index 575b447e6e..6eab75c5f2 100644 --- a/node/src/integration-test/kotlin/net/corda/services/messaging/MQSecurityAsRPCTest.kt +++ b/node/src/integration-test/kotlin/net/corda/services/messaging/MQSecurityAsRPCTest.kt @@ -1,6 +1,6 @@ package net.corda.services.messaging -import net.corda.node.services.User +import net.corda.nodeapi.User import net.corda.testing.messaging.SimpleMQClient import org.apache.activemq.artemis.api.core.ActiveMQSecurityException import org.assertj.core.api.Assertions.assertThatExceptionOfType diff --git a/node/src/integration-test/kotlin/net/corda/services/messaging/MQSecurityTest.kt b/node/src/integration-test/kotlin/net/corda/services/messaging/MQSecurityTest.kt index 7daa3ad8b3..2301c42271 100644 --- a/node/src/integration-test/kotlin/net/corda/services/messaging/MQSecurityTest.kt +++ b/node/src/integration-test/kotlin/net/corda/services/messaging/MQSecurityTest.kt @@ -2,6 +2,7 @@ package net.corda.services.messaging import co.paralleluniverse.fibers.Suspendable import com.google.common.net.HostAndPort +import net.corda.client.rpc.CordaRPCClientImpl import net.corda.nodeapi.config.SSLConfiguration import net.corda.core.crypto.Party import net.corda.core.crypto.composite @@ -13,16 +14,15 @@ import net.corda.core.random63BitValue import net.corda.core.seconds import net.corda.core.utilities.unwrap import net.corda.node.internal.Node -import net.corda.node.services.User -import net.corda.node.services.messaging.ArtemisMessagingComponent.Companion.CLIENTS_PREFIX -import net.corda.node.services.messaging.ArtemisMessagingComponent.Companion.INTERNAL_PREFIX -import net.corda.node.services.messaging.ArtemisMessagingComponent.Companion.NETWORK_MAP_QUEUE -import net.corda.node.services.messaging.ArtemisMessagingComponent.Companion.NOTIFICATIONS_ADDRESS -import net.corda.node.services.messaging.ArtemisMessagingComponent.Companion.P2P_QUEUE -import net.corda.node.services.messaging.ArtemisMessagingComponent.Companion.PEERS_PREFIX -import net.corda.node.services.messaging.ArtemisMessagingComponent.Companion.RPC_QUEUE_REMOVALS_QUEUE -import net.corda.node.services.messaging.ArtemisMessagingComponent.Companion.RPC_REQUESTS_QUEUE -import net.corda.node.services.messaging.CordaRPCClientImpl +import net.corda.nodeapi.ArtemisMessagingComponent.Companion.CLIENTS_PREFIX +import net.corda.nodeapi.ArtemisMessagingComponent.Companion.INTERNAL_PREFIX +import net.corda.nodeapi.ArtemisMessagingComponent.Companion.NETWORK_MAP_QUEUE +import net.corda.nodeapi.ArtemisMessagingComponent.Companion.NOTIFICATIONS_ADDRESS +import net.corda.nodeapi.ArtemisMessagingComponent.Companion.P2P_QUEUE +import net.corda.nodeapi.ArtemisMessagingComponent.Companion.PEERS_PREFIX +import net.corda.nodeapi.ArtemisMessagingComponent.Companion.RPC_QUEUE_REMOVALS_QUEUE +import net.corda.nodeapi.ArtemisMessagingComponent.Companion.RPC_REQUESTS_QUEUE +import net.corda.nodeapi.User import net.corda.testing.configureTestSSL import net.corda.testing.messaging.SimpleMQClient import net.corda.testing.node.NodeBasedTest diff --git a/node/src/main/kotlin/net/corda/node/Corda.kt b/node/src/main/kotlin/net/corda/node/Corda.kt index d59c29ab2a..4e642daf8b 100644 --- a/node/src/main/kotlin/net/corda/node/Corda.kt +++ b/node/src/main/kotlin/net/corda/node/Corda.kt @@ -172,7 +172,7 @@ private fun printPluginsAndServices(node: Node) { } val plugins = node.pluginRegistries .map { it.javaClass.name } - .filterNot { it.startsWith("net.corda.node.") || it.startsWith("net.corda.core.") } + .filterNot { it.startsWith("net.corda.node.") || it.startsWith("net.corda.core.") || it.startsWith("net.corda.nodeapi.")} .map { it.substringBefore('$') } if (plugins.isNotEmpty()) printBasicNodeInfo("Loaded plugins", plugins.joinToString()) 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 cc61d7c7b6..3e59d811eb 100644 --- a/node/src/main/kotlin/net/corda/node/driver/Driver.kt +++ b/node/src/main/kotlin/net/corda/node/driver/Driver.kt @@ -6,6 +6,7 @@ import com.google.common.util.concurrent.* import com.typesafe.config.Config import com.typesafe.config.ConfigRenderOptions import net.corda.core.ThreadBox +import net.corda.client.rpc.CordaRPCClient import net.corda.core.crypto.Party import net.corda.core.div import net.corda.core.flatMap @@ -16,15 +17,14 @@ import net.corda.core.node.services.ServiceInfo import net.corda.core.node.services.ServiceType import net.corda.core.utilities.loggerFor import net.corda.node.LOGS_DIRECTORY_NAME -import net.corda.node.services.User import net.corda.node.services.config.ConfigHelper import net.corda.node.services.config.FullNodeConfiguration -import net.corda.node.services.messaging.ArtemisMessagingComponent -import net.corda.node.services.messaging.CordaRPCClient import net.corda.node.services.messaging.NodeMessagingClient import net.corda.node.services.network.NetworkMapService import net.corda.node.services.transactions.RaftValidatingNotaryService import net.corda.node.utilities.ServiceIdentityGenerator +import net.corda.nodeapi.ArtemisMessagingComponent +import net.corda.nodeapi.User import net.corda.nodeapi.config.SSLConfiguration import okhttp3.OkHttpClient import okhttp3.Request diff --git a/node/src/main/kotlin/net/corda/node/internal/Node.kt b/node/src/main/kotlin/net/corda/node/internal/Node.kt index e4dd6e4c8c..7382bb5593 100644 --- a/node/src/main/kotlin/net/corda/node/internal/Node.kt +++ b/node/src/main/kotlin/net/corda/node/internal/Node.kt @@ -20,15 +20,14 @@ import net.corda.node.services.RPCUserService import net.corda.node.services.RPCUserServiceImpl import net.corda.node.services.api.MessagingServiceInternal import net.corda.node.services.config.FullNodeConfiguration -import net.corda.node.services.messaging.ArtemisMessagingComponent.NetworkMapAddress import net.corda.node.services.messaging.ArtemisMessagingServer import net.corda.node.services.messaging.NodeMessagingClient import net.corda.node.services.transactions.PersistentUniquenessProvider import net.corda.node.services.transactions.RaftUniquenessProvider import net.corda.node.services.transactions.RaftValidatingNotaryService import net.corda.node.utilities.AddressUtils -import net.corda.node.services.transactions.* import net.corda.node.utilities.AffinityExecutor +import net.corda.nodeapi.ArtemisMessagingComponent.NetworkMapAddress import org.slf4j.Logger import java.io.RandomAccessFile import java.lang.management.ManagementFactory diff --git a/node/src/main/kotlin/net/corda/node/services/RPCUserService.kt b/node/src/main/kotlin/net/corda/node/services/RPCUserService.kt index f9b242597a..64e479dbe0 100644 --- a/node/src/main/kotlin/net/corda/node/services/RPCUserService.kt +++ b/node/src/main/kotlin/net/corda/node/services/RPCUserService.kt @@ -2,6 +2,7 @@ package net.corda.node.services import net.corda.core.flows.FlowLogic import net.corda.node.services.config.NodeConfiguration +import net.corda.nodeapi.User /** * Service for retrieving [User] objects representing RPC users who are authorised to use the RPC system. A [User] @@ -24,10 +25,6 @@ class RPCUserServiceImpl(config: NodeConfiguration) : RPCUserService { override val users: List get() = _users.values.toList() } -data class User(val username: String, val password: String, val permissions: Set) { - override fun toString(): String = "${javaClass.simpleName}($username, permissions=$permissions)" -} - fun startFlowPermission(className: String) = "StartFlow.$className" fun

> startFlowPermission(clazz: Class

) = startFlowPermission(clazz.name) inline fun > startFlowPermission(): String = startFlowPermission(P::class.java) diff --git a/node/src/main/kotlin/net/corda/node/services/config/NodeConfiguration.kt b/node/src/main/kotlin/net/corda/node/services/config/NodeConfiguration.kt index 770739f466..19c3ce98ac 100644 --- a/node/src/main/kotlin/net/corda/node/services/config/NodeConfiguration.kt +++ b/node/src/main/kotlin/net/corda/node/services/config/NodeConfiguration.kt @@ -12,9 +12,9 @@ import net.corda.core.node.services.ServiceInfo import net.corda.node.internal.NetworkMapInfo import net.corda.node.internal.Node import net.corda.node.serialization.NodeClock -import net.corda.node.services.User import net.corda.node.services.network.NetworkMapService import net.corda.node.utilities.TestClock +import net.corda.nodeapi.User import java.net.URL import java.nio.file.Path import java.util.* diff --git a/node/src/main/kotlin/net/corda/node/services/messaging/ArtemisMessagingServer.kt b/node/src/main/kotlin/net/corda/node/services/messaging/ArtemisMessagingServer.kt index e0d5de8d5d..95f7bbfc1f 100644 --- a/node/src/main/kotlin/net/corda/node/services/messaging/ArtemisMessagingServer.kt +++ b/node/src/main/kotlin/net/corda/node/services/messaging/ArtemisMessagingServer.kt @@ -16,18 +16,19 @@ import net.corda.core.node.services.NetworkMapCache.MapChange import net.corda.core.seconds import net.corda.core.utilities.debug import net.corda.core.utilities.loggerFor -import net.corda.nodeapi.ArtemisTcpTransport -import net.corda.nodeapi.ConnectionDirection -import net.corda.nodeapi.expectedOnDefaultFileSystem import net.corda.node.printBasicNodeInfo import net.corda.node.services.RPCUserService import net.corda.node.services.config.NodeConfiguration -import net.corda.node.services.messaging.ArtemisMessagingComponent.Companion.CLIENTS_PREFIX -import net.corda.node.services.messaging.ArtemisMessagingComponent.Companion.NODE_USER -import net.corda.node.services.messaging.ArtemisMessagingComponent.Companion.PEER_USER import net.corda.node.services.messaging.NodeLoginModule.Companion.NODE_ROLE import net.corda.node.services.messaging.NodeLoginModule.Companion.PEER_ROLE import net.corda.node.services.messaging.NodeLoginModule.Companion.RPC_ROLE +import net.corda.nodeapi.ArtemisMessagingComponent.Companion.CLIENTS_PREFIX +import net.corda.nodeapi.ArtemisMessagingComponent.Companion.NODE_USER +import net.corda.nodeapi.ArtemisMessagingComponent.Companion.PEER_USER +import net.corda.nodeapi.ArtemisMessagingComponent +import net.corda.nodeapi.ArtemisTcpTransport +import net.corda.nodeapi.ConnectionDirection +import net.corda.nodeapi.expectedOnDefaultFileSystem import org.apache.activemq.artemis.api.core.SimpleString import org.apache.activemq.artemis.core.config.BridgeConfiguration import org.apache.activemq.artemis.core.config.Configuration diff --git a/node/src/main/kotlin/net/corda/node/services/messaging/NodeMessagingClient.kt b/node/src/main/kotlin/net/corda/node/services/messaging/NodeMessagingClient.kt index b71472dee0..e97cf9b444 100644 --- a/node/src/main/kotlin/net/corda/node/services/messaging/NodeMessagingClient.kt +++ b/node/src/main/kotlin/net/corda/node/services/messaging/NodeMessagingClient.kt @@ -19,6 +19,7 @@ import net.corda.node.services.api.MessagingServiceInternal import net.corda.node.services.config.NodeConfiguration import net.corda.node.services.statemachine.StateMachineManager import net.corda.node.utilities.* +import net.corda.nodeapi.ArtemisMessagingComponent import org.apache.activemq.artemis.api.core.ActiveMQObjectClosedException import org.apache.activemq.artemis.api.core.Message.* import org.apache.activemq.artemis.api.core.SimpleString diff --git a/node/src/main/kotlin/net/corda/node/services/messaging/RPCDispatcher.kt b/node/src/main/kotlin/net/corda/node/services/messaging/RPCDispatcher.kt index 964cbb53e6..335edc8728 100644 --- a/node/src/main/kotlin/net/corda/node/services/messaging/RPCDispatcher.kt +++ b/node/src/main/kotlin/net/corda/node/services/messaging/RPCDispatcher.kt @@ -5,6 +5,7 @@ import com.esotericsoftware.kryo.KryoException import com.esotericsoftware.kryo.Serializer import com.esotericsoftware.kryo.io.Input import com.esotericsoftware.kryo.io.Output +import com.esotericsoftware.kryo.pool.KryoPool import com.google.common.annotations.VisibleForTesting import com.google.common.collect.HashMultimap import net.corda.core.ErrorOr @@ -14,11 +15,11 @@ import net.corda.core.messaging.RPCReturnsObservables import net.corda.core.serialization.SerializedBytes import net.corda.core.serialization.deserialize import net.corda.core.serialization.serialize -import net.corda.core.utilities.debug import net.corda.node.services.RPCUserService -import net.corda.node.services.User -import net.corda.node.services.messaging.ArtemisMessagingComponent.Companion.NODE_USER import net.corda.node.utilities.AffinityExecutor +import net.corda.core.utilities.debug +import net.corda.nodeapi.* +import net.corda.nodeapi.ArtemisMessagingComponent.Companion.NODE_USER import org.apache.activemq.artemis.api.core.Message import org.apache.activemq.artemis.api.core.client.ClientConsumer import org.apache.activemq.artemis.api.core.client.ClientMessage @@ -192,4 +193,17 @@ abstract class RPCDispatcher(val ops: RPCOps, val userService: RPCUserService, v if (required) throw RPCException("missing $property property") else null } } -} \ No newline at end of file +} + +private val rpcSerKryoPool = KryoPool.Builder { RPCKryo(RPCDispatcher.ObservableSerializer()) }.build() + +fun createRPCKryoForSerialization(qName: String? = null, dispatcher: RPCDispatcher? = null): Kryo { + val kryo = rpcSerKryoPool.borrow() + kryo.context.put(RPCKryoQNameKey, qName) + kryo.context.put(RPCKryoDispatcherKey, dispatcher) + return kryo +} + +fun releaseRPCKryoForSerialization(kryo: Kryo) { + rpcSerKryoPool.release(kryo) +} diff --git a/node/src/main/kotlin/net/corda/node/services/messaging/RPCServerStructures.kt b/node/src/main/kotlin/net/corda/node/services/messaging/RPCServerStructures.kt new file mode 100644 index 0000000000..e1a3308867 --- /dev/null +++ b/node/src/main/kotlin/net/corda/node/services/messaging/RPCServerStructures.kt @@ -0,0 +1,17 @@ +@file:JvmName("RPCServerStructures") + +package net.corda.node.services.messaging + +import net.corda.nodeapi.ArtemisMessagingComponent +import net.corda.nodeapi.CURRENT_RPC_USER +import net.corda.nodeapi.PermissionException + +/** Helper method which checks that the current RPC user is entitled for the given permission. Throws a [PermissionException] otherwise. */ +fun requirePermission(permission: String) { + // TODO remove the NODE_USER condition once webserver doesn't need it + val currentUser = CURRENT_RPC_USER.get() + val currentUserPermissions = currentUser.permissions + if (currentUser.username != ArtemisMessagingComponent.NODE_USER && currentUserPermissions.intersect(listOf(permission, "ALL")).isEmpty()) { + throw PermissionException("User not permissioned for $permission, permissions are $currentUserPermissions") + } +} diff --git a/node/src/main/kotlin/net/corda/node/services/network/NetworkMapService.kt b/node/src/main/kotlin/net/corda/node/services/network/NetworkMapService.kt index fba01f9d37..5d3ea8c9dc 100644 --- a/node/src/main/kotlin/net/corda/node/services/network/NetworkMapService.kt +++ b/node/src/main/kotlin/net/corda/node/services/network/NetworkMapService.kt @@ -72,7 +72,7 @@ interface NetworkMapService { // Base topic for messages acknowledging pushed updates val PUSH_ACK_TOPIC = "platform.network_map.push_ack" - val type = ServiceType.corda.getSubType("network_map") + val type = ServiceType.networkMap } data class FetchMapRequest(val subscribe: Boolean, diff --git a/node/src/main/resources/META-INF/services/net.corda.core.node.CordaPluginRegistry b/node/src/main/resources/META-INF/services/net.corda.core.node.CordaPluginRegistry index 8b607465bc..884cc0cfae 100644 --- a/node/src/main/resources/META-INF/services/net.corda.core.node.CordaPluginRegistry +++ b/node/src/main/resources/META-INF/services/net.corda.core.node.CordaPluginRegistry @@ -1,4 +1,3 @@ # Register a ServiceLoader service extending from net.corda.core.node.CordaPluginRegistry net.corda.node.services.NotaryChange$Plugin -net.corda.node.services.persistence.DataVending$Plugin -net.corda.node.serialization.DefaultWhitelist \ No newline at end of file +net.corda.node.services.persistence.DataVending$Plugin \ No newline at end of file diff --git a/node/src/test/kotlin/net/corda/node/CordaRPCOpsImplTest.kt b/node/src/test/kotlin/net/corda/node/CordaRPCOpsImplTest.kt index 13de1d560c..eafcca17dd 100644 --- a/node/src/test/kotlin/net/corda/node/CordaRPCOpsImplTest.kt +++ b/node/src/test/kotlin/net/corda/node/CordaRPCOpsImplTest.kt @@ -13,13 +13,13 @@ import net.corda.core.transactions.SignedTransaction import net.corda.flows.CashIssueFlow import net.corda.flows.CashPaymentFlow import net.corda.node.internal.CordaRPCOpsImpl -import net.corda.node.services.User -import net.corda.node.services.messaging.CURRENT_RPC_USER -import net.corda.node.services.messaging.PermissionException import net.corda.node.services.network.NetworkMapService import net.corda.node.services.startFlowPermission import net.corda.node.services.transactions.SimpleNotaryService import net.corda.node.utilities.databaseTransaction +import net.corda.nodeapi.CURRENT_RPC_USER +import net.corda.nodeapi.PermissionException +import net.corda.nodeapi.User import net.corda.testing.expect import net.corda.testing.expectEvents import net.corda.testing.node.MockNetwork diff --git a/node/src/test/kotlin/net/corda/node/services/RPCUserServiceImplTest.kt b/node/src/test/kotlin/net/corda/node/services/RPCUserServiceImplTest.kt index 986d728b80..7a4d86af56 100644 --- a/node/src/test/kotlin/net/corda/node/services/RPCUserServiceImplTest.kt +++ b/node/src/test/kotlin/net/corda/node/services/RPCUserServiceImplTest.kt @@ -2,6 +2,7 @@ package net.corda.node.services import com.typesafe.config.ConfigFactory import net.corda.node.services.config.FullNodeConfiguration +import net.corda.nodeapi.User import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.Test diff --git a/node/webserver/build.gradle b/node/webserver/build.gradle index 9650a28b51..3c56692395 100644 --- a/node/webserver/build.gradle +++ b/node/webserver/build.gradle @@ -49,7 +49,7 @@ dependencies { compile "org.eclipse.jetty:jetty-webapp:${jetty_version}" compile "javax.servlet:javax.servlet-api:3.1.0" compile "org.jolokia:jolokia-agent-war:$jolokia_version" - compile "commons-fileupload:commons-fileupload:1.3.2" + compile "commons-fileupload:commons-fileupload:$fileupload_version" // Jersey for JAX-RS implementation for use in Jetty compile "org.glassfish.jersey.core:jersey-server:${jersey_version}" diff --git a/node/webserver/src/main/kotlin/net/corda/webserver/internal/NodeWebServer.kt b/node/webserver/src/main/kotlin/net/corda/webserver/internal/NodeWebServer.kt index 547812e9e5..0cf74dcbda 100644 --- a/node/webserver/src/main/kotlin/net/corda/webserver/internal/NodeWebServer.kt +++ b/node/webserver/src/main/kotlin/net/corda/webserver/internal/NodeWebServer.kt @@ -1,12 +1,12 @@ package net.corda.webserver.internal +import net.corda.client.rpc.CordaRPCClient import net.corda.core.messaging.CordaRPCOps import net.corda.core.node.CordaPluginRegistry import net.corda.core.utilities.loggerFor import net.corda.node.printBasicNodeInfo import net.corda.node.services.config.FullNodeConfiguration -import net.corda.node.services.messaging.ArtemisMessagingComponent -import net.corda.node.services.messaging.CordaRPCClient +import net.corda.nodeapi.ArtemisMessagingComponent import net.corda.webserver.servlets.AttachmentDownloadServlet import net.corda.webserver.servlets.DataUploadServlet import net.corda.webserver.servlets.ObjectMapperConfig @@ -23,7 +23,6 @@ import org.glassfish.jersey.server.ResourceConfig import org.glassfish.jersey.server.ServerProperties import org.glassfish.jersey.servlet.ServletContainer import java.lang.reflect.InvocationTargetException -import java.net.InetAddress import java.util.* class NodeWebServer(val config: FullNodeConfiguration) { diff --git a/samples/attachment-demo/src/integration-test/kotlin/net/corda/attachmentdemo/AttachmentDemoTest.kt b/samples/attachment-demo/src/integration-test/kotlin/net/corda/attachmentdemo/AttachmentDemoTest.kt index e1ddf1de70..5cc53e8f1a 100644 --- a/samples/attachment-demo/src/integration-test/kotlin/net/corda/attachmentdemo/AttachmentDemoTest.kt +++ b/samples/attachment-demo/src/integration-test/kotlin/net/corda/attachmentdemo/AttachmentDemoTest.kt @@ -4,8 +4,8 @@ import com.google.common.util.concurrent.Futures import net.corda.core.getOrThrow import net.corda.core.node.services.ServiceInfo import net.corda.node.driver.driver -import net.corda.node.services.User import net.corda.node.services.transactions.SimpleNotaryService +import net.corda.nodeapi.User import org.junit.Test import java.util.concurrent.CompletableFuture diff --git a/samples/attachment-demo/src/main/kotlin/net/corda/attachmentdemo/AttachmentDemo.kt b/samples/attachment-demo/src/main/kotlin/net/corda/attachmentdemo/AttachmentDemo.kt index 83d4d6daeb..ab4dbf863a 100644 --- a/samples/attachment-demo/src/main/kotlin/net/corda/attachmentdemo/AttachmentDemo.kt +++ b/samples/attachment-demo/src/main/kotlin/net/corda/attachmentdemo/AttachmentDemo.kt @@ -2,6 +2,7 @@ package net.corda.attachmentdemo import com.google.common.net.HostAndPort import joptsimple.OptionParser +import net.corda.client.rpc.CordaRPCClient import net.corda.nodeapi.config.SSLConfiguration import net.corda.core.contracts.TransactionType import net.corda.core.crypto.Party @@ -12,7 +13,6 @@ import net.corda.core.messaging.CordaRPCOps import net.corda.core.messaging.startFlow import net.corda.core.utilities.Emoji import net.corda.flows.FinalityFlow -import net.corda.node.services.messaging.CordaRPCClient import net.corda.testing.ALICE_KEY import java.nio.file.Path import java.nio.file.Paths diff --git a/samples/attachment-demo/src/main/kotlin/net/corda/attachmentdemo/Main.kt b/samples/attachment-demo/src/main/kotlin/net/corda/attachmentdemo/Main.kt index 1f5b233d1e..ec94622f21 100644 --- a/samples/attachment-demo/src/main/kotlin/net/corda/attachmentdemo/Main.kt +++ b/samples/attachment-demo/src/main/kotlin/net/corda/attachmentdemo/Main.kt @@ -3,8 +3,8 @@ package net.corda.attachmentdemo import net.corda.core.div import net.corda.core.node.services.ServiceInfo import net.corda.node.driver.driver -import net.corda.node.services.User import net.corda.node.services.transactions.SimpleNotaryService +import net.corda.nodeapi.User import java.nio.file.Paths /** diff --git a/samples/bank-of-corda-demo/build.gradle b/samples/bank-of-corda-demo/build.gradle index d4988cdf0e..a111de61a8 100644 --- a/samples/bank-of-corda-demo/build.gradle +++ b/samples/bank-of-corda-demo/build.gradle @@ -49,7 +49,7 @@ dependencies { runtime project(path: ":node:webserver:webcapsule", configuration: 'runtimeArtifacts') compile project(':core') compile project(':client:jfx') - compile project(':node') + compile project(':client:rpc') compile project(':finance') compile project(':test-utils') diff --git a/samples/bank-of-corda-demo/src/integration-test/kotlin/net/corda/bank/BankOfCordaHttpAPITest.kt b/samples/bank-of-corda-demo/src/integration-test/kotlin/net/corda/bank/BankOfCordaHttpAPITest.kt index f7f4fc1725..02c48873b2 100644 --- a/samples/bank-of-corda-demo/src/integration-test/kotlin/net/corda/bank/BankOfCordaHttpAPITest.kt +++ b/samples/bank-of-corda-demo/src/integration-test/kotlin/net/corda/bank/BankOfCordaHttpAPITest.kt @@ -7,7 +7,6 @@ import net.corda.core.getOrThrow import net.corda.core.node.services.ServiceInfo import net.corda.node.driver.driver import net.corda.node.services.transactions.SimpleNotaryService -import net.corda.node.utilities.getHostAndPort import org.junit.Test class BankOfCordaHttpAPITest { diff --git a/samples/bank-of-corda-demo/src/integration-test/kotlin/net/corda/bank/BankOfCordaRPCClientTest.kt b/samples/bank-of-corda-demo/src/integration-test/kotlin/net/corda/bank/BankOfCordaRPCClientTest.kt index 504006d755..26a7cb7468 100644 --- a/samples/bank-of-corda-demo/src/integration-test/kotlin/net/corda/bank/BankOfCordaRPCClientTest.kt +++ b/samples/bank-of-corda-demo/src/integration-test/kotlin/net/corda/bank/BankOfCordaRPCClientTest.kt @@ -7,9 +7,9 @@ import net.corda.core.messaging.startFlow import net.corda.core.node.services.ServiceInfo import net.corda.flows.IssuerFlow.IssuanceRequester import net.corda.node.driver.driver -import net.corda.node.services.User import net.corda.node.services.startFlowPermission import net.corda.node.services.transactions.SimpleNotaryService +import net.corda.nodeapi.User import net.corda.testing.BOC_PARTY_REF import net.corda.testing.expect import net.corda.testing.expectEvents diff --git a/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/BankOfCordaDriver.kt b/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/BankOfCordaDriver.kt index 6a137808b4..770cc44e9e 100644 --- a/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/BankOfCordaDriver.kt +++ b/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/BankOfCordaDriver.kt @@ -10,9 +10,9 @@ import net.corda.core.node.services.ServiceType import net.corda.core.transactions.SignedTransaction import net.corda.flows.CashPaymentFlow import net.corda.node.driver.driver -import net.corda.node.services.User import net.corda.node.services.startFlowPermission import net.corda.node.services.transactions.SimpleNotaryService +import net.corda.nodeapi.User import kotlin.system.exitProcess /** diff --git a/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/api/BankOfCordaClientApi.kt b/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/api/BankOfCordaClientApi.kt index b641f212cc..d7480ea7b9 100644 --- a/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/api/BankOfCordaClientApi.kt +++ b/samples/bank-of-corda-demo/src/main/kotlin/net/corda/bank/api/BankOfCordaClientApi.kt @@ -2,6 +2,7 @@ package net.corda.bank.api import com.google.common.net.HostAndPort import net.corda.bank.api.BankOfCordaWebApi.IssueRequestParams +import net.corda.client.rpc.CordaRPCClient import net.corda.core.contracts.Amount import net.corda.core.contracts.currency import net.corda.core.getOrThrow @@ -9,7 +10,6 @@ import net.corda.core.messaging.startFlow import net.corda.core.serialization.OpaqueBytes import net.corda.core.transactions.SignedTransaction import net.corda.flows.IssuerFlow.IssuanceRequester -import net.corda.node.services.messaging.CordaRPCClient import net.corda.testing.http.HttpApi /** diff --git a/samples/irs-demo/src/integration-test/kotlin/net/corda/irs/IRSDemoTest.kt b/samples/irs-demo/src/integration-test/kotlin/net/corda/irs/IRSDemoTest.kt index 083abef10e..df188de1a5 100644 --- a/samples/irs-demo/src/integration-test/kotlin/net/corda/irs/IRSDemoTest.kt +++ b/samples/irs-demo/src/integration-test/kotlin/net/corda/irs/IRSDemoTest.kt @@ -2,6 +2,7 @@ package net.corda.irs import com.google.common.net.HostAndPort import com.google.common.util.concurrent.Futures +import net.corda.client.rpc.CordaRPCClient import net.corda.core.crypto.Party import net.corda.core.getOrThrow import net.corda.core.node.services.ServiceInfo @@ -11,10 +12,9 @@ import net.corda.irs.utilities.postJson import net.corda.irs.utilities.putJson import net.corda.irs.utilities.uploadFile import net.corda.node.driver.driver -import net.corda.node.services.User import net.corda.node.services.config.FullNodeConfiguration -import net.corda.node.services.messaging.CordaRPCClient import net.corda.node.services.transactions.SimpleNotaryService +import net.corda.nodeapi.User import net.corda.testing.IntegrationTestCategory import org.apache.commons.io.IOUtils import org.junit.Test diff --git a/samples/raft-notary-demo/build.gradle b/samples/raft-notary-demo/build.gradle index eefc6576c2..269d887b6d 100644 --- a/samples/raft-notary-demo/build.gradle +++ b/samples/raft-notary-demo/build.gradle @@ -49,7 +49,7 @@ dependencies { runtime project(path: ":node:webserver:webcapsule", configuration: 'runtimeArtifacts') compile project(':core') compile project(':client:jfx') - compile project(':node') + compile project(':client:rpc') compile project(':test-utils') // Javax is required for webapis diff --git a/samples/raft-notary-demo/src/main/kotlin/net/corda/notarydemo/Main.kt b/samples/raft-notary-demo/src/main/kotlin/net/corda/notarydemo/Main.kt index 015710c596..b5f2000169 100644 --- a/samples/raft-notary-demo/src/main/kotlin/net/corda/notarydemo/Main.kt +++ b/samples/raft-notary-demo/src/main/kotlin/net/corda/notarydemo/Main.kt @@ -2,8 +2,8 @@ package net.corda.notarydemo import net.corda.core.div import net.corda.node.driver.driver -import net.corda.node.services.User import net.corda.node.services.transactions.RaftValidatingNotaryService +import net.corda.nodeapi.User import java.nio.file.Paths /** Creates and starts all nodes required for the demo. */ diff --git a/samples/raft-notary-demo/src/main/kotlin/net/corda/notarydemo/NotaryDemo.kt b/samples/raft-notary-demo/src/main/kotlin/net/corda/notarydemo/NotaryDemo.kt index fc50b7c33d..71e772aece 100644 --- a/samples/raft-notary-demo/src/main/kotlin/net/corda/notarydemo/NotaryDemo.kt +++ b/samples/raft-notary-demo/src/main/kotlin/net/corda/notarydemo/NotaryDemo.kt @@ -3,6 +3,7 @@ package net.corda.notarydemo import com.google.common.net.HostAndPort import com.google.common.util.concurrent.Futures import joptsimple.OptionParser +import net.corda.client.rpc.CordaRPCClient import net.corda.nodeapi.config.SSLConfiguration import net.corda.core.crypto.toStringShort import net.corda.core.div @@ -11,7 +12,6 @@ import net.corda.core.messaging.CordaRPCOps import net.corda.core.messaging.startFlow import net.corda.core.transactions.SignedTransaction import net.corda.flows.NotaryFlow -import net.corda.node.services.messaging.CordaRPCClient import net.corda.notarydemo.flows.DummyIssueAndMove import java.nio.file.Path import java.nio.file.Paths diff --git a/samples/raft-notary-demo/src/main/kotlin/net/corda/notarydemo/flows/DummyIssueAndMove.kt b/samples/raft-notary-demo/src/main/kotlin/net/corda/notarydemo/flows/DummyIssueAndMove.kt index 70a688940b..2ec05290d5 100644 --- a/samples/raft-notary-demo/src/main/kotlin/net/corda/notarydemo/flows/DummyIssueAndMove.kt +++ b/samples/raft-notary-demo/src/main/kotlin/net/corda/notarydemo/flows/DummyIssueAndMove.kt @@ -4,7 +4,6 @@ import co.paralleluniverse.fibers.Suspendable import net.corda.core.contracts.DummyContract import net.corda.core.crypto.Party import net.corda.core.flows.FlowLogic -import net.corda.core.node.recordTransactions import net.corda.core.transactions.SignedTransaction import java.util.* diff --git a/samples/raft-notary-demo/src/main/kotlin/net/corda/notarydemo/plugin/NotaryDemoPlugin.kt b/samples/raft-notary-demo/src/main/kotlin/net/corda/notarydemo/plugin/NotaryDemoPlugin.kt index f6f05665d8..5af02c6563 100644 --- a/samples/raft-notary-demo/src/main/kotlin/net/corda/notarydemo/plugin/NotaryDemoPlugin.kt +++ b/samples/raft-notary-demo/src/main/kotlin/net/corda/notarydemo/plugin/NotaryDemoPlugin.kt @@ -5,7 +5,6 @@ import net.corda.core.node.CordaPluginRegistry import net.corda.core.transactions.SignedTransaction import net.corda.flows.NotaryFlow import net.corda.notarydemo.flows.DummyIssueAndMove -import java.util.function.Function class NotaryDemoPlugin : CordaPluginRegistry() { // A list of protocols that are required for this cordapp diff --git a/samples/trader-demo/src/integration-test/kotlin/net/corda/traderdemo/TraderDemoTest.kt b/samples/trader-demo/src/integration-test/kotlin/net/corda/traderdemo/TraderDemoTest.kt index d77e705425..b46f37cb95 100644 --- a/samples/trader-demo/src/integration-test/kotlin/net/corda/traderdemo/TraderDemoTest.kt +++ b/samples/trader-demo/src/integration-test/kotlin/net/corda/traderdemo/TraderDemoTest.kt @@ -1,13 +1,13 @@ package net.corda.traderdemo import com.google.common.util.concurrent.Futures +import net.corda.client.rpc.CordaRPCClient import net.corda.core.getOrThrow import net.corda.core.node.services.ServiceInfo import net.corda.flows.IssuerFlow -import net.corda.node.services.User -import net.corda.node.services.messaging.CordaRPCClient import net.corda.node.services.startFlowPermission import net.corda.node.services.transactions.SimpleNotaryService +import net.corda.nodeapi.User import net.corda.testing.node.NodeBasedTest import org.junit.Test diff --git a/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/Main.kt b/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/Main.kt index 6a6c3433b7..e1e6649957 100644 --- a/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/Main.kt +++ b/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/Main.kt @@ -3,12 +3,12 @@ package net.corda.traderdemo import net.corda.flows.IssuerFlow import net.corda.core.node.services.ServiceInfo import net.corda.node.driver.driver -import net.corda.node.services.User import net.corda.node.services.startFlowPermission import net.corda.node.services.transactions.SimpleNotaryService import net.corda.testing.BOC import java.nio.file.Paths import net.corda.core.div +import net.corda.nodeapi.User /** * This file is exclusively for being able to run your nodes through an IDE (as opposed to running deployNodes) diff --git a/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/TraderDemo.kt b/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/TraderDemo.kt index 2d96511753..2eeb1aef25 100644 --- a/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/TraderDemo.kt +++ b/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/TraderDemo.kt @@ -2,14 +2,10 @@ package net.corda.traderdemo import com.google.common.net.HostAndPort import joptsimple.OptionParser -import net.corda.nodeapi.config.SSLConfiguration +import net.corda.client.rpc.CordaRPCClient import net.corda.core.contracts.DOLLARS -import net.corda.core.div import net.corda.core.utilities.loggerFor -import net.corda.node.services.messaging.CordaRPCClient import org.slf4j.Logger -import java.nio.file.Path -import java.nio.file.Paths import kotlin.system.exitProcess /** diff --git a/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/plugin/TraderDemoPlugin.kt b/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/plugin/TraderDemoPlugin.kt index 093740050e..382a2ef75a 100644 --- a/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/plugin/TraderDemoPlugin.kt +++ b/samples/trader-demo/src/main/kotlin/net/corda/traderdemo/plugin/TraderDemoPlugin.kt @@ -3,8 +3,6 @@ package net.corda.traderdemo.plugin import net.corda.core.contracts.Amount import net.corda.core.crypto.Party import net.corda.core.node.CordaPluginRegistry -import net.corda.core.serialization.OpaqueBytes -import net.corda.flows.IssuerFlow import net.corda.traderdemo.flow.BuyerFlow import net.corda.traderdemo.flow.SellerFlow import java.util.function.Function diff --git a/settings.gradle b/settings.gradle index 0368341586..39dea07db0 100644 --- a/settings.gradle +++ b/settings.gradle @@ -13,6 +13,7 @@ include 'node:webserver:webcapsule' include 'client:jackson' include 'client:jfx' include 'client:mock' +include 'client:rpc' include 'experimental' include 'experimental:sandbox' include 'test-utils' diff --git a/test-utils/src/main/kotlin/net/corda/testing/messaging/SimpleMQClient.kt b/test-utils/src/main/kotlin/net/corda/testing/messaging/SimpleMQClient.kt index c06af4b8ea..ff29645e35 100644 --- a/test-utils/src/main/kotlin/net/corda/testing/messaging/SimpleMQClient.kt +++ b/test-utils/src/main/kotlin/net/corda/testing/messaging/SimpleMQClient.kt @@ -2,9 +2,9 @@ package net.corda.testing.messaging import com.google.common.net.HostAndPort import net.corda.nodeapi.config.SSLConfiguration +import net.corda.nodeapi.ArtemisMessagingComponent import net.corda.nodeapi.ArtemisTcpTransport import net.corda.nodeapi.ConnectionDirection -import net.corda.node.services.messaging.ArtemisMessagingComponent import net.corda.testing.configureTestSSL import org.apache.activemq.artemis.api.core.client.* diff --git a/test-utils/src/main/kotlin/net/corda/testing/node/NodeBasedTest.kt b/test-utils/src/main/kotlin/net/corda/testing/node/NodeBasedTest.kt index da729d1eda..57584b6e19 100644 --- a/test-utils/src/main/kotlin/net/corda/testing/node/NodeBasedTest.kt +++ b/test-utils/src/main/kotlin/net/corda/testing/node/NodeBasedTest.kt @@ -9,11 +9,11 @@ import net.corda.core.map import net.corda.core.node.services.ServiceInfo import net.corda.core.node.services.ServiceType import net.corda.node.internal.Node -import net.corda.node.services.User import net.corda.node.services.config.ConfigHelper import net.corda.node.services.config.FullNodeConfiguration import net.corda.node.services.transactions.RaftValidatingNotaryService import net.corda.node.utilities.ServiceIdentityGenerator +import net.corda.nodeapi.User import net.corda.testing.MOCK_NODE_VERSION_INFO import net.corda.testing.getFreeLocalPorts import org.junit.After diff --git a/tools/demobench/build.gradle b/tools/demobench/build.gradle index 26e641643c..650b7582fa 100644 --- a/tools/demobench/build.gradle +++ b/tools/demobench/build.gradle @@ -49,9 +49,10 @@ dependencies { // Controls FX: more java FX components http://fxexperience.com/controlsfx/ compile "org.controlsfx:controlsfx:$controlsfx_version" - // ONLY USING THE RPC CLIENT!? - compile (project(':node')) { - exclude module: 'kotlin-test' + compile (project(':client:rpc')) { + exclude module: 'junit' + } + compile (project(':finance')) { exclude module: 'junit' } diff --git a/tools/demobench/src/main/kotlin/net/corda/demobench/rpc/NodeRPC.kt b/tools/demobench/src/main/kotlin/net/corda/demobench/rpc/NodeRPC.kt index 6ea1355fe9..fb431f08b6 100644 --- a/tools/demobench/src/main/kotlin/net/corda/demobench/rpc/NodeRPC.kt +++ b/tools/demobench/src/main/kotlin/net/corda/demobench/rpc/NodeRPC.kt @@ -3,10 +3,10 @@ package net.corda.demobench.rpc import com.google.common.net.HostAndPort import java.util.* import java.util.concurrent.TimeUnit.SECONDS +import net.corda.client.rpc.CordaRPCClient import net.corda.core.messaging.CordaRPCOps import net.corda.demobench.loggerFor import net.corda.demobench.model.NodeConfig -import net.corda.node.services.messaging.CordaRPCClient class NodeRPC(config: NodeConfig, start: () -> Unit, invoke: (CordaRPCOps) -> Unit): AutoCloseable { diff --git a/tools/demobench/src/main/kotlin/net/corda/demobench/views/NodeTerminalView.kt b/tools/demobench/src/main/kotlin/net/corda/demobench/views/NodeTerminalView.kt index 406f1b54ae..eb09805b25 100644 --- a/tools/demobench/src/main/kotlin/net/corda/demobench/views/NodeTerminalView.kt +++ b/tools/demobench/src/main/kotlin/net/corda/demobench/views/NodeTerminalView.kt @@ -132,8 +132,8 @@ class NodeTerminalView : Fragment() { ) Platform.runLater { - states.value = statesInVault.first.size.toString() - transactions.value = verifiedTx.first.size.toString() + states.value = fetchAndDrop(statesInVault).size.toString() + transactions.value = fetchAndDrop(verifiedTx).size.toString() balance.value = if (cashBalances.isNullOrEmpty()) "0" else cashBalances } } catch (e: Exception) { @@ -156,10 +156,15 @@ class NodeTerminalView : Fragment() { // TODO - Force a repaint somehow? My naive attempts have not worked. } + // TODO - Will change when we modify RPC Observables handling. + private fun fetchAndDrop(pair: Pair>): T { + pair.second.subscribe().unsubscribe() + return pair.first + } + class TerminalSettingsProvider : DefaultSettingsProvider() { override fun getDefaultStyle() = TextStyle(TerminalColor.WHITE, TerminalColor.BLACK) override fun emulateX11CopyPaste() = true } - } diff --git a/tools/explorer/build.gradle b/tools/explorer/build.gradle index 694684885d..ad15ff818a 100644 --- a/tools/explorer/build.gradle +++ b/tools/explorer/build.gradle @@ -33,6 +33,7 @@ repositories { dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" testCompile "junit:junit:$junit_version" // TornadoFX: A lightweight Kotlin framework for working with JavaFX UI's. diff --git a/tools/explorer/src/main/kotlin/net/corda/explorer/Main.kt b/tools/explorer/src/main/kotlin/net/corda/explorer/Main.kt index 6e57c0be49..da770d18f7 100644 --- a/tools/explorer/src/main/kotlin/net/corda/explorer/Main.kt +++ b/tools/explorer/src/main/kotlin/net/corda/explorer/Main.kt @@ -26,9 +26,9 @@ import net.corda.flows.CashPaymentFlow import net.corda.flows.IssuerFlow.IssuanceRequester import net.corda.node.driver.PortAllocation import net.corda.node.driver.driver -import net.corda.node.services.User import net.corda.node.services.startFlowPermission import net.corda.node.services.transactions.SimpleNotaryService +import net.corda.nodeapi.User import org.apache.commons.lang.SystemUtils import org.controlsfx.dialog.ExceptionDialog import tornadofx.App diff --git a/tools/loadtest/build.gradle b/tools/loadtest/build.gradle index aabdea7168..8f068e402a 100644 --- a/tools/loadtest/build.gradle +++ b/tools/loadtest/build.gradle @@ -25,6 +25,8 @@ mainClassName = 'net.corda.loadtest.MainKt' dependencies { compile project(':client:mock') + compile project(':client:rpc') + compile project(':node') // https://mvnrepository.com/artifact/com.jcraft/jsch compile group: 'com.jcraft', name: 'jsch', version: '0.1.54' diff --git a/tools/loadtest/src/main/kotlin/net/corda/loadtest/ConnectionManager.kt b/tools/loadtest/src/main/kotlin/net/corda/loadtest/ConnectionManager.kt index 26ae933ad5..4e97fc6966 100644 --- a/tools/loadtest/src/main/kotlin/net/corda/loadtest/ConnectionManager.kt +++ b/tools/loadtest/src/main/kotlin/net/corda/loadtest/ConnectionManager.kt @@ -7,12 +7,9 @@ import com.jcraft.jsch.agentproxy.connector.SSHAgentConnector import com.jcraft.jsch.agentproxy.usocket.JNAUSocketFactory import kotlinx.support.jdk8.collections.parallelStream import kotlinx.support.jdk8.streams.toList -import net.corda.core.createDirectories -import net.corda.core.div +import net.corda.client.rpc.CordaRPCClient import net.corda.core.messaging.CordaRPCOps import net.corda.node.driver.PortAllocation -import net.corda.nodeapi.config.SSLConfiguration -import net.corda.node.services.messaging.CordaRPCClient import org.slf4j.LoggerFactory import java.io.ByteArrayOutputStream import java.io.Closeable