jjwt
jjwt copied to clipboard
JwtParser to parse CharSequence instead of String?
JwtParser parameters that get parsed are all String, can these be made to CharSequence? it would make this a bit more flexible...
I am not sure I agree with having CharSequence
type parameters in the public interfaces without a strong justification.
My main concern here is that implementations of CharSequence
are not guaranteed to be immutable, while String
is.
I don't understand the request exactly - can you show a code snippet example of what you're asking for?
Closing due to inactivity or follow up from OP.
well somehow I missed the notifications for the followup questions... this awesome email spam filters in action...
the idea is when parsing from some source CharSequence is a bit more flexible... (String, StringBuilder ...)
for an example, in class Integer you have both:
public static int parseUnsignedInt(String s, int radix)
and: public static int parseUnsignedInt(CharSequence s, int beginIndex, int endIndex, int radix)
in case on JWT, lets say the web token needs to be parsed out of a string like:
"Bearer [JWT token]"
I want tp avoid doing a substring() and allocate memory for no good reason.. having a CharSequence parsing variant I could simply do: parse(myString, "Bearer ".length(), myString.length())
The existing interfaces don't need to be changed....
Reopening, but I don't know when we'll get to it. This is low priority given the 1.0 feature set we need to support.
The IO Streams work commited via https://github.com/jwtk/jjwt/commit/b687ca5c72681a41449fcb252549559e4e06771f makes this much easier, so we can sneak it in for 0.12.0. I should have a PR shortly.