3
3
import com .auth0 .jwt .algorithms .Algorithm ;
4
4
import com .auth0 .jwt .interfaces .ECDSAKeyProvider ;
5
5
import com .auth0 .jwt .interfaces .RSAKeyProvider ;
6
- import org .apache .commons .codec .binary .Base64 ;
6
+ import com .auth0 .jwt .wrapper .Base64Wrapper ;
7
+
7
8
import org .junit .Rule ;
8
9
import org .junit .Test ;
9
10
import org .junit .rules .ExpectedException ;
@@ -49,7 +50,7 @@ public void shouldAddHeaderClaim() throws Exception {
49
50
50
51
assertThat (signed , is (notNullValue ()));
51
52
String [] parts = signed .split ("\\ ." );
52
- String headerJson = new String (Base64 . decodeBase64 (parts [0 ]), StandardCharsets .UTF_8 );
53
+ String headerJson = new String (Base64Wrapper . getInstance (). decode (parts [0 ]), StandardCharsets .UTF_8 );
53
54
assertThat (headerJson , JsonMatcher .hasEntry ("asd" , 123 ));
54
55
}
55
56
@@ -61,7 +62,7 @@ public void shouldAddKeyId() throws Exception {
61
62
62
63
assertThat (signed , is (notNullValue ()));
63
64
String [] parts = signed .split ("\\ ." );
64
- String headerJson = new String (Base64 . decodeBase64 (parts [0 ]), StandardCharsets .UTF_8 );
65
+ String headerJson = new String (Base64Wrapper . getInstance (). decode (parts [0 ]), StandardCharsets .UTF_8 );
65
66
assertThat (headerJson , JsonMatcher .hasEntry ("kid" , "56a8bd44da435300010000015f5ed" ));
66
67
}
67
68
@@ -77,7 +78,7 @@ public void shouldAddKeyIdIfAvailableFromRSAAlgorithms() throws Exception {
77
78
78
79
assertThat (signed , is (notNullValue ()));
79
80
String [] parts = signed .split ("\\ ." );
80
- String headerJson = new String (Base64 . decodeBase64 (parts [0 ]), StandardCharsets .UTF_8 );
81
+ String headerJson = new String (Base64Wrapper . getInstance (). decode (parts [0 ]), StandardCharsets .UTF_8 );
81
82
assertThat (headerJson , JsonMatcher .hasEntry ("kid" , "my-key-id" ));
82
83
}
83
84
@@ -94,7 +95,7 @@ public void shouldNotOverwriteKeyIdIfAddedFromRSAAlgorithms() throws Exception {
94
95
95
96
assertThat (signed , is (notNullValue ()));
96
97
String [] parts = signed .split ("\\ ." );
97
- String headerJson = new String (Base64 . decodeBase64 (parts [0 ]), StandardCharsets .UTF_8 );
98
+ String headerJson = new String (Base64Wrapper . getInstance (). decode (parts [0 ]), StandardCharsets .UTF_8 );
98
99
assertThat (headerJson , JsonMatcher .hasEntry ("kid" , "my-key-id" ));
99
100
}
100
101
@@ -110,7 +111,7 @@ public void shouldAddKeyIdIfAvailableFromECDSAAlgorithms() throws Exception {
110
111
111
112
assertThat (signed , is (notNullValue ()));
112
113
String [] parts = signed .split ("\\ ." );
113
- String headerJson = new String (Base64 . decodeBase64 (parts [0 ]), StandardCharsets .UTF_8 );
114
+ String headerJson = new String (Base64Wrapper . getInstance (). decode (parts [0 ]), StandardCharsets .UTF_8 );
114
115
assertThat (headerJson , JsonMatcher .hasEntry ("kid" , "my-key-id" ));
115
116
}
116
117
@@ -127,7 +128,7 @@ public void shouldNotOverwriteKeyIdIfAddedFromECDSAAlgorithms() throws Exception
127
128
128
129
assertThat (signed , is (notNullValue ()));
129
130
String [] parts = signed .split ("\\ ." );
130
- String headerJson = new String (Base64 . decodeBase64 (parts [0 ]), StandardCharsets .UTF_8 );
131
+ String headerJson = new String (Base64Wrapper . getInstance (). decode (parts [0 ]), StandardCharsets .UTF_8 );
131
132
assertThat (headerJson , JsonMatcher .hasEntry ("kid" , "my-key-id" ));
132
133
}
133
134
@@ -227,7 +228,7 @@ public void shouldSetCorrectAlgorithmInTheHeader() throws Exception {
227
228
228
229
assertThat (signed , is (notNullValue ()));
229
230
String [] parts = signed .split ("\\ ." );
230
- String headerJson = new String (Base64 . decodeBase64 (parts [0 ]), StandardCharsets .UTF_8 );
231
+ String headerJson = new String (Base64Wrapper . getInstance (). decode (parts [0 ]), StandardCharsets .UTF_8 );
231
232
assertThat (headerJson , JsonMatcher .hasEntry ("alg" , "HS256" ));
232
233
}
233
234
@@ -238,7 +239,7 @@ public void shouldSetCorrectTypeInTheHeader() throws Exception {
238
239
239
240
assertThat (signed , is (notNullValue ()));
240
241
String [] parts = signed .split ("\\ ." );
241
- String headerJson = new String (Base64 . decodeBase64 (parts [0 ]), StandardCharsets .UTF_8 );
242
+ String headerJson = new String (Base64Wrapper . getInstance (). decode (parts [0 ]), StandardCharsets .UTF_8 );
242
243
assertThat (headerJson , JsonMatcher .hasEntry ("typ" , "JWT" ));
243
244
}
244
245
0 commit comments