Interface KeyStore


  • public interface KeyStore
    Keymanager interface that handles and stores its cryptographic keys.
    Since:
    1.0.0
    Author:
    Dharmesh Khandelwal
    • Method Detail

      • getPrivateKey

        PrivateKey getPrivateKey​(String alias)
        Get private key from keystore
        Parameters:
        alias - the alias
        Returns:
        The private key
      • getPublicKey

        PublicKey getPublicKey​(String alias)
        Get public key from keystore
        Parameters:
        alias - the alias
        Returns:
        The public key
      • getCertificate

        Certificate getCertificate​(String alias)
        Get certificate from keystore
        Parameters:
        alias - the alias
        Returns:
        The certificate
      • getSymmetricKey

        SecretKey getSymmetricKey​(String alias)
        Get Symmetric key from keystore
        Parameters:
        alias - the alias
        Returns:
        The Symmetric key
      • getAsymmetricKey

        KeyStore.PrivateKeyEntry getAsymmetricKey​(String alias)
        Get Asymmetric key from keystore
        Parameters:
        alias - the alias
        Returns:
        The asymmetric key
      • getAllAlias

        List<String> getAllAlias()
        Lists all the alias names of this keystore.
        Returns:
        list of all alias in keystore
      • getKey

        Key getKey​(String alias)
        Returns the key associated with the given alias, using the given password to recover it. The key must have been associated with the alias by a call to setKeyEntry, or by a call to setEntry with a PrivateKeyEntry or SecretKeyEntry.
        Parameters:
        alias - the alias
        Returns:
        the requested key, or null if the given alias does not exist or does not identify a key-related entry
      • storeSymmetricKey

        void storeSymmetricKey​(SecretKey secretKey,
                               String alias)
        Store symmetric key in keystore
        Parameters:
        secretKey - the secret key
        alias - the alias
      • storeAsymmetricKey

        void storeAsymmetricKey​(KeyPair keyPair,
                                String alias,
                                LocalDateTime validityFrom,
                                LocalDateTime validityTo)
        Store keypair in keystore
        Parameters:
        keyPair - the keypair
        alias - the alias
        validityFrom - validityFrom
        validityTo - validityTo
      • generateAndStoreSymmetricKey

        void generateAndStoreSymmetricKey​(String alias)
        Symmetric key will be generated based on the provider specified and Store the key in provider specific keystore
        Parameters:
        secretKey - the secret key
        alias - the alias
      • generateAndStoreAsymmetricKey

        void generateAndStoreAsymmetricKey​(String alias,
                                           String signKeyAlias,
                                           CertificateParameters certParams)
        Asymmetric(keypair) keys will be generated based on the provider specified and Store the keys along with self-signed certificate in provider specific keystore
        Parameters:
        alias - the alias
        signKeyAlias - alias used to sign the generated key
        certParams - required Certificate Parameters to create the certificate
      • deleteKey

        void deleteKey​(String alias)
        Delete key form keystore
        Parameters:
        alias - the alias
      • storeCertificate

        void storeCertificate​(String alias,
                              PrivateKey privateKey,
                              Certificate certificate)
        Stores the given trusted certificate to the given alias
        Parameters:
        alias - the alias
        privateKey - privateKey reference of the provided certificate
        certificate - Certificate to be stored
      • generateCertificate

        Certificate generateCertificate​(PrivateKey signPrivateKey,
                                        PublicKey publicKey,
                                        CertificateParameters certParams,
                                        X500Principal signerPrincipal)
        Creates a certificate for the given public key and signs the certificate with provided private key
        Parameters:
        signPrivateKey - privateKey used to create certificate
        publicKey - publicKey to be signed to create certificate
        certParams - required Certificate Parameters to create the certificate
        signerPrincipal - Signer Principal
        Returns:
        returns the generated certificate.
      • getKeystoreProviderName

        String getKeystoreProviderName()
        Gets the keyStore provider name.