Skip to content

Commit f7402bf

Browse files
committed
Some code changes
1 parent fd0d1b7 commit f7402bf

File tree

8 files changed

+11
-35
lines changed

8 files changed

+11
-35
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11

22

3-
# Java JWT [v3]
3+
# Java JWT
44

55
[![Build Status](https://travis-ci.org/auth0/java-jwt.svg?branch=v3)](https://travis-ci.org/auth0/java-jwt)
66
[![Coverage Status](https://img.shields.io/codecov/c/github/auth0/java-jwt/v3.svg?style=flat-square)](https://codecov.io/github/auth0/java-jwt)
77
[![License](http://img.shields.io/:license-mit-blue.svg?style=flat)](http://doge.mit-license.org)
88

9-
An implementation of [JSON Web Tokens](http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html) developed against `draft-ietf-oauth-json-web-token-08`.
9+
A Java implementation of [JSON Web Tokens (draft-ietf-oauth-json-web-token-08)](http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html)
1010

1111
## Installation
1212

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import java.util.List;
1010

1111
@SuppressWarnings("WeakerAccess")
12-
public final class JWT {
12+
public abstract class JWT implements DecodedJWT {
1313

1414
/**
1515
* Decode a given JWT token.
@@ -20,8 +20,8 @@ public final class JWT {
2020
* @return a decoded token.
2121
* @throws JWTDecodeException if any part of the token contained an invalid jwt or JSON format of each of the jwt parts.
2222
*/
23-
public static DecodedJWT decode(String token) throws JWTDecodeException {
24-
return JWTDecoder.decode(token);
23+
public static JWT decode(String token) throws JWTDecodeException {
24+
return new JWTDecoder(token);
2525
}
2626

2727
/**

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

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,18 @@
1616
* The JWTDecoder class holds the decode method to parse a given Token into it's DecodedJWT representation.
1717
*/
1818
@SuppressWarnings("WeakerAccess")
19-
final class JWTDecoder implements DecodedJWT {
19+
final class JWTDecoder extends JWT {
2020

2121
private final String token;
2222
private Header header;
2323
private Payload payload;
2424
private String signature;
2525

26-
private JWTDecoder(String jwt) throws JWTDecodeException {
26+
JWTDecoder(String jwt) throws JWTDecodeException {
2727
this.token = jwt;
2828
parseToken(jwt);
2929
}
3030

31-
/**
32-
* Decode a given Token into a DecodedJWT instance.
33-
* Note that this method doesn't verify the DecodedJWT's signature! Use it only if you trust the issuer of the Token.
34-
*
35-
* @param token the String representation of the DecodedJWT.
36-
* @return a decoded DecodedJWT.
37-
* @throws JWTDecodeException if any part of the Token contained an invalid DecodedJWT or JSON format.
38-
*/
39-
static DecodedJWT decode(String token) throws JWTDecodeException {
40-
return new JWTDecoder(token);
41-
}
42-
4331
private void parseToken(String token) throws JWTDecodeException {
4432
final String[] parts = TokenUtils.splitToken(token);
4533
final JWTParser converter = new JWTParser();

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ private void verifyClaims(DecodedJWT jwt, Map<String, Object> claims) {
260260
for (Map.Entry<String, Object> entry : claims.entrySet()) {
261261
switch (entry.getKey()) {
262262
case PublicClaims.AUDIENCE:
263+
//noinspection unchecked
263264
assertValidAudienceClaim(jwt.getAudience(), (List<String>) entry.getValue());
264265
break;
265266
case PublicClaims.EXPIRES_AT:

lib/src/main/java/com/auth0/jwt/interfaces/DecodedJWT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
* The DecodedJWT class represents a Json Web Token.
55
*/
66
public interface DecodedJWT extends Payload, Header, Signature {
7+
String getToken();
78
}

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

Lines changed: 0 additions & 14 deletions
This file was deleted.

lib/src/test/java/com/auth0/jwt/ConcurrentVerifyTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class ConcurrentVerifyTest {
2222

2323
private static final long TIMEOUT = 10 * 1000 * 1000; //1 min
2424
private static final int THREAD_COUNT = 100;
25-
private static final int REPEAT_COUNT = 2000;
25+
private static final int REPEAT_COUNT = 1000;
2626
private static final String PUBLIC_KEY_FILE = "src/test/resources/rsa-public.pem";
2727
private static final String PUBLIC_KEY_FILE_256 = "src/test/resources/ec256-key-public.pem";
2828
private static final String PUBLIC_KEY_FILE_384 = "src/test/resources/ec384-key-public.pem";

lib/src/test/java/com/auth0/jwt/JWTTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void shouldDecodeAStringToken() throws Exception {
4646
// getToken
4747
@Test
4848
public void shouldGetStringToken() throws Exception {
49-
JWT jwt = JWT.decode("eyJhbGciOiJIUzI1NiJ9.e30.XmNK3GpH3Ys_7wsYBfq4C3M6goz71I7dTgUkuIa5lyQ");
49+
DecodedJWT jwt = JWT.decode("eyJhbGciOiJIUzI1NiJ9.e30.XmNK3GpH3Ys_7wsYBfq4C3M6goz71I7dTgUkuIa5lyQ");
5050
assertThat(jwt, is(notNullValue()));
5151
assertThat(jwt.getToken(), is(notNullValue()));
5252
assertThat(jwt.getToken(), is("eyJhbGciOiJIUzI1NiJ9.e30.XmNK3GpH3Ys_7wsYBfq4C3M6goz71I7dTgUkuIa5lyQ"));

0 commit comments

Comments
 (0)