@Test public void tokenExpires_afterClockSkewLeeway_isValid() { Token token = tokenFactory.withExpiration(NOW.plus(ONE_MINUTE)).build(); ValidationResult validationResult = cut.validate(token); assertThat(validationResult.isValid()).isTrue(); }
@Override public ValidationResult validate(Token token) { ValidationResult validationResult; Instant expiration = token.getExpiration(); if (expiration != null) { validationResult = checkExpiration(expiration); } else { return ValidationResults.createInvalid("Jwt does not contain expiration (exp) claim. Cannot be validated!"); } Instant notBefore = token.getNotBefore(); if (notBefore != null && validationResult.isValid()) { validationResult = checkNotBefore(notBefore); } return validationResult; }
JwtTimestampValidator implements Validator<Token> { @Override public ValidationResult validate(Token token) { ValidationResult validationResult; Instant expiration = token.getExpiration(); if (expiration != null) { validationResult = checkExpiration(expiration); } else { return ValidationResults.createInvalid("Jwt does not contain expiration (exp) claim. Cannot be validated!"); } Instant notBefore = token.getNotBefore(); if (notBefore != null && validationResult.isValid()) { validationResult = checkNotBefore(notBefore); } return validationResult; } }
JwtTimestampValidator implements Validator<Token> { @Override public ValidationResult validate(Token token) { ValidationResult validationResult; Instant expiration = token.getExpiration(); if (expiration != null) { validationResult = checkExpiration(expiration); } else { return ValidationResults.createInvalid("Jwt does not contain expiration (exp) claim. Cannot be validated!"); } Instant notBefore = token.getNotBefore(); if (notBefore != null && validationResult.isValid()) { validationResult = checkNotBefore(notBefore); } return validationResult; } JwtTimestampValidator();   JwtTimestampValidator(Supplier<Instant> timeProvider, @Nullable TemporalAmount tolerance); }
JwtTimestampValidator implements Validator<Token> { @Override public ValidationResult validate(Token token) { ValidationResult validationResult; Instant expiration = token.getExpiration(); if (expiration != null) { validationResult = checkExpiration(expiration); } else { return ValidationResults.createInvalid("Jwt does not contain expiration (exp) claim. Cannot be validated!"); } Instant notBefore = token.getNotBefore(); if (notBefore != null && validationResult.isValid()) { validationResult = checkNotBefore(notBefore); } return validationResult; } JwtTimestampValidator();   JwtTimestampValidator(Supplier<Instant> timeProvider, @Nullable TemporalAmount tolerance); @Override ValidationResult validate(Token token); }
JwtTimestampValidator implements Validator<Token> { @Override public ValidationResult validate(Token token) { ValidationResult validationResult; Instant expiration = token.getExpiration(); if (expiration != null) { validationResult = checkExpiration(expiration); } else { return ValidationResults.createInvalid("Jwt does not contain expiration (exp) claim. Cannot be validated!"); } Instant notBefore = token.getNotBefore(); if (notBefore != null && validationResult.isValid()) { validationResult = checkNotBefore(notBefore); } return validationResult; } JwtTimestampValidator();   JwtTimestampValidator(Supplier<Instant> timeProvider, @Nullable TemporalAmount tolerance); @Override ValidationResult validate(Token token);  }