From c8865c1b40a7a9d03e140f5803b9a6e6ff652ebc Mon Sep 17 00:00:00 2001 From: Ross Nicoll Date: Wed, 27 Apr 2016 11:43:10 +0100 Subject: [PATCH] Remove deregisterIdentity() Remove the ability to remove registered identities. Once registered, identities are part of a permanent record (for example you would want to ensure parties to contracts cannot "disappear" by removing themselves from the identity service). --- core/src/main/kotlin/core/node/services/IdentityService.kt | 6 +++++- .../kotlin/core/node/services/InMemoryIdentityService.kt | 5 +---- src/main/kotlin/core/testing/MockIdentityService.kt | 1 - 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/src/main/kotlin/core/node/services/IdentityService.kt b/core/src/main/kotlin/core/node/services/IdentityService.kt index c2006c32fd..ae312f51fd 100644 --- a/core/src/main/kotlin/core/node/services/IdentityService.kt +++ b/core/src/main/kotlin/core/node/services/IdentityService.kt @@ -10,7 +10,11 @@ import java.security.PublicKey */ interface IdentityService { fun registerIdentity(party: Party) - fun deregisterIdentity(party: Party) + + // There is no method for removing identities, as once we are made aware of a Party we want to keep track of them + // indefinitely. It may be that in the long term we need to drop or archive very old Party information for space, + // but for now this is not supported. + fun partyFromKey(key: PublicKey): Party? fun partyFromName(name: String): Party? } diff --git a/src/main/kotlin/core/node/services/InMemoryIdentityService.kt b/src/main/kotlin/core/node/services/InMemoryIdentityService.kt index 2e2a1260e4..271206079d 100644 --- a/src/main/kotlin/core/node/services/InMemoryIdentityService.kt +++ b/src/main/kotlin/core/node/services/InMemoryIdentityService.kt @@ -17,10 +17,7 @@ class InMemoryIdentityService() : IdentityService { keyToParties[party.owningKey] = party nameToParties[party.name] = party } - override fun deregisterIdentity(party: Party) { - keyToParties.remove(party.owningKey) - nameToParties.remove(party.name) - } + override fun partyFromKey(key: PublicKey): Party? = keyToParties[key] override fun partyFromName(name: String): Party? = nameToParties[name] } \ No newline at end of file diff --git a/src/main/kotlin/core/testing/MockIdentityService.kt b/src/main/kotlin/core/testing/MockIdentityService.kt index 7772238ae4..6226a7eb50 100644 --- a/src/main/kotlin/core/testing/MockIdentityService.kt +++ b/src/main/kotlin/core/testing/MockIdentityService.kt @@ -19,7 +19,6 @@ class MockIdentityService(val identities: List) : IdentityService { get() = synchronized(identities) { identities.associateBy { it.name } } override fun registerIdentity(party: Party) { throw UnsupportedOperationException() } - override fun deregisterIdentity(party: Party) { throw UnsupportedOperationException() } override fun partyFromKey(key: PublicKey): Party? = keyToParties[key] override fun partyFromName(name: String): Party? = nameToParties[name] } \ No newline at end of file