APIdia Launch Partner
Top Description Fields Constructors Methods
sun.security.util

public Class KeyStoreDelegator

extends KeyStoreSpi
Class Inheritance
Known Direct Subclasses
sun.security.pkcs12.PKCS12KeyStore.DualFormatPKCS12, sun.security.provider.JavaKeyStore.DualFormatJKS
Imports
java.io.BufferedInputStream, .IOException, .InputStream, .OutputStream, java.security.*, java.security.cert.Certificate, .CertificateException, java.util.Date, .Enumeration, .Set

This class delegates to a primary or secondary keystore implementation.
Since
9

Field Summary

Modifier and TypeField and Description
private final boolean
private static final Debug
private KeyStoreSpi
private static final String
private final Class<? extends KeyStoreSpi>
private final String
private final Class<? extends KeyStoreSpi>
private final String
private String

Constructor Summary

AccessConstructor and Description
public
KeyStoreDelegator(String primaryType, Class<? extends KeyStoreSpi> primaryKeyStore, String secondaryType, Class<? extends KeyStoreSpi> secondaryKeyStore)

Method Summary

Modifier and TypeMethod and Description
public Enumeration<String>
engineAliases()

Implements abstract java.security.KeyStoreSpi.engineAliases.

Lists all the alias names of this keystore.

public boolean
engineContainsAlias(String alias)

Implements abstract java.security.KeyStoreSpi.engineContainsAlias.

Checks if the given alias exists in this keystore.

public void
engineDeleteEntry(String alias)

Implements abstract java.security.KeyStoreSpi.engineDeleteEntry.

Deletes the entry identified by the given alias from this keystore.

public boolean
engineEntryInstanceOf(String alias, Class<? extends KeyStore.Entry> entryClass)

Overrides java.security.KeyStoreSpi.engineEntryInstanceOf.

Determines if the keystore Entry for the specified alias is an instance or subclass of the specified entryClass.

public Set<KeyStore.Entry.Attribute>
engineGetAttributes(String alias)

Overrides java.security.KeyStoreSpi.engineGetAttributes.

Retrieves the attributes associated with the given alias.

public Certificate
engineGetCertificate(String alias)

Implements abstract java.security.KeyStoreSpi.engineGetCertificate.

Returns the certificate associated with the given alias.

public String
engineGetCertificateAlias(Certificate cert)

Implements abstract java.security.KeyStoreSpi.engineGetCertificateAlias.

Returns the (alias) name of the first keystore entry whose certificate matches the given certificate.

public Certificate[]
engineGetCertificateChain(String alias)

Implements abstract java.security.KeyStoreSpi.engineGetCertificateChain.

Returns the certificate chain associated with the given alias.

public Date
engineGetCreationDate(String alias)

Implements abstract java.security.KeyStoreSpi.engineGetCreationDate.

Returns the creation date of the entry identified by the given alias.

public KeyStore.Entry
engineGetEntry(String alias, KeyStore.ProtectionParameter protParam)

Overrides java.security.KeyStoreSpi.engineGetEntry.

Gets a KeyStore.Entry for the specified alias with the specified protection parameter.

public Key
engineGetKey(String alias, char[] password)

Implements abstract java.security.KeyStoreSpi.engineGetKey.

Returns the key associated with the given alias, using the given password to recover it.

public boolean
engineIsCertificateEntry(String alias)

Implements abstract java.security.KeyStoreSpi.engineIsCertificateEntry.

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.

public boolean
engineIsKeyEntry(String alias)

Implements abstract java.security.KeyStoreSpi.engineIsKeyEntry.

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.

public void
engineLoad(InputStream stream, char[] password)

Implements abstract java.security.KeyStoreSpi.engineLoad.

Loads the keystore from the given input stream.

public boolean
engineProbe(InputStream stream)

Overrides java.security.KeyStoreSpi.engineProbe.

Probe the first few bytes of the keystore data stream for a valid keystore encoding.

public void
engineSetCertificateEntry(String alias, Certificate cert)

Implements abstract java.security.KeyStoreSpi.engineSetCertificateEntry.

Assigns the given certificate to the given alias.

public void
engineSetEntry(String alias, KeyStore.Entry entry, KeyStore.ProtectionParameter protParam)

Overrides java.security.KeyStoreSpi.engineSetEntry.

Saves a KeyStore.Entry under the specified alias.

public void
engineSetKeyEntry(String alias, Key key, char[] password, Certificate[] chain)

Implements abstract java.security.KeyStoreSpi.engineSetKeyEntry.

Assigns the given key to the given alias, protecting it with the given password.

public void
engineSetKeyEntry(String alias, byte[] key, Certificate[] chain)

