From 49d1cee6d4da4da231909513451933394d588733 Mon Sep 17 00:00:00 2001 From: Shams Asari Date: Thu, 22 Nov 2018 20:30:37 +0000 Subject: [PATCH] Removed crypto service config (#4284) --- .ci/check-api-changes.sh | 2 +- .idea/compiler.xml | 4 ++- .../node/services/config/NodeConfiguration.kt | 11 +----- .../services/config/NodeConfigurationImpl.kt | 15 -------- .../schema/v1/V1NodeConfigurationSpec.kt | 7 +--- .../config/NodeConfigurationImplTest.kt | 35 +++++-------------- .../NetworkRegistrationHelperTest.kt | 2 -- .../node/internal/InternalMockNetwork.kt | 2 -- 8 files changed, 15 insertions(+), 63 deletions(-) diff --git a/.ci/check-api-changes.sh b/.ci/check-api-changes.sh index c896a70aa5..2b01bfb74a 100755 --- a/.ci/check-api-changes.sh +++ b/.ci/check-api-changes.sh @@ -12,7 +12,7 @@ if [ ! -f $apiCurrent ]; then fi # Remove the two header lines from the diff output. -diffContents=`diff -u $apiCurrent $APIHOME/../build/api/api-corda-*.txt | tail -n +3` +diffContents=`diff --minimal -u $apiCurrent $APIHOME/../build/api/api-corda-*.txt | tail -n +3` echo "Diff contents:" echo "$diffContents" echo diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 51247be08d..2f513af44c 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -79,6 +79,8 @@ + + @@ -243,4 +245,4 @@ - + \ No newline at end of file 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 1e43d25104..7a4293a85d 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 @@ -10,7 +10,6 @@ import net.corda.core.utilities.NetworkHostAndPort import net.corda.node.services.config.rpc.NodeRpcOptions import net.corda.node.services.config.schema.v1.V1NodeConfigurationSpec import net.corda.node.services.keys.cryptoservice.BCCryptoService -import net.corda.node.services.keys.cryptoservice.SupportedCryptoServices import net.corda.nodeapi.internal.config.FileBasedCertificateStoreSupplier import net.corda.nodeapi.internal.config.MutualSslConfiguration import net.corda.nodeapi.internal.config.User @@ -80,11 +79,6 @@ interface NodeConfiguration { val cordappSignerKeyFingerprintBlacklist: List - // TODO At the moment this is just an identifier for the desired CryptoService engine. Consider using a classname to - // to allow for pluggable implementations. - val cryptoServiceName: SupportedCryptoServices? - val cryptoServiceConf: String? // Location for the cryptoService conf file. - val networkParameterAcceptanceSettings: NetworkParameterAcceptanceSettings companion object { @@ -108,10 +102,7 @@ interface NodeConfiguration { } fun makeCryptoService(): CryptoService { - return when(cryptoServiceName) { - // Pick default BCCryptoService when null. - SupportedCryptoServices.BC_SIMPLE, null -> BCCryptoService(this.myLegalName.x500Principal, this.signingCertificateStore) - } + return BCCryptoService(this.myLegalName.x500Principal, this.signingCertificateStore) } } diff --git a/node/src/main/kotlin/net/corda/node/services/config/NodeConfigurationImpl.kt b/node/src/main/kotlin/net/corda/node/services/config/NodeConfigurationImpl.kt index 72db3c4446..ff26ab372a 100644 --- a/node/src/main/kotlin/net/corda/node/services/config/NodeConfigurationImpl.kt +++ b/node/src/main/kotlin/net/corda/node/services/config/NodeConfigurationImpl.kt @@ -7,7 +7,6 @@ import net.corda.core.utilities.NetworkHostAndPort import net.corda.core.utilities.loggerFor import net.corda.core.utilities.seconds import net.corda.node.services.config.rpc.NodeRpcOptions -import net.corda.node.services.keys.cryptoservice.SupportedCryptoServices import net.corda.nodeapi.BrokerRpcSslOptions import net.corda.nodeapi.internal.DEV_PUB_KEY_HASHES import net.corda.nodeapi.internal.config.FileBasedCertificateStoreSupplier @@ -75,8 +74,6 @@ data class NodeConfigurationImpl( override val jmxReporterType: JmxReporterType? = Defaults.jmxReporterType, override val flowOverrides: FlowOverrideConfig?, override val cordappSignerKeyFingerprintBlacklist: List = Defaults.cordappSignerKeyFingerprintBlacklist, - override val cryptoServiceName: SupportedCryptoServices? = null, - override val cryptoServiceConf: String? = null, override val networkParameterAcceptanceSettings: NetworkParameterAcceptanceSettings = Defaults.networkParameterAcceptanceSettings ) : NodeConfiguration { internal object Defaults { @@ -203,7 +200,6 @@ data class NodeConfigurationImpl( errors += validateTlsCertCrlConfig() errors += validateNetworkServices() errors += validateH2Settings() - errors += validateCryptoService() return errors } @@ -228,17 +224,6 @@ data class NodeConfigurationImpl( return errors } - private fun validateCryptoService(): List { - val errors = mutableListOf() - if (cryptoServiceName == null && cryptoServiceConf != null) { - errors += "'cryptoServiceName' is mandatory when 'cryptoServiceConf' is specified" - } - if (notary != null && !(cryptoServiceName == null || cryptoServiceName == SupportedCryptoServices.BC_SIMPLE)) { - errors += "Notary node with a non supported 'cryptoServiceName' has been detected" - } - return errors - } - private fun validateRpcSettings(options: NodeRpcSettings): List { val errors = mutableListOf() if (options.adminAddress == null) { diff --git a/node/src/main/kotlin/net/corda/node/services/config/schema/v1/V1NodeConfigurationSpec.kt b/node/src/main/kotlin/net/corda/node/services/config/schema/v1/V1NodeConfigurationSpec.kt index dc51187a10..6657096da8 100644 --- a/node/src/main/kotlin/net/corda/node/services/config/schema/v1/V1NodeConfigurationSpec.kt +++ b/node/src/main/kotlin/net/corda/node/services/config/schema/v1/V1NodeConfigurationSpec.kt @@ -25,7 +25,6 @@ import net.corda.node.services.config.schema.parsers.toPrincipal import net.corda.node.services.config.schema.parsers.toProperties import net.corda.node.services.config.schema.parsers.toURL import net.corda.node.services.config.schema.parsers.toUUID -import net.corda.node.services.keys.cryptoservice.SupportedCryptoServices internal object V1NodeConfigurationSpec : Configuration.Specification("NodeConfiguration") { private val myLegalName by string().mapValid(::toCordaX500Name) @@ -74,8 +73,6 @@ internal object V1NodeConfigurationSpec : Configuration.Specification error.contains("cryptoServiceName is null, but cryptoServiceConf is set to unsupported.conf") - } - } - - @Test - fun `fail on wrong cryptoServiceName`() { - var rawConfig = ConfigFactory.parseResources("working-config.conf", ConfigParseOptions.defaults().setAllowMissing(false)) - rawConfig = rawConfig.withValue("cryptoServiceName", ConfigValueFactory.fromAnyRef("UNSUPPORTED")) - - val config = rawConfig.parseAsNodeConfiguration() - - assertThat(config.errors.asSequence().map(Configuration.Validation.Error::message).filter { it.contains("has no constant of the name 'UNSUPPORTED'") }.toList()).isNotEmpty - } - @Test fun `rpcAddress and rpcSettings_address are equivalent`() { var rawConfig = ConfigFactory.parseResources("working-config.conf", ConfigParseOptions.defaults().setAllowMissing(false)) @@ -235,7 +218,7 @@ class NodeConfigurationImplTest { fun `jmxReporterType is null and defaults to Jokolia`() { val rawConfig = getConfig("working-config.conf", ConfigFactory.parseMap(mapOf("devMode" to true))) val nodeConfig = rawConfig.parseAsNodeConfiguration().value() - assertTrue(JmxReporterType.JOLOKIA.toString() == nodeConfig.jmxReporterType.toString()) + assertEquals(JmxReporterType.JOLOKIA.toString(), nodeConfig.jmxReporterType.toString()) } @Test @@ -243,7 +226,7 @@ class NodeConfigurationImplTest { var rawConfig = getConfig("working-config.conf", ConfigFactory.parseMap(mapOf("devMode" to true))) rawConfig = rawConfig.withValue("jmxReporterType", ConfigValueFactory.fromAnyRef("NEW_RELIC")) val nodeConfig = rawConfig.parseAsNodeConfiguration().value() - assertTrue(JmxReporterType.NEW_RELIC.toString() == nodeConfig.jmxReporterType.toString()) + assertEquals(JmxReporterType.NEW_RELIC.toString(), nodeConfig.jmxReporterType.toString()) } @Test @@ -251,7 +234,7 @@ class NodeConfigurationImplTest { var rawConfig = getConfig("working-config.conf", ConfigFactory.parseMap(mapOf("devMode" to true))) rawConfig = rawConfig.withValue("jmxReporterType", ConfigValueFactory.fromAnyRef("JOLOKIA")) val nodeConfig = rawConfig.parseAsNodeConfiguration().value() - assertTrue(JmxReporterType.JOLOKIA.toString() == nodeConfig.jmxReporterType.toString()) + assertEquals(JmxReporterType.JOLOKIA.toString(), nodeConfig.jmxReporterType.toString()) } private fun configDebugOptions(devMode: Boolean, devModeOptions: DevModeOptions?): NodeConfigurationImpl { diff --git a/node/src/test/kotlin/net/corda/node/utilities/registration/NetworkRegistrationHelperTest.kt b/node/src/test/kotlin/net/corda/node/utilities/registration/NetworkRegistrationHelperTest.kt index 320e499718..024a5d8346 100644 --- a/node/src/test/kotlin/net/corda/node/utilities/registration/NetworkRegistrationHelperTest.kt +++ b/node/src/test/kotlin/net/corda/node/utilities/registration/NetworkRegistrationHelperTest.kt @@ -69,8 +69,6 @@ class NetworkRegistrationHelperTest { doReturn(null).whenever(it).tlsCertCrlDistPoint doReturn(null).whenever(it).tlsCertCrlIssuer doReturn(true).whenever(it).crlCheckSoftFail - doReturn(null).whenever(it).cryptoServiceName - doReturn(null).whenever(it).cryptoServiceConf } } diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/InternalMockNetwork.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/InternalMockNetwork.kt index f2b9315920..b549219f05 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/InternalMockNetwork.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/InternalMockNetwork.kt @@ -617,8 +617,6 @@ private fun mockNodeConfiguration(certificatesDirectory: Path): NodeConfiguratio doReturn(FlowTimeoutConfiguration(1.hours, 3, backoffBase = 1.0)).whenever(it).flowTimeout doReturn(5.seconds.toMillis()).whenever(it).additionalNodeInfoPollingFrequencyMsec doReturn(null).whenever(it).devModeOptions - doReturn(null).whenever(it).cryptoServiceName - doReturn(null).whenever(it).cryptoServiceConf doReturn(NetworkParameterAcceptanceSettings()).whenever(it).networkParameterAcceptanceSettings } }