Skip to content

Commit

Permalink
Merged in mike-kms-has-identity-key (pull request corda#155)
Browse files Browse the repository at this point in the history
Place the long term identity key into the KMS for now. This will all change later.
  • Loading branch information
Mike Hearn committed Jun 16, 2016
2 parents aa0a68b + 7d09a09 commit 77b3f39
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.r3corda.node.internal

import com.codahale.metrics.MetricRegistry
import com.google.common.util.concurrent.Futures
import com.google.common.util.concurrent.JdkFutureAdapters
import com.google.common.util.concurrent.ListenableFuture
import com.google.common.util.concurrent.SettableFuture
import com.r3corda.core.RunOnCallerThread
Expand Down Expand Up @@ -49,7 +47,6 @@ import java.security.KeyPair
import java.time.Clock
import java.time.Instant
import java.util.*
import java.util.concurrent.CompletableFuture

/**
* A base node implementation that can be customised either for production (with real implementations that do real
Expand Down Expand Up @@ -130,9 +127,12 @@ abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration,
checkpointStorage = storageServices.second
net = makeMessagingService()
wallet = NodeWalletService(services)
keyManagement = E2ETestKeyManagementService()
makeInterestRatesOracleService()
identity = makeIdentityService()
// 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 identity key. But the infrastructure to make that easy isn't here yet.
keyManagement = E2ETestKeyManagementService(setOf(storage.myLegalIdentityKey))
api = APIServerImpl(this)
smm = StateMachineManager(services, listOf(storage, net, wallet, keyManagement, identity, platformClock), checkpointStorage, serverThread)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,21 @@ import javax.annotation.concurrent.ThreadSafe
* etc
*/
@ThreadSafe
class E2ETestKeyManagementService() : SingletonSerializeAsToken(), KeyManagementService {
class E2ETestKeyManagementService(initialKeys: Set<KeyPair>) : SingletonSerializeAsToken(), KeyManagementService {
private class InnerState {
val keys = HashMap<PublicKey, PrivateKey>()
}

private val mutex = ThreadBox(InnerState())

init {
mutex.locked {
for (key in initialKeys) {
keys[key.public] = key.private
}
}
}

// Accessing this map clones it.
override val keys: Map<PublicKey, PrivateKey> get() = mutex.locked { HashMap(keys) }

Expand Down

0 comments on commit 77b3f39

Please sign in to comment.