Class BcKeyStoreSpi
java.lang.Object
java.security.KeyStoreSpi
org.bouncycastle.jcajce.provider.keystore.bc.BcKeyStoreSpi
- All Implemented Interfaces:
BCKeyStore
- Direct Known Subclasses:
BcKeyStoreSpi.BouncyCastleStore,BcKeyStoreSpi.Std,BcKeyStoreSpi.Version1
public class BcKeyStoreSpi extends KeyStoreSpi implements BCKeyStore
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBcKeyStoreSpi.BouncyCastleStorethe BouncyCastle store.static classBcKeyStoreSpi.Stdstatic classBcKeyStoreSpi.Version1 -
Field Summary
Fields Modifier and Type Field Description protected SecureRandomrandomprotected Hashtabletableprotected intversion -
Constructor Summary
Constructors Constructor Description BcKeyStoreSpi(int version) -
Method Summary
Modifier and Type Method Description EnumerationengineAliases()Returns anEnumerationover all alias names stored in thisKeyStoreSpi.booleanengineContainsAlias(String alias)Indicates whether the given alias is present in thisKeyStoreSpi.voidengineDeleteEntry(String alias)Deletes the entry identified with the given alias from thisKeyStoreSpi.CertificateengineGetCertificate(String alias)Returns the trusted certificate for the entry with the given alias.StringengineGetCertificateAlias(Certificate cert)Returns the alias associated with the first entry whose certificate matches the specified certificate.Certificate[]engineGetCertificateChain(String alias)Returns the certificate chain for the entry with the given alias.DateengineGetCreationDate(String alias)Returns the creation date of the entry with the given alias.KeyengineGetKey(String alias, char[] password)Returns the key with the given alias, using the password to recover the key from the store.booleanengineIsCertificateEntry(String alias)Indicates whether the specified alias is associated with aKeyStore.TrustedCertificateEntry.booleanengineIsKeyEntry(String alias)Indicates whether the specified alias is associated with either aKeyStore.PrivateKeyEntryor aKeyStore.SecretKeyEntry.voidengineLoad(InputStream stream, char[] password)Loads thisKeyStoreSpifrom the givenInputStream.voidengineSetCertificateEntry(String alias, Certificate cert)Associates the given alias with a certificate.voidengineSetKeyEntry(String alias, byte[] key, Certificate[] chain)Associates the given alias with a key and a certificate chain.voidengineSetKeyEntry(String alias, Key key, char[] password, Certificate[] chain)Associates the given alias with the key, password and certificate chain.intengineSize()Returns the number of entries stored in thisKeyStoreSpi.voidengineStore(OutputStream stream, char[] password)Writes thisKeyStoreSpito the specifiedOutputStream.protected voidloadStore(InputStream in)protected CiphermakePBECipher(String algorithm, int mode, char[] password, byte[] salt, int iterationCount)protected voidsaveStore(OutputStream out)voidsetRandom(SecureRandom rand)set the random source for the key storeMethods inherited from class java.security.KeyStoreSpi
engineEntryInstanceOf, engineGetEntry, engineLoad, engineSetEntry, engineStore
-
Field Details
-
table
-
random
-
version
protected int version
-
-
Constructor Details
-
BcKeyStoreSpi
public BcKeyStoreSpi(int version)
-
-
Method Details
-
makePBECipher
protected Cipher makePBECipher(String algorithm, int mode, char[] password, byte[] salt, int iterationCount) throws IOException- Throws:
IOException
-
setRandom
Description copied from interface:BCKeyStoreset the random source for the key store- Specified by:
setRandomin interfaceBCKeyStore
-
engineAliases
Description copied from class:KeyStoreSpiReturns anEnumerationover all alias names stored in thisKeyStoreSpi.- Specified by:
engineAliasesin classKeyStoreSpi- Returns:
- an
Enumerationover all alias names stored in thisKeyStoreSpi.
-
engineContainsAlias
Description copied from class:KeyStoreSpiIndicates whether the given alias is present in thisKeyStoreSpi.- Specified by:
engineContainsAliasin classKeyStoreSpi- Parameters:
alias- the alias of an entry.- Returns:
trueif the alias exists,falseotherwise.
-
engineDeleteEntry
Description copied from class:KeyStoreSpiDeletes the entry identified with the given alias from thisKeyStoreSpi.- Specified by:
engineDeleteEntryin classKeyStoreSpi- Parameters:
alias- the alias for the entry.- Throws:
KeyStoreException- if the entry can not be deleted.
-
engineGetCertificate
Description copied from class:KeyStoreSpiReturns the trusted certificate for the entry with the given alias.- Specified by:
engineGetCertificatein classKeyStoreSpi- Parameters:
alias- the alias for the entry.- Returns:
- the trusted certificate for the entry with the given alias, or
nullif the specified alias is not bound to an entry.
-
engineGetCertificateAlias
Description copied from class:KeyStoreSpiReturns the alias associated with the first entry whose certificate matches the specified certificate.- Specified by:
engineGetCertificateAliasin classKeyStoreSpi- Parameters:
cert- the certificate to find the associated entry's alias for.- Returns:
- the alias or
nullif no entry with the specified certificate can be found.
-
engineGetCertificateChain
Description copied from class:KeyStoreSpiReturns the certificate chain for the entry with the given alias.- Specified by:
engineGetCertificateChainin classKeyStoreSpi- Parameters:
alias- the alias for the entry- Returns:
- the certificate chain for the entry with the given alias, or
nullif the specified alias is not bound to an entry.
-
engineGetCreationDate
Description copied from class:KeyStoreSpiReturns the creation date of the entry with the given alias.- Specified by:
engineGetCreationDatein classKeyStoreSpi- Parameters:
alias- the alias for the entry.- Returns:
- the creation date, or
nullif the specified alias is not bound to an entry.
-
engineGetKey
public Key engineGetKey(String alias, char[] password) throws NoSuchAlgorithmException, UnrecoverableKeyExceptionDescription copied from class:KeyStoreSpiReturns the key with the given alias, using the password to recover the key from the store.- Specified by:
engineGetKeyin classKeyStoreSpi- Parameters:
alias- the alias for the entry.password- the password used to recover the key.- Returns:
- the key with the specified alias, or
nullif the specified alias is not bound to an entry. - Throws:
NoSuchAlgorithmException- if the algorithm for recovering the key is not available.UnrecoverableKeyException- if the key can not be recovered.
-
engineIsCertificateEntry
Description copied from class:KeyStoreSpiIndicates whether the specified alias is associated with aKeyStore.TrustedCertificateEntry.- Specified by:
engineIsCertificateEntryin classKeyStoreSpi- Parameters:
alias- the alias of an entry.- Returns:
trueif the given alias is associated with a certificate entry.
-
engineIsKeyEntry
Description copied from class:KeyStoreSpiIndicates whether the specified alias is associated with either aKeyStore.PrivateKeyEntryor aKeyStore.SecretKeyEntry.- Specified by:
engineIsKeyEntryin classKeyStoreSpi- Parameters:
alias- the alias of an entry.- Returns:
trueif the given alias is associated with a key entry.
-
engineSetCertificateEntry
Description copied from class:KeyStoreSpiAssociates the given alias with a certificate.If the specified alias already exists, it will be reassigned.
- Specified by:
engineSetCertificateEntryin classKeyStoreSpi- Parameters:
alias- the alias for the certificate.cert- the certificate.- Throws:
KeyStoreException- if an existing alias is not associated to an entry containing a trusted certificate, or this method fails for any other reason.
-
engineSetKeyEntry
public void engineSetKeyEntry(String alias, byte[] key, Certificate[] chain) throws KeyStoreExceptionDescription copied from class:KeyStoreSpiAssociates the given alias with a key and a certificate chain.If the specified alias already exists, it will be reassigned.
- Specified by:
engineSetKeyEntryin classKeyStoreSpi- Parameters:
alias- the alias for the key.key- the key in an encoded format.chain- the certificate chain.- Throws:
KeyStoreException- if this operation fails.
-
engineSetKeyEntry
public void engineSetKeyEntry(String alias, Key key, char[] password, Certificate[] chain) throws KeyStoreExceptionDescription copied from class:KeyStoreSpiAssociates the given alias with the key, password and certificate chain.If the specified alias already exists, it will be reassigned.
- Specified by:
engineSetKeyEntryin classKeyStoreSpi- Parameters:
alias- the alias for the key.key- the key.password- the password.chain- the certificate chain.- Throws:
KeyStoreException- if the specified key can not be protected, or if this operation fails for another reason.
-
engineSize
public int engineSize()Description copied from class:KeyStoreSpiReturns the number of entries stored in thisKeyStoreSpi.- Specified by:
engineSizein classKeyStoreSpi- Returns:
- the number of entries stored in this
KeyStoreSpi.
-
loadStore
- Throws:
IOException
-
saveStore
- Throws:
IOException
-
engineLoad
Description copied from class:KeyStoreSpiLoads thisKeyStoreSpifrom the givenInputStream. Utilizes the given password to verify the stored data.- Specified by:
engineLoadin classKeyStoreSpi- Parameters:
stream- theInputStreamto load thisKeyStoreSpi's data from.password- the password to verify the stored data, maybenull.- Throws:
IOException- if a problem occurred while reading from the stream.
-
engineStore
Description copied from class:KeyStoreSpiWrites thisKeyStoreSpito the specifiedOutputStream. The data written to theOutputStreamis protected by the specified password.- Specified by:
engineStorein classKeyStoreSpi- Parameters:
stream- theOutputStreamto write the store's data to.password- the password to protect the data.- Throws:
IOException- if a problem occurred while writing to the stream.
-