Implements abstract java.security.KeyStoreSpi.engineSetKeyEntry.

Assigns the given key (that has already been protected) to the given alias.

public int
engineSize()

Implements abstract java.security.KeyStoreSpi.engineSize.

Retrieves the number of entries in this keystore.

public void
engineStore(OutputStream stream, char[] password)

Implements abstract java.security.KeyStoreSpi.engineStore.

Stores this keystore to the given output stream, and protects its integrity with the given password.

Inherited from java.security.KeyStoreSpi:
engineGetCreationInstantengineLoadengineStore

Field Detail

compatModeEnabledback to summary
private final boolean compatModeEnabled
debugback to summary
private static final Debug debug
keystoreback to summary
private KeyStoreSpi keystore
KEYSTORE_TYPE_COMPATback to summary
private static final String KEYSTORE_TYPE_COMPAT
primaryKeyStoreback to summary
private final Class<? extends KeyStoreSpi> primaryKeyStore
primaryTypeback to summary
private final String primaryType
secondaryKeyStoreback to summary
private final Class<? extends KeyStoreSpi> secondaryKeyStore
secondaryTypeback to summary
private final String secondaryType
typeback to summary
private String type

Constructor Detail

KeyStoreDelegatorback to summary
public KeyStoreDelegator(String primaryType, Class<? extends KeyStoreSpi> primaryKeyStore, String secondaryType, Class<? extends KeyStoreSpi> secondaryKeyStore)

Method Detail

engineAliasesback to summary
public Enumeration<String> engineAliases()

Implements abstract java.security.KeyStoreSpi.engineAliases.

Doc from java.security.KeyStoreSpi.engineAliases.

Lists all the alias names of this keystore.

Annotations
@Override
engineContainsAliasback to summary
public boolean engineContainsAlias(String alias)

Implements abstract java.security.KeyStoreSpi.engineContainsAlias.

Doc from java.security.KeyStoreSpi.engineContainsAlias.

Checks if the given alias exists in this keystore.

Annotations
@Override
engineDeleteEntryback to summary
public void engineDeleteEntry(String alias) throws KeyStoreException

Implements abstract java.security.KeyStoreSpi.engineDeleteEntry.

Doc from java.security.KeyStoreSpi.engineDeleteEntry.

Deletes the entry identified by the given alias from this keystore.

Annotations
@Override
Exceptions
KeyStoreException:
if the entry cannot be removed.
engineEntryInstanceOfback to summary
public boolean engineEntryInstanceOf(String alias, Class<? extends KeyStore.Entry> entryClass)

Overrides java.security.KeyStoreSpi.engineEntryInstanceOf.

Doc from java.security.KeyStoreSpi.engineEntryInstanceOf.

Determines if the keystore Entry for the specified alias is an instance or subclass of the specified entryClass.

Annotations
@Override
engineGetAttributesback to summary
public Set<KeyStore.Entry.Attribute> engineGetAttributes(String alias)

Overrides java.security.KeyStoreSpi.engineGetAttributes.

Doc from java.security.KeyStoreSpi.engineGetAttributes.

Retrieves the attributes associated with the given alias.

Annotations
@Override
engineGetCertificateback to summary
public Certificate engineGetCertificate(String alias)

Implements abstract java.security.KeyStoreSpi.engineGetCertificate.

Doc from java.security.KeyStoreSpi.engineGetCertificate.

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.

Annotations
@Override
engineGetCertificateAliasback to summary
public String engineGetCertificateAlias(Certificate cert)

Implements abstract java.security.KeyStoreSpi.engineGetCertificateAlias.

Doc from java.security.KeyStoreSpi.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 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.

Annotations
@Override
engineGetCertificateChainback to summary
public Certificate[] engineGetCertificateChain(String alias)

Implements abstract java.security.KeyStoreSpi.engineGetCertificateChain.

Doc from java.security.KeyStoreSpi.engineGetCertificateChain.

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.

Annotations
@Override
engineGetCreationDateback to summary
public Date engineGetCreationDate(String alias)

Implements abstract java.security.KeyStoreSpi.engineGetCreationDate.

Doc from java.security.KeyStoreSpi.engineGetCreationDate.

Returns the creation date of the entry identified by the given alias.

Annotations
@Override
engineGetEntryback to summary
public KeyStore.Entry engineGetEntry(String alias, KeyStore.ProtectionParameter protParam) throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableEntryException

Overrides java.security.KeyStoreSpi.engineGetEntry.

Doc from java.security.KeyStoreSpi.engineGetEntry.

Gets a KeyStore.Entry for the specified alias with the specified protection parameter.

