@@ -25,7 +25,7 @@ public class JWTDecoderTest {
2525
2626 @ Test
2727 public void getSubject () throws Exception {
28- DecodedJWT jwt = JWTDecoder .decode ("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ" );
28+ DecodedJWT jwt = JWT .decode ("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ" );
2929 assertThat (jwt .getSubject (), is (notNullValue ()));
3030 assertThat (jwt .getSubject (), is ("1234567890" ));
3131 }
@@ -35,14 +35,14 @@ public void getSubject() throws Exception {
3535 public void shouldThrowIfLessThan3Parts () throws Exception {
3636 exception .expect (JWTDecodeException .class );
3737 exception .expectMessage ("The token was expected to have 3 parts, but got 2." );
38- JWTDecoder .decode ("two.parts" );
38+ JWT .decode ("two.parts" );
3939 }
4040
4141 @ Test
4242 public void shouldThrowIfMoreThan3Parts () throws Exception {
4343 exception .expect (JWTDecodeException .class );
4444 exception .expectMessage ("The token was expected to have 3 parts, but got 4." );
45- JWTDecoder .decode ("this.has.four.parts" );
45+ JWT .decode ("this.has.four.parts" );
4646 }
4747
4848 @ Test
@@ -66,7 +66,7 @@ public void shouldThrowIfHeaderHasInvalidJSONFormat() throws Exception {
6666 // getToken
6767 @ Test
6868 public void shouldGetStringToken () throws Exception {
69- DecodedJWT jwt = JWTDecoder .decode ("eyJhbGciOiJIUzI1NiJ9.e30.XmNK3GpH3Ys_7wsYBfq4C3M6goz71I7dTgUkuIa5lyQ" );
69+ DecodedJWT jwt = JWT .decode ("eyJhbGciOiJIUzI1NiJ9.e30.XmNK3GpH3Ys_7wsYBfq4C3M6goz71I7dTgUkuIa5lyQ" );
7070 assertThat (jwt , is (notNullValue ()));
7171 assertThat (jwt .getToken (), is (notNullValue ()));
7272 assertThat (jwt .getToken (), is ("eyJhbGciOiJIUzI1NiJ9.e30.XmNK3GpH3Ys_7wsYBfq4C3M6goz71I7dTgUkuIa5lyQ" ));
@@ -76,14 +76,14 @@ public void shouldGetStringToken() throws Exception {
7676
7777 @ Test
7878 public void shouldGetAlgorithm () throws Exception {
79- DecodedJWT jwt = JWTDecoder .decode ("eyJhbGciOiJIUzI1NiJ9.e30.XmNK3GpH3Ys_7wsYBfq4C3M6goz71I7dTgUkuIa5lyQ" );
79+ DecodedJWT jwt = JWT .decode ("eyJhbGciOiJIUzI1NiJ9.e30.XmNK3GpH3Ys_7wsYBfq4C3M6goz71I7dTgUkuIa5lyQ" );
8080 assertThat (jwt , is (notNullValue ()));
8181 assertThat (jwt .getAlgorithm (), is ("HS256" ));
8282 }
8383
8484 @ Test
8585 public void shouldGetSignature () throws Exception {
86- DecodedJWT jwt = JWTDecoder .decode ("eyJhbGciOiJIUzI1NiJ9.e30.XmNK3GpH3Ys_7wsYBfq4C3M6goz71I7dTgUkuIa5lyQ" );
86+ DecodedJWT jwt = JWT .decode ("eyJhbGciOiJIUzI1NiJ9.e30.XmNK3GpH3Ys_7wsYBfq4C3M6goz71I7dTgUkuIa5lyQ" );
8787 assertThat (jwt , is (notNullValue ()));
8888 assertThat (jwt .getSignature (), is ("XmNK3GpH3Ys_7wsYBfq4C3M6goz71I7dTgUkuIa5lyQ" ));
8989 }
@@ -92,37 +92,37 @@ public void shouldGetSignature() throws Exception {
9292
9393 @ Test
9494 public void shouldGetIssuer () throws Exception {
95- DecodedJWT jwt = JWTDecoder .decode ("eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJKb2huIERvZSJ9.SgXosfRR_IwCgHq5lF3tlM-JHtpucWCRSaVuoHTbWbQ" );
95+ DecodedJWT jwt = JWT .decode ("eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJKb2huIERvZSJ9.SgXosfRR_IwCgHq5lF3tlM-JHtpucWCRSaVuoHTbWbQ" );
9696 assertThat (jwt , is (notNullValue ()));
9797 assertThat (jwt .getIssuer (), is ("John Doe" ));
9898 }
9999
100100 @ Test
101101 public void shouldGetSubject () throws Exception {
102- DecodedJWT jwt = JWTDecoder .decode ("eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJUb2szbnMifQ.RudAxkslimoOY3BLl2Ghny3BrUKu9I1ZrXzCZGDJtNs" );
102+ DecodedJWT jwt = JWT .decode ("eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJUb2szbnMifQ.RudAxkslimoOY3BLl2Ghny3BrUKu9I1ZrXzCZGDJtNs" );
103103 assertThat (jwt , is (notNullValue ()));
104104 assertThat (jwt .getSubject (), is ("Tok3ns" ));
105105 }
106106
107107 @ Test
108108 public void shouldGetArrayAudience () throws Exception {
109- DecodedJWT jwt = JWTDecoder .decode ("eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOlsiSG9wZSIsIlRyYXZpcyIsIlNvbG9tb24iXX0.Tm4W8WnfPjlmHSmKFakdij0on2rWPETpoM7Sh0u6-S4" );
109+ DecodedJWT jwt = JWT .decode ("eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOlsiSG9wZSIsIlRyYXZpcyIsIlNvbG9tb24iXX0.Tm4W8WnfPjlmHSmKFakdij0on2rWPETpoM7Sh0u6-S4" );
110110 assertThat (jwt , is (notNullValue ()));
111111 assertThat (jwt .getAudience (), is (IsCollectionWithSize .hasSize (3 )));
112112 assertThat (jwt .getAudience (), is (IsCollectionContaining .hasItems ("Hope" , "Travis" , "Solomon" )));
113113 }
114114
115115 @ Test
116116 public void shouldGetStringAudience () throws Exception {
117- DecodedJWT jwt = JWTDecoder .decode ("eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJKYWNrIFJleWVzIn0.a4I9BBhPt1OB1GW67g2P1bEHgi6zgOjGUL4LvhE9Dgc" );
117+ DecodedJWT jwt = JWT .decode ("eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJKYWNrIFJleWVzIn0.a4I9BBhPt1OB1GW67g2P1bEHgi6zgOjGUL4LvhE9Dgc" );
118118 assertThat (jwt , is (notNullValue ()));
119119 assertThat (jwt .getAudience (), is (IsCollectionWithSize .hasSize (1 )));
120120 assertThat (jwt .getAudience (), is (IsCollectionContaining .hasItems ("Jack Reyes" )));
121121 }
122122
123123 @ Test
124124 public void shouldGetExpirationTime () throws Exception {
125- DecodedJWT jwt = JWTDecoder .decode ("eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE0NzY3MjcwODZ9.L9dcPHEDQew2u9MkDCORFkfDGcSOsgoPqNY-LUMLEHg" );
125+ DecodedJWT jwt = JWT .decode ("eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE0NzY3MjcwODZ9.L9dcPHEDQew2u9MkDCORFkfDGcSOsgoPqNY-LUMLEHg" );
126126 assertThat (jwt , is (notNullValue ()));
127127 assertThat (jwt .getExpiresAt (), is (instanceOf (Date .class )));
128128 long ms = 1476727086L * 1000 ;
@@ -133,7 +133,7 @@ public void shouldGetExpirationTime() throws Exception {
133133
134134 @ Test
135135 public void shouldGetNotBefore () throws Exception {
136- DecodedJWT jwt = JWTDecoder .decode ("eyJhbGciOiJIUzI1NiJ9.eyJuYmYiOjE0NzY3MjcwODZ9.tkpD3iCPQPVqjnjpDVp2bJMBAgpVCG9ZjlBuMitass0" );
136+ DecodedJWT jwt = JWT .decode ("eyJhbGciOiJIUzI1NiJ9.eyJuYmYiOjE0NzY3MjcwODZ9.tkpD3iCPQPVqjnjpDVp2bJMBAgpVCG9ZjlBuMitass0" );
137137 assertThat (jwt , is (notNullValue ()));
138138 assertThat (jwt .getNotBefore (), is (instanceOf (Date .class )));
139139 long ms = 1476727086L * 1000 ;
@@ -144,7 +144,7 @@ public void shouldGetNotBefore() throws Exception {
144144
145145 @ Test
146146 public void shouldGetIssuedAt () throws Exception {
147- DecodedJWT jwt = JWTDecoder .decode ("eyJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE0NzY3MjcwODZ9.KPjGoW665E8V5_27Jugab8qSTxLk2cgquhPCBfAP0_w" );
147+ DecodedJWT jwt = JWT .decode ("eyJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE0NzY3MjcwODZ9.KPjGoW665E8V5_27Jugab8qSTxLk2cgquhPCBfAP0_w" );
148148 assertThat (jwt , is (notNullValue ()));
149149 assertThat (jwt .getIssuedAt (), is (instanceOf (Date .class )));
150150 long ms = 1476727086L * 1000 ;
@@ -155,21 +155,21 @@ public void shouldGetIssuedAt() throws Exception {
155155
156156 @ Test
157157 public void shouldGetId () throws Exception {
158- DecodedJWT jwt = JWTDecoder .decode ("eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIxMjM0NTY3ODkwIn0.m3zgEfVUFOd-CvL3xG5BuOWLzb0zMQZCqiVNQQOPOvA" );
158+ DecodedJWT jwt = JWT .decode ("eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIxMjM0NTY3ODkwIn0.m3zgEfVUFOd-CvL3xG5BuOWLzb0zMQZCqiVNQQOPOvA" );
159159 assertThat (jwt , is (notNullValue ()));
160160 assertThat (jwt .getId (), is ("1234567890" ));
161161 }
162162
163163 @ Test
164164 public void shouldGetContentType () throws Exception {
165- DecodedJWT jwt = JWTDecoder .decode ("eyJhbGciOiJIUzI1NiIsImN0eSI6ImF3ZXNvbWUifQ.e30.AIm-pJDOaAyct9qKMlN-lQieqNDqc3d4erqUZc5SHAs" );
165+ DecodedJWT jwt = JWT .decode ("eyJhbGciOiJIUzI1NiIsImN0eSI6ImF3ZXNvbWUifQ.e30.AIm-pJDOaAyct9qKMlN-lQieqNDqc3d4erqUZc5SHAs" );
166166 assertThat (jwt , is (notNullValue ()));
167167 assertThat (jwt .getContentType (), is ("awesome" ));
168168 }
169169
170170 @ Test
171171 public void shouldGetType () throws Exception {
172- DecodedJWT jwt = JWTDecoder .decode ("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXUyJ9.e30.WdFmrzx8b9v_a-r6EHC2PTAaWywgm_8LiP8RBRhYwkI" );
172+ DecodedJWT jwt = JWT .decode ("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXUyJ9.e30.WdFmrzx8b9v_a-r6EHC2PTAaWywgm_8LiP8RBRhYwkI" );
173173 assertThat (jwt , is (notNullValue ()));
174174 assertThat (jwt .getType (), is ("JWS" ));
175175 }
@@ -178,23 +178,23 @@ public void shouldGetType() throws Exception {
178178
179179 @ Test
180180 public void shouldGetMissingClaimIfClaimDoesNotExist () throws Exception {
181- DecodedJWT jwt = JWTDecoder .decode ("eyJhbGciOiJIUzI1NiJ9.e30.K17vlwhE8FCMShdl1_65jEYqsQqBOVMPUU9IgG-QlTM" );
181+ DecodedJWT jwt = JWT .decode ("eyJhbGciOiJIUzI1NiJ9.e30.K17vlwhE8FCMShdl1_65jEYqsQqBOVMPUU9IgG-QlTM" );
182182 assertThat (jwt , is (notNullValue ()));
183183 assertThat (jwt .getClaim ("notExisting" ), is (notNullValue ()));
184184 assertThat (jwt .getClaim ("notExisting" ), is (instanceOf (NullClaim .class )));
185185 }
186186
187187 @ Test
188188 public void shouldGetValidClaim () throws Exception {
189- DecodedJWT jwt = JWTDecoder .decode ("eyJhbGciOiJIUzI1NiJ9.eyJvYmplY3QiOnsibmFtZSI6ImpvaG4ifX0.lrU1gZlOdlmTTeZwq0VI-pZx2iV46UWYd5-lCjy6-c4" );
189+ DecodedJWT jwt = JWT .decode ("eyJhbGciOiJIUzI1NiJ9.eyJvYmplY3QiOnsibmFtZSI6ImpvaG4ifX0.lrU1gZlOdlmTTeZwq0VI-pZx2iV46UWYd5-lCjy6-c4" );
190190 assertThat (jwt , is (notNullValue ()));
191191 assertThat (jwt .getClaim ("object" ), is (notNullValue ()));
192192 assertThat (jwt .getClaim ("object" ), is (instanceOf (Claim .class )));
193193 }
194194
195195 @ Test
196196 public void shouldNotGetNullClaimIfClaimIsEmptyObject () throws Exception {
197- DecodedJWT jwt = JWTDecoder .decode ("eyJhbGciOiJIUzI1NiJ9.eyJvYmplY3QiOnt9fQ.d3nUeeL_69QsrHL0ZWij612LHEQxD8EZg1rNoY3a4aI" );
197+ DecodedJWT jwt = JWT .decode ("eyJhbGciOiJIUzI1NiJ9.eyJvYmplY3QiOnt9fQ.d3nUeeL_69QsrHL0ZWij612LHEQxD8EZg1rNoY3a4aI" );
198198 assertThat (jwt , is (notNullValue ()));
199199 assertThat (jwt .getClaim ("object" ), is (notNullValue ()));
200200 assertThat (jwt .getClaim ("object" ).isNull (), is (false ));
@@ -262,7 +262,7 @@ public void shouldGetCustomMapClaim() throws Exception {
262262
263263 @ Test
264264 public void shouldGetAvailableClaims () throws Exception {
265- DecodedJWT jwt = JWTDecoder .decode ("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOiIxMjM0NTY3ODkwIiwiaWF0IjoiMTIzNDU2Nzg5MCIsIm5iZiI6IjEyMzQ1Njc4OTAiLCJqdGkiOiJodHRwczovL2p3dC5pby8iLCJhdWQiOiJodHRwczovL2RvbWFpbi5hdXRoMC5jb20iLCJzdWIiOiJsb2dpbiIsImlzcyI6ImF1dGgwIiwiZXh0cmFDbGFpbSI6IkpvaG4gRG9lIn0.TX9Ct4feGp9YyeGK9Zl91tO0YBOrguJ4As9jeqgHdZQ" );
265+ DecodedJWT jwt = JWT .decode ("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOiIxMjM0NTY3ODkwIiwiaWF0IjoiMTIzNDU2Nzg5MCIsIm5iZiI6IjEyMzQ1Njc4OTAiLCJqdGkiOiJodHRwczovL2p3dC5pby8iLCJhdWQiOiJodHRwczovL2RvbWFpbi5hdXRoMC5jb20iLCJzdWIiOiJsb2dpbiIsImlzcyI6ImF1dGgwIiwiZXh0cmFDbGFpbSI6IkpvaG4gRG9lIn0.TX9Ct4feGp9YyeGK9Zl91tO0YBOrguJ4As9jeqgHdZQ" );
266266 assertThat (jwt , is (notNullValue ()));
267267 assertThat (jwt .getClaims (), is (notNullValue ()));
268268 assertThat (jwt .getClaims (), is (instanceOf (Map .class )));
@@ -281,7 +281,7 @@ public void shouldGetAvailableClaims() throws Exception {
281281 private DecodedJWT customJWT (String jsonHeader , String jsonPayload , String signature ) {
282282 String header = Base64 .encodeBase64URLSafeString (jsonHeader .getBytes (StandardCharsets .UTF_8 ));
283283 String body = Base64 .encodeBase64URLSafeString (jsonPayload .getBytes (StandardCharsets .UTF_8 ));
284- return JWTDecoder .decode (String .format ("%s.%s.%s" , header , body , signature ));
284+ return JWT .decode (String .format ("%s.%s.%s" , header , body , signature ));
285285 }
286286
287287}
0 commit comments