public abstract class ChainVerifier
extends java.lang.Object
SimpleChainVerifier
class for a basic implementation of such logic.
See the documentation of the
verifyChain
method
for more information about the verification that is performed.
NOTE: This class currently includes only a very basic support for X.509v3 extensions.
SimpleChainVerifier
Modifier | Constructor and Description |
---|---|
protected |
ChainVerifier()
Constructor for use by subclasses.
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkExtensions(java.security.cert.X509Certificate[] certificateChain,
int index)
Verifies if the extensions in the certificate at the given index in the
certificate chain are valid.
|
abstract boolean |
isTrustedCertificate(java.security.cert.X509Certificate cert)
Tests whether the given certificate is explicitly trusted.
|
static java.security.cert.X509Certificate[] |
orderCertificateChain(java.security.cert.X509Certificate leaf,
java.security.cert.X509Certificate[] certs)
Reorder a set of certificates so that it becomes a valid chain.
|
boolean |
verifyChain(java.security.cert.X509Certificate[] certificateChain)
This method verifies a certificate chain.
|
boolean |
verifyChain(java.security.cert.X509Certificate[] certificateChain,
boolean reversed)
This method verifies a (reversed) certificate chain.
|
public abstract boolean isTrustedCertificate(java.security.cert.X509Certificate cert) throws java.security.cert.CertificateException
verifyChain
.cert
- the certificate to be checkedtrue
if the certificate shall be trusted,
false
if notjava.security.cert.CertificateException
public boolean verifyChain(java.security.cert.X509Certificate[] certificateChain) throws java.security.cert.CertificateException
certificateChain
- the certificate chain to be checkedjava.security.cert.CertificateException
- if there is some error in the certificate chainprotected void checkExtensions(java.security.cert.X509Certificate[] certificateChain, int index) throws java.security.cert.CertificateException
NOTE: This method currently only works for instances of iaik.x509.X509Certificate, for other subclasses of java.security.cert.X509Certificate no extension checking will be done at all.
The handling of X.509 extensions by this class is far from complete. If you
want to implement your own extension checking, override this method. It is
supposed to be called only by verifyChain()
.
Current handling of extensions:
KeyUsage.keyCertSign
if the
extension is present.
certificateChain
- the certificate chain containing the certificate to be checkedindex
- the index of the certificate to be checkedjava.security.cert.CertificateException
- if the verification failspublic boolean verifyChain(java.security.cert.X509Certificate[] certificateChain, boolean reversed) throws java.security.cert.CertificateException
certificateChain
- the certificate chain to be verifiedreversed
- whether the user certificate is loacted at index 0 (reversed =
false), or at index n-1 (reversed = true)java.security.cert.CertificateException
- if there is some error in the certificate chainpublic static java.security.cert.X509Certificate[] orderCertificateChain(java.security.cert.X509Certificate leaf, java.security.cert.X509Certificate[] certs) throws java.security.cert.CertificateException
leaf
- the leaf certificatecerts
- the certificate chain to be reorderedjava.security.cert.CertificateException
- if a required issuer certificate cannot be found in the set of
certificates.