Class AbstractValidator
java.lang.Object
eu.emi.security.authn.x509.helpers.pkipath.AbstractValidator
- All Implemented Interfaces:
X509CertChainValidator,X509CertChainValidatorExt
- Direct Known Subclasses:
OpensslCertChainValidator,PlainCRLValidator
Base implementation of
X509CertChainValidator.
It is configured with CertStore providing CRLs and TrustAnchorStore
providing trusted CAs. The implementation validates certificates using
the BCCertPathValidator.
This class is thread safe and its extensions should also guarantee this.
- Author:
- K. Benedyczak
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected Set<ValidationErrorListener>protected final ObserversHandlerprotected BCCertPathValidator -
Constructor Summary
ConstructorsConstructorDescriptionAbstractValidator(Collection<? extends StoreUpdateListener> initialListeners) Default constructor is available, the subclass must initialize the parent with the init() method. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddUpdateListener(StoreUpdateListener listener) Registers a listener which can react to errors found during refreshing of the trust material: trusted CAs or CRLs.voidaddValidationListener(ValidationErrorListener listener) Registers a listener which can react to errors found during certificate validation.voiddispose()Disposes resources used by this Validator, like threads.Returns whether this validator supports proxy certificates.Gets the current revocation checking mode.Returns a list of trusted issuers of certificates.protected voidinit(TrustAnchorStore caStore, AbstractCRLStoreSPI crlStore, ProxySupport proxySupport, RevocationParameters revocationCheckingMode) Use this method to initialize the parent from the extension class, if not using the non-default constructor.protected booleanprotected booleannotifyListeners(ValidationError error) Notifies all registered listeners.protected voidprocessErrorList(List<ValidationError> errors) voidremoveUpdateListener(StoreUpdateListener listener) Unregisters a previously registered CA or CRL update listener.voidUnregisters a previously registered validation listener.Performs validation of a provided certificate path.validate(X509Certificate[] certChain) Performs validation of a provided certificate chain.protected ValidationResultvalidate(X509Certificate[] certChain, Set<TrustAnchor> anchors)
-
Field Details
-
listeners
-
observers
-
validator
-
disposed
protected boolean disposed
-
-
Constructor Details
-
AbstractValidator
Default constructor is available, the subclass must initialize the parent with the init() method. Note that it is strongly suggested to call the init() method from the child class constructor.This is not a cleanest design possible but it is required as arguments to the init() method require some code to be created in subclasses. Therefore we have a trade off: a bit unclean design inside the library and a clean external API without factory methods.
- Parameters:
initialListeners- initial listeners
-
-
Method Details
-
init
protected void init(TrustAnchorStore caStore, AbstractCRLStoreSPI crlStore, ProxySupport proxySupport, RevocationParameters revocationCheckingMode) Use this method to initialize the parent from the extension class, if not using the non-default constructor.- Parameters:
caStore- CA storecrlStore- CRL storeproxySupport- proxy supportrevocationCheckingMode- revocation checking mode
-
validate
Performs validation of a provided certificate path.- Specified by:
validatein interfaceX509CertChainValidator- Parameters:
certPath- to be validated- Returns:
- result of validation
-
validate
Performs validation of a provided certificate chain.- Specified by:
validatein interfaceX509CertChainValidator- Parameters:
certChain- to be validated- Returns:
- result of validation
-
validate
-
processErrorList
-
getTrustedIssuers
Returns a list of trusted issuers of certificates.- Specified by:
getTrustedIssuersin interfaceX509CertChainValidator- Returns:
- array containing trusted issuers' certificates
-
notifyListeners
Notifies all registered listeners.- Parameters:
error- validation error- Returns:
- true if the error should be ignored false otherwise.
-
addValidationListener
Registers a listener which can react to errors found during certificate validation. It is useful in two cases: (rarely) if you want to change the default logic of the validator and if you will use the validator indirectly (e.g. to validate SSL socket connections) and want to get the originalValidationError, not the exception.- Specified by:
addValidationListenerin interfaceX509CertChainValidator- Parameters:
listener- to be registered
-
removeValidationListener
Unregisters a previously registered validation listener. If the listener was not registered then the method does nothing.- Specified by:
removeValidationListenerin interfaceX509CertChainValidator- Parameters:
listener- to be unregistered
-
getProxySupport
Returns whether this validator supports proxy certificates.- Specified by:
getProxySupportin interfaceX509CertChainValidatorExt- Returns:
- proxy certificates support mode
-
getRevocationCheckingMode
Gets the current revocation checking mode.- Specified by:
getRevocationCheckingModein interfaceX509CertChainValidatorExt- Returns:
- the current mode
-
dispose
public void dispose()Disposes resources used by this Validator, like threads. After calling this method the validator can not be used anymore.- Specified by:
disposein interfaceX509CertChainValidatorExt
-
isDisposed
protected boolean isDisposed() -
addUpdateListener
Registers a listener which can react to errors found during refreshing of the trust material: trusted CAs or CRLs. This method is useful only if the implementation supports updating of CAs or CRLs, otherwise the listener will not be invoked.- Specified by:
addUpdateListenerin interfaceX509CertChainValidator- Parameters:
listener- to be registered
-
removeUpdateListener
Unregisters a previously registered CA or CRL update listener. If the listener was not registered then the method does nothing.- Specified by:
removeUpdateListenerin interfaceX509CertChainValidator- Parameters:
listener- to be unregistered
-