WebServer init failure on config produced by plugins >= 4.0.2 [CORDA-877] (#2624)

This commit is contained in:
igor nitto 2018-02-23 18:29:49 +00:00 committed by GitHub
parent 5be0e4b39e
commit fd491d91ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 4 deletions

View File

@ -5,6 +5,7 @@ import net.corda.core.utilities.NetworkHostAndPort
import net.corda.nodeapi.internal.config.NodeSSLConfiguration
import net.corda.nodeapi.internal.config.User
import net.corda.nodeapi.internal.config.getValue
import net.corda.nodeapi.internal.config.parseAs
import java.nio.file.Path
/**
@ -25,5 +26,16 @@ class WebServerConfig(override val baseDirectory: Path, val config: Config) : No
throw Exception("Missing rpc address property. Either 'rpcSettings' or 'rpcAddress' must be specified.")
}
val webAddress: NetworkHostAndPort by config
val rpcUsers: List<User> by config
val runAs: User
init {
// TODO: replace with credentials supplied by a user
val users = if (config.hasPath("rpcUsers")) {
// TODO: remove this once config format is updated
config.getConfigList("rpcUsers")
} else {
config.getConfigList("security.authService.dataSource.users")
}
runAs = users.first().parseAs<User>()
}
}

View File

@ -189,10 +189,9 @@ class NodeWebServer(val config: WebServerConfig) {
}
private fun connectLocalRpcAsNodeUser(): CordaRPCOps {
val rpcUser = config.rpcUsers.firstOrNull() ?: throw IllegalArgumentException("The node config has not specified any RPC users")
log.info("Connecting to node at ${config.rpcAddress} as $rpcUser")
log.info("Connecting to node at ${config.rpcAddress} as ${config.runAs}")
val client = CordaRPCClient(config.rpcAddress)
val connection = client.start(rpcUser.username, rpcUser.password)
val connection = client.start(config.runAs.username, config.runAs.password)
return connection.proxy
}