Package org.italiangrid.voms.util
Class CachingCertificateValidator
java.lang.Object
org.italiangrid.voms.util.CachingCertificateValidator
- All Implemented Interfaces:
eu.emi.security.authn.x509.X509CertChainValidator,eu.emi.security.authn.x509.X509CertChainValidatorExt
public class CachingCertificateValidator
extends Object
implements eu.emi.security.authn.x509.X509CertChainValidatorExt
A Certificate validator that caches validation results for a configurable
period of time. The cache is keyed by the fingerprint of the certificate at
the top of the chain (likely the EEC).
- Author:
- andreaceccanti
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final longThe cache entry lifetime for this validatorprotected final ConcurrentMap<String, org.italiangrid.voms.util.CachedValidationResult> Simple concurrent cache for validation resultsprotected final eu.emi.security.authn.x509.X509CertChainValidatorExtThe wrapped CANL certificate validator -
Constructor Summary
ConstructorsConstructorDescriptionCachingCertificateValidator(eu.emi.security.authn.x509.X509CertChainValidatorExt val, long maxCacheEntryLifetime) Builds a caching validator wrapping the validator passed as argument. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddUpdateListener(eu.emi.security.authn.x509.StoreUpdateListener listener) voidaddValidationListener(eu.emi.security.authn.x509.ValidationErrorListener listener) booleancachedValidationResultHasExpired(org.italiangrid.voms.util.CachedValidationResult cvr, long referenceTime) Checks whether theCachedValidationResultpassed as argument has expired with respect to thecacheEntryLifetimeMsecdefined for this validator and the reference time passed as argument.voiddispose()protected eu.emi.security.authn.x509.ValidationResultgetCachedResult(String certFingerprint) Gets a validation result from the memory cacheeu.emi.security.authn.x509.ProxySupporteu.emi.security.authn.x509.RevocationParametersvoidremoveUpdateListener(eu.emi.security.authn.x509.StoreUpdateListener listener) voidremoveValidationListener(eu.emi.security.authn.x509.ValidationErrorListener listener) eu.emi.security.authn.x509.ValidationResulteu.emi.security.authn.x509.ValidationResultvalidate(X509Certificate[] certChain) Validates a certificate chain using the wrapped validator, caching the result for future validation calls.
-
Field Details
-
validationResultsCache
protected final ConcurrentMap<String,org.italiangrid.voms.util.CachedValidationResult> validationResultsCacheSimple concurrent cache for validation results -
validator
protected final eu.emi.security.authn.x509.X509CertChainValidatorExt validatorThe wrapped CANL certificate validator -
cacheEntryLifetimeMsec
protected final long cacheEntryLifetimeMsecThe cache entry lifetime for this validator
-
-
Constructor Details
-
CachingCertificateValidator
public CachingCertificateValidator(eu.emi.security.authn.x509.X509CertChainValidatorExt val, long maxCacheEntryLifetime) Builds a caching validator wrapping the validator passed as argument.- Parameters:
val- The CANL validator to be wrapped.maxCacheEntryLifetime- the maximum cache entry lifetime (in msecs)
-
-
Method Details
-
cachedValidationResultHasExpired
public boolean cachedValidationResultHasExpired(org.italiangrid.voms.util.CachedValidationResult cvr, long referenceTime) Checks whether theCachedValidationResultpassed as argument has expired with respect to thecacheEntryLifetimeMsecdefined for this validator and the reference time passed as argument.- Parameters:
cvr- aCachedValidationResultobjectreferenceTime- the reference time (msecs since the epoch)- Returns:
truewhen expired,falseotherwise
-
getCachedResult
Gets a validation result from the memory cache- Parameters:
certFingerprint- the certificate fingerprint for the certificate at the top of the chain- Returns:
- the validation result, if found.
nullotherwise.
-
validate
Validates a certificate chain using the wrapped validator, caching the result for future validation calls.- Specified by:
validatein interfaceeu.emi.security.authn.x509.X509CertChainValidator- Parameters:
certChain- the certificate chain that will be validated- Returns:
- a possibly cached
ValidationResult - See Also:
-
dispose
public void dispose()- Specified by:
disposein interfaceeu.emi.security.authn.x509.X509CertChainValidatorExt- See Also:
-
getProxySupport
public eu.emi.security.authn.x509.ProxySupport getProxySupport()- Specified by:
getProxySupportin interfaceeu.emi.security.authn.x509.X509CertChainValidatorExt- Returns:
- the proxy support information
- See Also:
-
validate
- Specified by:
validatein interfaceeu.emi.security.authn.x509.X509CertChainValidator- Parameters:
certPath- the certificate path that will be validated- Returns:
- the
ValidationResult - See Also:
-
getRevocationCheckingMode
public eu.emi.security.authn.x509.RevocationParameters getRevocationCheckingMode()- Specified by:
getRevocationCheckingModein interfaceeu.emi.security.authn.x509.X509CertChainValidatorExt- Returns:
- revocation parameters for the wrapped validator
- See Also:
-
getTrustedIssuers
- Specified by:
getTrustedIssuersin interfaceeu.emi.security.authn.x509.X509CertChainValidator- Returns:
- trusted issuers from the wrapped validator
- See Also:
-
addValidationListener
public void addValidationListener(eu.emi.security.authn.x509.ValidationErrorListener listener) - Specified by:
addValidationListenerin interfaceeu.emi.security.authn.x509.X509CertChainValidator- Parameters:
listener- theValidationErrorListenerto be added to this validator- See Also:
-
removeValidationListener
public void removeValidationListener(eu.emi.security.authn.x509.ValidationErrorListener listener) - Specified by:
removeValidationListenerin interfaceeu.emi.security.authn.x509.X509CertChainValidator- Parameters:
listener- theValidationErrorListenerthat must be removed from this validator- See Also:
-
addUpdateListener
public void addUpdateListener(eu.emi.security.authn.x509.StoreUpdateListener listener) - Specified by:
addUpdateListenerin interfaceeu.emi.security.authn.x509.X509CertChainValidator- Parameters:
listener- theStoreUpdateListenerthat must be added to this validator- See Also:
-
removeUpdateListener
public void removeUpdateListener(eu.emi.security.authn.x509.StoreUpdateListener listener) - Specified by:
removeUpdateListenerin interfaceeu.emi.security.authn.x509.X509CertChainValidator- Parameters:
listener- theStoreUpdateListenerthat must be removed from this validator- See Also:
-