|
|||||||||
| Home >> All >> java >> [ security overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.security
Class KeyStore

java.lang.Objectjava.security.KeyStore
- public class KeyStore
- extends java.lang.Object
Keystore represents an in-memory collection of keys and certificates. There are two types of entries:
- Key Entry
This type of keystore entry store sensitive crytographic key information in a protected format.Typically this is a secret key or a private key with a certificate chain.
- Trusted Ceritificate Entry
This type of keystore entry contains a single public key certificate belonging to annother entity. It is called trusted because the keystore owner trusts that the certificates belongs to the subject (owner) of the certificate.
Entries in a key store are referred to by their "alias": a simple unique string.
The structure and persistentence of the key store is not specified. Any method could be used to protect sensitive (private or secret) keys. Smart cards or integrated cryptographic engines could be used or the keystore could be simply stored in a file.
| Field Summary | |
private static java.lang.String |
KEY_STORE
Service name for key stores. |
private KeyStoreSpi |
keyStoreSpi
|
private Provider |
provider
|
private java.lang.String |
type
|
| Constructor Summary | |
protected |
KeyStore(KeyStoreSpi keyStoreSpi,
Provider provider,
java.lang.String type)
Creates an instance of KeyStore |
| Method Summary | |
java.util.Enumeration |
aliases()
Generates a list of all the aliases in the keystore. |
boolean |
containsAlias(java.lang.String alias)
Determines if the keystore contains the specified alias. |
void |
deleteEntry(java.lang.String alias)
Deletes the entry for the specified entry. |
java.security.cert.Certificate |
getCertificate(java.lang.String alias)
Gets a Certificate for the specified alias. |
java.lang.String |
getCertificateAlias(java.security.cert.Certificate cert)
Determines if the keystore contains the specified certificate entry and returns the alias. |
java.security.cert.Certificate[] |
getCertificateChain(java.lang.String alias)
Gets a Certificate chain for the specified alias. |
java.util.Date |
getCreationDate(java.lang.String alias)
Gets entry creation date for the specified alias. |
static java.lang.String |
getDefaultType()
Returns the default KeyStore type. |
static KeyStore |
getInstance(java.lang.String type)
Gets an instance of the KeyStore class representing the specified keystore. |
static KeyStore |
getInstance(java.lang.String type,
Provider provider)
Gets an instance of the KeyStore class representing the specified key store from the specified provider. |
static KeyStore |
getInstance(java.lang.String type,
java.lang.String provider)
Gets an instance of the KeyStore class representing the specified key store from the specified provider. |
Key |
getKey(java.lang.String alias,
char[] password)
Returns the key associated with given alias using the supplied password. |
Provider |
getProvider()
Gets the provider that the class is from. |
java.lang.String |
getType()
Returns the type of the KeyStore supported |
boolean |
isCertificateEntry(java.lang.String alias)
Determines if the keystore contains a certificate entry for the specified alias. |
boolean |
isKeyEntry(java.lang.String alias)
Determines if the keystore contains a key entry for the specified alias. |
void |
load(java.io.InputStream stream,
char[] password)
Loads the keystore from the specified input stream and it uses the specified password to check for integrity if supplied. |
void |
setCertificateEntry(java.lang.String alias,
java.security.cert.Certificate cert)
Assign the certificate to the alias in the keystore. |
void |
setKeyEntry(java.lang.String alias,
byte[] key,
java.security.cert.Certificate[] chain)
Assign the key to the alias in the keystore. |
void |
setKeyEntry(java.lang.String alias,
Key key,
char[] password,
java.security.cert.Certificate[] chain)
Assign the key to the alias in the keystore, protecting it with the given password. |
int |
size()
Returns the number of entries in the keystore. |
void |
store(java.io.OutputStream stream,
char[] password)
Stores the keystore in the specified output stream and it uses the specified key it keep it secure. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
KEY_STORE
private static final java.lang.String KEY_STORE
- Service name for key stores.
- See Also:
- Constant Field Values
keyStoreSpi
private KeyStoreSpi keyStoreSpi
provider
private Provider provider
type
private java.lang.String type
| Constructor Detail |
KeyStore
protected KeyStore(KeyStoreSpi keyStoreSpi, Provider provider, java.lang.String type)
- Creates an instance of KeyStore
| Method Detail |
getInstance
public static KeyStore getInstance(java.lang.String type) throws KeyStoreException
- Gets an instance of the KeyStore class representing
the specified keystore. If the type is not
found then, it throws KeyStoreException.
getInstance
public static KeyStore getInstance(java.lang.String type, java.lang.String provider) throws KeyStoreException, NoSuchProviderException
- Gets an instance of the KeyStore class representing
the specified key store from the specified provider.
If the type is not found then, it throws KeyStoreException.
If the provider is not found, then it throws
NoSuchProviderException.
getInstance
public static KeyStore getInstance(java.lang.String type, Provider provider) throws KeyStoreException
- Gets an instance of the KeyStore class representing
the specified key store from the specified provider.
If the type is not found then, it throws KeyStoreException.
If the provider is not found, then it throws
NoSuchProviderException.
- Since:
- 1.4
getDefaultType
public static final java.lang.String getDefaultType()
- Returns the default KeyStore type. This method looks up the
type in <JAVA_HOME>/lib/security/java.security with the
property "keystore.type" or if that fails then "gkr" .
getProvider
public final Provider getProvider()
- Gets the provider that the class is from.
getType
public final java.lang.String getType()
- Returns the type of the KeyStore supported
getKey
public final Key getKey(java.lang.String alias, char[] password) throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException
- Returns the key associated with given alias using the
supplied password.
getCertificateChain
public final java.security.cert.Certificate[] getCertificateChain(java.lang.String alias) throws KeyStoreException
- Gets a Certificate chain for the specified alias.
getCertificate
public final java.security.cert.Certificate getCertificate(java.lang.String alias) throws KeyStoreException
- Gets a Certificate for the specified alias.
If there is a trusted certificate entry then that is returned.
it there is a key entry with a certificate chain then the
first certificate is return or else null.
getCreationDate
public final java.util.Date getCreationDate(java.lang.String alias) throws KeyStoreException
- Gets entry creation date for the specified alias.
setKeyEntry
public final void setKeyEntry(java.lang.String alias, Key key, char[] password, java.security.cert.Certificate[] chain) throws KeyStoreException
- Assign the key to the alias in the keystore, protecting it
with the given password. It will overwrite an existing
entry and if the key is a PrivateKey, also add the
certificate chain representing the corresponding public key.
setKeyEntry
public final void setKeyEntry(java.lang.String alias, byte[] key, java.security.cert.Certificate[] chain) throws KeyStoreException
- Assign the key to the alias in the keystore. It will overwrite
an existing entry and if the key is a PrivateKey, also
add the certificate chain representing the corresponding
public key.
setCertificateEntry
public final void setCertificateEntry(java.lang.String alias, java.security.cert.Certificate cert) throws KeyStoreException
- Assign the certificate to the alias in the keystore. It
will overwrite an existing entry.
deleteEntry
public final void deleteEntry(java.lang.String alias) throws KeyStoreException
- Deletes the entry for the specified entry.
aliases
public final java.util.Enumeration aliases() throws KeyStoreException
- Generates a list of all the aliases in the keystore.
containsAlias
public final boolean containsAlias(java.lang.String alias) throws KeyStoreException
- Determines if the keystore contains the specified alias.
size
public final int size()
throws KeyStoreException
- Returns the number of entries in the keystore.
isKeyEntry
public final boolean isKeyEntry(java.lang.String alias) throws KeyStoreException
- Determines if the keystore contains a key entry for
the specified alias.
isCertificateEntry
public final boolean isCertificateEntry(java.lang.String alias) throws KeyStoreException
- Determines if the keystore contains a certificate entry for
the specified alias.
getCertificateAlias
public final java.lang.String getCertificateAlias(java.security.cert.Certificate cert) throws KeyStoreException
- Determines if the keystore contains the specified certificate
entry and returns the alias.
It checks every entry and for a key entry checks only the
first certificate in the chain.
store
public final void store(java.io.OutputStream stream, char[] password) throws KeyStoreException, java.io.IOException, NoSuchAlgorithmException, java.security.cert.CertificateException
- Stores the keystore in the specified output stream and it
uses the specified key it keep it secure.
load
public final void load(java.io.InputStream stream, char[] password) throws java.io.IOException, NoSuchAlgorithmException, java.security.cert.CertificateException
- Loads the keystore from the specified input stream and it
uses the specified password to check for integrity if supplied.
|
|||||||||
| Home >> All >> java >> [ security overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
java.security.KeyStore