Class LocalKeyStore


  • public final class LocalKeyStore
    extends KeyStore
    • Constructor Detail

      • LocalKeyStore

        public LocalKeyStore()
    • Method Detail

      • engineGetCertificateChain

        public Certificate[] engineGetCertificateChain​(String alias)
        Returns the certificate chain associated with the given alias.
        Specified by:
        engineGetCertificateChain in class KeyStore
        Parameters:
        alias - the alias name
        Returns:
        the certificate chain
      • engineGetCertificate

        public Certificate engineGetCertificate​(String alias)
        Description copied from class: KeyStore
        Returns the certificate associated with the given alias.
        Overrides:
        engineGetCertificate in class KeyStore
        Parameters:
        alias - the alias name
        Returns:
        the certificate, or null if the given alias does not exist or does not contain a certificate.
      • engineGetCreationDate

        public Date engineGetCreationDate​(String alias)
        Returns the creation date of the entry identified by the given alias.
        Specified by:
        engineGetCreationDate in class KeyStore
        Parameters:
        alias - the alias name
        Returns:
        the creation date of this entry, or null if the given alias does not exist
      • engineSetKeyEntry

        public void engineSetKeyEntry​(String alias,
                                      Key key,
                                      char[] password,
                                      Certificate[] chain)
                               throws KeyStoreException
        Assigns the given private key to the given alias

        The given java.security.PrivateKey key must be accompanied by a certificate chain certifying the corresponding public key.

        If the given alias already exists, the keystore information associated with it is overridden by the given key and certificate chain.

        Specified by:
        engineSetKeyEntry in class KeyStore
        Parameters:
        alias - the alias name
        key - the private key to be associated with the alias
        password - the password to protect the key
        chain - the certificate chain for the corresponding public key (only required if the given key is of type java.security.PrivateKey).
        Throws:
        KeyStoreException
      • engineSetCertificateEntry

        public void engineSetCertificateEntry​(String alias,
                                              Certificate cert)
        Assigns the given certificate to the given alias.

        If the given alias already exists in this keystore and identifies a trusted certificate entry, the certificate associated with it is overridden by the given certificate.

        Specified by:
        engineSetCertificateEntry in class KeyStore
        Parameters:
        alias - the alias name
        cert - the certificate
      • engineAliases

        public Enumeration<String> engineAliases()
        Lists all the alias names of this keystore.
        Specified by:
        engineAliases in class KeyStore
        Returns:
        enumeration of the alias names
      • engineContainsAlias

        public boolean engineContainsAlias​(String alias)
        Checks if the given alias exists in this keystore.
        Specified by:
        engineContainsAlias in class KeyStoreSpi
        Parameters:
        alias - the alias name
        Returns:
        true if the alias exists, false otherwise
      • engineSize

        public int engineSize()
        Retrieves the number of entries in this keystore.
        Specified by:
        engineSize in class KeyStore
        Returns:
        the number of entries in this keystore
      • engineIsKeyEntry

        public boolean engineIsKeyEntry​(String alias)
        Returns true if the entry identified by the given alias is a key entry, and false otherwise.
        Specified by:
        engineIsKeyEntry in class KeyStore
        Returns:
        true if the entry identified by the given alias is a key entry, false otherwise.
      • engineIsCertificateEntry

        public boolean engineIsCertificateEntry​(String alias)
        Returns true if the entry identified by the given alias is a trusted certificate entry, and false otherwise.
        Specified by:
        engineIsCertificateEntry in class KeyStore
        Returns:
        true if the entry identified by the given alias is a trusted certificate entry, false otherwise.
      • engineGetCertificateAlias

        public String engineGetCertificateAlias​(Certificate cert)
        Returns the (alias) name of the first keystore entry whose certificate matches the given certificate.
        Specified by:
        engineGetCertificateAlias in class KeyStore
        Parameters:
        cert - the certificate to match with.
        Returns:
        the (alias) name of the first entry with matching certificate, or null if no such entry exists in this keystore.
      • engineStore

        public void engineStore​(OutputStream stream,
                                char[] password)
                         throws IOException
        Stores this keystore to the given output stream, and protects its integrity with the given password.
        Specified by:
        engineStore in class KeyStore
        Parameters:
        stream - the output stream to which this keystore is written.
        password - the password (optional)
        Throws:
        IOException - if there was an I/O problem with data
      • engineLoad

        public void engineLoad​(InputStream stream,
                               char[] password)
                        throws IOException
        Loads the keystore from the given input stream.
        Specified by:
        engineLoad in class KeyStore
        Parameters:
        stream - the input stream from which the keystore is loaded
        password - the (optional) password
        Throws:
        IOException - if there is an I/O or format problem with the keystore data