#18: fixed Android detection algorithm from class check to system property check. This is to ensure that, during tests, the stub android .jar isn't used since it is in the classpath.

This commit is contained in:
Les Hazlewood 2015-04-29 10:06:08 -07:00
parent 115b6f4dca
commit 01996aa15b
1 changed files with 18 additions and 3 deletions

View File

@ -15,11 +15,26 @@
*/
package io.jsonwebtoken.impl;
import io.jsonwebtoken.lang.Classes;
public class Base64Codec extends AbstractTextCodec {
private static final boolean ANDROID = Classes.isAvailable("android.util.Base64");
private static final boolean ANDROID = isAndroid();
private static boolean isAndroid() {
String name = System.getProperty("java.vm.name");
if (name != null) {
String lcase = name.toLowerCase();
return lcase.contains("dalvik");
}
name = System.getProperty("java.vm.vendor");
if (name != null) {
String lcase = name.toLowerCase();
return lcase.contains("android");
}
return false;
}
public String encode(byte[] data) {