Class KeymanagerUtil


  • @Component
    public class KeymanagerUtil
    extends Object
    Utility class for Keymanager
    Since:
    1.0.0
    Author:
    Dharmesh Khandelwal, Urvil Joshi
    • Constructor Detail

      • KeymanagerUtil

        public KeymanagerUtil()
    • Method Detail

      • isValidTimestamp

        public boolean isValidTimestamp​(LocalDateTime timeStamp,
                                        KeyAlias keyAlias)
        Function to check valid timestamp
        Parameters:
        timeStamp - timeStamp
        keyAlias - keyAlias
        Returns:
        true if timestamp is valid, else false
      • isOverlapping

        public boolean isOverlapping​(LocalDateTime timeStamp,
                                     LocalDateTime policyExpiryTime,
                                     LocalDateTime keyGenerationTime,
                                     LocalDateTime keyExpiryTime)
        Function to check if timestamp is overlapping
        Parameters:
        timeStamp - timeStamp
        policyExpiryTime - policyExpiryTime
        keyGenerationTime - keyGenerationTime
        keyExpiryTime - keyExpiryTime
        Returns:
        true if timestamp is overlapping, else false
      • isValidReferenceId

        public boolean isValidReferenceId​(String referenceId)
        Function to check is reference id is valid
        Parameters:
        referenceId - referenceId
        Returns:
        true if referenceId is valid, else false
      • setMetaData

        public <T extends BaseEntity> T setMetaData​(T entity)
        Function to set metadata
        Type Parameters:
        T - is a type parameter
        Parameters:
        entity - entity of T type
        Returns:
        Entity with metadata
      • encryptKey

        public byte[] encryptKey​(PrivateKey privateKey,
                                 PublicKey masterKey)
        Function to encrypt key
        Parameters:
        privateKey - privateKey
        masterKey - masterKey
        Returns:
        encrypted key
      • decryptKey

        public byte[] decryptKey​(byte[] key,
                                 PrivateKey privateKey,
                                 PublicKey publicKey)
        Function to decrypt key
        Parameters:
        key - key
        privateKey - privateKey
        Returns:
        decrypted key
      • parseToLocalDateTime

        public LocalDateTime parseToLocalDateTime​(String dateTime)
        Parse a date string of pattern UTC_DATETIME_PATTERN into LocalDateTime
        Parameters:
        dateTime - of type String of pattern UTC_DATETIME_PATTERN
        Returns:
        a LocalDateTime of given pattern
      • isValidResponseType

        public boolean isValidResponseType​(String responseType)
      • isValidApplicationId

        public boolean isValidApplicationId​(String appId)
      • isValidCertificateData

        public boolean isValidCertificateData​(String certData)
      • convertToCertificate

        public Certificate convertToCertificate​(String certData)
      • convertToCertificate

        public Certificate convertToCertificate​(byte[] certDataBytes)
      • getPEMFormatedData

        public String getPEMFormatedData​(Object anyObject)
      • destoryKey

        public void destoryKey​(PrivateKey privateKey)
      • destoryKey

        public void destoryKey​(SecretKey secretKey)