mirror of
https://github.com/corda/corda.git
synced 2025-02-20 09:26:41 +00:00
CORDA-3180: Added ability to lookup the associated UUID for a public key to KeyManagementService (#5411)
* expose identity cache to KMSinternal * apply shams comments * Addressed review comments.
This commit is contained in:
parent
cd0d5c7724
commit
c2057e0893
@ -90,4 +90,13 @@ interface KeyManagementService {
|
||||
*/
|
||||
@Suspendable
|
||||
fun sign(signableData: SignableData, publicKey: PublicKey): TransactionSignature
|
||||
|
||||
/**
|
||||
* This method allows lookups of [PublicKey]s to an associated "external ID" / [UUID]. Providing a [PublicKey] that is unknown by the node
|
||||
* or is not mapped to an external ID will return null. Otherwise, if the [PublicKey] has been mapped to an external ID, then the [UUID]
|
||||
* for that external ID will be returned.
|
||||
* @param publicKey the [PublicKey] used to perform the lookup to external ID
|
||||
*/
|
||||
@Suspendable
|
||||
fun externalIdForPublicKey(publicKey: PublicKey): UUID?
|
||||
}
|
@ -7,6 +7,8 @@ release, see :doc:`app-upgrade-notes`.
|
||||
Unreleased
|
||||
----------
|
||||
|
||||
* Introduced a new API on ``KeyManagementService`` which facilitates lookups of ``PublicKey`` s to ``externalId`` s (Account IDs).
|
||||
|
||||
* Introduced a new low level flow diagnostics tool: checkpoint agent (that can be used standalone or in conjunction with the ``dumpCheckpoints`` shell command).
|
||||
See :doc:`checkpoint-tooling` for more information.
|
||||
|
||||
|
@ -35,6 +35,7 @@ class BasicHSMKeyManagementService(cacheFactory: NamedCacheFactory,
|
||||
private val database: CordaPersistence,
|
||||
private val cryptoService: SignOnlyCryptoService,
|
||||
private val pkToIdCache: WritablePublicKeyToOwningIdentityCache) : SingletonSerializeAsToken(), KeyManagementServiceInternal {
|
||||
|
||||
@Entity
|
||||
@Table(name = "${NODE_DATABASE_PREFIX}our_key_pairs")
|
||||
class PersistentKey(
|
||||
@ -156,4 +157,8 @@ class BasicHSMKeyManagementService(cacheFactory: NamedCacheFactory,
|
||||
keyPair.sign(signableData)
|
||||
}
|
||||
}
|
||||
|
||||
override fun externalIdForPublicKey(publicKey: PublicKey): UUID? {
|
||||
return pkToIdCache[publicKey]?.uuid
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import javax.annotation.concurrent.ThreadSafe
|
||||
*/
|
||||
@ThreadSafe
|
||||
class E2ETestKeyManagementService(override val identityService: IdentityService, private val cryptoService: CryptoService? = null) : SingletonSerializeAsToken(), KeyManagementServiceInternal {
|
||||
|
||||
private class InnerState {
|
||||
val keys = HashMap<PublicKey, PrivateKey>()
|
||||
}
|
||||
@ -87,4 +88,8 @@ class E2ETestKeyManagementService(override val identityService: IdentityService,
|
||||
val keyPair = getSigningKeyPair(publicKey)
|
||||
return keyPair.sign(signableData)
|
||||
}
|
||||
|
||||
override fun externalIdForPublicKey(publicKey: PublicKey): UUID? {
|
||||
throw UnsupportedOperationException("This operation is only supported by persistent key management service variants.")
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ import java.util.*
|
||||
class MockKeyManagementService(override val identityService: IdentityService,
|
||||
vararg initialKeys: KeyPair,
|
||||
private val pkToIdCache: WritablePublicKeyToOwningIdentityCache) : SingletonSerializeAsToken(), KeyManagementServiceInternal {
|
||||
|
||||
|
||||
private val keyStore: MutableMap<PublicKey, PrivateKey> = initialKeys.associateByTo(HashMap(), { it.public }, { it.private })
|
||||
|
||||
override val keys: Set<PublicKey> get() = keyStore.keys
|
||||
@ -57,4 +59,8 @@ class MockKeyManagementService(override val identityService: IdentityService,
|
||||
val keyPair = getSigningKeyPair(publicKey)
|
||||
return keyPair.sign(signableData)
|
||||
}
|
||||
|
||||
override fun externalIdForPublicKey(publicKey: PublicKey): UUID? {
|
||||
return pkToIdCache[publicKey]?.uuid
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user