Class LocalKeyStore


  • public final class LocalKeyStore
    extends KeyStore
    • Constructor Summary

      Constructors 
      Constructor Description
      LocalKeyStore()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Enumeration<java.lang.String> engineAliases()
      Lists all the alias names of this keystore.
      boolean engineContainsAlias​(java.lang.String alias)
      Checks if the given alias exists in this keystore.
      void engineDeleteEntry​(java.lang.String alias)
      Deletes the entry identified by the given alias from this keystore.
      java.security.cert.Certificate engineGetCertificate​(java.lang.String alias)
      Returns the certificate associated with the given alias.
      java.lang.String engineGetCertificateAlias​(java.security.cert.Certificate cert)
      Returns the (alias) name of the first keystore entry whose certificate matches the given certificate.
      java.security.cert.Certificate[] engineGetCertificateChain​(java.lang.String alias)
      Returns the certificate chain associated with the given alias.
      java.util.Date engineGetCreationDate​(java.lang.String alias)
      Returns the creation date of the entry identified by the given alias.
      java.security.Key engineGetKey​(java.lang.String alias, char[] password)
      Returns the key associated with the given alias, using the given password to recover it.
      boolean engineIsCertificateEntry​(java.lang.String alias)
      Returns true if the entry identified by the given alias is a trusted certificate entry, and false otherwise.
      boolean engineIsKeyEntry​(java.lang.String alias)
      Returns true if the entry identified by the given alias is a key entry, and false otherwise.
      void engineLoad​(java.io.InputStream stream, char[] password)
      Loads the keystore from the given input stream.
      void engineSetCertificateEntry​(java.lang.String alias, java.security.cert.Certificate cert)
      Assigns the given certificate to the given alias.
      void engineSetKeyEntry​(java.lang.String alias, java.security.Key key, char[] password, java.security.cert.Certificate[] chain)
      Assigns the given private key to the given alias
      int engineSize()
      Retrieves the number of entries in this keystore.
      void engineStore​(java.io.OutputStream stream, char[] password)
      Stores this keystore to the given output stream, and protects its integrity with the given password.
      • Methods inherited from class java.security.KeyStoreSpi

        engineEntryInstanceOf, engineGetEntry, engineLoad, engineProbe, engineSetEntry, engineStore
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LocalKeyStore

        public LocalKeyStore()
    • Method Detail

      • engineGetKey

        public java.security.Key engineGetKey​(java.lang.String alias,
                                              char[] password)
                                       throws java.security.NoSuchAlgorithmException,
                                              java.security.UnrecoverableKeyException
        Returns the key associated with the given alias, using the given password to recover it.
        Specified by:
        engineGetKey in class KeyStore
        Parameters:
        alias - the alias name
        password - : always null
        Returns:
        the requested key, or null if the given alias does not exist or does not identify a key entry.
        Throws:
        java.security.NoSuchAlgorithmException
        java.security.UnrecoverableKeyException
      • engineGetCertificateChain

        public java.security.cert.Certificate[] engineGetCertificateChain​(java.lang.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 java.security.cert.Certificate engineGetCertificate​(java.lang.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 java.util.Date engineGetCreationDate​(java.lang.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​(java.lang.String alias,
                                      java.security.Key key,
                                      char[] password,
                                      java.security.cert.Certificate[] chain)
                               throws java.security.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:
        java.security.KeyStoreException
      • engineSetCertificateEntry

        public void engineSetCertificateEntry​(java.lang.String alias,
                                              java.security.cert.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
      • engineDeleteEntry

        public void engineDeleteEntry​(java.lang.String alias)
                               throws java.security.KeyStoreException
        Deletes the entry identified by the given alias from this keystore.
        Specified by:
        engineDeleteEntry in class KeyStore
        Parameters:
        alias - the alias name
        Throws:
        java.security.KeyStoreException - if the entry cannot be removed.
      • engineAliases

        public java.util.Enumeration<java.lang.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​(java.lang.String alias)
        Checks if the given alias exists in this keystore.
        Specified by:
        engineContainsAlias in class java.security.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​(java.lang.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​(java.lang.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 java.lang.String engineGetCertificateAlias​(java.security.cert.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​(java.io.OutputStream stream,
                                char[] password)
                         throws java.io.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:
        java.io.IOException - if there was an I/O problem with data
      • engineLoad

        public void engineLoad​(java.io.InputStream stream,
                               char[] password)
                        throws java.io.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:
        java.io.IOException - if there is an I/O or format problem with the keystore data