public class CertStore
extends java.lang.Object
CertStore class reads and writes certificates.| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ALG_STRING_3DES |
static java.lang.String |
ALG_STRING_CAST |
static java.lang.String |
ALG_STRING_DES |
static java.lang.String |
ALG_STRING_IDEA |
static boolean |
DEBUG |
| Constructor and Description |
|---|
CertStore(boolean write)
Creates an empty certificate store.
|
CertStore(java.lang.String path,
SecureStringBuffer password,
boolean write)
Creates a new
CertStore object. |
| Modifier and Type | Method and Description |
|---|---|
void |
addCertificate(java.security.cert.Certificate cert,
java.lang.String alias)
Adds a certificate to this certificate store.
|
boolean |
containsAlias(java.lang.String alias)
Returns
true if the certificate store contains a
certificate for the given alias. |
void |
deleteAllCertificates()
Deletes all certificates from this certificate store.
|
void |
deleteCertificate(java.lang.String alias)
Deletes the certificate with the given alias from this
certificate store.
|
java.lang.String |
getAlias(java.security.cert.Certificate cert)
Returns the alias of the given certificate, or
null
if the certificate cannot be found. |
java.lang.String[] |
getAliases()
Returns all aliases contained in this certificate store.
|
java.security.cert.Certificate |
getCertificate(java.lang.String alias)
Returns the certificate with the given alias.
|
boolean |
isWriteStore()
Returns
true if this is a read/write store, and
false if it is a read-only store. |
int |
size()
Returns the number of entries this certificate store contains.
|
void |
store()
Writes this certicate store to the
p12 file if it
is a read/write certificate store. |
void |
store(java.io.OutputStream os,
SecureStringBuffer pwd)
Writes this certificate store to the given output stream and protects it
with the given password.
|
public static final java.lang.String ALG_STRING_CAST
public static final java.lang.String ALG_STRING_DES
public static final java.lang.String ALG_STRING_3DES
public static final java.lang.String ALG_STRING_IDEA
public static final boolean DEBUG
public CertStore(java.lang.String path,
SecureStringBuffer password,
boolean write)
throws java.io.IOException
CertStore object.
The CertStore is checked to determine if the given
CertStore already exists. If so, the certificates
from this CertStore are read.
path - the full pathname to the certificate store (*.p12)password - the password used to protect the certificate storewrite - indicates whether this certificate store is used for writing
certificates (true), or for reading certificates
(false)java.lang.IllegalArgumentException - thrown if path does not point to a
.p12 filejava.io.IOException - Thrown if a certificate with the given path exists,
but cannot be readpublic CertStore(boolean write)
Add certificates by calling the addCertificate
method.
write - true to create a read/write cert store,
false to create a read-only storepublic boolean isWriteStore()
true if this is a read/write store, and
false if it is a read-only store.true if this is a read/write storepublic void addCertificate(java.security.cert.Certificate cert,
java.lang.String alias)
If a certificate already exists with the given alias, the old entry is overwritten.
cert - the certificate to be added to the certificate storealias - the alias under which the certificate will be storedpublic void deleteCertificate(java.lang.String alias)
If there is no certificate with the given alias in the certificate store, the method returns without doing anything.
alias - the alias of the certificate to be deletedpublic void deleteAllCertificates()
public java.security.cert.Certificate getCertificate(java.lang.String alias)
alias - the alias of the certificate to be returned, if it is foundpublic boolean containsAlias(java.lang.String alias)
true if the certificate store contains a
certificate for the given alias.alias - the alias of the certificate to be foundpublic java.lang.String[] getAliases()
public java.lang.String getAlias(java.security.cert.Certificate cert)
null
if the certificate cannot be found.public int size()
public void store()
throws java.io.IOException
p12 file if it
is a read/write certificate store.java.io.IOException - thrown if the certificate store cannot be writtenpublic void store(java.io.OutputStream os,
SecureStringBuffer pwd)
throws java.io.IOException
java.io.IOException - thrown if the certificate store cannot be stored