Interface KeyProvider


  • @SupportedAll
    public interface KeyProvider
    The class KeyProvider is an interface that is implemented to retrieve X509Certificates and Private Keys from user data store.
    • Method Detail

      • setKey

        void setKey​(String storepass,
                    String keypass)
        Set the key to access key store database. This method will only need to be called once if the key could not be obtained by other means.
        Parameters:
        storepass - password for the key store
        keypass - password for the certificate
      • getX509Certificate

        X509Certificate getX509Certificate​(String certAlias)
        Return java.security.cert.X509Certificate for the specified certAlias.
        Parameters:
        certAlias - Certificate alias name
        Returns:
        X509Certificate which matches the certAlias, return null if the certificate could not be found.
      • getPublicKey

        PublicKey getPublicKey​(String keyAlias)
        Returns java.security.PublicKey for the specified keyAlias
        Parameters:
        keyAlias - Key alias name
        Returns:
        PublicKey which matches the keyAlias, return null if the PublicKey could not be found.
      • getPrivateKey

        PrivateKey getPrivateKey​(String certAlias)
        Returns java.security.PrivateKey for the specified certAlias.
        Parameters:
        certAlias - Certificate alias name
        Returns:
        PrivateKey which matches the certAlias, return null if the private key could not be found.
      • getSecretKey

        SecretKey getSecretKey​(String certAlias)
        Retrieves the secret key for the given certificate alias.
        Parameters:
        certAlias - the certificate alieas
        Returns:
        the secret key or returns null if the key does not exist or this key provider does not support secret keys
      • getPrivateKey

        PrivateKey getPrivateKey​(String certAlias,
                                 String encryptedKeyPass)
        Return the PrivateKey for the specified certAlias and encrypted private key password.
        Parameters:
        certAlias - Certificate alias name
        encryptedKeyPass - The encrypted keypass to use when getting the private certificate
        Returns:
        PrivateKey which matches the certAlias, return null if the private key could not be found.
      • getCertificateAlias

        String getCertificateAlias​(Certificate cert)
        Get the alias name of the first keystore entry whose certificate matches the given certificate.
        Parameters:
        cert - Certificate
        Returns:
        the (alias) name of the first entry with matching certificate, or null if no such entry exists in this keystore. If the keystore has not been loaded properly, return null as well.
      • getCertificate

        Certificate getCertificate​(PublicKey publicKey)
        Returns certificate corresponding to the specified PublicKey.
        Parameters:
        publicKey - Certificate public key
        Returns:
        Certificate which matches the PublicKey, return null if the Certificate could not be found.
      • getKeyPair

        KeyPair getKeyPair​(String certAlias)
        Return KeyPair containing PublicKey and PrivateKey for the specified certAlias.
        Parameters:
        certAlias - Certificate alias name
        Returns:
        KeyPair which matches the certAlias, return null if the PrivateKey or PublicKey could not be found.
      • getKeyStore

        KeyStore getKeyStore()
        Returns the keystore instance.
        Returns:
        the keystore instance.
      • containsKey

        boolean containsKey​(String alias)
        Whether the key alias exists in the keystore.
        Parameters:
        alias - the key alias
        Returns:
        whether the key alias exists