Class KeymanagerDBHelper

java.lang.Object
io.mosip.kernel.keymanagerservice.helper.KeymanagerDBHelper

@Component public class KeymanagerDBHelper extends Object
DB Helper class for Keymanager
Since:
1.1.2
Author:
Mahammed Taheer
  • Constructor Details

    • KeymanagerDBHelper

      public KeymanagerDBHelper()
  • Method Details

    • init

      @PostConstruct public void init()
    • storeKeyInAlias

      public void storeKeyInAlias(String applicationId, LocalDateTime timeStamp, String referenceId, String alias, LocalDateTime expiryDateTime, String certThumbprint, String uniqueIdentifier)
      Function to store key in keyalias table
      Parameters:
      applicationId - applicationId
      timeStamp - timeStamp
      referenceId - referenceId
      alias - alias
      expiryDateTime - expiryDateTime
    • storeKeyInDBStore

      public void storeKeyInDBStore(String alias, String masterAlias, String certificateData, String encryptedPrivateKey)
      Function to store key in DB store
      Parameters:
      alias - alias
      masterAlias - masterAlias
      encryptedPrivateKey - encryptedPrivateKey
    • getKeyAliases

      public Map<String,List<KeyAlias>> getKeyAliases(String applicationId, String referenceId, LocalDateTime timeStamp)
      Function to get keyalias from keyalias table
      Parameters:
      applicationId - applicationId
      referenceId - referenceId
      timeStamp - timeStamp
      Returns:
      a map containing a list of all keyalias matching applicationId and referenceId with key "keyAlias"; and a list of all keyalias with matching timestamp with key "currentKeyAlias"
    • getExpiryPolicy

      public LocalDateTime getExpiryPolicy(String applicationId, LocalDateTime timeStamp, List<KeyAlias> keyAlias)
      Function to get expiry datetime using keypolicy table. If a overlapping key exists for same time interval, then expiry datetime of current key will be till generation datetime of overlapping key
      Parameters:
      applicationId - applicationId
      timeStamp - timeStamp
      keyAlias - keyAlias
      Returns:
      expiry datetime
    • getKeyStoreFromDB

      public Optional<KeyStore> getKeyStoreFromDB(String keyAlias)
      Function to fetch Keystore from DB.
      Parameters:
      keyAlias - alias of the key.
      Returns:
      KeyStore
    • getKeyPolicy

      public Optional<KeyPolicy> getKeyPolicy(String applicationId)
      Function to fetch KeyPolicy from DB.
      Parameters:
      applicationId - App Id of the key.
      Returns:
      KeyPolicy
    • getKeyPolicyFromCache

      public Optional<KeyPolicy> getKeyPolicyFromCache(String applicationId)
    • getKeyAlias

      public KeyStore getKeyAlias(String certThumbprint, String appIdRefIdKey, String applicationId, String referenceId)