44
44
public final class JwtTimestampValidator implements OAuth2TokenValidator <Jwt > {
45
45
private static final Duration DEFAULT_MAX_CLOCK_SKEW = Duration .of (60 , ChronoUnit .SECONDS );
46
46
47
- private final Duration maxClockSkew ;
47
+ private final Duration clockSkew ;
48
48
49
49
private Clock clock = Clock .systemUTC ();
50
50
@@ -55,10 +55,10 @@ public JwtTimestampValidator() {
55
55
this (DEFAULT_MAX_CLOCK_SKEW );
56
56
}
57
57
58
- public JwtTimestampValidator (Duration maxClockSkew ) {
59
- Assert .notNull (maxClockSkew , "maxClockSkew cannot be null" );
58
+ public JwtTimestampValidator (Duration clockSkew ) {
59
+ Assert .notNull (clockSkew , "clockSkew cannot be null" );
60
60
61
- this .maxClockSkew = maxClockSkew ;
61
+ this .clockSkew = clockSkew ;
62
62
}
63
63
64
64
/**
@@ -71,7 +71,7 @@ public OAuth2TokenValidatorResult validate(Jwt jwt) {
71
71
Instant expiry = jwt .getExpiresAt ();
72
72
73
73
if (expiry != null ) {
74
- if (Instant .now (this .clock ).minus (maxClockSkew ).isAfter (expiry )) {
74
+ if (Instant .now (this .clock ).minus (clockSkew ).isAfter (expiry )) {
75
75
OAuth2Error error = new OAuth2Error (
76
76
OAuth2ErrorCodes .INVALID_REQUEST ,
77
77
String .format ("Jwt expired at %s" , jwt .getExpiresAt ()),
@@ -83,7 +83,7 @@ public OAuth2TokenValidatorResult validate(Jwt jwt) {
83
83
Instant notBefore = jwt .getNotBefore ();
84
84
85
85
if (notBefore != null ) {
86
- if (Instant .now (this .clock ).plus (maxClockSkew ).isBefore (notBefore )) {
86
+ if (Instant .now (this .clock ).plus (clockSkew ).isBefore (notBefore )) {
87
87
OAuth2Error error = new OAuth2Error (
88
88
OAuth2ErrorCodes .INVALID_REQUEST ,
89
89
String .format ("Jwt used before %s" , jwt .getNotBefore ()),
0 commit comments