mirror of
https://github.com/corda/corda.git
synced 2025-01-18 18:56:28 +00:00
Merged in andrius-servicename-gen (pull request #475)
Allow specifying advertised service identity name in configuration, generate a name if none specified
This commit is contained in:
commit
e261167343
@ -129,18 +129,9 @@ abstract class AbstractNode(open val configuration: NodeConfiguration, val netwo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val info: NodeInfo by lazy {
|
|
||||||
val services = mutableListOf<ServiceEntry>()
|
|
||||||
for (service in advertisedServices) {
|
|
||||||
val identity = obtainKeyPair(configuration.basedir, service.type.id + "-private-key", service.type.id + "-public", service.type.id).first
|
|
||||||
services += ServiceEntry(service, identity)
|
|
||||||
}
|
|
||||||
val legalIdentity = obtainLegalIdentity()
|
|
||||||
NodeInfo(net.myAddress, legalIdentity, services, findMyLocation())
|
|
||||||
}
|
|
||||||
|
|
||||||
open fun findMyLocation(): PhysicalLocation? = CityDatabase[configuration.nearestCity]
|
open fun findMyLocation(): PhysicalLocation? = CityDatabase[configuration.nearestCity]
|
||||||
|
|
||||||
|
lateinit var info: NodeInfo
|
||||||
lateinit var storage: TxWritableStorageService
|
lateinit var storage: TxWritableStorageService
|
||||||
lateinit var checkpointStorage: CheckpointStorage
|
lateinit var checkpointStorage: CheckpointStorage
|
||||||
lateinit var smm: StateMachineManager
|
lateinit var smm: StateMachineManager
|
||||||
@ -202,8 +193,8 @@ abstract class AbstractNode(open val configuration: NodeConfiguration, val netwo
|
|||||||
schemas = makeSchemaService()
|
schemas = makeSchemaService()
|
||||||
vault = makeVaultService()
|
vault = makeVaultService()
|
||||||
|
|
||||||
|
info = makeInfo()
|
||||||
identity = makeIdentityService()
|
identity = makeIdentityService()
|
||||||
|
|
||||||
// Place the long term identity key in the KMS. Eventually, this is likely going to be separated again because
|
// Place the long term identity key in the KMS. Eventually, this is likely going to be separated again because
|
||||||
// the KMS is meant for derived temporary keys used in transactions, and we're not supposed to sign things with
|
// the KMS is meant for derived temporary keys used in transactions, and we're not supposed to sign things with
|
||||||
// the identity key. But the infrastructure to make that easy isn't here yet.
|
// the identity key. But the infrastructure to make that easy isn't here yet.
|
||||||
@ -264,6 +255,25 @@ abstract class AbstractNode(open val configuration: NodeConfiguration, val netwo
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun makeInfo(): NodeInfo {
|
||||||
|
val services = makeServiceEntries()
|
||||||
|
val legalIdentity = obtainLegalIdentity()
|
||||||
|
return NodeInfo(net.myAddress, legalIdentity, services, findMyLocation())
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A service entry contains the advertised [ServiceInfo] along with the service identity. The identity *name* is
|
||||||
|
* taken from the configuration or, if non specified, generated by combining the node's legal name and the service id.
|
||||||
|
*/
|
||||||
|
private fun makeServiceEntries(): List<ServiceEntry> {
|
||||||
|
return advertisedServices.map {
|
||||||
|
val serviceId = it.type.id
|
||||||
|
val serviceName = it.name ?: "$serviceId|${configuration.myLegalName}"
|
||||||
|
val identity = obtainKeyPair(configuration.basedir, serviceId + "-private-key", serviceId + "-public", serviceName).first
|
||||||
|
ServiceEntry(it, identity)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected open fun acceptableLiveFiberCountOnStop(): Int = 0
|
protected open fun acceptableLiveFiberCountOnStop(): Int = 0
|
||||||
|
|
||||||
@ -446,12 +456,6 @@ abstract class AbstractNode(open val configuration: NodeConfiguration, val netwo
|
|||||||
val checkpointStorage = DBCheckpointStorage()
|
val checkpointStorage = DBCheckpointStorage()
|
||||||
val transactionStorage = DBTransactionStorage()
|
val transactionStorage = DBTransactionStorage()
|
||||||
_servicesThatAcceptUploads += attachments
|
_servicesThatAcceptUploads += attachments
|
||||||
// Populate the partyKeys set.
|
|
||||||
obtainKeyPair(dir, PRIVATE_KEY_FILE_NAME, PUBLIC_IDENTITY_FILE_NAME)
|
|
||||||
for (service in advertisedServices) {
|
|
||||||
// Ensure all required keys exist.
|
|
||||||
obtainKeyPair(configuration.basedir, service.type.id + "-private-key", service.type.id + "-public", service.type.id)
|
|
||||||
}
|
|
||||||
val stateMachineTransactionMappingStorage = DBTransactionMappingStorage()
|
val stateMachineTransactionMappingStorage = DBTransactionMappingStorage()
|
||||||
return Pair(
|
return Pair(
|
||||||
constructStorageService(attachments, transactionStorage, stateMachineTransactionMappingStorage),
|
constructStorageService(attachments, transactionStorage, stateMachineTransactionMappingStorage),
|
||||||
@ -475,7 +479,7 @@ abstract class AbstractNode(open val configuration: NodeConfiguration, val netwo
|
|||||||
// the legal name is actually validated in some way.
|
// the legal name is actually validated in some way.
|
||||||
val privKeyFile = dir / privateKeyFileName
|
val privKeyFile = dir / privateKeyFileName
|
||||||
val pubIdentityFile = dir / publicKeyFileName
|
val pubIdentityFile = dir / publicKeyFileName
|
||||||
val identityName = if (serviceName == null) configuration.myLegalName else configuration.myLegalName + "|" + serviceName
|
val identityName = serviceName ?: configuration.myLegalName
|
||||||
|
|
||||||
val identityAndKey = if (!privKeyFile.exists()) {
|
val identityAndKey = if (!privKeyFile.exists()) {
|
||||||
log.info("Identity key not found, generating fresh key!")
|
log.info("Identity key not found, generating fresh key!")
|
||||||
|
Loading…
Reference in New Issue
Block a user