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.booleanengineContainsAlias(String alias)Checks if the given alias exists in this keystore.voidengineDeleteEntry(String alias)Deletes the entry identified by the given alias from this keystore.CertificateengineGetCertificate(String alias)Returns the certificate associated with the given alias.StringengineGetCertificateAlias(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.DateengineGetCreationDate(String alias)Returns the creation date of the entry identified by the given alias.KeyengineGetKey(String alias, char[] password)Returns the key associated with the given alias, using the given password to recover it.booleanengineIsCertificateEntry(String alias)Returns true if the entry identified by the given alias is a trusted certificate entry, and false otherwise.booleanengineIsKeyEntry(String alias)Returns true if the entry identified by the given alias is a key entry, and false otherwise.voidengineLoad(InputStream stream, char[] password)Loads the keystore from the given input stream.voidengineSetCertificateEntry(String alias, Certificate cert)Assigns the given certificate to the given alias.voidengineSetKeyEntry(String alias, Key key, char[] password, Certificate[] chain)Assigns the given private key to the given aliasintengineSize()Retrieves the number of entries in this keystore.voidengineStore(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:
engineGetKeyin 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:
NoSuchAlgorithmExceptionUnrecoverableKeyException
-
engineGetCertificateChain
public Certificate[] engineGetCertificateChain(String alias)
Returns the certificate chain associated with the given alias.- Specified by:
engineGetCertificateChainin classKeyStore- Parameters:
alias- the alias name- Returns:
- the certificate chain
-
engineGetCertificate
public Certificate engineGetCertificate(String alias)
Description copied from class:KeyStoreReturns the certificate associated with the given alias.- Overrides:
engineGetCertificatein 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:
engineGetCreationDatein 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
keymust 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:
engineSetKeyEntryin 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:
engineSetCertificateEntryin 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:
engineDeleteEntryin 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:
engineAliasesin classKeyStore- Returns:
- enumeration of the alias names
-
engineContainsAlias
public boolean engineContainsAlias(String alias)
Checks if the given alias exists in this keystore.- Specified by:
engineContainsAliasin 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:
engineSizein 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:
engineIsKeyEntryin 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:
engineIsCertificateEntryin 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:
engineGetCertificateAliasin 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:
engineStorein 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:
engineLoadin 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
-
-