2121import static java .util .Collections .singletonList ;
2222import static java .util .Objects .requireNonNull ;
2323
24- import com .google . common .cache .Cache ;
25- import com .google . common . cache .CacheBuilder ;
26- import com .google . common . cache .CacheStats ;
24+ import com .github . benmanes . caffeine .cache .Cache ;
25+ import com .github . benmanes . caffeine . cache .Caffeine ;
26+ import com .github . benmanes . caffeine . cache . stats .CacheStats ;
2727import com .google .common .hash .Hasher ;
2828import com .google .common .hash .Hashing ;
2929import eu .emi .security .authn .x509 .ProxySupport ;
3939import java .security .cert .CertificateExpiredException ;
4040import java .security .cert .CertificateNotYetValidException ;
4141import java .security .cert .X509Certificate ;
42- import java .util .concurrent .ExecutionException ;
42+ import java .util .concurrent .CompletionException ;
4343import java .util .concurrent .TimeUnit ;
4444
4545/**
@@ -53,7 +53,7 @@ public class CachingCertificateValidator implements X509CertChainValidatorExt {
5353
5454 public CachingCertificateValidator (X509CertChainValidatorExt val ,
5555 long maxCacheEntryLifetime ) {
56- cache = CacheBuilder .newBuilder ()
56+ cache = Caffeine .newBuilder ()
5757 .expireAfterWrite (maxCacheEntryLifetime , TimeUnit .MILLISECONDS ).build ();
5858 validator = val ;
5959 }
@@ -77,12 +77,12 @@ public ValidationResult validate(final X509Certificate[] certChain) {
7777
7878 String certFingerprint = hasher .hash ().toString ();
7979
80- return cache .get (certFingerprint , () -> validator .validate (certChain ));
80+ return cache .get (certFingerprint , (key ) -> validator .validate (certChain ));
8181 } catch (CertificateEncodingException e ) {
8282 return new ValidationResult (false , singletonList (
8383 new ValidationError (certChain , pos , ValidationErrorCode .inputError ,
8484 e .getMessage ())));
85- } catch (ExecutionException e ) {
85+ } catch (CompletionException e ) {
8686 return new ValidationResult (false , singletonList (
8787 new ValidationError (certChain , pos , ValidationErrorCode .inputError ,
8888 e .getMessage ())));
0 commit comments