Simplify the configuration object.

This commit is contained in:
Chris Rankin 2017-02-07 10:48:01 +00:00
parent 7ea2dbdd77
commit d57f7cd557

View File

@ -20,14 +20,14 @@ class NodeConfig(
val nodeDir: Path = baseDir.resolve(key) val nodeDir: Path = baseDir.resolve(key)
private var networkMapValue: NetworkMapConfig? = null val user: Map<String, Any> = mapOf(
var networkMap : NetworkMapConfig? "user" to "guest",
get() = networkMapValue "password" to "letmein",
set(value) { networkMapValue = value } "permissions" to listOf(
"StartFlow.net.corda.flows.CashFlow",
private val userMap: Map<String, Any> "StartFlow.net.corda.flows.IssuerFlow\$IssuanceRequester"
val user: Map<String, Any> )
get() = userMap )
val ssl: SSLConfiguration = object : SSLConfiguration { val ssl: SSLConfiguration = object : SSLConfiguration {
override val certificatesDirectory: Path = nodeDir.resolve("certificates") override val certificatesDirectory: Path = nodeDir.resolve("certificates")
@ -35,6 +35,12 @@ class NodeConfig(
override val keyStorePassword: String = "cordacadevpass" override val keyStorePassword: String = "cordacadevpass"
} }
var networkMap: NetworkMapConfig? = null
/*
* The configuration object depends upon the networkMap,
* which is mutable.
*/
val toFileConfig: Config val toFileConfig: Config
get() = ConfigFactory.empty() get() = ConfigFactory.empty()
.withValue("myLegalName", valueFor(legalName)) .withValue("myLegalName", valueFor(legalName))
@ -46,26 +52,14 @@ class NodeConfig(
.withValue("legalName", valueFor(n.legalName)) .withValue("legalName", valueFor(n.legalName))
} )) } ))
.withValue("webAddress", addressValueFor(webPort)) .withValue("webAddress", addressValueFor(webPort))
.withValue("rpcUsers", valueFor(listOf<Any>(user))) .withValue("rpcUsers", valueFor(listOf(user)))
.withValue("h2port", valueFor(h2Port)) .withValue("h2port", valueFor(h2Port))
.withValue("useTestClock", valueFor(true)) .withValue("useTestClock", valueFor(true))
val isCashIssuer: Boolean val isCashIssuer: Boolean = extraServices.any {
get() = extraServices.any {
it.startsWith("corda.issuer.") it.startsWith("corda.issuer.")
} }
init {
userMap = mapOf<String, Any>(
"password" to "letmein",
"user" to "guest",
"permissions" to listOf(
"StartFlow.net.corda.flows.CashFlow",
"StartFlow.net.corda.flows.IssuerFlow\$IssuanceRequester"
)
)
}
} }
private fun <T> valueFor(any: T): ConfigValue? = ConfigValueFactory.fromAnyRef(any) private fun <T> valueFor(any: T): ConfigValue? = ConfigValueFactory.fromAnyRef(any)