Skip to content

Commit 2bf84e0

Browse files
authored
Merge pull request auth0#150 from auth0/change-decode-return-type
Change the JWT.decode() return type to DecodedJWT
2 parents d84aa9d + e4f2aeb commit 2bf84e0

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ try {
9090
JWTVerifier verifier = JWT.require(Algorithm.HMAC256("secret"))
9191
.withIssuer("auth0")
9292
.build(); //Reusable verifier instance
93-
JWT jwt = verifier.verify(token);
93+
DecodedJWT jwt = verifier.verify(token);
9494
} catch (JWTVerificationException exception){
9595
//Invalid signature/claims
9696
}
@@ -105,7 +105,7 @@ try {
105105
JWTVerifier verifier = JWT.require(Algorithm.RSA256(key))
106106
.withIssuer("auth0")
107107
.build(); //Reusable verifier instance
108-
JWT jwt = verifier.verify(token);
108+
DecodedJWT jwt = verifier.verify(token);
109109
} catch (JWTVerificationException exception){
110110
//Invalid signature/claims
111111
}
@@ -155,7 +155,7 @@ JWTVerifier verifier = verification.build(clock);
155155
```java
156156
String token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXUyJ9.eyJpc3MiOiJhdXRoMCJ9.AbIJTDMFc7yUa5MhvcP03nJPyCPzZtQcGEp-zWfOkEE";
157157
try {
158-
JWT jwt = JWT.decode(token);
158+
DecodedJWT jwt = JWT.decode(token);
159159
} catch (JWTDecodeException exception){
160160
//Invalid token
161161
}

lib/src/main/java/com/auth0/jwt/JWT.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
public abstract class JWT implements DecodedJWT {
1010

1111
/**
12-
* Decode a given JWT token.
12+
* Decode a given Json Web Token.
1313
* <p>
1414
* Note that this method <b>doesn't verify the token's signature!</b> Use it only if you trust the token or you already verified it.
1515
*
1616
* @param token with jwt format as string.
17-
* @return a decoded token.
17+
* @return a decoded JWT.
1818
* @throws JWTDecodeException if any part of the token contained an invalid jwt or JSON format of each of the jwt parts.
1919
*/
20-
public static JWT decode(String token) throws JWTDecodeException {
20+
public static DecodedJWT decode(String token) throws JWTDecodeException {
2121
return new JWTDecoder(token);
2222
}
2323

@@ -33,9 +33,9 @@ public static Verification require(Algorithm algorithm) {
3333
}
3434

3535
/**
36-
* Returns a JWT builder used to create and sign jwt tokens
36+
* Returns a Json Web Token builder used to create and sign tokens
3737
*
38-
* @return a jwt token builder.
38+
* @return a token builder.
3939
*/
4040
public static JWTCreator.Builder create() {
4141
return JWTCreator.init();

0 commit comments

Comments
 (0)