- edited description
StandardCharsets.UTF_8 not available on Android before API level 19
Using this library on Android I get a NoClassDefFoundError as it can't find the StandardCharsets class (which was added in API 19, https://developer.android.com/reference/java/nio/charset/StandardCharsets.html) while getting the UTF8 constant.
Stacktrace:
Caused by: java.lang.NoClassDefFoundError: java.nio.charset.StandardCharsets
at org.jose4j.lang.StringUtil.getBytesUtf8(StringUtil.java:59)
at org.jose4j.base64url.internal.apache.commons.codec.binary.BaseNCodec.decode(BaseNCodec.java:341)
at org.jose4j.base64url.Base64Url.base64UrlDecode(Base64Url.java:46)
at org.jose4j.base64url.Base64Url.base64UrlDecodeToString(Base64Url.java:40)
at org.jose4j.base64url.Base64Url.base64UrlDecodeToUtf8String(Base64Url.java:35)
at org.jose4j.jwx.Headers.setEncodedHeader(Headers.java:107)
at org.jose4j.jwx.JsonWebStructure.setEncodedHeader(JsonWebStructure.java:113)
at org.jose4j.jws.JsonWebSignature.setCompactSerializationParts(JsonWebSignature.java:64)
at org.jose4j.jwx.JsonWebStructure.fromCompactSerialization(JsonWebStructure.java:80)
at org.jose4j.jwt.consumer.JwtConsumer.process(JwtConsumer.java:234)
at org.jose4j.jwt.consumer.JwtConsumer.processToClaims(JwtConsumer.java:115)
The offending line is here:
In org.jose4j.lang.StringUtil.java
public static byte[] getBytesUtf8(String string)
{
return getBytes(string, StandardCharsets.UTF_8);
}
Can you please change it so it uses the UTF-8 constant from somewhere else (or create your own UTF_8 constant)
Comments (11)
-
reporter -
reporter - edited description
-
repo owner That's a fair ask. Removed use of the class with 2141fa8
-
repo owner - attached jose4j-0.4.2-SNAPSHOT.jar
here's a snapshot build with the 2141fa8 change that removes usage of StandardCharsets
-
repo owner - changed status to resolved
-
reporter Thank you!
-
reporter How long before version 4.2 is out?
-
repo owner I don't have a specific date in mind. But it's probably getting close to time to cut a new release. There are a few other minor enhancements I'd like to make first.
Can you use the attached jose4j-0.4.2-SNAPSHOT.jar in the meantime?
-
repo owner 0.4.2 is now available
-
reporter Great thanks! :-) Adding it now.
-
repo owner Issue
#30was marked as a duplicate of this issue. - Log in to comment