mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-05-19 11:34:57 +08:00
Fix dex index overflow exception (#1007)
fix DexIndexOverflowException due to com.auth0.jwt #1002 use another lib - nimbus-jose-jwt
This commit is contained in:
committed by
Ruslan Bikkinin
parent
2704277e93
commit
32f82e6050
@@ -22,7 +22,5 @@ android {
|
||||
|
||||
dependencies {
|
||||
compile "com.facebook.react:react-native:+"
|
||||
//todo as required minimal sdk version will be more then 23, upgrade this to latest version
|
||||
//see https://github.com/auth0/java-jwt/issues/131
|
||||
compile 'com.auth0:java-jwt:2.2.2'
|
||||
}
|
||||
compile 'com.nimbusds:nimbus-jose-jwt:5.1'
|
||||
}
|
||||
@@ -3,7 +3,11 @@ package com.microsoft.codepush.react;
|
||||
import android.content.Context;
|
||||
import android.util.Base64;
|
||||
|
||||
import com.auth0.jwt.JWTVerifier;
|
||||
import java.security.interfaces.*;
|
||||
|
||||
import com.nimbusds.jose.*;
|
||||
import com.nimbusds.jose.crypto.*;
|
||||
import com.nimbusds.jwt.*;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
@@ -176,11 +180,17 @@ public class CodePushUpdateUtils {
|
||||
|
||||
public static Map<String, Object> verifyAndDecodeJWT(String jwt, PublicKey publicKey) {
|
||||
try {
|
||||
final JWTVerifier verifier = new JWTVerifier(publicKey);
|
||||
final Map<String, Object> claims = verifier.verify(jwt);
|
||||
CodePushUtils.log("JWT verification succeeded:\n" + claims.toString());
|
||||
return claims;
|
||||
} catch (Exception e) {
|
||||
SignedJWT signedJWT = SignedJWT.parse(jwt);
|
||||
JWSVerifier verifier = new RSASSAVerifier((RSAPublicKey)publicKey);
|
||||
if (signedJWT.verify(verifier)) {
|
||||
Map<String, Object> claims = signedJWT.getJWTClaimsSet().getClaims();
|
||||
CodePushUtils.log("JWT verification succeeded:\n" + claims.toString());
|
||||
return claims;
|
||||
}
|
||||
return null;
|
||||
} catch (Exception ex) {
|
||||
CodePushUtils.log(ex.getMessage());
|
||||
CodePushUtils.log(ex.getStackTrace().toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -248,5 +258,4 @@ public class CodePushUpdateUtils {
|
||||
|
||||
CodePushUpdateUtils.verifyFolderHash(folderPath, contentHash);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user