Annotations
@Override
Exceptions
KeyStoreException:
if the operation failed
NoSuchAlgorithmException:
if the algorithm for recovering the entry cannot be found
UnrecoverableEntryException:
if the specified protParam were insufficient or invalid
engineGetKeyback to summary
public Key engineGetKey(String alias, char[] password) throws NoSuchAlgorithmException, UnrecoverableKeyException

Implements abstract java.security.KeyStoreSpi.engineGetKey.

Doc from java.security.KeyStoreSpi.engineGetKey.

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.

Annotations
@Override
Exceptions
NoSuchAlgorithmException:
if the algorithm for recovering the key cannot be found
UnrecoverableKeyException:
if the key cannot be recovered (e.g., the given password is wrong).
engineIsCertificateEntryback to summary
public boolean engineIsCertificateEntry(String alias)

Implements abstract java.security.KeyStoreSpi.engineIsCertificateEntry.

Doc from java.security.KeyStoreSpi.engineIsCertificateEntry.

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.

Annotations
@Override
engineIsKeyEntryback to summary
public boolean engineIsKeyEntry(String alias)

Implements abstract java.security.KeyStoreSpi.engineIsKeyEntry.

Doc from java.security.KeyStoreSpi.engineIsKeyEntry.

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.

Annotations
@Override
engineLoadback to summary
public void engineLoad(InputStream stream, char[] password) throws IOException, NoSuchAlgorithmException, CertificateException

Implements abstract java.security.KeyStoreSpi.engineLoad.

Doc from java.security.KeyStoreSpi.engineLoad.

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.

Annotations
@Override
Exceptions
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 incorrect. If the error is due to a wrong password, the cause of the IOException should be an UnrecoverableKeyException
NoSuchAlgorithmException:
if the algorithm used to check the integrity of the keystore cannot be found
CertificateException:
if any of the certificates in the keystore could not be loaded
engineProbeback to summary
public boolean engineProbe(InputStream stream) throws IOException

Overrides java.security.KeyStoreSpi.engineProbe.

Probe the first few bytes of the keystore data stream for a valid keystore encoding. Only the primary keystore implementation is probed.

Annotations
@Override
Exceptions
IOException:

Doc from java.security.KeyStoreSpi.engineProbe.

if there is an I/O problem with the keystore data.

engineSetCertificateEntryback to summary
public void engineSetCertificateEntry(String alias, Certificate cert) throws KeyStoreException

Implements abstract java.security.KeyStoreSpi.engineSetCertificateEntry.

Doc from java.security.KeyStoreSpi.engineSetCertificateEntry.

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.

Annotations
@Override
Exceptions
KeyStoreException:
if the given alias already exists and does not identify an entry containing a trusted certificate, or this operation fails for some other reason.
engineSetEntryback to summary
public void engineSetEntry(String alias, KeyStore.Entry entry, KeyStore.ProtectionParameter protParam) throws KeyStoreException

Overrides java.security.KeyStoreSpi.engineSetEntry.

Doc from java.security.KeyStoreSpi.engineSetEntry.

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.

Annotations
@Override
Exceptions
KeyStoreException:
if this operation fails
engineSetKeyEntryback to summary
public void engineSetKeyEntry(String alias, Key key, char[] password, Certificate[] chain) throws KeyStoreException

Implements abstract java.security.KeyStoreSpi.engineSetKeyEntry.

Doc from java.security.KeyStoreSpi.engineSetKeyEntry.

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).

Annotations
@Override
Exceptions
KeyStoreException:
if the given key cannot be protected, or this operation fails for some other reason
engineSetKeyEntryback to summary
public void engineSetKeyEntry(String alias, byte[] key, Certificate[] chain) throws KeyStoreException

Implements abstract java.security.KeyStoreSpi.engineSetKeyEntry.

Doc from java.security.KeyStoreSpi.engineSetKeyEntry.

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).

Annotations
@Override
Exceptions
KeyStoreException:
if this operation fails.
engineSizeback to summary
public int engineSize()

Implements abstract java.security.KeyStoreSpi.engineSize.

Doc from java.security.KeyStoreSpi.engineSize.

Retrieves the number of entries in this keystore.

Annotations
@Override
engineStoreback to summary
public void engineStore(OutputStream stream, char[] password) throws IOException, NoSuchAlgorithmException, CertificateException

Implements abstract java.security.KeyStoreSpi.engineStore.

Doc from java.security.KeyStoreSpi.engineStore.

Stores this keystore to the given output stream, and protects its integrity with the given password.

Annotations
@Override
Exceptions
IOException:
if there was an I/O problem with data
NoSuchAlgorithmException:
if the appropriate data integrity algorithm could not be found
CertificateException:
if any of the certificates included in the keystore data could not be stored