diff --git a/network-management/build.gradle b/network-management/build.gradle index 7b3b7cabb1..41d521366b 100644 --- a/network-management/build.gradle +++ b/network-management/build.gradle @@ -1,7 +1,7 @@ ext { // We use Corda release artifact dependencies instead of project dependencies to make sure each doorman releases are // aligned with the corresponding Corda release. - corda_dependency_version = '3.0-20171115.000100-7' + corda_dependency_version = '3.0-NETWORKMAP-20171201.110332-5' } version "$corda_dependency_version" @@ -82,7 +82,6 @@ dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compile "net.corda:corda-core:$corda_dependency_version" - compile "net.corda:corda-node:$corda_dependency_version" compile "net.corda:corda-node-api:$corda_dependency_version" testCompile "net.corda:corda-test-utils:$corda_dependency_version" testCompile "net.corda:corda-node-driver:$corda_dependency_version" @@ -126,6 +125,9 @@ dependencies { } // Needed by jira rest client compile "com.atlassian.fugue:fugue:2.6.1" + + // SQL connection pooling library + compile "com.zaxxer:HikariCP:2.5.1" } publishing { diff --git a/network-management/src/integration-test/kotlin/com/r3/corda/networkmanage/doorman/DoormanIntegrationTest.kt b/network-management/src/integration-test/kotlin/com/r3/corda/networkmanage/doorman/DoormanIntegrationTest.kt index 103da7669e..001b91c375 100644 --- a/network-management/src/integration-test/kotlin/com/r3/corda/networkmanage/doorman/DoormanIntegrationTest.kt +++ b/network-management/src/integration-test/kotlin/com/r3/corda/networkmanage/doorman/DoormanIntegrationTest.kt @@ -1,7 +1,7 @@ package com.r3.corda.networkmanage.doorman import com.nhaarman.mockito_kotlin.whenever -import com.r3.corda.networkmanage.common.persistence.SchemaService +import com.r3.corda.networkmanage.common.persistence.configureDatabase import com.r3.corda.networkmanage.common.utils.buildCertPath import com.r3.corda.networkmanage.common.utils.toX509Certificate import com.r3.corda.networkmanage.doorman.signer.LocalSigner @@ -16,9 +16,9 @@ import net.corda.core.node.NodeInfo import net.corda.core.serialization.serialize import net.corda.core.utilities.NetworkHostAndPort import net.corda.node.services.network.NetworkMapClient -import net.corda.node.utilities.* import net.corda.node.utilities.registration.HTTPNetworkRegistrationService import net.corda.node.utilities.registration.NetworkRegistrationHelper +import net.corda.nodeapi.internal.crypto.* import net.corda.testing.ALICE import net.corda.testing.SerializationEnvironmentRule import net.corda.testing.common.internal.testNetworkParameters @@ -112,7 +112,7 @@ class DoormanIntegrationTest { NetworkRegistrationHelper(config, HTTPNetworkRegistrationService(config.compatibilityZoneURL!!)).buildKeystore() // Publish NodeInfo - val networkMapClient = NetworkMapClient(config.compatibilityZoneURL!!) + val networkMapClient = NetworkMapClient(config.compatibilityZoneURL!!, rootCertAndKey.certificate.cert) val certs = loadKeyStore(config.nodeKeystore, config.keyStorePassword).getCertificateChain(X509Utilities.CORDA_CLIENT_CA) val keyPair = loadKeyStore(config.nodeKeystore, config.keyStorePassword).getKeyPair(X509Utilities.CORDA_CLIENT_CA, config.keyStorePassword) val nodeInfo = NodeInfo(listOf(NetworkHostAndPort("my.company.com", 1234)), listOf(PartyAndCertificate(buildCertPath(*certs))), 1, serial = 1L) @@ -166,10 +166,7 @@ fun startDoorman(intermediateCACertAndKey: CertificateAndKeyPair, rootCACert: X5 } fun startDoorman(localSigner: LocalSigner? = null): DoormanServer { - val database = configureDatabase(makeTestDataSourceProperties(), null, { - // Identity service not needed doorman, corda persistence is not very generic. - throw UnsupportedOperationException() - }, SchemaService()) + val database = configureDatabase(makeTestDataSourceProperties()) //Start doorman server - return startDoorman(NetworkHostAndPort("localhost", 0), database, true, testNetworkParameters(emptyList()), localSigner, 2, 30,null) + return startDoorman(NetworkHostAndPort("localhost", 0), database, true, testNetworkParameters(emptyList()), localSigner, 2, 30, null) } \ No newline at end of file diff --git a/network-management/src/integration-test/kotlin/com/r3/corda/networkmanage/hsm/DemoMain.kt b/network-management/src/integration-test/kotlin/com/r3/corda/networkmanage/hsm/DemoMain.kt index e7c738fbe5..bfc4366eeb 100644 --- a/network-management/src/integration-test/kotlin/com/r3/corda/networkmanage/hsm/DemoMain.kt +++ b/network-management/src/integration-test/kotlin/com/r3/corda/networkmanage/hsm/DemoMain.kt @@ -24,7 +24,7 @@ import java.util.* fun main(args: Array) { run(Parameters( dataSourceProperties = makeTestDataSourceProperties(), - databaseProperties = makeNotInitialisingTestDatabaseProperties(), + databaseConfig = makeNotInitialisingTestDatabaseProperties(), csrPrivateKeyPassword = "", networkMapPrivateKeyPassword = "", rootPrivateKeyPassword = "", diff --git a/network-management/src/integration-test/kotlin/com/r3/corda/networkmanage/hsm/SigningServiceIntegrationTest.kt b/network-management/src/integration-test/kotlin/com/r3/corda/networkmanage/hsm/SigningServiceIntegrationTest.kt index f9dee558c4..63673b20f4 100644 --- a/network-management/src/integration-test/kotlin/com/r3/corda/networkmanage/hsm/SigningServiceIntegrationTest.kt +++ b/network-management/src/integration-test/kotlin/com/r3/corda/networkmanage/hsm/SigningServiceIntegrationTest.kt @@ -4,7 +4,7 @@ import com.nhaarman.mockito_kotlin.any import com.nhaarman.mockito_kotlin.mock import com.nhaarman.mockito_kotlin.verify import com.nhaarman.mockito_kotlin.whenever -import com.r3.corda.networkmanage.common.persistence.SchemaService +import com.r3.corda.networkmanage.common.persistence.configureDatabase import com.r3.corda.networkmanage.common.utils.buildCertPath import com.r3.corda.networkmanage.common.utils.toX509Certificate import com.r3.corda.networkmanage.doorman.startDoorman @@ -17,11 +17,11 @@ import net.corda.core.identity.CordaX500Name import net.corda.core.internal.uncheckedCast import net.corda.core.utilities.NetworkHostAndPort import net.corda.core.utilities.seconds -import net.corda.node.utilities.CertificateType -import net.corda.node.utilities.X509Utilities -import net.corda.node.utilities.configureDatabase import net.corda.node.utilities.registration.HTTPNetworkRegistrationService import net.corda.node.utilities.registration.NetworkRegistrationHelper +import net.corda.nodeapi.internal.crypto.CertificateType +import net.corda.nodeapi.internal.crypto.X509Utilities +import net.corda.nodeapi.internal.persistence.DatabaseConfig import net.corda.testing.* import net.corda.testing.common.internal.testNetworkParameters import org.bouncycastle.pkcs.jcajce.JcaPKCS10CertificationRequest @@ -35,7 +35,6 @@ import kotlin.concurrent.scheduleAtFixedRate import kotlin.concurrent.thread class SigningServiceIntegrationTest { - companion object { val H2_TCP_PORT = "8092" val HOST = "localhost" @@ -89,10 +88,7 @@ class SigningServiceIntegrationTest { @Test fun `Signing service signs approved CSRs`() { //Start doorman server - val database = configureDatabase(makeTestDataSourceProperties(), null, { - // Identity service not needed doorman, corda persistence is not very generic. - throw UnsupportedOperationException() - }, SchemaService()) + val database = configureDatabase(makeTestDataSourceProperties()) val doorman = startDoorman(NetworkHostAndPort(HOST, 0), database, approveAll = true, approveInterval = 2, signInterval = 30, networkMapParameters = testNetworkParameters(emptyList())) // Start Corda network registration. @@ -103,10 +99,7 @@ class SigningServiceIntegrationTest { whenever(it.compatibilityZoneURL).thenReturn(URL("http://${doormanHostAndPort.host}:${doormanHostAndPort.port}")) } - val signingServiceStorage = DBSignedCertificateRequestStorage(configureDatabase(makeTestDataSourceProperties(), makeNotInitialisingTestDatabaseProperties(), { - // Identity service not needed doorman, corda persistence is not very generic. - throw UnsupportedOperationException() - }, SchemaService())) + val signingServiceStorage = DBSignedCertificateRequestStorage(configureDatabase(makeTestDataSourceProperties())) val hsmSigner = givenSignerSigningAllRequests(signingServiceStorage) // Poll the database for approved requests @@ -145,10 +138,7 @@ class SigningServiceIntegrationTest { @Ignore fun `DEMO - Create CSR and poll`() { //Start doorman server - val database = configureDatabase(makeTestDataSourceProperties(), null, { - // Identity service not needed doorman, corda persistence is not very generic. - throw UnsupportedOperationException() - }, SchemaService()) + val database = configureDatabase(makeTestDataSourceProperties(), DatabaseConfig()) val doorman = startDoorman(NetworkHostAndPort(HOST, 0), database, approveAll = true, approveInterval = 2, signInterval = 10, networkMapParameters = testNetworkParameters(emptyList())) thread(start = true, isDaemon = true) { @@ -186,8 +176,4 @@ private fun makeTestDataSourceProperties(): Properties { return props } -internal fun makeNotInitialisingTestDatabaseProperties(): Properties { - val props = Properties() - props.setProperty("initDatabase", "false") - return props -} \ No newline at end of file +internal fun makeNotInitialisingTestDatabaseProperties() = DatabaseConfig(initialiseSchema = false) \ No newline at end of file diff --git a/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/NetworkMapStorage.kt b/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/NetworkMapStorage.kt index 1eb0258c0e..629a5d8d7e 100644 --- a/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/NetworkMapStorage.kt +++ b/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/NetworkMapStorage.kt @@ -2,7 +2,7 @@ package com.r3.corda.networkmanage.common.persistence import com.r3.corda.networkmanage.common.signer.SignedNetworkMap import net.corda.core.crypto.SecureHash -import net.corda.core.node.NetworkParameters +import net.corda.nodeapi.internal.NetworkParameters /** * Data access object interface for NetworkMap persistence layer diff --git a/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/PersistenceUtils.kt b/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/PersistenceUtils.kt index 6a709ed2ee..d30bb74e48 100644 --- a/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/PersistenceUtils.kt +++ b/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/PersistenceUtils.kt @@ -1,6 +1,13 @@ package com.r3.corda.networkmanage.common.persistence -import net.corda.node.utilities.DatabaseTransaction +import com.r3.corda.networkmanage.common.persistence.entity.* +import com.zaxxer.hikari.HikariConfig +import com.zaxxer.hikari.HikariDataSource +import net.corda.core.schemas.MappedSchema +import net.corda.nodeapi.internal.persistence.CordaPersistence +import net.corda.nodeapi.internal.persistence.DatabaseConfig +import net.corda.nodeapi.internal.persistence.DatabaseTransaction +import java.util.* import javax.persistence.LockModeType import javax.persistence.criteria.CriteriaBuilder import javax.persistence.criteria.Path @@ -24,3 +31,19 @@ fun DatabaseTransaction.deleteRequest(clazz: Class, predicate: (CriteriaB return session.createQuery(delete).executeUpdate() } +fun configureDatabase(dataSourceProperties: Properties, + databaseConfig: DatabaseConfig = DatabaseConfig()): CordaPersistence { + val config = HikariConfig(dataSourceProperties) + val dataSource = HikariDataSource(config) + return CordaPersistence(dataSource, databaseConfig, setOf(NetworkManagementSchemaServices.SchemaV1), emptyList()) +} + +sealed class NetworkManagementSchemaServices { + object SchemaV1 : MappedSchema(schemaFamily = NetworkManagementSchemaServices::class.java, version = 1, + mappedTypes = listOf( + CertificateSigningRequestEntity::class.java, + CertificateDataEntity::class.java, + NodeInfoEntity::class.java, + NetworkParametersEntity::class.java, + NetworkMapEntity::class.java)) +} diff --git a/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/PersistentCertificateRequestStorage.kt b/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/PersistentCertificateRequestStorage.kt index 3e3c7a8f4c..5a591c1a5d 100644 --- a/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/PersistentCertificateRequestStorage.kt +++ b/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/PersistentCertificateRequestStorage.kt @@ -6,13 +6,13 @@ import com.r3.corda.networkmanage.common.utils.hashString import net.corda.core.crypto.SecureHash import net.corda.core.identity.CordaX500Name import net.corda.core.internal.x500Name -import net.corda.node.utilities.CordaPersistence -import net.corda.node.utilities.DatabaseTransaction +import net.corda.nodeapi.internal.persistence.CordaPersistence +import net.corda.nodeapi.internal.persistence.DatabaseTransaction +import net.corda.nodeapi.internal.persistence.TransactionIsolationLevel import org.bouncycastle.asn1.x500.X500Name import org.bouncycastle.pkcs.PKCS10CertificationRequest import org.hibernate.Session import java.security.cert.CertPath -import java.sql.Connection import java.time.Instant /** @@ -20,7 +20,7 @@ import java.time.Instant */ class PersistentCertificateRequestStorage(private val database: CordaPersistence) : CertificationRequestStorage { override fun putCertificatePath(requestId: String, certificates: CertPath, signedBy: List) { - return database.transaction(Connection.TRANSACTION_SERIALIZABLE) { + return database.transaction(TransactionIsolationLevel.SERIALIZABLE) { val request = singleRequestWhere(CertificateSigningRequestEntity::class.java) { builder, path -> val requestIdEq = builder.equal(path.get(CertificateSigningRequestEntity::requestId.name), requestId) val statusEq = builder.equal(path.get(CertificateSigningRequestEntity::status.name), RequestStatus.APPROVED) @@ -44,7 +44,7 @@ class PersistentCertificateRequestStorage(private val database: CordaPersistence override fun saveRequest(request: PKCS10CertificationRequest): String { val requestId = SecureHash.randomSHA256().toString() - database.transaction(Connection.TRANSACTION_SERIALIZABLE) { + database.transaction(TransactionIsolationLevel.SERIALIZABLE) { val (legalName, rejectReason) = parseAndValidateLegalName(request, session) session.save(CertificateSigningRequestEntity( requestId = requestId, @@ -72,7 +72,7 @@ class PersistentCertificateRequestStorage(private val database: CordaPersistence } override fun markRequestTicketCreated(requestId: String) { - return database.transaction(Connection.TRANSACTION_SERIALIZABLE) { + return database.transaction(TransactionIsolationLevel.SERIALIZABLE) { val request = findRequest(requestId, RequestStatus.NEW) request ?: throw IllegalArgumentException("Error when creating request ticket with id: $requestId. Request does not exist or its status is not NEW.") val update = request.copy( @@ -83,7 +83,7 @@ class PersistentCertificateRequestStorage(private val database: CordaPersistence } override fun approveRequest(requestId: String, approvedBy: String) { - return database.transaction(Connection.TRANSACTION_SERIALIZABLE) { + return database.transaction(TransactionIsolationLevel.SERIALIZABLE) { val request = findRequest(requestId, RequestStatus.TICKET_CREATED) request ?: throw IllegalArgumentException("Error when approving request with id: $requestId. Request does not exist or its status is not TICKET_CREATED.") val update = request.copy( @@ -95,7 +95,7 @@ class PersistentCertificateRequestStorage(private val database: CordaPersistence } override fun rejectRequest(requestId: String, rejectedBy: String, rejectReason: String) { - database.transaction(Connection.TRANSACTION_SERIALIZABLE) { + database.transaction(TransactionIsolationLevel.SERIALIZABLE) { val request = findRequest(requestId) request ?: throw IllegalArgumentException("Error when rejecting request with id: $requestId. Request does not exist.") val update = request.copy( diff --git a/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/PersistentNetworkMapStorage.kt b/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/PersistentNetworkMapStorage.kt index 029024ac08..f8f00bb257 100644 --- a/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/PersistentNetworkMapStorage.kt +++ b/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/PersistentNetworkMapStorage.kt @@ -7,9 +7,9 @@ import com.r3.corda.networkmanage.common.signer.NetworkMap import com.r3.corda.networkmanage.common.signer.SignedNetworkMap import net.corda.core.crypto.SecureHash import net.corda.core.crypto.sha256 -import net.corda.core.node.NetworkParameters import net.corda.core.serialization.serialize -import net.corda.node.utilities.CordaPersistence +import net.corda.nodeapi.internal.NetworkParameters +import net.corda.nodeapi.internal.persistence.CordaPersistence import org.hibernate.Session import org.hibernate.jpa.QueryHints diff --git a/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/PersistentNodeInfoStorage.kt b/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/PersistentNodeInfoStorage.kt index 33a268c324..2fce724f85 100644 --- a/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/PersistentNodeInfoStorage.kt +++ b/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/PersistentNodeInfoStorage.kt @@ -9,15 +9,15 @@ import net.corda.core.crypto.SecureHash import net.corda.core.crypto.SignedData import net.corda.core.node.NodeInfo import net.corda.core.serialization.SerializedBytes -import net.corda.node.utilities.CordaPersistence +import net.corda.nodeapi.internal.persistence.CordaPersistence +import net.corda.nodeapi.internal.persistence.TransactionIsolationLevel import java.security.cert.CertPath -import java.sql.Connection /** * Database implementation of the [NetworkMapStorage] interface */ class PersistentNodeInfoStorage(private val database: CordaPersistence) : NodeInfoStorage { - override fun putNodeInfo(signedNodeInfo: SignedData): SecureHash = database.transaction(Connection.TRANSACTION_SERIALIZABLE) { + override fun putNodeInfo(signedNodeInfo: SignedData): SecureHash = database.transaction(TransactionIsolationLevel.SERIALIZABLE) { val nodeInfo = signedNodeInfo.verified() val publicKeyHash = nodeInfo.legalIdentities.first().owningKey.hashString() val request = singleRequestWhere(CertificateDataEntity::class.java) { builder, path -> diff --git a/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/SchemaService.kt b/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/SchemaService.kt deleted file mode 100644 index 3dad8bf102..0000000000 --- a/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/SchemaService.kt +++ /dev/null @@ -1,27 +0,0 @@ -package com.r3.corda.networkmanage.common.persistence - -import com.r3.corda.networkmanage.common.persistence.entity.* -import net.corda.core.contracts.ContractState -import net.corda.core.schemas.MappedSchema -import net.corda.core.schemas.PersistentState -import net.corda.node.services.api.SchemaService - -class SchemaService : SchemaService { - // Entities for compulsory services - object SchemaServices - - object NetworkServicesV1 : MappedSchema(schemaFamily = SchemaServices.javaClass, version = 1, - mappedTypes = listOf( - CertificateSigningRequestEntity::class.java, - CertificateDataEntity::class.java, - NodeInfoEntity::class.java, - NetworkParametersEntity::class.java, - NetworkMapEntity::class.java)) - - override var schemaOptions: Map = mapOf(Pair(NetworkServicesV1, SchemaService.SchemaOptions())) - - override fun selectSchemas(state: ContractState): Iterable = setOf(NetworkServicesV1) - - override fun generateMappedObject(state: ContractState, schema: MappedSchema): PersistentState = throw UnsupportedOperationException() - -} \ No newline at end of file diff --git a/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/entity/NetworkParametersEntity.kt b/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/entity/NetworkParametersEntity.kt index 281c0b0121..59a2a332a1 100644 --- a/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/entity/NetworkParametersEntity.kt +++ b/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/persistence/entity/NetworkParametersEntity.kt @@ -1,7 +1,7 @@ package com.r3.corda.networkmanage.common.persistence.entity -import net.corda.core.node.NetworkParameters import net.corda.core.serialization.deserialize +import net.corda.nodeapi.internal.NetworkParameters import javax.persistence.* @Entity diff --git a/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/utils/Utils.kt b/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/utils/Utils.kt index 53176d3782..13c3ab188f 100644 --- a/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/utils/Utils.kt +++ b/network-management/src/main/kotlin/com/r3/corda/networkmanage/common/utils/Utils.kt @@ -5,12 +5,11 @@ import com.typesafe.config.ConfigFactory import joptsimple.ArgumentAcceptingOptionSpec import joptsimple.OptionParser import net.corda.core.crypto.sha256 +import net.corda.nodeapi.internal.crypto.X509CertificateFactory import org.bouncycastle.cert.X509CertificateHolder -import java.io.ByteArrayInputStream import java.security.PublicKey import java.security.cert.CertPath import java.security.cert.Certificate -import java.security.cert.CertificateFactory import java.security.cert.X509Certificate // TODO: replace this with Crypto.hash when its available. @@ -37,16 +36,8 @@ fun Array.toConfigWithOptions(registerOptions: OptionParser.() -> Un class ShowHelpException(val parser: OptionParser) : Exception() -object CertificateUtilities { - fun toX509Certificate(byteArray: ByteArray): X509Certificate { - return CertificateFactory.getInstance("X509").generateCertificate(ByteArrayInputStream(byteArray)) as X509Certificate - } -} +fun X509CertificateHolder.toX509Certificate(): X509Certificate = X509CertificateFactory().generateCertificate(encoded.inputStream()) -fun X509CertificateHolder.toX509Certificate(): Certificate = CertificateUtilities.toX509Certificate(encoded) +fun buildCertPath(vararg certificates: Certificate): CertPath = X509CertificateFactory().delegate.generateCertPath(certificates.asList()) -fun buildCertPath(vararg certificates: Certificate): CertPath { - return CertificateFactory.getInstance("X509").generateCertPath(certificates.asList()) -} - -fun buildCertPath(certPathBytes: ByteArray): CertPath = CertificateFactory.getInstance("X509").generateCertPath(certPathBytes.inputStream()) \ No newline at end of file +fun buildCertPath(certPathBytes: ByteArray): CertPath = X509CertificateFactory().delegate.generateCertPath(certPathBytes.inputStream()) diff --git a/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/JiraCient.kt b/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/JiraCient.kt index 16e82e2ba0..e53a927b14 100644 --- a/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/JiraCient.kt +++ b/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/JiraCient.kt @@ -10,7 +10,7 @@ import net.corda.core.internal.country import net.corda.core.internal.locality import net.corda.core.internal.organisation import net.corda.core.utilities.loggerFor -import net.corda.node.utilities.X509Utilities +import net.corda.nodeapi.internal.crypto.X509Utilities import org.bouncycastle.asn1.x500.style.BCStyle import org.bouncycastle.openssl.jcajce.JcaPEMWriter import org.bouncycastle.pkcs.PKCS10CertificationRequest diff --git a/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/Main.kt b/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/Main.kt index 90454103a0..510370cd66 100644 --- a/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/Main.kt +++ b/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/Main.kt @@ -15,10 +15,11 @@ import com.typesafe.config.ConfigFactory import net.corda.core.crypto.Crypto import net.corda.core.identity.CordaX500Name import net.corda.core.internal.createDirectories -import net.corda.core.node.NetworkParameters import net.corda.core.utilities.NetworkHostAndPort import net.corda.core.utilities.loggerFor -import net.corda.node.utilities.* +import net.corda.nodeapi.internal.NetworkParameters +import net.corda.nodeapi.internal.crypto.* +import net.corda.nodeapi.internal.persistence.CordaPersistence import org.bouncycastle.pkcs.PKCS10CertificationRequest import org.eclipse.jetty.server.Server import org.eclipse.jetty.server.ServerConnector @@ -277,7 +278,7 @@ fun main(args: Array) { keystorePassword, caPrivateKeyPassword) DoormanParameters.Mode.DOORMAN -> { - val database = configureDatabase(dataSourceProperties, databaseProperties, { throw UnsupportedOperationException() }, SchemaService()) + val database = configureDatabase(dataSourceProperties) val signer = buildLocalSigner(this) val networkParameters = commandLineOptions.updateNetworkParametersFile?.let { parseNetworkParametersFrom(it) diff --git a/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/NetworkParametersConfiguration.kt b/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/NetworkParametersConfiguration.kt index 200603ecf9..112cc145a1 100644 --- a/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/NetworkParametersConfiguration.kt +++ b/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/NetworkParametersConfiguration.kt @@ -5,11 +5,11 @@ import com.typesafe.config.ConfigParseOptions import net.corda.core.identity.CordaX500Name import net.corda.core.identity.Party import net.corda.core.internal.exists -import net.corda.core.node.NetworkParameters -import net.corda.core.node.NotaryInfo import net.corda.core.utilities.days import net.corda.core.utilities.parsePublicKeyBase58 import net.corda.nodeapi.config.parseAs +import net.corda.nodeapi.internal.NetworkParameters +import net.corda.nodeapi.internal.NotaryInfo import java.nio.file.Path import java.time.Instant diff --git a/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/signer/LocalSigner.kt b/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/signer/LocalSigner.kt index 3e9d1b0a89..7139df39fa 100644 --- a/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/signer/LocalSigner.kt +++ b/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/signer/LocalSigner.kt @@ -7,9 +7,8 @@ import com.r3.corda.networkmanage.common.utils.toX509Certificate import net.corda.core.crypto.sign import net.corda.core.identity.CordaX500Name import net.corda.core.internal.toX509CertHolder -import net.corda.core.internal.x500Name -import net.corda.node.utilities.CertificateType -import net.corda.node.utilities.X509Utilities +import net.corda.nodeapi.internal.crypto.CertificateType +import net.corda.nodeapi.internal.crypto.X509Utilities import org.bouncycastle.asn1.x509.GeneralName import org.bouncycastle.asn1.x509.GeneralSubtree import org.bouncycastle.asn1.x509.NameConstraints diff --git a/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/webservice/RegistrationWebService.kt b/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/webservice/RegistrationWebService.kt index 4cf69d6def..228378baaf 100644 --- a/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/webservice/RegistrationWebService.kt +++ b/network-management/src/main/kotlin/com/r3/corda/networkmanage/doorman/webservice/RegistrationWebService.kt @@ -3,9 +3,9 @@ package com.r3.corda.networkmanage.doorman.webservice import com.r3.corda.networkmanage.common.persistence.CertificateResponse import com.r3.corda.networkmanage.doorman.DoormanServerStatus import com.r3.corda.networkmanage.doorman.signer.CsrHandler -import net.corda.node.utilities.X509Utilities.CORDA_CLIENT_CA -import net.corda.node.utilities.X509Utilities.CORDA_INTERMEDIATE_CA -import net.corda.node.utilities.X509Utilities.CORDA_ROOT_CA +import net.corda.nodeapi.internal.crypto.X509Utilities.CORDA_CLIENT_CA +import net.corda.nodeapi.internal.crypto.X509Utilities.CORDA_INTERMEDIATE_CA +import net.corda.nodeapi.internal.crypto.X509Utilities.CORDA_ROOT_CA import org.bouncycastle.pkcs.jcajce.JcaPKCS10CertificationRequest import org.codehaus.jackson.map.ObjectMapper import java.io.ByteArrayOutputStream diff --git a/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/Main.kt b/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/Main.kt index cc0f5d72f7..153411eebb 100644 --- a/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/Main.kt +++ b/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/Main.kt @@ -1,7 +1,7 @@ package com.r3.corda.networkmanage.hsm import com.r3.corda.networkmanage.common.persistence.PersistentNetworkMapStorage -import com.r3.corda.networkmanage.common.persistence.SchemaService +import com.r3.corda.networkmanage.common.persistence.configureDatabase import com.r3.corda.networkmanage.hsm.authentication.AuthMode import com.r3.corda.networkmanage.hsm.authentication.Authenticator import com.r3.corda.networkmanage.hsm.authentication.createProvider @@ -15,7 +15,6 @@ import com.r3.corda.networkmanage.hsm.persistence.DBSignedCertificateRequestStor import com.r3.corda.networkmanage.hsm.signer.HsmCsrSigner import com.r3.corda.networkmanage.hsm.signer.HsmNetworkMapSigner import com.r3.corda.networkmanage.hsm.utils.mapCryptoServerException -import net.corda.node.utilities.configureDatabase fun main(args: Array) { run(parseParameters(*args)) @@ -25,10 +24,7 @@ fun run(parameters: Parameters) { parameters.run { // Create DB connection. checkNotNull(dataSourceProperties) - val database = configureDatabase(dataSourceProperties, databaseProperties, { - // Identity service not needed - throw UnsupportedOperationException() - }, SchemaService()) + val database = configureDatabase(dataSourceProperties, databaseConfig) val csrStorage = DBSignedCertificateRequestStorage(database) val networkMapStorage = PersistentNetworkMapStorage(database) val hsmNetworkMapSigningThread = HsmNetworkMapSigner( diff --git a/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/configuration/Configuration.kt b/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/configuration/Configuration.kt index f39aced56a..71a9823646 100644 --- a/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/configuration/Configuration.kt +++ b/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/configuration/Configuration.kt @@ -13,8 +13,9 @@ import com.r3.corda.networkmanage.hsm.configuration.Parameters.Companion.DEFAULT import com.typesafe.config.ConfigFactory import com.typesafe.config.ConfigParseOptions import net.corda.core.internal.div -import net.corda.node.utilities.X509Utilities import net.corda.nodeapi.config.parseAs +import net.corda.nodeapi.internal.crypto.X509Utilities +import net.corda.nodeapi.internal.persistence.DatabaseConfig import java.nio.file.Path import java.nio.file.Paths import java.util.* @@ -22,11 +23,10 @@ import java.util.* /** * Configuration parameters. */ -data class Parameters(val basedir: Path = Paths.get("."), - val dataSourceProperties: Properties, - val databaseProperties: Properties? = null, +data class Parameters(val dataSourceProperties: Properties, + val databaseConfig: DatabaseConfig = DatabaseConfig(), val device: String = DEFAULT_DEVICE, - // TODO this needs cleaning up after the config-file-only support is implemented + // TODO this needs cleaning up after the config-file-only support is implemented val keyGroup: String, val keySpecifier: Int = DEFAULT_KEY_SPECIFIER, val rootPrivateKeyPassword: String, @@ -42,7 +42,7 @@ data class Parameters(val basedir: Path = Paths.get("."), val authKeyFilePath: Path? = DEFAULT_KEY_FILE_PATH, val authKeyFilePassword: String? = DEFAULT_KEY_FILE_PASSWORD, val autoUsername: String? = DEFAULT_AUTO_USERNAME, - // TODO Change this to Duration in the future. + // TODO Change this to Duration in the future. val signInterval: Long = DEFAULT_SIGN_INTERVAL) { companion object { val DEFAULT_DEVICE = "3001@127.0.0.1" @@ -93,5 +93,5 @@ fun parseParameters(vararg args: String): Parameters { } val config = argConfig.withFallback(ConfigFactory.parseFile(configFile.toFile(), ConfigParseOptions.defaults().setAllowMissing(true))).resolve() - return config.parseAs() + return config.parseAs() } \ No newline at end of file diff --git a/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/generator/KeyCertificateGenerator.kt b/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/generator/KeyCertificateGenerator.kt index da54182417..8940ad5155 100644 --- a/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/generator/KeyCertificateGenerator.kt +++ b/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/generator/KeyCertificateGenerator.kt @@ -8,7 +8,7 @@ import com.r3.corda.networkmanage.hsm.utils.X509Utilities.createSelfSignedCACert import com.r3.corda.networkmanage.hsm.utils.X509Utilities.getAndInitializeKeyStore import com.r3.corda.networkmanage.hsm.utils.X509Utilities.getCleanEcdsaKeyPair import com.r3.corda.networkmanage.hsm.utils.X509Utilities.retrieveCertificateAndKeys -import net.corda.node.utilities.addOrReplaceKey +import net.corda.nodeapi.internal.crypto.addOrReplaceKey import java.security.KeyPair import java.security.KeyStore import java.security.PrivateKey diff --git a/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/persistence/DBSignedCertificateRequestStorage.kt b/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/persistence/DBSignedCertificateRequestStorage.kt index 8576b0d9e2..7bea59678f 100644 --- a/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/persistence/DBSignedCertificateRequestStorage.kt +++ b/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/persistence/DBSignedCertificateRequestStorage.kt @@ -3,7 +3,7 @@ package com.r3.corda.networkmanage.hsm.persistence import com.r3.corda.networkmanage.common.persistence.CertificateSigningRequest import com.r3.corda.networkmanage.common.persistence.PersistentCertificateRequestStorage import com.r3.corda.networkmanage.common.persistence.RequestStatus -import net.corda.node.utilities.CordaPersistence +import net.corda.nodeapi.internal.persistence.CordaPersistence import org.bouncycastle.pkcs.PKCS10CertificationRequest import java.security.cert.CertPath diff --git a/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/utils/X509Utils.kt b/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/utils/X509Utils.kt index f6e765660c..4876c721d0 100644 --- a/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/utils/X509Utils.kt +++ b/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/utils/X509Utils.kt @@ -5,10 +5,10 @@ import net.corda.core.crypto.DigitalSignature import net.corda.core.identity.CordaX500Name import net.corda.core.internal.toX509CertHolder import net.corda.core.internal.x500Name -import net.corda.node.utilities.CertificateAndKeyPair -import net.corda.node.utilities.CertificateType -import net.corda.node.utilities.X509Utilities -import net.corda.node.utilities.getX509Certificate +import net.corda.nodeapi.internal.crypto.CertificateAndKeyPair +import net.corda.nodeapi.internal.crypto.CertificateType +import net.corda.nodeapi.internal.crypto.X509Utilities +import net.corda.nodeapi.internal.crypto.getX509Certificate import org.bouncycastle.asn1.ASN1EncodableVector import org.bouncycastle.asn1.ASN1Sequence import org.bouncycastle.asn1.DERSequence diff --git a/network-management/src/test/kotlin/com/r3/corda/networkmanage/TestBase.kt b/network-management/src/test/kotlin/com/r3/corda/networkmanage/TestBase.kt index a04bdf59a3..75984ac3be 100644 --- a/network-management/src/test/kotlin/com/r3/corda/networkmanage/TestBase.kt +++ b/network-management/src/test/kotlin/com/r3/corda/networkmanage/TestBase.kt @@ -5,12 +5,10 @@ import com.r3.corda.networkmanage.common.persistence.CertificateData import com.r3.corda.networkmanage.common.persistence.CertificateSigningRequest import com.r3.corda.networkmanage.common.persistence.CertificateStatus import com.r3.corda.networkmanage.common.persistence.RequestStatus -import com.r3.corda.networkmanage.common.persistence.entity.CertificateDataEntity -import com.r3.corda.networkmanage.common.persistence.entity.CertificateSigningRequestEntity import net.corda.core.crypto.SecureHash -import net.corda.core.node.NetworkParameters -import net.corda.core.node.NotaryInfo import net.corda.core.utilities.seconds +import net.corda.nodeapi.internal.NetworkParameters +import net.corda.nodeapi.internal.NotaryInfo import net.corda.testing.SerializationEnvironmentRule import org.bouncycastle.pkcs.PKCS10CertificationRequest import org.junit.Rule diff --git a/network-management/src/test/kotlin/com/r3/corda/networkmanage/common/persistence/DBCertificateRequestStorageTest.kt b/network-management/src/test/kotlin/com/r3/corda/networkmanage/common/persistence/DBCertificateRequestStorageTest.kt index ae2ec1bed3..36d9893644 100644 --- a/network-management/src/test/kotlin/com/r3/corda/networkmanage/common/persistence/DBCertificateRequestStorageTest.kt +++ b/network-management/src/test/kotlin/com/r3/corda/networkmanage/common/persistence/DBCertificateRequestStorageTest.kt @@ -8,10 +8,10 @@ import com.r3.corda.networkmanage.common.utils.toX509Certificate import net.corda.core.crypto.Crypto import net.corda.core.crypto.SecureHash import net.corda.core.identity.CordaX500Name -import net.corda.node.utilities.CertificateType -import net.corda.node.utilities.CordaPersistence -import net.corda.node.utilities.X509Utilities -import net.corda.node.utilities.configureDatabase +import net.corda.nodeapi.internal.crypto.CertificateType +import net.corda.nodeapi.internal.crypto.X509Utilities +import net.corda.nodeapi.internal.persistence.CordaPersistence +import net.corda.nodeapi.internal.persistence.DatabaseConfig import org.assertj.core.api.Assertions.assertThat import org.bouncycastle.asn1.x500.X500Name import org.bouncycastle.pkcs.PKCS10CertificationRequest @@ -30,7 +30,7 @@ class DBCertificateRequestStorageTest : TestBase() { @Before fun startDb() { - persistence = configureDatabase(makeTestDataSourceProperties(), makeTestDatabaseProperties(), { throw UnsupportedOperationException() }, SchemaService()) + persistence = configureDatabase(makeTestDataSourceProperties()) storage = PersistentCertificateRequestStorage(persistence) } @@ -224,15 +224,6 @@ class DBCertificateRequestStorageTest : TestBase() { props.setProperty("dataSource.password", "") return props } - - private fun makeTestDatabaseProperties(key: String? = null, value: String? = null): Properties { - val props = Properties() - props.setProperty("transactionIsolationLevel", "repeatableRead") //for other possible values see net.corda.node.utilities.CordaPeristence.parserTransactionIsolationLevel(String) - if (key != null) { - props.setProperty(key, value) - } - return props - } } internal fun createRequest(organisation: String): Pair { diff --git a/network-management/src/test/kotlin/com/r3/corda/networkmanage/common/persistence/DBNetworkMapStorageTest.kt b/network-management/src/test/kotlin/com/r3/corda/networkmanage/common/persistence/DBNetworkMapStorageTest.kt index 1dabed21a2..6f208e072b 100644 --- a/network-management/src/test/kotlin/com/r3/corda/networkmanage/common/persistence/DBNetworkMapStorageTest.kt +++ b/network-management/src/test/kotlin/com/r3/corda/networkmanage/common/persistence/DBNetworkMapStorageTest.kt @@ -14,13 +14,12 @@ import net.corda.core.identity.PartyAndCertificate import net.corda.core.node.NodeInfo import net.corda.core.serialization.serialize import net.corda.core.utilities.NetworkHostAndPort -import net.corda.node.utilities.CertificateType -import net.corda.node.utilities.CordaPersistence -import net.corda.node.utilities.X509Utilities -import net.corda.node.utilities.configureDatabase +import net.corda.nodeapi.internal.crypto.CertificateType +import net.corda.nodeapi.internal.crypto.X509Utilities +import net.corda.nodeapi.internal.persistence.CordaPersistence +import net.corda.nodeapi.internal.persistence.DatabaseConfig import net.corda.testing.common.internal.testNetworkParameters import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties -import net.corda.testing.node.MockServices.Companion.makeTestDatabaseProperties import org.junit.After import org.junit.Before import org.junit.Test @@ -39,7 +38,7 @@ class DBNetworkMapStorageTest : TestBase() { @Before fun startDb() { - persistence = configureDatabase(makeTestDataSourceProperties(), makeTestDatabaseProperties(), { throw UnsupportedOperationException() }, SchemaService()) + persistence = configureDatabase(makeTestDataSourceProperties()) networkMapStorage = PersistentNetworkMapStorage(persistence) nodeInfoStorage = PersistentNodeInfoStorage(persistence) requestStorage = PersistentCertificateRequestStorage(persistence) diff --git a/network-management/src/test/kotlin/com/r3/corda/networkmanage/common/persistence/PersitenceNodeInfoStorageTest.kt b/network-management/src/test/kotlin/com/r3/corda/networkmanage/common/persistence/PersitenceNodeInfoStorageTest.kt index 9229573296..62165bea88 100644 --- a/network-management/src/test/kotlin/com/r3/corda/networkmanage/common/persistence/PersitenceNodeInfoStorageTest.kt +++ b/network-management/src/test/kotlin/com/r3/corda/networkmanage/common/persistence/PersitenceNodeInfoStorageTest.kt @@ -13,10 +13,10 @@ import net.corda.core.identity.PartyAndCertificate import net.corda.core.node.NodeInfo import net.corda.core.serialization.serialize import net.corda.core.utilities.NetworkHostAndPort -import net.corda.node.utilities.CertificateType -import net.corda.node.utilities.CordaPersistence -import net.corda.node.utilities.X509Utilities -import net.corda.node.utilities.configureDatabase +import net.corda.nodeapi.internal.crypto.CertificateType +import net.corda.nodeapi.internal.crypto.X509Utilities +import net.corda.nodeapi.internal.persistence.CordaPersistence +import net.corda.nodeapi.internal.persistence.DatabaseConfig import net.corda.testing.node.MockServices import org.junit.After import org.junit.Before @@ -36,7 +36,7 @@ class PersitenceNodeInfoStorageTest : TestBase() { @Before fun startDb() { - persistence = configureDatabase(MockServices.makeTestDataSourceProperties(), MockServices.makeTestDatabaseProperties(), { throw UnsupportedOperationException() }, SchemaService()) + persistence = configureDatabase(MockServices.makeTestDataSourceProperties()) nodeInfoStorage = PersistentNodeInfoStorage(persistence) requestStorage = PersistentCertificateRequestStorage(persistence) } diff --git a/network-management/src/test/kotlin/com/r3/corda/networkmanage/doorman/DefaultRequestProcessorTest.kt b/network-management/src/test/kotlin/com/r3/corda/networkmanage/doorman/DefaultRequestProcessorTest.kt index d280d55dc4..3029723e79 100644 --- a/network-management/src/test/kotlin/com/r3/corda/networkmanage/doorman/DefaultRequestProcessorTest.kt +++ b/network-management/src/test/kotlin/com/r3/corda/networkmanage/doorman/DefaultRequestProcessorTest.kt @@ -15,7 +15,7 @@ import com.r3.corda.networkmanage.doorman.signer.DefaultCsrHandler import com.r3.corda.networkmanage.doorman.signer.LocalSigner import net.corda.core.crypto.Crypto import net.corda.core.identity.CordaX500Name -import net.corda.node.utilities.X509Utilities +import net.corda.nodeapi.internal.crypto.X509Utilities import org.junit.Test import kotlin.test.assertEquals diff --git a/network-management/src/test/kotlin/com/r3/corda/networkmanage/doorman/NodeInfoWebServiceTest.kt b/network-management/src/test/kotlin/com/r3/corda/networkmanage/doorman/NodeInfoWebServiceTest.kt index ab7e2030a1..2502acbd5f 100644 --- a/network-management/src/test/kotlin/com/r3/corda/networkmanage/doorman/NodeInfoWebServiceTest.kt +++ b/network-management/src/test/kotlin/com/r3/corda/networkmanage/doorman/NodeInfoWebServiceTest.kt @@ -18,8 +18,8 @@ import net.corda.core.node.NodeInfo import net.corda.core.serialization.deserialize import net.corda.core.serialization.serialize import net.corda.core.utilities.NetworkHostAndPort -import net.corda.node.utilities.CertificateType -import net.corda.node.utilities.X509Utilities +import net.corda.nodeapi.internal.crypto.CertificateType +import net.corda.nodeapi.internal.crypto.X509Utilities import net.corda.testing.SerializationEnvironmentRule import org.bouncycastle.asn1.x500.X500Name import org.junit.Rule @@ -33,7 +33,6 @@ import kotlin.test.assertEquals import kotlin.test.assertFailsWith class NodeInfoWebServiceTest { - @Rule @JvmField val testSerialization = SerializationEnvironmentRule(true) diff --git a/network-management/src/test/kotlin/com/r3/corda/networkmanage/doorman/RegistrationWebServiceTest.kt b/network-management/src/test/kotlin/com/r3/corda/networkmanage/doorman/RegistrationWebServiceTest.kt index 521d248f58..5c2bf4f841 100644 --- a/network-management/src/test/kotlin/com/r3/corda/networkmanage/doorman/RegistrationWebServiceTest.kt +++ b/network-management/src/test/kotlin/com/r3/corda/networkmanage/doorman/RegistrationWebServiceTest.kt @@ -11,10 +11,10 @@ import net.corda.core.crypto.Crypto import net.corda.core.crypto.SecureHash import net.corda.core.identity.CordaX500Name import net.corda.core.utilities.NetworkHostAndPort -import net.corda.node.utilities.CertificateStream -import net.corda.node.utilities.CertificateType -import net.corda.node.utilities.X509Utilities -import net.corda.node.utilities.X509Utilities.DEFAULT_TLS_SIGNATURE_SCHEME +import net.corda.nodeapi.internal.crypto.CertificateType +import net.corda.nodeapi.internal.crypto.X509CertificateFactory +import net.corda.nodeapi.internal.crypto.X509Utilities +import net.corda.nodeapi.internal.crypto.X509Utilities.DEFAULT_TLS_SIGNATURE_SCHEME import org.apache.commons.io.IOUtils import org.assertj.core.api.Assertions.assertThat import org.bouncycastle.asn1.x500.X500Name @@ -184,10 +184,10 @@ class RegistrationWebServiceTest : TestBase() { return when (conn.responseCode) { HTTP_OK -> ZipInputStream(conn.inputStream).use { - val stream = CertificateStream(it) val certificates = ArrayList() + val factory = X509CertificateFactory() while (it.nextEntry != null) { - certificates.add(stream.nextCertificate()) + certificates += factory.generateCertificate(it) } PollResponse.Ready(certificates) } diff --git a/network-management/src/test/kotlin/com/r3/corda/networkmanage/doorman/signer/CsrHandlerTest.kt b/network-management/src/test/kotlin/com/r3/corda/networkmanage/doorman/signer/CsrHandlerTest.kt index 854a749845..21d3ed1375 100644 --- a/network-management/src/test/kotlin/com/r3/corda/networkmanage/doorman/signer/CsrHandlerTest.kt +++ b/network-management/src/test/kotlin/com/r3/corda/networkmanage/doorman/signer/CsrHandlerTest.kt @@ -8,7 +8,7 @@ import com.r3.corda.networkmanage.common.persistence.RequestStatus import com.r3.corda.networkmanage.doorman.JiraClient import net.corda.core.crypto.Crypto import net.corda.core.identity.CordaX500Name -import net.corda.node.utilities.X509Utilities +import net.corda.nodeapi.internal.crypto.X509Utilities import org.junit.Before import org.junit.Rule import org.junit.Test @@ -32,11 +32,11 @@ class JiraCsrHandlerTest { lateinit var defaultCsrHandler: DefaultCsrHandler @Mock - var certPath : CertPath = mock() + var certPath: CertPath = mock() - private lateinit var jiraCsrHandler : JiraCsrHandler + private lateinit var jiraCsrHandler: JiraCsrHandler private val requestId = "id" - private lateinit var certificateResponse : CertificateResponse.Ready + private lateinit var certificateResponse: CertificateResponse.Ready private val keyPair = Crypto.generateKeyPair(X509Utilities.DEFAULT_TLS_SIGNATURE_SCHEME) private val pkcS10CertificationRequest = X509Utilities.createCertificateSigningRequest(CordaX500Name(locality = "London", organisation = "LegalName", country = "GB"), "my@mail.com", keyPair)