public class ArchiveCertCache extends CertificateStore
ArchiveCertCache is used to read and write the Entrust .CCH
and .XCC certificate cache files, used to store user certificates
and cross certificates respectively.
This class can be used in two different ways. It can
be used as a traditional CertificateStore object, providing
access to certificates that could not be retrieved otherwise when a User is
logging in with no Directory connection, for example.
In this case, initialize the certificate cache
and add it to the main certificate store using the following code:
ArchiveCertCache archiveCertCache = new ArchiveCertCache(inputStream);
user.getCertificateStore().attach(archiveCertCache);
ArchiveCertCache can also be used to hold all certificates
in the memory cache, and to put them back into memory when a
program starts up again. In this case, use the methods addMemoryCache
and initMemoryCache(). Before ending the
application, call addMemoryCache() to add all certificates
currently in memory to the cache object, and then write out the cache
object. When starting the application, call initMemoryCache(),
which adds all certificates in the archive to the memory cache. In this case,
the archive does not need to be added as a certificate store.
| Modifier and Type | Field and Description |
|---|---|
static int |
CROSS_CERT_ONLY
Specifies that only cross certificates should be written.
|
static int |
USER_AND_CROSS_CERT
Specifies that both user certificates and
cross certificates should be written.
|
static int |
USER_CERT_ONLY
Specifies that only user certificates should be written.
|
| Constructor and Description |
|---|
ArchiveCertCache()
Creates an empty archive cache.
|
ArchiveCertCache(java.io.InputStream is)
Creates an archive cache, and initializes
it with the contents of the cache file specified by the
InputStream
argument. |
| Modifier and Type | Method and Description |
|---|---|
void |
addCertificate(X509Certificate cert)
Adds the specified certificate to this cache.
|
void |
addCertificates(X509Certificate[] certs)
Adds the specified certificates to this cache.
|
void |
addMemoryCache()
Adds all certificates currently in the main certificate
graph to this cache object.
|
void |
cleanup()
Removes all certificates from the cache
that have passed their
notAfter usage period, and are
no longer valid. |
CertificateSet |
findCerts(GeneralName location)
Generalized version of findCerts.
|
CertificateSet |
findCerts(java.security.Principal dn)
Returns all certificates currently in the certificate cache that belong
to the specified DN.
|
void |
initMemoryCache()
Adds all certificates currently in the cache object
to the main certificate graph.
|
void |
parse(java.io.InputStream cacheFile)
Adds the contents of an archive cache (
.CCH or
.XCC) to the cache object. |
void |
write(java.io.OutputStream os,
int writeMode)
Writes the certificates contained in this cache object to a stream,
in the Entrust certificate cache format.
|
findpublic static int USER_CERT_ONLY
public static int CROSS_CERT_ONLY
public static int USER_AND_CROSS_CERT
public ArchiveCertCache()
public ArchiveCertCache(java.io.InputStream is)
throws UserFatalException
InputStream
argument.is - the .CCH or .XCC certificate cache
to be read. This stream is closed by this call.UserFatalException - if there is an error reading the protected entries in the cache file.public CertificateSet findCerts(java.security.Principal dn)
findCerts in class CertificateStoredn - the DN for which to find matching certificates.dn, or
null if no certificates for dn are
found in this CertificateStorepublic void addCertificate(X509Certificate cert)
cert - the certificate to add to the cache.public void addCertificates(X509Certificate[] certs)
certs - the certificates to add to the cache.public void addMemoryCache()
Using this method makes the certificates easy to retrieve.
Use this method in combination with initMemoryCache as
the easiest way to use the certificate archive cache.
public void initMemoryCache()
Using this method makes the certificates easily available
to the certificate validation algorithm. Use this method in combination
with addMemoryCache as the easiest way to use the
certificate archive cache.
public void cleanup()
notAfter usage period, and are
no longer valid.
The method is used to prevent runaway growth of the cache file, since certificates in the cache never expire otherwise.
public void write(java.io.OutputStream os,
int writeMode)
throws UserFatalException,
java.lang.IllegalArgumentException
The method can write the user certificates only (to create an Entrust
.CCH file), the cross certificates only (to create an
Entrust .XCC file), or it can write both user certificates
and cross certificates.
os - the stream to which to write the archive cache. This stream
is not closed by this call.writeMode - one of:
USER_CERT_ONLY to write user
certificates.CROSS_CERT_ONLY to write cross
certificates.USER_AND_CROSS_CERT to write
both user and cross certificates.UserFatalException - if there is an error protecting the entries in the cache.java.lang.IllegalArgumentException - if writeMode is not one of the listed modes.public void parse(java.io.InputStream cacheFile)
throws UserFatalException
.CCH or
.XCC) to the cache object.cacheFile - a stream containing the cache file to read. This stream is
closed after this call completes.UserFatalException - if there is an error reading the protected entries in the cache file.public CertificateSet findCerts(GeneralName location) throws CertificationException
findCerts in class CertificateStorelocation - The GeneralName. It must represent a type of
java.security.Principal or this check cannot be done.location, or
null if no certificates for location are
found in this CertificateStoreCertificationException - if there is a problem finding the certificates.