Cherry picked commit from the release DEV preview branch. This is the fix for the database config not being honoured by doorman (#408)

This commit is contained in:
Michal Kit 2018-01-25 15:41:59 +00:00 committed by GitHub
parent 1be4f0950d
commit 5f1590d97f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 19 deletions

View File

@ -35,7 +35,7 @@ Allowed parameters are:
:approveAll: Whether to approve all request (defaults to false), this is for debug only. :approveAll: Whether to approve all request (defaults to false), this is for debug only.
:databaseProperties: database properties :database: database properties. The same (including its default value) as for node configuration (see :doc:`corda-configuration-file`).
:dataSourceProperties: datasource properties :dataSourceProperties: datasource properties

View File

@ -12,6 +12,11 @@ dataSourceProperties {
"dataSource.user" = sa "dataSource.user" = sa
"dataSource.password" = "" "dataSource.password" = ""
} }
database {
runMigration = true
}
h2port = 0 h2port = 0
# Comment out this section if running without doorman service # Comment out this section if running without doorman service

View File

@ -7,6 +7,7 @@ import net.corda.core.internal.div
import net.corda.core.internal.isRegularFile import net.corda.core.internal.isRegularFile
import net.corda.core.utilities.seconds import net.corda.core.utilities.seconds
import net.corda.nodeapi.internal.config.parseAs import net.corda.nodeapi.internal.config.parseAs
import net.corda.nodeapi.internal.persistence.DatabaseConfig
import java.nio.file.Path import java.nio.file.Path
import java.nio.file.Paths import java.nio.file.Paths
import java.util.* import java.util.*
@ -15,7 +16,7 @@ data class NetworkManagementServerParameters(// TODO: Move local signing to sign
val host: String, val host: String,
val port: Int, val port: Int,
val dataSourceProperties: Properties, val dataSourceProperties: Properties,
val databaseProperties: Properties? = null, val database: DatabaseConfig = DatabaseConfig(),
val mode: Mode, val mode: Mode,
val doormanConfig: DoormanConfig?, val doormanConfig: DoormanConfig?,

View File

@ -8,26 +8,20 @@ import com.r3.corda.networkmanage.common.utils.CertPathAndKey
import com.r3.corda.networkmanage.common.utils.ShowHelpException import com.r3.corda.networkmanage.common.utils.ShowHelpException
import com.r3.corda.networkmanage.doorman.signer.LocalSigner import com.r3.corda.networkmanage.doorman.signer.LocalSigner
import com.r3.corda.networkmanage.hsm.configuration.Parameters.Companion.DEFAULT_CSR_CERTIFICATE_NAME import com.r3.corda.networkmanage.hsm.configuration.Parameters.Companion.DEFAULT_CSR_CERTIFICATE_NAME
import net.corda.core.crypto.Crypto
import net.corda.core.crypto.SignatureScheme
import net.corda.core.identity.CordaX500Name
import net.corda.core.internal.createDirectories
import net.corda.core.internal.div
import net.corda.core.serialization.internal.SerializationEnvironmentImpl import net.corda.core.serialization.internal.SerializationEnvironmentImpl
import net.corda.core.serialization.internal.nodeSerializationEnv import net.corda.core.serialization.internal.nodeSerializationEnv
import net.corda.core.utilities.NetworkHostAndPort import net.corda.core.utilities.NetworkHostAndPort
import net.corda.nodeapi.internal.crypto.* import net.corda.nodeapi.internal.crypto.getCertificateAndKeyPair
import net.corda.nodeapi.internal.crypto.getSupportedKey
import net.corda.nodeapi.internal.crypto.loadOrCreateKeyStore
import net.corda.nodeapi.internal.network.NetworkParameters import net.corda.nodeapi.internal.network.NetworkParameters
import net.corda.nodeapi.internal.serialization.AMQP_P2P_CONTEXT import net.corda.nodeapi.internal.serialization.AMQP_P2P_CONTEXT
import net.corda.nodeapi.internal.serialization.SerializationFactoryImpl import net.corda.nodeapi.internal.serialization.SerializationFactoryImpl
import net.corda.nodeapi.internal.serialization.amqp.AMQPClientSerializationScheme import net.corda.nodeapi.internal.serialization.amqp.AMQPClientSerializationScheme
import org.bouncycastle.pkcs.PKCS10CertificationRequest import org.bouncycastle.pkcs.PKCS10CertificationRequest
import java.nio.file.Path
import java.security.cert.X509Certificate import java.security.cert.X509Certificate
import java.time.Instant import java.time.Instant
import javax.security.auth.x500.X500Principal
import kotlin.concurrent.thread import kotlin.concurrent.thread
import kotlin.system.exitProcess
data class NetworkMapStartParams(val signer: LocalSigner?, val updateNetworkParameters: NetworkParameters?, val config: NetworkMapConfig) data class NetworkMapStartParams(val signer: LocalSigner?, val updateNetworkParameters: NetworkParameters?, val config: NetworkMapConfig)
@ -84,7 +78,7 @@ fun main(args: Array<String>) {
caPrivateKeyPassword) caPrivateKeyPassword)
Mode.DOORMAN -> { Mode.DOORMAN -> {
initialiseSerialization() initialiseSerialization()
val database = configureDatabase(dataSourceProperties) val persistence = configureDatabase(dataSourceProperties, database)
// TODO: move signing to signing server. // TODO: move signing to signing server.
val csrAndNetworkMap = processKeyStore(this) val csrAndNetworkMap = processKeyStore(this)
@ -103,7 +97,7 @@ fun main(args: Array<String>) {
NetworkMapStartParams(csrAndNetworkMap?.second, networkParameters, it) NetworkMapStartParams(csrAndNetworkMap?.second, networkParameters, it)
} }
networkManagementServer.start(NetworkHostAndPort(host, port), database, csrAndNetworkMap?.first, doormanConfig, networkMapStartParams) networkManagementServer.start(NetworkHostAndPort(host, port), persistence, csrAndNetworkMap?.first, doormanConfig, networkMapStartParams)
Runtime.getRuntime().addShutdownHook(thread(start = false) { Runtime.getRuntime().addShutdownHook(thread(start = false) {
networkManagementServer.close() networkManagementServer.close()

View File

@ -10,6 +10,7 @@ import java.lang.reflect.InvocationTargetException
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith import kotlin.test.assertFailsWith
import kotlin.test.assertNull import kotlin.test.assertNull
import kotlin.test.assertTrue
class DoormanParametersTest { class DoormanParametersTest {
private val validOverrideNetworkConfigPath = File("network-parameters.conf").absolutePath private val validOverrideNetworkConfigPath = File("network-parameters.conf").absolutePath
@ -48,12 +49,9 @@ class DoormanParametersTest {
} }
@Test @Test
fun `should parse jira config correctly`() { fun `should parse database config correctly`() {
val parameter = parseParameters(*validArgs).doormanConfig!! val parameter = parseParameters(*validArgs).database
assertEquals("https://doorman-jira-host.com/", parameter.jiraConfig?.address) assertTrue(parameter.runMigration)
assertEquals("TD", parameter.jiraConfig?.projectCode)
assertEquals("username", parameter.jiraConfig?.username)
assertEquals("password", parameter.jiraConfig?.password)
} }
@Test @Test