2323package eu .webeid .security .validator ;
2424
2525import com .fasterxml .jackson .databind .ObjectMapper ;
26+ import com .fasterxml .jackson .databind .ObjectReader ;
2627import eu .webeid .security .authtoken .WebEidAuthToken ;
2728import eu .webeid .security .certificate .CertificateLoader ;
2829import eu .webeid .security .certificate .CertificateValidator ;
2930import eu .webeid .security .exceptions .JceException ;
3031import eu .webeid .security .exceptions .AuthTokenParseException ;
3132import eu .webeid .security .exceptions .AuthTokenException ;
32- import eu .webeid .security .validator .certvalidators .SubjectCertificateExpiryValidator ;
3333import eu .webeid .security .validator .certvalidators .SubjectCertificateNotRevokedValidator ;
3434import eu .webeid .security .validator .certvalidators .SubjectCertificatePolicyValidator ;
3535import eu .webeid .security .validator .certvalidators .SubjectCertificatePurposeValidator ;
@@ -57,7 +57,7 @@ final class AuthTokenValidatorImpl implements AuthTokenValidator {
5757 private static final int TOKEN_MAX_LENGTH = 10000 ;
5858 private static final Logger LOG = LoggerFactory .getLogger (AuthTokenValidatorImpl .class );
5959
60- private static final ObjectMapper objectMapper = new ObjectMapper ();
60+ private static final ObjectReader OBJECT_READER = new ObjectMapper (). readerFor ( WebEidAuthToken . class );
6161
6262 private final AuthTokenValidationConfiguration configuration ;
6363 private final SubjectCertificateValidatorBatch simpleSubjectCertificateValidators ;
@@ -84,7 +84,6 @@ final class AuthTokenValidatorImpl implements AuthTokenValidator {
8484 trustedCACertificateCertStore = CertificateValidator .buildCertStoreFromCertificates (configuration .getTrustedCACertificates ());
8585
8686 simpleSubjectCertificateValidators = SubjectCertificateValidatorBatch .createFrom (
87- new SubjectCertificateExpiryValidator (trustedCACertificateAnchors )::validateCertificateExpiry ,
8887 SubjectCertificatePurposeValidator ::validateCertificatePurpose ,
8988 new SubjectCertificatePolicyValidator (configuration .getDisallowedSubjectCertificatePolicies ())::validateCertificatePolicies
9089 );
@@ -109,7 +108,7 @@ public WebEidAuthToken parse(String authToken) throws AuthTokenException {
109108 validateTokenLength (authToken );
110109 return parseToken (authToken );
111110 } catch (Exception e ) {
112- // Generally "log and rethrow" is an anti-pattern , but it fits with the surrounding logging style.
111+ // Generally "log and rethrow" is an antipattern , but it fits with the surrounding logging style.
113112 LOG .warn ("Token parsing was interrupted:" , e );
114113 throw e ;
115114 }
@@ -121,7 +120,7 @@ public X509Certificate validate(WebEidAuthToken authToken, String currentChallen
121120 LOG .info ("Starting token validation" );
122121 return validateToken (authToken , currentChallengeNonce );
123122 } catch (Exception e ) {
124- // Generally "log and rethrow" is an anti-pattern , but it fits with the surrounding logging style.
123+ // Generally "log and rethrow" is an antipattern , but it fits with the surrounding logging style.
125124 LOG .warn ("Token validation was interrupted:" , e );
126125 throw e ;
127126 }
@@ -138,7 +137,7 @@ private void validateTokenLength(String authToken) throws AuthTokenParseExceptio
138137
139138 private WebEidAuthToken parseToken (String authToken ) throws AuthTokenParseException {
140139 try {
141- final WebEidAuthToken token = objectMapper .readValue (authToken , WebEidAuthToken . class );
140+ final WebEidAuthToken token = OBJECT_READER .readValue (authToken );
142141 if (token == null ) {
143142 throw new AuthTokenParseException ("Web eID authentication token is null" );
144143 }
@@ -185,7 +184,11 @@ private SubjectCertificateValidatorBatch getCertTrustValidators() {
185184 return SubjectCertificateValidatorBatch .createFrom (
186185 certTrustedValidator ::validateCertificateTrusted
187186 ).addOptional (configuration .isUserCertificateRevocationCheckWithOcspEnabled (),
188- new SubjectCertificateNotRevokedValidator (certTrustedValidator , ocspClient , ocspServiceProvider )::validateCertificateNotRevoked
187+ new SubjectCertificateNotRevokedValidator (certTrustedValidator ,
188+ ocspClient , ocspServiceProvider ,
189+ configuration .getAllowedOcspResponseTimeSkew (),
190+ configuration .getMaxOcspResponseThisUpdateAge ()
191+ )::validateCertificateNotRevoked
189192 );
190193 }
191194
0 commit comments