77import com .auth0 .jwt .exceptions .SignatureVerificationException ;
88import com .auth0 .jwt .impl .PublicClaims ;
99import com .auth0 .jwt .interfaces .Claim ;
10+ import com .auth0 .jwt .interfaces .Clock ;
1011import com .auth0 .jwt .interfaces .DecodedJWT ;
12+ import com .auth0 .jwt .interfaces .Verification ;
1113import org .apache .commons .codec .binary .Base64 ;
1214
1315import java .nio .charset .StandardCharsets ;
@@ -35,19 +37,19 @@ public final class JWTVerifier {
3537 * @return a JWTVerifier.Verification instance to configure.
3638 * @throws IllegalArgumentException if the provided algorithm is null.
3739 */
38- static JWTVerifier . Verification init (Algorithm algorithm ) throws IllegalArgumentException {
39- return new Verification (algorithm );
40+ static Verification init (Algorithm algorithm ) throws IllegalArgumentException {
41+ return new BaseVerification (algorithm );
4042 }
4143
4244 /**
4345 * The Verification class holds the Claims required by a JWT to be valid.
4446 */
45- public static class Verification {
47+ public static class BaseVerification implements Verification {
4648 private final Algorithm algorithm ;
4749 private final Map <String , Object > claims ;
4850 private long defaultLeeway ;
4951
50- Verification (Algorithm algorithm ) throws IllegalArgumentException {
52+ BaseVerification (Algorithm algorithm ) throws IllegalArgumentException {
5153 if (algorithm == null ) {
5254 throw new IllegalArgumentException ("The Algorithm cannot be null." );
5355 }
@@ -63,6 +65,7 @@ public static class Verification {
6365 * @param issuer the required Issuer value
6466 * @return this same Verification instance.
6567 */
68+ @ Override
6669 public Verification withIssuer (String issuer ) {
6770 requireClaim (PublicClaims .ISSUER , issuer );
6871 return this ;
@@ -74,6 +77,7 @@ public Verification withIssuer(String issuer) {
7477 * @param subject the required Subject value
7578 * @return this same Verification instance.
7679 */
80+ @ Override
7781 public Verification withSubject (String subject ) {
7882 requireClaim (PublicClaims .SUBJECT , subject );
7983 return this ;
@@ -85,6 +89,7 @@ public Verification withSubject(String subject) {
8589 * @param audience the required Audience value
8690 * @return this same Verification instance.
8791 */
92+ @ Override
8893 public Verification withAudience (String ... audience ) {
8994 requireClaim (PublicClaims .AUDIENCE , Arrays .asList (audience ));
9095 return this ;
@@ -98,6 +103,7 @@ public Verification withAudience(String... audience) {
98103 * @return this same Verification instance.
99104 * @throws IllegalArgumentException if leeway is negative.
100105 */
106+ @ Override
101107 public Verification acceptLeeway (long leeway ) throws IllegalArgumentException {
102108 assertPositive (leeway );
103109 this .defaultLeeway = leeway ;
@@ -112,6 +118,7 @@ public Verification acceptLeeway(long leeway) throws IllegalArgumentException {
112118 * @return this same Verification instance.
113119 * @throws IllegalArgumentException if leeway is negative.
114120 */
121+ @ Override
115122 public Verification acceptExpiresAt (long leeway ) throws IllegalArgumentException {
116123 assertPositive (leeway );
117124 requireClaim (PublicClaims .EXPIRES_AT , leeway );
@@ -126,6 +133,7 @@ public Verification acceptExpiresAt(long leeway) throws IllegalArgumentException
126133 * @return this same Verification instance.
127134 * @throws IllegalArgumentException if leeway is negative.
128135 */
136+ @ Override
129137 public Verification acceptNotBefore (long leeway ) throws IllegalArgumentException {
130138 assertPositive (leeway );
131139 requireClaim (PublicClaims .NOT_BEFORE , leeway );
@@ -140,6 +148,7 @@ public Verification acceptNotBefore(long leeway) throws IllegalArgumentException
140148 * @return this same Verification instance.
141149 * @throws IllegalArgumentException if leeway is negative.
142150 */
151+ @ Override
143152 public Verification acceptIssuedAt (long leeway ) throws IllegalArgumentException {
144153 assertPositive (leeway );
145154 requireClaim (PublicClaims .ISSUED_AT , leeway );
@@ -152,6 +161,7 @@ public Verification acceptIssuedAt(long leeway) throws IllegalArgumentException
152161 * @param jwtId the required Id value
153162 * @return this same Verification instance.
154163 */
164+ @ Override
155165 public Verification withJWTId (String jwtId ) {
156166 requireClaim (PublicClaims .JWT_ID , jwtId );
157167 return this ;
@@ -165,6 +175,7 @@ public Verification withJWTId(String jwtId) {
165175 * @return this same Verification instance.
166176 * @throws IllegalArgumentException if the name is null.
167177 */
178+ @ Override
168179 public Verification withClaim (String name , Boolean value ) throws IllegalArgumentException {
169180 assertNonNull (name );
170181 requireClaim (name , value );
@@ -179,6 +190,7 @@ public Verification withClaim(String name, Boolean value) throws IllegalArgument
179190 * @return this same Verification instance.
180191 * @throws IllegalArgumentException if the name is null.
181192 */
193+ @ Override
182194 public Verification withClaim (String name , Integer value ) throws IllegalArgumentException {
183195 assertNonNull (name );
184196 requireClaim (name , value );
@@ -193,6 +205,7 @@ public Verification withClaim(String name, Integer value) throws IllegalArgument
193205 * @return this same Verification instance.
194206 * @throws IllegalArgumentException if the name is null.
195207 */
208+ @ Override
196209 public Verification withClaim (String name , Double value ) throws IllegalArgumentException {
197210 assertNonNull (name );
198211 requireClaim (name , value );
@@ -207,6 +220,7 @@ public Verification withClaim(String name, Double value) throws IllegalArgumentE
207220 * @return this same Verification instance.
208221 * @throws IllegalArgumentException if the name is null.
209222 */
223+ @ Override
210224 public Verification withClaim (String name , String value ) throws IllegalArgumentException {
211225 assertNonNull (name );
212226 requireClaim (name , value );
@@ -221,6 +235,7 @@ public Verification withClaim(String name, String value) throws IllegalArgumentE
221235 * @return this same Verification instance.
222236 * @throws IllegalArgumentException if the name is null.
223237 */
238+ @ Override
224239 public Verification withClaim (String name , Date value ) throws IllegalArgumentException {
225240 assertNonNull (name );
226241 requireClaim (name , value );
@@ -235,6 +250,7 @@ public Verification withClaim(String name, Date value) throws IllegalArgumentExc
235250 * @return this same Verification instance.
236251 * @throws IllegalArgumentException if the name is null.
237252 */
253+ @ Override
238254 public Verification withArrayClaim (String name , String ... items ) throws IllegalArgumentException {
239255 assertNonNull (name );
240256 requireClaim (name , items );
@@ -249,6 +265,7 @@ public Verification withArrayClaim(String name, String... items) throws IllegalA
249265 * @return this same Verification instance.
250266 * @throws IllegalArgumentException if the name is null.
251267 */
268+ @ Override
252269 public Verification withArrayClaim (String name , Integer ... items ) throws IllegalArgumentException {
253270 assertNonNull (name );
254271 requireClaim (name , items );
@@ -260,8 +277,9 @@ public Verification withArrayClaim(String name, Integer... items) throws Illegal
260277 *
261278 * @return a new JWTVerifier instance.
262279 */
280+ @ Override
263281 public JWTVerifier build () {
264- return this .build (new Clock ());
282+ return this .build (new ClockImpl ());
265283 }
266284
267285 /**
@@ -271,7 +289,7 @@ public JWTVerifier build() {
271289 * @param clock the instance that will handle the current time.
272290 * @return a new JWTVerifier instance with a custom Clock.
273291 */
274- JWTVerifier build (Clock clock ) {
292+ public JWTVerifier build (Clock clock ) {
275293 addLeewayToDateClaims ();
276294 return new JWTVerifier (algorithm , claims , clock );
277295 }
0 commit comments