Using a List for the identity certs in InMemoryIdentityService and PersistentIdentityService (#3210)

This commit is contained in:
Siddhartha Sengupta 2018-05-23 05:14:13 -04:00 committed by Shams Asari
parent 57fce1dd16
commit 093be1b88c
7 changed files with 14 additions and 6 deletions

View File

@ -161,6 +161,7 @@ see changes to this list.
* Sasmit Sahu
* Scott James
* Shams Asari (R3)
* Siddhartha Sengupta (Tradewind Markets)
* Simon Taylor (Barclays)
* Sofus Mortensen (Digital Asset Holdings)
* stevenroose

View File

@ -826,7 +826,7 @@ abstract class AbstractNode(val configuration: NodeConfiguration,
private fun makeIdentityService(identityCert: X509Certificate): PersistentIdentityService {
val trustRoot = configuration.loadTrustStore().getCertificate(X509Utilities.CORDA_ROOT_CA)
val nodeCa = configuration.loadNodeKeyStore().getCertificate(X509Utilities.CORDA_CLIENT_CA)
return PersistentIdentityService(trustRoot, identityCert, nodeCa)
return PersistentIdentityService(trustRoot, listOf(identityCert, nodeCa))
}
protected abstract fun makeTransactionVerifierService(): TransactionVerifierService

View File

@ -24,7 +24,7 @@ import javax.annotation.concurrent.ThreadSafe
*/
// TODO There is duplicated logic between this and PersistentIdentityService
@ThreadSafe
class InMemoryIdentityService(identities: Array<out PartyAndCertificate>,
class InMemoryIdentityService(identities: List<out PartyAndCertificate> = emptyList(),
override val trustRoot: X509Certificate) : SingletonSerializeAsToken(), IdentityService {
companion object {
private val log = contextLogger()

View File

@ -28,10 +28,17 @@ import javax.persistence.Entity
import javax.persistence.Id
import javax.persistence.Lob
/**
* An identity service that stores parties and their identities to a key value tables in the database. The entries are
* cached for efficient lookup.
*
* @param trustRoot certificate from the zone operator for identity on the network.
* @param caCertificates list of additional certificates.
*/
// TODO There is duplicated logic between this and InMemoryIdentityService
@ThreadSafe
class PersistentIdentityService(override val trustRoot: X509Certificate,
vararg caCertificates: X509Certificate) : SingletonSerializeAsToken(), IdentityServiceInternal {
caCertificates: List<X509Certificate> = emptyList()) : SingletonSerializeAsToken(), IdentityServiceInternal {
companion object {
private val log = contextLogger()

View File

@ -32,7 +32,7 @@ class InMemoryIdentityServiceTests {
val BOB get() = bob.party
val BOB_IDENTITY get() = bob.identity
val BOB_PUBKEY get() = bob.publicKey
fun createService(vararg identities: PartyAndCertificate) = InMemoryIdentityService(identities, DEV_ROOT_CA.certificate)
fun createService(vararg identities: PartyAndCertificate) = InMemoryIdentityService(identities.toList(), DEV_ROOT_CA.certificate)
}
@Rule

View File

@ -45,7 +45,7 @@ import java.util.*
/**
* Returns a simple [InMemoryIdentityService] containing the supplied [identities].
*/
fun makeTestIdentityService(vararg identities: PartyAndCertificate) = InMemoryIdentityService(identities, DEV_ROOT_CA.certificate)
fun makeTestIdentityService(vararg identities: PartyAndCertificate) = InMemoryIdentityService(identities.toList(), DEV_ROOT_CA.certificate)
/**
* An implementation of [ServiceHub] that is designed for in-memory unit tests of contract validation logic. It has

View File

@ -36,7 +36,7 @@ class InteractiveShellTest {
override fun call() = a
}
private val ids = InMemoryIdentityService(arrayOf(megaCorp.identity), DEV_ROOT_CA.certificate)
private val ids = InMemoryIdentityService(listOf(megaCorp.identity), DEV_ROOT_CA.certificate)
@Suppress("DEPRECATION")
private val om = JacksonSupport.createInMemoryMapper(ids, YAMLFactory())