3
3
import android .content .Context ;
4
4
import android .util .Base64 ;
5
5
6
- import com .auth0 .jwt .JWTVerifier ;
6
+ import java .security .interfaces .*;
7
+
8
+ import com .nimbusds .jose .*;
9
+ import com .nimbusds .jose .crypto .*;
10
+ import com .nimbusds .jwt .*;
7
11
8
12
import org .json .JSONArray ;
9
13
import org .json .JSONException ;
@@ -176,11 +180,17 @@ public static void verifyFolderHash(String folderPath, String expectedHash) {
176
180
177
181
public static Map <String , Object > verifyAndDecodeJWT (String jwt , PublicKey publicKey ) {
178
182
try {
179
- final JWTVerifier verifier = new JWTVerifier (publicKey );
180
- final Map <String , Object > claims = verifier .verify (jwt );
181
- CodePushUtils .log ("JWT verification succeeded:\n " + claims .toString ());
182
- return claims ;
183
- } catch (Exception e ) {
183
+ SignedJWT signedJWT = SignedJWT .parse (jwt );
184
+ JWSVerifier verifier = new RSASSAVerifier ((RSAPublicKey )publicKey );
185
+ if (signedJWT .verify (verifier )) {
186
+ Map <String , Object > claims = signedJWT .getJWTClaimsSet ().getClaims ();
187
+ CodePushUtils .log ("JWT verification succeeded:\n " + claims .toString ());
188
+ return claims ;
189
+ }
190
+ return null ;
191
+ } catch (Exception ex ) {
192
+ CodePushUtils .log (ex .getMessage ());
193
+ CodePushUtils .log (ex .getStackTrace ().toString ());
184
194
return null ;
185
195
}
186
196
}
@@ -248,5 +258,4 @@ public static void verifySignature(String folderPath, String stringPublicKey) th
248
258
249
259
CodePushUpdateUtils .verifyFolderHash (folderPath , contentHash );
250
260
}
251
-
252
261
}
0 commit comments