Skip to content

Commit

Permalink
Merge pull request #150 from auth0/change-decode-return-type
Browse files Browse the repository at this point in the history
Change the JWT.decode() return type to DecodedJWT
  • Loading branch information
lbalmaceda authored Mar 14, 2017
2 parents d84aa9d + e4f2aeb commit 2bf84e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ try {
JWTVerifier verifier = JWT.require(Algorithm.HMAC256("secret"))
.withIssuer("auth0")
.build(); //Reusable verifier instance
JWT jwt = verifier.verify(token);
DecodedJWT jwt = verifier.verify(token);
} catch (JWTVerificationException exception){
//Invalid signature/claims
}
Expand All @@ -105,7 +105,7 @@ try {
JWTVerifier verifier = JWT.require(Algorithm.RSA256(key))
.withIssuer("auth0")
.build(); //Reusable verifier instance
JWT jwt = verifier.verify(token);
DecodedJWT jwt = verifier.verify(token);
} catch (JWTVerificationException exception){
//Invalid signature/claims
}
Expand Down Expand Up @@ -155,7 +155,7 @@ JWTVerifier verifier = verification.build(clock);
```java
String token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXUyJ9.eyJpc3MiOiJhdXRoMCJ9.AbIJTDMFc7yUa5MhvcP03nJPyCPzZtQcGEp-zWfOkEE";
try {
JWT jwt = JWT.decode(token);
DecodedJWT jwt = JWT.decode(token);
} catch (JWTDecodeException exception){
//Invalid token
}
Expand Down
10 changes: 5 additions & 5 deletions lib/src/main/java/com/auth0/jwt/JWT.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
public abstract class JWT implements DecodedJWT {

/**
* Decode a given JWT token.
* Decode a given Json Web Token.
* <p>
* 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.
*
* @param token with jwt format as string.
* @return a decoded token.
* @return a decoded JWT.
* @throws JWTDecodeException if any part of the token contained an invalid jwt or JSON format of each of the jwt parts.
*/
public static JWT decode(String token) throws JWTDecodeException {
public static DecodedJWT decode(String token) throws JWTDecodeException {
return new JWTDecoder(token);
}

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

/**
* Returns a JWT builder used to create and sign jwt tokens
* Returns a Json Web Token builder used to create and sign tokens
*
* @return a jwt token builder.
* @return a token builder.
*/
public static JWTCreator.Builder create() {
return JWTCreator.init();
Expand Down

0 comments on commit 2bf84e0

Please sign in to comment.