|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--iaik.me.keymgmt.KeyStore
This class encodes and decodes IAIK-JCE-ME KeyStores. It uses a new, more efficient and compact format than the previous IAIK keystores. The registered object identifier of this keystore is "1.3.6.1.4.1.2706.2.1".
Note: The old keystore format is not supported anymore, only keystores with the new format can be parsed with this implementation. You can convert keystores with the old format to the new one with the conversion tool provided with this distribution.
Constructor Summary | |
KeyStore()
Creates a new empty KeyStore. |
|
KeyStore(InputStream in,
char[] password)
Reads a keystore from the given InputStream. |
Method Summary | |
void |
addCertificateChainEntry(String alias,
X509Certificate[] cert)
Adds a X509 certificate chain to the Keystore. |
void |
addCertificateEntry(String alias,
X509Certificate cert)
Adds a certificate to the Keystore. |
void |
addKeyAndCertEntry(String alias,
KeyAndCert kac)
Adds a KeyAndCert object containing a private key and the corresponsing certifacte(chain) to the keystore. |
void |
addKeyAndCertEntry(String alias,
PrivateKey key,
X509Certificate[] chain)
Adds a private key and the corresponsing certifacte chain to the keystore. |
void |
addKeyEntry(String alias,
PrivateKey key)
Adds a PrivateKey object to the keystore. |
Enumeration |
aliases()
Returns an enumeration of the aliases in this KeyStore. |
void |
deleteEntry(String alias)
Deletes an entry from the keystore. |
X509Certificate[] |
getCertificateChain(String alias)
Returns the certificate chain specified by the given alias or null if the chain is not in the keystore. If the alias points to a iaik.me.keymgmt.KeyAndCert object, the certificatechain of this object is returned.This method is also used to retrieve single certificates from the keystore. |
Object |
getEntry(String alias)
Returns an entry from the keystore of arbitrary type which is define by its alias (for those who have forgotten of what kind the entry is). The type of the entry can be determined this way:
Object thing = keystore.getEntry("myalias"); |
KeyAndCert |
getKeyAndCert(String alias)
Return the KeyAndCert with the given alias or null if the object can not be found within the keystore. |
PrivateKey |
getPrivateKey(String alias)
Returns the private key that is specified by the given alias or null if the key is not in the keystore. If the alias points to a KeyAndCert object, the private key of that object is returned. |
void |
setSecureRandom(SecureRandom rnd)
Sets a secure random number generator for the cipher operations during password based keystore encryption. |
byte[] |
store(char[] password)
Store the KeyStore protecting it with the given password. |
byte[] |
store(char[] password,
int iterationCount)
Store the KeyStore protecting it with the given password. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public KeyStore()
public KeyStore(InputStream in, char[] password) throws CryptoException, IOException
KeyStore ks = new KeyStore(new FileInputStream("keystore.ks"), "mypassword".toCharArray());
in
- the inpustreampassword
- the password of the keystoreIOException
- CryptoException
- Method Detail |
public void setSecureRandom(SecureRandom rnd)
rnd
- the secure random objectSecureRandom
public Enumeration aliases()
Enumeration enum = keystore.aliases();
while (enum.hasMoreElements()) {
System.out.println(enum.nextElement());
}
public PrivateKey getPrivateKey(String alias) throws CryptoException
KeyAndCert
object, the private key of that object is returned.alias
- alias of the private keyKeyAndCert
public X509Certificate[] getCertificateChain(String alias)
iaik.me.keymgmt.KeyAndCert
object, the certificatechain of this object is returned.
X509Certificate[] certs = keystore.getCertificateChain("mycertificate");
X509Certificate cert = certs[0];
alias
- certificate chain aliasKeyAndCert
public KeyAndCert getKeyAndCert(String alias) throws CryptoException
alias
- alias of the KeyAndCert objectKeyAndCert
objectKeyAndCert
public byte[] store(char[] password) throws CryptoException
byte[] newstore = keystore.store("mypassword".toCharArray());
password
- characterarray of the keystore passwordCryptoException
-
public byte[] store(char[] password, int iterationCount) throws CryptoException
password
- characterarray of the keystore passworditerationCount
- iteration count for the password- based encryptionCryptoException
- public void addKeyAndCertEntry(String alias, PrivateKey key, X509Certificate[] chain)
KeyAndCert
object.
store.addKeyAndCertEntry("myalias", PrivateKey key, X509Certificate[] chain);
alias
- alias of the KeyAndCert
entrykey
- the privatekeychain
- the X509 certificate chainKeyAndCert
public void addKeyAndCertEntry(String alias, KeyAndCert kac)
KeyAndCert kac = new KeyAndCert(certChain, privateKey);
store.addKeyAndCertEntry("myalias", kac);
alias
- the alias for the keystore entrykac
- a KeyAndCert
objectpublic void deleteEntry(String alias)
alias
- alias of the objectpublic void addKeyEntry(String alias, PrivateKey key)
PrivateKey
object to the keystore.alias
- of the private keykey
- the priate keypublic void addCertificateChainEntry(String alias, X509Certificate[] cert)
alias
- alias of the certificate chaincert
- the certificate chainpublic void addCertificateEntry(String alias, X509Certificate cert)
alias
- alias of the certificatecert
- the X509Certificatepublic Object getEntry(String alias)
Object thing = keystore.getEntry("myalias");
if( thing instanceof X509Certificate[] ) {
// certificate (chain)
} else if( thing instanceof KeyAndCert ) {
// KeyAndCert object
} else if ( thing instanceof PrivateKey ) {
// Private key object
}
alias
- the alias of the entry
|
This Javadoc may contain text parts from IETF Internet Standard specifications, see copyright note) and RSA Data Security Public-Key Cryptography Standards (see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |