Class KeymanagerDBHelper


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

      • KeymanagerDBHelper

        public KeymanagerDBHelper()
    • Method Detail

      • storeKeyInAlias

        public void storeKeyInAlias​(String applicationId,
                                    LocalDateTime timeStamp,
                                    String referenceId,
                                    String alias,
                                    LocalDateTime expiryDateTime)
        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
        publicKey - publicKey
        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