public class SimpleChainVerifier extends ChainVerifier implements java.io.Serializable
ChainVerifier
class which provides the
cryptographic foundation and adds to it a simple trust mechanism. Each
object internally maintains a list of trusted certificates (user certificates
or CA certificates) in a Hashtable.
See the superclass documentation for more information about the handling
of trusted certificates by the verifyChain
method.
To use it, first create a SimpleChainVerifier object and then add trusted
certificates by means of the addTrustedCertificate
or setTrustedCertificates
methods. Then call verifyChain
for any certificate chain you want to verify. Note that you can also
use this class without any trusted certificates purely to verify a chain
cryptographically. Simply call verifyChain
without trusted certificates, it will then return false for cryptographically
valid chains and throw a CertificateException for bad chains (broken, expired, etc.)
Modifier and Type | Field and Description |
---|---|
protected java.util.Hashtable |
signers
A Hashtable holding the X.509 Certificates of the trusted signers.
|
Constructor and Description |
---|
SimpleChainVerifier()
Creates a new SimpleChainVerifier.
|
Modifier and Type | Method and Description |
---|---|
void |
addTrustedCertificate(java.security.cert.X509Certificate certificate)
Add a trusted certificate.
|
boolean |
isTrustedCertificate(java.security.cert.X509Certificate cert)
Checks whether a given certificate is marked as trusted.
|
java.security.cert.X509Certificate |
removeTrustedCertificate(java.security.cert.X509Certificate certificate)
Remove a certificate from the list of trusted certificates.
|
void |
setTrustedCertificates(java.security.cert.X509Certificate[] certificateList)
Sets the certificates to be trusted.
|
java.util.Enumeration |
trustedCertificates()
Returns the enumeration of the currently trusted certificates.
|
checkExtensions, orderCertificateChain, verifyChain, verifyChain
protected java.util.Hashtable signers
public SimpleChainVerifier()
public boolean isTrustedCertificate(java.security.cert.X509Certificate cert) throws java.security.cert.CertificateException
isTrustedCertificate
in class ChainVerifier
cert
- the certificate to be checkedtrue
if the given cert is trusted, false
otherwisejava.security.cert.CertificateException
- never thrown by this method; only declared because
also declared in super classpublic java.util.Enumeration trustedCertificates()
public void setTrustedCertificates(java.security.cert.X509Certificate[] certificateList)
certificateList
- the list of trusted certificatespublic void addTrustedCertificate(java.security.cert.X509Certificate certificate)
certificate
- the certificate to be marked as trustedpublic java.security.cert.X509Certificate removeTrustedCertificate(java.security.cert.X509Certificate certificate)
certificate
- the certificate to no longer be marked as trusted