88import com .auth0 .jwt .impl .PublicClaims ;
99import com .auth0 .jwt .interfaces .Claim ;
1010import com .auth0 .jwt .interfaces .DecodedJWT ;
11+ import com .auth0 .jwt .interfaces .Verification ;
1112import org .apache .commons .codec .binary .Base64 ;
1213
1314import java .nio .charset .StandardCharsets ;
@@ -35,19 +36,19 @@ public final class JWTVerifier {
3536 * @return a JWTVerifier.Verification instance to configure.
3637 * @throws IllegalArgumentException if the provided algorithm is null.
3738 */
38- static JWTVerifier . Verification init (Algorithm algorithm ) throws IllegalArgumentException {
39- return new Verification (algorithm );
39+ static Verification init (Algorithm algorithm ) throws IllegalArgumentException {
40+ return new BaseVerification (algorithm );
4041 }
4142
4243 /**
4344 * The Verification class holds the Claims required by a JWT to be valid.
4445 */
45- public static class Verification {
46+ public static class BaseVerification implements Verification {
4647 private final Algorithm algorithm ;
4748 private final Map <String , Object > claims ;
4849 private long defaultLeeway ;
4950
50- Verification (Algorithm algorithm ) throws IllegalArgumentException {
51+ BaseVerification (Algorithm algorithm ) throws IllegalArgumentException {
5152 if (algorithm == null ) {
5253 throw new IllegalArgumentException ("The Algorithm cannot be null." );
5354 }
@@ -63,6 +64,7 @@ public static class Verification {
6364 * @param issuer the required Issuer value
6465 * @return this same Verification instance.
6566 */
67+ @ Override
6668 public Verification withIssuer (String issuer ) {
6769 requireClaim (PublicClaims .ISSUER , issuer );
6870 return this ;
@@ -74,6 +76,7 @@ public Verification withIssuer(String issuer) {
7476 * @param subject the required Subject value
7577 * @return this same Verification instance.
7678 */
79+ @ Override
7780 public Verification withSubject (String subject ) {
7881 requireClaim (PublicClaims .SUBJECT , subject );
7982 return this ;
@@ -85,6 +88,7 @@ public Verification withSubject(String subject) {
8588 * @param audience the required Audience value
8689 * @return this same Verification instance.
8790 */
91+ @ Override
8892 public Verification withAudience (String ... audience ) {
8993 requireClaim (PublicClaims .AUDIENCE , Arrays .asList (audience ));
9094 return this ;
@@ -98,6 +102,7 @@ public Verification withAudience(String... audience) {
98102 * @return this same Verification instance.
99103 * @throws IllegalArgumentException if leeway is negative.
100104 */
105+ @ Override
101106 public Verification acceptLeeway (long leeway ) throws IllegalArgumentException {
102107 assertPositive (leeway );
103108 this .defaultLeeway = leeway ;
@@ -112,6 +117,7 @@ public Verification acceptLeeway(long leeway) throws IllegalArgumentException {
112117 * @return this same Verification instance.
113118 * @throws IllegalArgumentException if leeway is negative.
114119 */
120+ @ Override
115121 public Verification acceptExpiresAt (long leeway ) throws IllegalArgumentException {
116122 assertPositive (leeway );
117123 requireClaim (PublicClaims .EXPIRES_AT , leeway );
@@ -126,6 +132,7 @@ public Verification acceptExpiresAt(long leeway) throws IllegalArgumentException
126132 * @return this same Verification instance.
127133 * @throws IllegalArgumentException if leeway is negative.
128134 */
135+ @ Override
129136 public Verification acceptNotBefore (long leeway ) throws IllegalArgumentException {
130137 assertPositive (leeway );
131138 requireClaim (PublicClaims .NOT_BEFORE , leeway );
@@ -140,6 +147,7 @@ public Verification acceptNotBefore(long leeway) throws IllegalArgumentException
140147 * @return this same Verification instance.
141148 * @throws IllegalArgumentException if leeway is negative.
142149 */
150+ @ Override
143151 public Verification acceptIssuedAt (long leeway ) throws IllegalArgumentException {
144152 assertPositive (leeway );
145153 requireClaim (PublicClaims .ISSUED_AT , leeway );
@@ -152,6 +160,7 @@ public Verification acceptIssuedAt(long leeway) throws IllegalArgumentException
152160 * @param jwtId the required Id value
153161 * @return this same Verification instance.
154162 */
163+ @ Override
155164 public Verification withJWTId (String jwtId ) {
156165 requireClaim (PublicClaims .JWT_ID , jwtId );
157166 return this ;
@@ -165,6 +174,7 @@ public Verification withJWTId(String jwtId) {
165174 * @return this same Verification instance.
166175 * @throws IllegalArgumentException if the name is null.
167176 */
177+ @ Override
168178 public Verification withClaim (String name , Boolean value ) throws IllegalArgumentException {
169179 assertNonNull (name );
170180 requireClaim (name , value );
@@ -179,6 +189,7 @@ public Verification withClaim(String name, Boolean value) throws IllegalArgument
179189 * @return this same Verification instance.
180190 * @throws IllegalArgumentException if the name is null.
181191 */
192+ @ Override
182193 public Verification withClaim (String name , Integer value ) throws IllegalArgumentException {
183194 assertNonNull (name );
184195 requireClaim (name , value );
@@ -193,6 +204,7 @@ public Verification withClaim(String name, Integer value) throws IllegalArgument
193204 * @return this same Verification instance.
194205 * @throws IllegalArgumentException if the name is null.
195206 */
207+ @ Override
196208 public Verification withClaim (String name , Double value ) throws IllegalArgumentException {
197209 assertNonNull (name );
198210 requireClaim (name , value );
@@ -207,6 +219,7 @@ public Verification withClaim(String name, Double value) throws IllegalArgumentE
207219 * @return this same Verification instance.
208220 * @throws IllegalArgumentException if the name is null.
209221 */
222+ @ Override
210223 public Verification withClaim (String name , String value ) throws IllegalArgumentException {
211224 assertNonNull (name );
212225 requireClaim (name , value );
@@ -221,6 +234,7 @@ public Verification withClaim(String name, String value) throws IllegalArgumentE
221234 * @return this same Verification instance.
222235 * @throws IllegalArgumentException if the name is null.
223236 */
237+ @ Override
224238 public Verification withClaim (String name , Date value ) throws IllegalArgumentException {
225239 assertNonNull (name );
226240 requireClaim (name , value );
@@ -235,6 +249,7 @@ public Verification withClaim(String name, Date value) throws IllegalArgumentExc
235249 * @return this same Verification instance.
236250 * @throws IllegalArgumentException if the name is null.
237251 */
252+ @ Override
238253 public Verification withArrayClaim (String name , String ... items ) throws IllegalArgumentException {
239254 assertNonNull (name );
240255 requireClaim (name , items );
@@ -249,6 +264,7 @@ public Verification withArrayClaim(String name, String... items) throws IllegalA
249264 * @return this same Verification instance.
250265 * @throws IllegalArgumentException if the name is null.
251266 */
267+ @ Override
252268 public Verification withArrayClaim (String name , Integer ... items ) throws IllegalArgumentException {
253269 assertNonNull (name );
254270 requireClaim (name , items );
@@ -260,6 +276,7 @@ public Verification withArrayClaim(String name, Integer... items) throws Illegal
260276 *
261277 * @return a new JWTVerifier instance.
262278 */
279+ @ Override
263280 public JWTVerifier build () {
264281 return this .build (new Clock ());
265282 }
@@ -271,7 +288,7 @@ public JWTVerifier build() {
271288 * @param clock the instance that will handle the current time.
272289 * @return a new JWTVerifier instance with a custom Clock.
273290 */
274- JWTVerifier build (Clock clock ) {
291+ public JWTVerifier build (Clock clock ) {
275292 addLeewayToDateClaims ();
276293 return new JWTVerifier (algorithm , claims , clock );
277294 }
0 commit comments