Hi,
I have developed a code to verify the token and signature with JWT.
Everything works correctly in my Android application if the version is higher than 27.
I started testing with Android 26 but I get an exception in “verifier.verify (license)”
How can I correct the problem?
Thanks
fun verifyLicence(cert: JWKObject, license: String, context: Context){
val objCert = Gson().toJsonTree(cert)
val connectionError = getString(R.string.ConnectionError)
try {
val e = objCert.asJsonObject["e"].asString
val n = objCert.asJsonObject["n"].asString.replace('+', '-').replace('/', '_').replace("=",
"")
val eInt = BigInteger(1, Base64.getUrlDecoder().decode(e))
val nInt = BigInteger(1, Base64.getUrlDecoder().decode(n))
val spec = RSAPublicKeySpec(nInt, eInt)
val publicKey = KeyFactory.getInstance("RSA").generatePublic(spec) as RSAPublicKey
val algorithm: Algorithm = Algorithm.RSA256(publicKey, null)
val verifier: JWTVerifier = com.auth0.jwt.JWT.require(algorithm).build()
**verifier.verify(license)**
val decodeLicense = JWT(license)
val objDecodeLicense = Gson().toJsonTree(decodeLicense)
I get the error on verifier.verify(license)
*java.lang.NoSuchMethodError: No static method decodeBase64(Ljava/lang/String;)[B in class Lorg/apache/commons/codec/binary/Base64; or its super classes (declaration of 'org.apache.commons.codec.binary.Base64' appears in /system/framework/org.apache.http.legacy.boot.jar)*
these are the libraries I use
// JWT Decode
implementation 'com.auth0.android:jwtdecode:2.0.0'
// Licensing
implementation 'com.auth0:java-jwt:3.13.0'
implementation 'com.google.code.gson:gson:2.8.6'