public abstract class java.security
KeyStoreSpi


Show All Login
Java SE 6
  
Details
This class defines the Service Provider Interface (SPI) for the KeyStore class. All the abstract methods in this class must be implemented by each cryptographic service provider who wishes to supply the implementation of a keystore for a particular keystore type.
version1.22, 04/07/06
since1.2
See also java.security.KeyStore

Constructors
public KeyStoreSpi()

Methods
abstract public Enumeration engineAliases() Details
Lists all the alias names of this keystore.
returnenumeration of the alias names
abstract public boolean engineContainsAlias(String alias) Details
Checks if the given alias exists in this keystore.
aliasthe alias name
returntrue if the alias exists, false otherwise
abstract public void engineDeleteEntry(String alias) throws KeyStoreException Details
Deletes the entry identified by the given alias from this keystore.
aliasthe alias name
ThrowsKeyStoreException: if the entry cannot be removed.
public boolean engineEntryInstanceOf(String alias, Class entryClass) Details
Determines if the keystore Entry for the specified alias is an instance or subclass of the specified entryClass.
aliasthe alias name
entryClassthe entry class
returntrue if the keystore Entry for the specified alias is an instance or subclass of the specified entryClass, false otherwise
since1.5
abstract public Certificate engineGetCertificate(String alias) Details
Returns the certificate associated with the given alias.

If the given alias name identifies an entry created by a call to setCertificateEntry, or created by a call to setEntry with a TrustedCertificateEntry, then the trusted certificate contained in that entry is returned.

If the given alias name identifies an entry created by a call to setKeyEntry, or created by a call to setEntry with a PrivateKeyEntry, then the first element of the certificate chain in that entry (if a chain exists) is returned.
aliasthe alias name
returnthe certificate, or null if the given alias does not exist or does not contain a certificate.

abstract public String engineGetCertificateAlias(Certificate cert) Details
Returns the (alias) name of the first keystore entry whose certificate matches the given certificate.

This method attempts to match the given certificate with each keystore entry. If the entry being considered was created by a call to setCertificateEntry, or created by a call to setEntry with a TrustedCertificateEntry, then the given certificate is compared to that entry's certificate.

If the entry being considered was created by a call to setKeyEntry, or created by a call to setEntry with a PrivateKeyEntry, then the given certificate is compared to the first element of that entry's certificate chain.
certthe certificate to match with.
returnthe alias name of the first entry with matching certificate, or null if no such entry exists in this keystore.

