Permissioning server: added new node properties in node config for certificate signing request

This commit is contained in:
Patrick Kuo
2016-09-14 16:32:29 +01:00
parent 4d83f1489f
commit 1388747484
6 changed files with 97 additions and 26 deletions

View File

@ -31,9 +31,12 @@ interface NodeSSLConfiguration {
interface NodeConfiguration : NodeSSLConfiguration {
val myLegalName: String
val exportJMXto: String
val nearestCity: String
val emailAddress: String
val exportJMXto: String
val dataSourceProperties: Properties get() = Properties()
val devMode: Boolean
val certificateSigningService: HostAndPort
companion object {
val log = LoggerFactory.getLogger("NodeConfiguration")
@ -74,6 +77,19 @@ operator fun <T> Config.getValue(receiver: Any, metadata: KProperty<*>): T {
}
}
/**
* Helper class for optional configurations
*/
class OptionalConfig<out T>(val conf: Config, val lambda: () -> T) {
operator fun getValue(receiver: Any, metadata: KProperty<*>): T {
return if (conf.hasPath(metadata.name)) conf.getValue(receiver, metadata) else lambda()
}
}
fun <T> Config.getOrElse(lambda: () -> T): OptionalConfig<T> {
return OptionalConfig(this, lambda)
}
fun Config.getProperties(path: String): Properties {
val obj = this.getObject(path)
val props = Properties()
@ -85,21 +101,27 @@ fun Config.getProperties(path: String): Properties {
class NodeConfigurationFromConfig(val config: Config = ConfigFactory.load()) : NodeConfiguration {
override val myLegalName: String by config
override val exportJMXto: String by config
override val nearestCity: String by config
override val emailAddress: String by config
override val exportJMXto: String by config
override val keyStorePassword: String by config
override val trustStorePassword: String by config
override val dataSourceProperties: Properties by config
override val devMode: Boolean by config.getOrElse { false }
override val certificateSigningService: HostAndPort by config
}
class FullNodeConfiguration(conf: Config) : NodeConfiguration {
val basedir: Path by conf
override val myLegalName: String by conf
override val nearestCity: String by conf
override val emailAddress: String by conf
override val exportJMXto: String = "http"
override val keyStorePassword: String by conf
override val trustStorePassword: String by conf
override val dataSourceProperties: Properties by conf
override val devMode: Boolean by conf.getOrElse { false }
override val certificateSigningService: HostAndPort by conf
val useHTTPS: Boolean by conf
val artemisAddress: HostAndPort by conf
val webAddress: HostAndPort by conf

View File

@ -1,6 +1,7 @@
myLegalName = "Vast Global MegaCorp, Ltd"
exportJMXto = "http"
nearestCity = "The Moon"
emailAddress = "admin@company.com"
exportJMXto = "http"
keyStorePassword = "cordacadevpass"
trustStorePassword = "trustpass"
dataSourceProperties = {
@ -9,4 +10,6 @@ dataSourceProperties = {
"dataSource.user" = sa
"dataSource.password" = ""
}
devMode = true
certificateSigningService = "localhost:0"
useHTTPS = false

View File

@ -28,12 +28,19 @@ class ArtemisMessagingTests {
val hostAndPort = freeLocalHostAndPort()
val topic = "platform.self"
val identity = generateKeyPair()
// TODO: create a base class that provides a default implementation
val config = object : NodeConfiguration {
override val myLegalName: String = "me"
override val exportJMXto: String = ""
override val nearestCity: String = "London"
override val emailAddress: String = ""
override val devMode: Boolean = true
override val exportJMXto: String = ""
override val keyStorePassword: String = "testpass"
override val trustStorePassword: String = "trustpass"
override val certificateSigningService: HostAndPort = HostAndPort.fromParts("localhost", 0)
}
var messagingClient: NodeMessagingClient? = null