File tree Expand file tree Collapse file tree 6 files changed +31
-6
lines changed
Expand file tree Collapse file tree 6 files changed +31
-6
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ script:
1515after_success :
1616 - bash <(curl -s https://codecov.io/bash)
1717after_failure :
18- - cat file:///home /travis/build/auth0/java-jwt/lib/build/reports/tests/index.html
18+ - cat $HOME /travis/build/auth0/java-jwt/lib/build/reports/tests/index.html
1919branches :
2020 only :
2121 - v3
Original file line number Diff line number Diff line change @@ -117,4 +117,9 @@ public String getContentType() {
117117 public String getKeyId () {
118118 return jwt .getKeyId ();
119119 }
120+
121+ @ Override
122+ public String getToken () {
123+ return jwt .getToken ();
124+ }
120125}
Original file line number Diff line number Diff line change 1818@ SuppressWarnings ("WeakerAccess" )
1919final class JWTDecoder implements JWT {
2020
21+ private final String token ;
2122 private Header header ;
2223 private Payload payload ;
2324 private String signature ;
2425
2526 private JWTDecoder (String jwt ) throws JWTDecodeException {
27+ this .token = jwt ;
2628 parseToken (jwt );
2729 }
2830
@@ -124,4 +126,8 @@ public String getSignature() {
124126 return signature ;
125127 }
126128
129+ @ Override
130+ public String getToken () {
131+ return token ;
132+ }
127133}
Original file line number Diff line number Diff line change 44 * The JWT class represents a Json Web Token.
55 */
66public interface JWT extends Payload , Header , Signature {
7+
8+ /**
9+ * Returns the String representation of the token.
10+ *
11+ * @return the String representation of the token.
12+ */
13+ String getToken ();
714}
Original file line number Diff line number Diff line change 77import org .apache .commons .codec .binary .Base64 ;
88import org .hamcrest .collection .IsCollectionWithSize ;
99import org .hamcrest .core .IsCollectionContaining ;
10- import org .junit .Ignore ;
1110import org .junit .Rule ;
1211import org .junit .Test ;
1312import org .junit .rules .ExpectedException ;
@@ -61,14 +60,13 @@ public void shouldThrowIfHeaderHasInvalidJSONFormat() throws Exception {
6160 customJWT (invalidJson , validJson , "signature" );
6261 }
6362
64- // toString
63+ // getToken
6564 @ Test
66- @ Ignore ("Pending implementation" )
6765 public void shouldGetStringToken () throws Exception {
6866 JWT jwt = JWTDecoder .decode ("eyJhbGciOiJIUzI1NiJ9.e30.XmNK3GpH3Ys_7wsYBfq4C3M6goz71I7dTgUkuIa5lyQ" );
6967 assertThat (jwt , is (notNullValue ()));
70- assertThat (jwt .toString (), is (notNullValue ()));
71- assertThat (jwt .toString (), is ("eyJhbGciOiJIUzI1NiJ9.e30.XmNK3GpH3Ys_7wsYBfq4C3M6goz71I7dTgUkuIa5lyQ" ));
68+ assertThat (jwt .getToken (), is (notNullValue ()));
69+ assertThat (jwt .getToken (), is ("eyJhbGciOiJIUzI1NiJ9.e30.XmNK3GpH3Ys_7wsYBfq4C3M6goz71I7dTgUkuIa5lyQ" ));
7270 }
7371
7472 // Parts
Original file line number Diff line number Diff line change @@ -42,6 +42,15 @@ public void shouldDecodeAStringToken() throws Exception {
4242 assertThat (jwt , is (notNullValue ()));
4343 }
4444
45+ // getToken
46+ @ Test
47+ public void shouldGetStringToken () throws Exception {
48+ JWT jwt = JWT .decode ("eyJhbGciOiJIUzI1NiJ9.e30.XmNK3GpH3Ys_7wsYBfq4C3M6goz71I7dTgUkuIa5lyQ" );
49+ assertThat (jwt , is (notNullValue ()));
50+ assertThat (jwt .getToken (), is (notNullValue ()));
51+ assertThat (jwt .getToken (), is ("eyJhbGciOiJIUzI1NiJ9.e30.XmNK3GpH3Ys_7wsYBfq4C3M6goz71I7dTgUkuIa5lyQ" ));
52+ }
53+
4554
4655 // Verify
4756
You can’t perform that action at this time.
0 commit comments