abstract public Certificate[] engineGetCertificateChain(String alias) Details
Returns the certificate chain associated with the given alias. The certificate chain must have been associated with the alias by a call to setKeyEntry, or by a call to setEntry with a PrivateKeyEntry.
aliasthe alias name
returnthe certificate chain (ordered with the user's certificate first and the root certificate authority last), or null if the given alias does not exist or does not contain a certificate chain
abstract public Date engineGetCreationDate(String alias) Details
Returns the creation date of the entry identified by the given alias.
aliasthe alias name
returnthe creation date of this entry, or null if the given alias does not exist
public KeyStore.Entry engineGetEntry(String alias, KeyStore.ProtectionParameter protParam) throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableEntryException Details
Gets a KeyStore.Entry for the specified alias with the specified protection parameter.
aliasget the KeyStore.Entry for this alias
protParamthe ProtectionParameter used to protect the Entry, which may be null
returnthe KeyStore.Entry for the specified alias, or null if there is no such entry
ThrowsKeyStoreException: if the operation failed
ThrowsNoSuchAlgorithmException: if the algorithm for recovering the entry cannot be found
ThrowsUnrecoverableEntryException: if the specified protParam were insufficient or invalid
ThrowsUnrecoverableKeyException: if the entry is a PrivateKeyEntry or SecretKeyEntry and the specified protParam does not contain the information needed to recover the key (e.g. wrong password)
since1.5
abstract public Key engineGetKey(String alias, char[] password) throws NoSuchAlgorithmException, UnrecoverableKeyException Details
Returns the key associated with the given alias, using the given password to recover it. The key must have been associated with the alias by a call to setKeyEntry, or by a call to setEntry with a PrivateKeyEntry or SecretKeyEntry.
aliasthe alias name
passwordthe password for recovering the key
returnthe requested key, or null if the given alias does not exist or does not identify a key-related entry.
ThrowsNoSuchAlgorithmException: if the algorithm for recovering the key cannot be found
ThrowsUnrecoverableKeyException: if the key cannot be recovered (e.g., the given password is wrong).
abstract public boolean engineIsCertificateEntry(String alias) Details
Returns true if the entry identified by the given alias was created by a call to setCertificateEntry, or created by a call to setEntry with a TrustedCertificateEntry.
aliasthe alias for the keystore entry to be checked
returntrue if the entry identified by the given alias contains a trusted certificate, false otherwise.
abstract public boolean engineIsKeyEntry(String alias) Details
Returns true if the entry identified by the given alias was created by a call to setKeyEntry, or created by a call to setEntry with a PrivateKeyEntry or a SecretKeyEntry.
aliasthe alias for the keystore entry to be checked
returntrue if the entry identified by the given alias is a key-related, false otherwise.
abstract public void engineLoad(InputStream stream, char[] password) throws IOException, NoSuchAlgorithmException, CertificateException Details
Loads the keystore from the given input stream.

A password may be given to unlock the keystore (e.g. the keystore resides on a hardware token device), or to check the integrity of the keystore data. If a password is not given for integrity checking, then integrity checking is not performed.
streamthe input stream from which the keystore is loaded, or null
passwordthe password used to check the integrity of the keystore, the password used to unlock the keystore, or null
ThrowsIOException: if there is an I/O or format problem with the keystore data, if a password is required but not given, or if the given password was incorrect. If the error is due to a wrong password, the cause of the IOException should be an UnrecoverableKeyException
ThrowsNoSuchAlgorithmException: if the algorithm used to check the integrity of the keystore cannot be found
ThrowsCertificateException: if any of the certificates in the keystore could not be loaded

public void engineLoad(KeyStore.LoadStoreParameter param) throws IOException, NoSuchAlgorithmException, CertificateException Details
Loads the keystore using the given KeyStore.LoadStoreParameter.

Note that if this KeyStore has already been loaded, it is reinitialized and loaded again from the given parameter.
paramthe KeyStore.LoadStoreParameter that specifies how to load the keystore, which may be null
ThrowsIllegalArgumentException: if the given KeyStore.LoadStoreParameter input is not recognized
ThrowsIOException: if there is an I/O or format problem with the keystore data. If the error is due to an incorrect ProtectionParameter (e.g. wrong password) the cause of the IOException should be an UnrecoverableKeyException
ThrowsNoSuchAlgorithmException: if the algorithm used to check the integrity of the keystore cannot be found
ThrowsCertificateException: if any of the certificates in the keystore could not be loaded
since1.5

abstract public void engineSetCertificateEntry(String alias, Certificate cert) throws KeyStoreException Details
Assigns the given certificate to the given alias.

If the given alias identifies an existing entry created by a call to setCertificateEntry, or created by a call to setEntry with a TrustedCertificateEntry, the trusted certificate in the existing entry is overridden by the given certificate.
aliasthe alias name
certthe certificate
ThrowsKeyStoreException: if the given alias already exists and does not identify an entry containing a trusted certificate, or this operation fails for some other reason.

public void engineSetEntry(String alias, KeyStore.Entry entry, KeyStore.ProtectionParameter protParam) throws KeyStoreException Details
Saves a KeyStore.Entry under the specified alias. The specified protection parameter is used to protect the Entry.

If an entry already exists for the specified alias, it is overridden.
aliassave the KeyStore.Entry under this alias
entrythe Entry to save
protParamthe ProtectionParameter used to protect the Entry, which may be null
ThrowsKeyStoreException: if this operation fails
since1.5

abstract public void engineSetKeyEntry(String alias, Key key, char[] password, Certificate[] chain) throws KeyStoreException Details
Assigns the given key to the given alias, protecting it with the given password.

If the given key is of type java.security.PrivateKey, it 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 possibly certificate chain).
aliasthe alias name
keythe key to be associated with the alias
passwordthe password to protect the key
chainthe certificate chain for the corresponding public key (only required if the given key is of type java.security.PrivateKey).
ThrowsKeyStoreException: if the given key cannot be protected, or this operation fails for some other reason

abstract public void engineSetKeyEntry(String alias, byte[] key, Certificate[] chain) throws KeyStoreException Details
Assigns the given key (that has already been protected) to the given alias.

If the protected key is of type java.security.PrivateKey, it 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 possibly certificate chain).
aliasthe alias name
keythe key (in protected format) to be associated with the alias
chainthe certificate chain for the corresponding public key (only useful if the protected key is of type java.security.PrivateKey).
ThrowsKeyStoreException: if this operation fails.

abstract public int engineSize() Details
Retrieves the number of entries in this keystore.
returnthe number of entries in this keystore
abstract public void engineStore(OutputStream stream, char[] password) throws IOException, NoSuchAlgorithmException, CertificateException Details
Stores this keystore to the given output stream, and protects its integrity with the given password.
streamthe output stream to which this keystore is written.
passwordthe password to generate the keystore integrity check
ThrowsIOException: if there was an I/O problem with data
ThrowsNoSuchAlgorithmException: if the appropriate data integrity algorithm could not be found
ThrowsCertificateException: if any of the certificates included in the keystore data could not be stored
public void engineStore(KeyStore.LoadStoreParameter param) throws IOException, NoSuchAlgorithmException, CertificateException Details
Stores this keystore using the given KeyStore.LoadStoreParmeter.
paramthe KeyStore.LoadStoreParmeter that specifies how to store the keystore, which may be null
ThrowsIllegalArgumentException: if the given KeyStore.LoadStoreParmeter input is not recognized
ThrowsIOException: if there was an I/O problem with data
ThrowsNoSuchAlgorithmException: if the appropriate data integrity algorithm could not be found
ThrowsCertificateException: if any of the certificates included in the keystore data could not be stored
since1.5