33import android .content .Context ;
44import android .util .Base64 ;
55
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 .*;
711
812import org .json .JSONArray ;
913import org .json .JSONException ;
@@ -176,11 +180,17 @@ public static void verifyFolderHash(String folderPath, String expectedHash) {
176180
177181 public static Map <String , Object > verifyAndDecodeJWT (String jwt , PublicKey publicKey ) {
178182 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 ());
184194 return null ;
185195 }
186196 }
@@ -248,5 +258,4 @@ public static void verifySignature(String folderPath, String stringPublicKey) th
248258
249259 CodePushUpdateUtils .verifyFolderHash (folderPath , contentHash );
250260 }
251-
252261}
0 commit comments