net.corda.node.services.keys

## Class PersistentKeyManagementService

- SingletonSerializeAsToken
- - net.corda.node.services.keys.PersistentKeyManagementService

- All Implemented Interfaces:
    KeyManagementService, SerializeAsToken

      public class PersistentKeyManagementService
      extends SingletonSerializeAsToken
      implements KeyManagementService

  A persistent re-implementation of `class E2ETestKeyManagementService` to support node re-start.

  This is not the long-term implementation. See the list of items in the above class.

  This class needs database transactions to be in-flight during method calls and init.

  See Also:
    `class E2ETestKeyManagementService`

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface net.corda.core.node.services.KeyManagementService

      `KeyManagementService.DefaultImpls`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PersistentKeyManagementService(java.util.Set<java.security.KeyPair> initialKeys)` A persistent re-implementation of `class E2ETestKeyManagementService` to support node re-start.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.security.KeyPair` | `freshKey()` Generates a new random key and adds it to the exposed map.
    `java.util.Map<java.security.PublicKey,java.security.PrivateKey>` | `getKeys()` Returns a snapshot of the current pubkey->privkey mapping.
    `java.security.KeyPair` | `toKeyPair(java.security.PublicKey publicKey)`
    `java.security.KeyPair` | `toKeyPair(java.lang.Iterable<? extends java.security.PublicKey> publicKeys)` Returns the first KeyPair matching any of the publicKeys
    `java.security.PrivateKey` | `toPrivate(java.security.PublicKey publicKey)`

    - ### Methods inherited from class net.corda.core.serialization.SingletonSerializeAsToken

      `toToken`

    - ### Methods inherited from interface net.corda.core.node.services.KeyManagementService

      `freshKey, getKeys, toKeyPair, toKeyPair, toPrivate`

    - ### Methods inherited from interface net.corda.core.serialization.SerializeAsToken

      `toToken`

- - ### Constructor Detail

    - #### PersistentKeyManagementService

          public PersistentKeyManagementService(java.util.Set<java.security.KeyPair> initialKeys)

      A persistent re-implementation of `class E2ETestKeyManagementService` to support node re-start.

      This is not the long-term implementation. See the list of items in the above class.

      This class needs database transactions to be in-flight during method calls and init.

      See Also:
        `class E2ETestKeyManagementService`

  - ### Method Detail

    - #### getKeys

          public java.util.Map<java.security.PublicKey,java.security.PrivateKey> getKeys()

      Returns a snapshot of the current pubkey->privkey mapping.

    - #### freshKey

          public java.security.KeyPair freshKey()

      Generates a new random key and adds it to the exposed map.

    - #### toPrivate

          public java.security.PrivateKey toPrivate(java.security.PublicKey publicKey)

    - #### toKeyPair

          public java.security.KeyPair toKeyPair(java.security.PublicKey publicKey)

    - #### toKeyPair

          public java.security.KeyPair toKeyPair(java.lang.Iterable<? extends java.security.PublicKey> publicKeys)

      Returns the first KeyPair matching any of the publicKeys

      See Also:
        KeyPair