77import com .auth0 .jwt .exceptions .SignatureVerificationException ;
88import com .auth0 .jwt .impl .PublicClaims ;
99import com .auth0 .jwt .interfaces .Claim ;
10+ import com .auth0 .jwt .interfaces .DecodedJWT ;
1011import org .apache .commons .codec .binary .Base64 ;
1112
1213import java .util .*;
1314
1415/**
15- * The JWTVerifier class holds the verify method to assert that a given Token has not only a proper JWT format, but also it's signature matches.
16+ * The JWTVerifier class holds the verify method to assert that a given Token has not only a proper DecodedJWT format, but also it's signature matches.
1617 */
1718@ SuppressWarnings ("WeakerAccess" )
1819public final class JWTVerifier {
@@ -29,7 +30,7 @@ public final class JWTVerifier {
2930 /**
3031 * Initialize a JWTVerifier instance using the given Algorithm.
3132 *
32- * @param algorithm the Algorithm to use on the JWT verification.
33+ * @param algorithm the Algorithm to use on the DecodedJWT verification.
3334 * @return a JWTVerifier.Verification instance to configure.
3435 * @throws IllegalArgumentException if the provided algorithm is null.
3536 */
@@ -38,7 +39,7 @@ static JWTVerifier.Verification init(Algorithm algorithm) throws IllegalArgument
3839 }
3940
4041 /**
41- * The Verification class holds the Claims required by a JWT to be valid.
42+ * The Verification class holds the Claims required by a DecodedJWT to be valid.
4243 */
4344 public static class Verification {
4445 private final Algorithm algorithm ;
@@ -153,7 +154,7 @@ public Verification acceptIssuedAt(long leeway) throws IllegalArgumentException
153154 }
154155
155156 /**
156- * Require a specific JWT Id ("jti") claim.
157+ * Require a specific DecodedJWT Id ("jti") claim.
157158 *
158159 * @param jwtId the required Id value
159160 * @return this same Verification instance.
@@ -231,12 +232,12 @@ private void requireClaim(String name, Object value) {
231232 /**
232233 * Perform the verification against the given Token, using any previous configured options.
233234 *
234- * @param token the String representation of the JWT .
235- * @return a verified JWT .
236- * @throws JWTVerificationException if any of the required contents inside the JWT is invalid.
235+ * @param token the String representation of the DecodedJWT .
236+ * @return a verified DecodedJWT .
237+ * @throws JWTVerificationException if any of the required contents inside the DecodedJWT is invalid.
237238 */
238- public JWT verify (String token ) throws JWTVerificationException {
239- JWT jwt = new JWT ( JWTDecoder .decode (token ) );
239+ public DecodedJWT verify (String token ) throws JWTVerificationException {
240+ DecodedJWT jwt = JWTDecoder .decode (token );
240241 verifyAlgorithm (jwt , algorithm );
241242 verifySignature (TokenUtils .splitToken (token ));
242243 verifyClaims (jwt , claims );
@@ -249,16 +250,17 @@ private void verifySignature(String[] parts) throws SignatureVerificationExcepti
249250 algorithm .verify (content , signature );
250251 }
251252
252- private void verifyAlgorithm (JWT jwt , Algorithm expectedAlgorithm ) throws AlgorithmMismatchException {
253+ private void verifyAlgorithm (DecodedJWT jwt , Algorithm expectedAlgorithm ) throws AlgorithmMismatchException {
253254 if (!expectedAlgorithm .getName ().equals (jwt .getAlgorithm ())) {
254- throw new AlgorithmMismatchException ("The provided Algorithm doesn't match the one defined in the JWT 's Header." );
255+ throw new AlgorithmMismatchException ("The provided Algorithm doesn't match the one defined in the DecodedJWT 's Header." );
255256 }
256257 }
257258
258- private void verifyClaims (JWT jwt , Map <String , Object > claims ) {
259+ private void verifyClaims (DecodedJWT jwt , Map <String , Object > claims ) {
259260 for (Map .Entry <String , Object > entry : claims .entrySet ()) {
260261 switch (entry .getKey ()) {
261262 case PublicClaims .AUDIENCE :
263+ //noinspection unchecked
262264 assertValidAudienceClaim (jwt .getAudience (), (List <String >) entry .getValue ());
263265 break ;
264266 case PublicClaims .EXPIRES_AT :
0 commit comments