- changed status to open
Consider switching base64 codec to http://migbase64.sourceforge.net/
See issue #52:
https://bitbucket.org/nimbusds/nimbus-jose-jwt/issue/52/library-does-not-work-on-android-b-c-of
http://migbase64.sourceforge.net/
Comments (6)
-
reporter -
reporter migbase64 doesn't support URL-safe encoding and decoding.
The URL-safe encoding can be added with little effort. The decoding, however, will require more work.
-
In our implementation with migbase64, we did a simple string replace for the characters:
Base64URL:
public static Base64URL encode(final byte[] bytes) { return new Base64URL(util.Base64.encodeToString(bytes,false).replace('+','-').replace('/','_')); }
Base64:
public byte[] decode() { return util.Base64.decode(value.replace('-','+').replace('_','/')); }
However, once caveat is that the migbase64 decode method always expects padding (len divisible by 4) whereas with the original apache codec version it was optional.
-
reporter Thanks for the suggestion.
I added an URL-safe alphabet to the Mig code, see commit a6f1ef8. The decoding will indeed be trickier to modify to accept non-padded strings. The author has a routine at the beginning that precomputes the resulting array and that has to be modified to work in both cases (with and without padding).
-
reporter Just added a routine that computes the encoded length for regular as well as for URL-safe encoding and wired it into the original code (commit f1d03e6). The URL-safe encoding works now, and the original Mig encoding alg is preserved :)
The next task is to modify decoding to support both modes.
-
reporter - changed status to resolved
The alternative migbase64 codec is fully integrated now and the commons codec dependency is removed, see release 2.24.
- Log in to comment