Class HybridRACFKeyStore
This KeyStore makes use of the "JCERACFKS" and "JCECCARACFKS" keystore types to interact with the SAF security backend. It will allow a user to load a single SAF keyring as both a JCECCARACFKS and JCERACFKS keystore representation. When loaded the new JCEHYBRIDRACFKS will contain a mashup of the available key and certificate material from both the JCECCARACFKS and JCERACFKS keystore representations of the same SAF keyring.
Before this keystore can be accessed, it must be
loaded
similar to below:
KeyStore ks = KeyStore.getInstance("JCEHYBRIDRACFKS","IBMJCEHYBRID");
//Get input stream to a SAF keyring and load the keystore.
HybridRACFInputStream his = new HybridRACFInputStream(userid, keyring, passwordChars);
ks.load(his, passwordChars);
After the keystore has been
loaded
various keys and certificates will be available to the
caller. Available keys depend on what key material was
available in the SAF keyring at the time it was loaded. The
working state of ICSF may determine what types of key
material will
be available. Please see the IBM JCE Hybrid Provider
Reference Guide for more information.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionLists 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.engineGetCertificate(String alias) Returns the certificate associated with the given alias.Returns the (alias) name of the first keystore entry whose certificate matches the given certificate.engineGetCertificateChain(String alias) Returns the certificate chain associated with the given alias.engineGetCreationDate(String alias) Fetch the time at which the certificate object was created.engineGetKey(String alias, char[] password) Returns theHybridRACFPrivateKeyassociated with the given alias, using the given password to recover it.booleanengineIsCertificateEntry(String alias) Returns true if the entry identified by the given alias was created by a call tosetCertificateEntry.booleanengineIsKeyEntry(String alias) Returns true if the entry identified by the given alias was created by a call tosetKeyEntry.voidengineLoad(InputStream stream, char[] password) Loads this KeyStore from the givenHybridRACFOutputStreamstream.voidengineSetCertificateEntry(String alias, Certificate cert) Assigns the given trusted certificate to the given alias.voidengineSetKeyEntry(String alias, byte[] key, Certificate[] chain) This method is not supported by the JCEHYBRIDRACFKS keystore.voidengineSetKeyEntry(String alias, Key key, char[] password, Certificate[] chain) Assigns the given key to the given alias, protecting it with the given password.intRetrieves the number of entries in this keystore.voidengineStore(OutputStream stream, char[] password) Stores this keystore to the givenHybridRACFOutputStreamstream, and protects its integrity with the given password.Methods inherited from class java.security.KeyStoreSpi
engineEntryInstanceOf, engineGetAttributes, engineGetEntry, engineLoad, engineProbe, engineSetEntry, engineStore
-
Constructor Details
-
HybridRACFKeyStore
public HybridRACFKeyStore()Constructor
-
-
Method Details
-
engineGetKey
public Key engineGetKey(String alias, char[] password) throws NoSuchAlgorithmException, UnrecoverableKeyException Returns theHybridRACFPrivateKeyassociated with the given alias, using the given password to recover it. The key must have been associated with the alias by a call tosetKeyEntry.- Specified by:
engineGetKeyin classKeyStoreSpi- Parameters:
alias- the alias namepassword- the password for recovering the key- Returns:
- the requested
HybridRACFPrivateKeykey, or null if the given alias does not exist or does not identify a key-related entry. - Throws:
KeyStoreException- if the keystore has not been initialized (loaded).NoSuchAlgorithmException- if the algorithm for recovering the key cannot be foundUnrecoverableKeyException- if the key cannot be recovered (e.g., the given password is wrong).
-
engineGetCertificateChain
Returns the certificate chain associated with the given alias. The certificate chain must have been associated with the alias by a call tosetKeyEntry.- Specified by:
engineGetCertificateChainin classKeyStoreSpi- Parameters:
alias- the alias name- Returns:
- the 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
- Throws:
KeyStoreException- if the keystore has not been initialized (loaded).
-
engineGetCertificate
Returns the certificate associated with the given alias.If the given alias name identifies an entry created by a call to
setCertificateEntrythen the trusted certificate contained in that entry is returned.If the given alias name identifies an entry created by a call to
setKeyEntrythen the first element of the certificate chain in that entry is returned.- Specified by:
engineGetCertificatein classKeyStoreSpi- Parameters:
alias- the alias name- Returns:
- the certificate, or null if the given alias does not exist or does not contain a certificate.
- Throws:
KeyStoreException- if the keystore has not been initialized (loaded).
-
engineGetCreationDate
Fetch the time at which the certificate object was created.- Specified by:
engineGetCreationDatein classKeyStoreSpi- Parameters:
alias- the alias name- Returns:
- null if the alias is null, and empty sting, or not found in the underlying keystore. Return the date at which the certificate object was created.
- Throws:
KeyStoreException- if the keystore has not been initialized (loaded).
-
engineSetKeyEntry
public void engineSetKeyEntry(String alias, Key key, char[] password, Certificate[] chain) throws KeyStoreException 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).
If the key being inserted is derived from the IBMJCECCA provider and is a ECPrivateHWKey or RSAPrivateHWKey, it will be placed into the underlying JCECCARACFKS keystore along with inserting it into the local keystore cache.
If the key being inserted is derived from the IBMZSecurity provider and is an ECPrivateKey, RSAPrivateKey or RSAPrivateCrtKey it will be placed into the underlying JCERACFKS keystore along with inserting it into the local keystore cache.
- Specified by:
engineSetKeyEntryin classKeyStoreSpi- Parameters:
alias- the alias namekey- the 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- if the keystore has not been initialized (loaded), the given key cannot be protected, or this operation fails for some other reason
-
engineSetKeyEntry
public void engineSetKeyEntry(String alias, byte[] key, Certificate[] chain) throws KeyStoreException This method is not supported by the JCEHYBRIDRACFKS keystore. A KeyStoreException will always be thrown.- Specified by:
engineSetKeyEntryin classKeyStoreSpi- Parameters:
alias- the alias namekey- the key to be associated with the aliaschain- the certificate chain for the corresponding to the key.- Throws:
KeyStoreException- will always be thrown.
-
engineSetCertificateEntry
Assigns the given trusted certificate to the given alias.If the given alias identifies an existing entry created by a call to
setCertificateEntrythe trusted certificate in the existing entry is overridden by the given certificate.- Specified by:
engineSetCertificateEntryin classKeyStoreSpi- Parameters:
alias- the alias namecert- the certificate- Throws:
KeyStoreException- if the keystore has not been initialized, or the given alias already exists and does not identify an entry containing a trusted certificate, or this operation fails for some other reason.
-
engineDeleteEntry
Deletes the entry identified by the given alias from this keystore.- Specified by:
engineDeleteEntryin classKeyStoreSpi- Parameters:
alias- the alias name- Throws:
KeyStoreException- if the keystore has not been initialized, or if the entry cannot be removed.
-
engineAliases
Lists all the alias names of this keystore.- Specified by:
engineAliasesin classKeyStoreSpi- Returns:
- enumeration of the alias names
- Throws:
KeyStoreException- if the keystore has not been initialized (loaded).
-
engineContainsAlias
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
- Throws:
KeyStoreException- if the keystore has not been initialized (loaded).
-
engineSize
public int engineSize()Retrieves the number of entries in this keystore.- Specified by:
engineSizein classKeyStoreSpi- Returns:
- the number of entries in this keystore
- Throws:
KeyStoreException- if the keystore has not been initialized (loaded).
-
engineIsKeyEntry
Returns true if the entry identified by the given alias was created by a call tosetKeyEntry.- Specified by:
engineIsKeyEntryin classKeyStoreSpi- Parameters:
alias- the alias for the keystore entry to be checked- Returns:
- true if the entry identified by the given alias is a key-related entry, false otherwise.
- Throws:
KeyStoreException- if the keystore has not been initialized (loaded).IllegalArgumentException- if the alias name is null.
-
engineIsCertificateEntry
Returns true if the entry identified by the given alias was created by a call tosetCertificateEntry.- Specified by:
engineIsCertificateEntryin classKeyStoreSpi- Parameters:
alias- the alias for the keystore entry to be checked- Returns:
- true if the entry identified by the given alias contains a trusted certificate, false otherwise.
- Throws:
KeyStoreException- if the keystore has not been initialized (loaded).
-
engineGetCertificateAlias
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
setCertificateEntrythen the given certificate is compared to that entry's certificate.If the entry being considered was created by a call to
setKeyEntrythen the given certificate is compared to the first element of that entry's certificate chain.- Specified by:
engineGetCertificateAliasin classKeyStoreSpi- Parameters:
cert- the certificate to match with.- Returns:
- the alias name of the first entry with a matching certificate, or null if no such entry exists in this keystore.
- Throws:
KeyStoreException- if the keystore has not been initialized (loaded).
-
engineStore
public void engineStore(OutputStream stream, char[] password) throws IOException, NoSuchAlgorithmException, CertificateException Stores this keystore to the givenHybridRACFOutputStreamstream, and protects its integrity with the given password.- Specified by:
engineStorein classKeyStoreSpi- Parameters:
stream- the output stream to which this keystore is written.password- the password to generate the keystore integrity check- Throws:
KeyStoreException- if the keystore has not been initialized (loaded).IOException- if there was an I/O problem with dataNoSuchAlgorithmException- if the appropriate data integrity algorithm could not be foundCertificateException- if any of the certificates included in the keystore data could not be stored
-
engineLoad
public void engineLoad(InputStream stream, char[] password) throws IOException, NoSuchAlgorithmException, CertificateException Loads this KeyStore from the givenHybridRACFOutputStreamstream.In order to create an empty keystore, or if the keystore cannot be initialized from a stream, pass
nullas thestreamargument.Note that if this keystore has already been loaded, it is reinitialized and loaded again from the given input stream.
- Specified by:
engineLoadin classKeyStoreSpi- Parameters:
stream- theHybridRACFOutputStreamstream from which the keystore is loaded, ornullpassword- the password used to check the integrity of the keystore, the password used to unlock the keystore, ornull- Throws:
IOException- 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 incorrectNoSuchAlgorithmException- if the algorithm used to check the integrity of the keystore cannot be foundCertificateException- if any of the certificates in the keystore could not be loaded
-