|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.security.KeyStoreSpi
com.ibm.crypto.pkcs11impl.provider.PKCS11KeyStore
public final class PKCS11KeyStore
This class provides the keystore implementation of PKCS #11.
KeyStoreSpi
Constructor Summary | |
---|---|
PKCS11KeyStore()
Creates an instance of this class |
|
PKCS11KeyStore(java.security.Provider provider)
Creates an instance of this class |
Method Summary | |
---|---|
java.util.Enumeration |
engineAliases()
Lists all the alias names of this keystore. |
boolean |
engineContainsAlias(java.lang.String alias)
Checks if the given alias exists in this keystore. |
void |
engineDeleteEntry(java.lang.String alias)
Deletes the entry identified by the given alias from this keystore and the token. |
java.security.cert.Certificate |
engineGetCertificate(java.lang.String alias)
Returns the certificate associated with the given alias. |
java.lang.String |
engineGetCertificateAlias(java.security.cert.Certificate cert)
Returns the (alias) name of the first keystore entry whose certificate matches the given certificate. |
java.security.cert.Certificate[] |
engineGetCertificateChain(java.lang.String alias)
Returns the certificate chain associated with the given alias. |
java.util.Date |
engineGetCreationDate(java.lang.String alias)
This method is suppose to return the creation date of the entry identified by the given alias. |
java.security.KeyStore.Entry |
engineGetEntry(java.lang.String alias,
java.security.KeyStore.ProtectionParameter protParam)
Get a KeyStore.Entry for the specified alias |
java.security.Key |
engineGetKey(java.lang.String alias,
char[] password)
Returns the key associated with the given alias. |
boolean |
engineIsCertificateEntry(java.lang.String alias)
Returns true if the entry identified by the given alias is a trusted certificate entry, and false otherwise. |
boolean |
engineIsKeyEntry(java.lang.String alias)
Returns true if the entry identified by the given alias is a key entry, and false otherwise. |
void |
engineLoad(java.io.InputStream stream,
char[] password)
Loads the keystore from the session associated with the IBMPKCS11Impl provider. |
void |
engineLoad(java.security.KeyStore.LoadStoreParameter param)
Loads the keystore from the session associated with the IBMPKCS11Impl provider. |
void |
engineSetCertificateEntry(java.lang.String alias,
java.security.cert.Certificate cert)
Assigns the given certificate to the given alias. |
void |
engineSetEntry(java.lang.String alias,
java.security.KeyStore.Entry entry,
java.security.KeyStore.ProtectionParameter protParam)
Save a KeyStore.Entry under the specified alias. |
void |
engineSetKeyEntry(java.lang.String alias,
byte[] key,
java.security.cert.Certificate[] chain)
Assigns the given key (that has already been protected) to the given alias. |
void |
engineSetKeyEntry(java.lang.String alias,
java.security.Key key,
char[] password,
java.security.cert.Certificate[] chain)
Assigns the given key to the given alias. |
int |
engineSize()
Retrieves the number of entries in this keystore. |
void |
engineStore(java.io.OutputStream stream,
char[] password)
Stores this keystore to the given output stream, and protects its integrity with the given password. |
Methods inherited from class java.security.KeyStoreSpi |
---|
engineEntryInstanceOf, engineStore |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PKCS11KeyStore()
public PKCS11KeyStore(java.security.Provider provider)
Method Detail |
---|
public java.security.Key engineGetKey(java.lang.String alias, char[] password) throws java.security.NoSuchAlgorithmException, java.security.UnrecoverableKeyException
engineGetKey
in class java.security.KeyStoreSpi
alias
- the alias namepassword
- is not used by this key store.
java.security.NoSuchAlgorithmException
- if the algorithm for recovering the
key cannot be found
java.security.UnrecoverableKeyException
- if the key cannot be recovered
(e.g., the given password is wrong).public java.security.cert.Certificate[] engineGetCertificateChain(java.lang.String alias)
engineGetCertificateChain
in class java.security.KeyStoreSpi
alias
- the alias name
public java.security.cert.Certificate engineGetCertificate(java.lang.String alias)
If the given alias name identifies a trusted certificate entry, the certificate associated with that entry is returned. If the given alias name identifies a key entry, the first element of the certificate chain of that entry is returned, or null if that entry does not have a certificate chain.
engineGetCertificate
in class java.security.KeyStoreSpi
alias
- the alias name
public java.security.KeyStore.Entry engineGetEntry(java.lang.String alias, java.security.KeyStore.ProtectionParameter protParam) throws java.security.KeyStoreException, java.security.NoSuchAlgorithmException, java.security.UnrecoverableEntryException
KeyStore.Entry
for the specified alias
engineGetEntry
in class java.security.KeyStoreSpi
alias
- get the KeyStore.Entry
for this aliasprotParam
- this must be null
KeyStore.Entry
for the specified alias,
or null
if there is no such entry
java.security.KeyStoreException
- if the operation failed
java.security.NoSuchAlgorithmException
- if the algorithm for recovering the
entry cannot be found
java.security.UnrecoverableEntryException
- if the specified
protParam
were insufficient or invalidpublic void engineSetEntry(java.lang.String alias, java.security.KeyStore.Entry entry, java.security.KeyStore.ProtectionParameter protParam) throws java.security.KeyStoreException
KeyStore.Entry
under the specified alias.
If an entry already exists for the specified alias, it is overridden.
This KeyStore implementation only supports the standard entry types, This implementation does not support a protection Parameter, it will be ignored. The password will be the one associated with the token.
Entries are immediately stored on the token.
see engineSetKeyEntry and engineSetCertificateEntry for more information on adding keys and certificates using this keystore.
engineSetEntry
in class java.security.KeyStoreSpi
alias
- save the KeyStore.Entry
under this aliasentry
- the Entry
to saveprotParam
- this must be null
java.security.KeyStoreException
- if this operation failspublic java.util.Date engineGetCreationDate(java.lang.String alias)
engineGetCreationDate
in class java.security.KeyStoreSpi
alias
- the alias name
public void engineSetKeyEntry(java.lang.String alias, java.security.Key key, char[] password, java.security.cert.Certificate[] chain) throws java.security.KeyStoreException
If the given key is of type java.security.PrivateKey
,
it must be accompanied by a certificate chain certifying the
corresponding public key.
If a key entry already exists with that alias than that key entry will be replaced with the new one.
If the key is already a PKCS11 session key than this function will try and make the key a token key. Basically save the key on the card permanently.
If the key to be associated with alias is not a PKCS11Key than the code will try to translate the key to a PKCS11Key using the KeyFactory for than type of key. Therefore, if a configuration file was used to initialize the provider than attributes from that will be used to import the key to the card. If not, than the key will be created as a session key only and not be actually stored on the token permanently.
Note: The certificates in the certificate chain are not added or deleted from the token. This should be done using certificate entries.
engineSetKeyEntry
in class java.security.KeyStoreSpi
alias
- the alias namekey
- the key to be associated with the aliaspassword
- this parameter has no meaning currently for PKCS11 and there is not
used.chain
- the certificate chain for the corresponding public
key (only required if the given key is of type
java.security.PrivateKey
).
java.security.KeyStoreException
- if the given key cannot be protected, or
this operation fails for some other reasonpublic void engineSetKeyEntry(java.lang.String alias, byte[] key, java.security.cert.Certificate[] chain) throws java.security.KeyStoreException
engineSetKeyEntry
in class java.security.KeyStoreSpi
alias
- the alias namekey
- the key (in protected format) to be associated with the aliaschain
- the certificate chain for the corresponding public
key (only useful if the protected key is of type
java.security.PrivateKey
).
java.security.KeyStoreException
- is always thrown.public void engineSetCertificateEntry(java.lang.String alias, java.security.cert.Certificate cert) throws java.security.KeyStoreException
If a trusted certificate entry already exists with that alias than that entry
may be replaced with the new one. To make sure that this keystore matchs, what is
currently associated with the token than use load
to reload the key store.
Note: This method will add the certificate to the token as a token object.
engineSetCertificateEntry
in class java.security.KeyStoreSpi
alias
- the alias namecert
- the certificate
java.security.KeyStoreException
- if the given alias already exists and does
not identify a trusted certificate entry, or this operation
fails for some other reason.public void engineDeleteEntry(java.lang.String alias) throws java.security.KeyStoreException
engineDeleteEntry
in class java.security.KeyStoreSpi
alias
- the alias name
java.security.KeyStoreException
- if the entry cannot be removed.public java.util.Enumeration engineAliases()
engineAliases
in class java.security.KeyStoreSpi
public boolean engineContainsAlias(java.lang.String alias)
engineContainsAlias
in class java.security.KeyStoreSpi
alias
- the alias name
public int engineSize()
engineSize
in class java.security.KeyStoreSpi
public boolean engineIsKeyEntry(java.lang.String alias)
engineIsKeyEntry
in class java.security.KeyStoreSpi
public boolean engineIsCertificateEntry(java.lang.String alias)
engineIsCertificateEntry
in class java.security.KeyStoreSpi
public java.lang.String engineGetCertificateAlias(java.security.cert.Certificate cert)
This method attempts to match the given certificate with each keystore entry. If the entry being considered is a trusted certificate entry, the given certificate is compared to that entry's certificate. If the entry being considered is a key entry, the given certificate is compared to the first element of that entry's certificate chain (if a chain exists).
engineGetCertificateAlias
in class java.security.KeyStoreSpi
cert
- the certificate to match with.
public void engineStore(java.io.OutputStream stream, char[] password) throws java.io.IOException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateException
This method is not supported by this key store and will always throw a IOException
engineStore
in class java.security.KeyStoreSpi
stream
- the output stream to which this keystore is written.password
- the password to generate the keystore integrity check
java.io.IOException
- always thrown
java.security.NoSuchAlgorithmException
- is here for compatability.
java.security.cert.CertificateException
- is here for compatability.public void engineLoad(java.security.KeyStore.LoadStoreParameter param) throws java.io.IOException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateException
engineLoad
in class java.security.KeyStoreSpi
stream
- this parameter is not used by the method and can be any valuepassword
- this parameter is not used by the method and can be any value
java.io.IOException
- if there is an I/O or format problem with the
keystore data
java.security.NoSuchAlgorithmException
- if the algorithm used to check
the integrity of the keystore cannot be found
java.security.cert.CertificateException
- if any of the certificates in the
keystore could not be loadedpublic void engineLoad(java.io.InputStream stream, char[] password) throws java.io.IOException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateException
engineLoad
in class java.security.KeyStoreSpi
stream
- this parameter is not used by the method and can be any valuepassword
- this parameter is not used by the method and can be any value
java.io.IOException
- if there is an I/O or format problem with the
keystore data
java.security.NoSuchAlgorithmException
- if the algorithm used to check
the integrity of the keystore cannot be found
java.security.cert.CertificateException
- if any of the certificates in the
keystore could not be loaded
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |