Skip to content

Commit 36f58e5

Browse files
committed
add claimName to InvalidClaimException
1 parent 24b2fa9 commit 36f58e5

File tree

3 files changed

+17
-25
lines changed

3 files changed

+17
-25
lines changed

lib/src/main/java/com/auth0/jwt/exceptions/IncorrectClaimException.java

+1-12
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* This exception is thrown when the expected value is not found while verifying the Claims.
77
*/
88
public class IncorrectClaimException extends InvalidClaimException {
9-
private final String claimName;
109

1110
private final Claim claimValue;
1211

@@ -19,20 +18,10 @@ public class IncorrectClaimException extends InvalidClaimException {
1918
* @param claim The Claim value for which verification failed
2019
*/
2120
public IncorrectClaimException(String message, String claimName, Claim claim) {
22-
super(message);
23-
this.claimName = claimName;
21+
super(message, claimName);
2422
this.claimValue = claim;
2523
}
2624

27-
/**
28-
* This method can be used to fetch the name for which the Claim verification failed.
29-
*
30-
* @return The claim name for which the verification failed.
31-
*/
32-
public String getClaimName() {
33-
return claimName;
34-
}
35-
3625
/**
3726
* This method can be used to fetch the value for which the Claim verification failed.
3827
*

lib/src/main/java/com/auth0/jwt/exceptions/InvalidClaimException.java

+15-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,21 @@
44
* The exception that will be thrown while verifying Claims of a JWT.
55
*/
66
public class InvalidClaimException extends JWTVerificationException {
7-
public InvalidClaimException(String message) {
7+
8+
private final String claimName;
9+
10+
public InvalidClaimException(String message, String claimName) {
811
super(message);
12+
this.claimName = claimName;
913
}
14+
15+
/**
16+
* This method can be used to fetch the name for which the Claim verification failed.
17+
*
18+
* @return The claim name for which the verification failed.
19+
*/
20+
public String getClaimName() {
21+
return claimName;
22+
}
23+
1024
}

lib/src/main/java/com/auth0/jwt/exceptions/MissingClaimException.java

+1-12
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,8 @@
55
*/
66
public class MissingClaimException extends InvalidClaimException {
77

8-
private final String claimName;
9-
108
public MissingClaimException(String claimName) {
11-
super(String.format("The Claim '%s' is not present in the JWT.", claimName));
12-
this.claimName = claimName;
9+
super(String.format("The Claim '%s' is not present in the JWT.", claimName), claimName);
1310
}
1411

15-
/**
16-
* This method can be used to fetch the name for which the Claim is missing during the verification.
17-
*
18-
* @return The name of the Claim that doesn't exist.
19-
*/
20-
public String getClaimName() {
21-
return claimName;
22-
}
2312
}

0 commit comments

Comments
 (0)