Package com.fortanix.sdkms.jce.provider
Class LocalKeyStore
- java.lang.Object
-
- java.security.KeyStoreSpi
-
- com.fortanix.sdkms.jce.provider.KeyStore
-
- com.fortanix.sdkms.jce.provider.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 Enumeration<String>
engineAliases()
Lists all the alias names of this keystore.boolean
engineContainsAlias(String alias)
Checks if the given alias exists in this keystore.void
engineDeleteEntry(String alias)
Deletes the entry identified by the given alias from this keystore.Certificate
engineGetCertificate(String alias)
Returns the certificate associated with the given alias.String
engineGetCertificateAlias(Certificate cert)
Returns the (alias) name of the first keystore entry whose certificate matches the given certificate.Certificate[]
engineGetCertificateChain(String alias)
Returns the certificate chain associated with the given alias.Date
engineGetCreationDate(String alias)
Returns the creation date of the entry identified by the given alias.Key
engineGetKey(String alias, char[] password)
Returns the key associated with the given alias, using the given password to recover it.boolean
engineIsCertificateEntry(String alias)
Returns true if the entry identified by the given alias is a trusted certificate entry, and false otherwise.boolean
engineIsKeyEntry(String alias)
Returns true if the entry identified by the given alias is a key entry, and false otherwise.void
engineLoad(InputStream stream, char[] password)
Loads the keystore from the given input stream.void
engineSetCertificateEntry(String alias, Certificate cert)
Assigns the given certificate to the given alias.void
engineSetKeyEntry(String alias, Key key, char[] password, Certificate[] chain)
Assigns the given private key to the given aliasint
engineSize()
Retrieves the number of entries in this keystore.void
engineStore(OutputStream stream, char[] password)
Stores this keystore to the given output stream, and protects its integrity with the given password.-
Methods inherited from class com.fortanix.sdkms.jce.provider.KeyStore
engineSetKeyEntry, setCertificateEntry
-
Methods inherited from class java.security.KeyStoreSpi
engineEntryInstanceOf, engineGetEntry, engineLoad, engineProbe, engineSetEntry, engineStore
-
-
-
-
Method Detail
-
engineGetKey
public Key engineGetKey(String alias, char[] password) throws NoSuchAlgorithmException, UnrecoverableKeyException
Returns the key associated with the given alias, using the given password to recover it.- Specified by:
engineGetKey
in classKeyStore
- Parameters:
alias
- the alias namepassword
- : always null- Returns:
- the requested key, or null if the given alias does not exist or does not identify a key entry.
- Throws:
NoSuchAlgorithmException
UnrecoverableKeyException
-
engineGetCertificateChain
public Certificate[] engineGetCertificateChain(String alias)
Returns the certificate chain associated with the given alias.- Specified by:
engineGetCertificateChain
in classKeyStore
- 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 classKeyStore
- 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 classKeyStore
- 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 aliasThe 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 classKeyStore
- Parameters:
alias
- the alias namekey
- the private key to be associated with the aliaspassword
- the password to protect the keychain
- the certificate chain for the corresponding public key (only required if the given key is of typejava.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 classKeyStore
- Parameters:
alias
- the alias namecert
- the certificate
-
engineDeleteEntry
public void engineDeleteEntry(String alias) throws KeyStoreException
Deletes the entry identified by the given alias from this keystore.- Specified by:
engineDeleteEntry
in classKeyStore
- Parameters:
alias
- the alias name- Throws:
KeyStoreException
- if the entry cannot be removed.
-
engineAliases
public Enumeration<String> engineAliases()
Lists all the alias names of this keystore.- Specified by:
engineAliases
in classKeyStore
- 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 classKeyStoreSpi
- 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 classKeyStore
- 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 classKeyStore
- 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 classKeyStore
- 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 classKeyStore
- 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 classKeyStore
- 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 classKeyStore
- Parameters:
stream
- the input stream from which the keystore is loadedpassword
- the (optional) password- Throws:
IOException
- if there is an I/O or format problem with the keystore data
-
-