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:
Stefano Franz
2019-09-01 06:57:46 +00:00
committed by Roger Willis
parent cd0d5c7724
commit c2057e0893
5 changed files with 27 additions and 0 deletions

View File

@ -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
}
}