-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace String/byte[] with (N)IO streams #838
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Created new Writer/Reader concepts with backing implementations and tests, and deprecated the respective Serializer/Deserializer concepts. Each Serializer/Deserializer implementation now subclasses/extends their respective parent Writer/Reader implementation out of convenience. Serializer/Deserializer are not (currently) subinterfaces of Writer/Reader to avoid forcing new implementation requirements on existing implementations.
lhazlewood
changed the title
Closes #837
Serializer/Deserializer replaced by Writer/Reader concepts
Sep 18, 2023
lhazlewood
changed the title
Serializer/Deserializer replaced by Writer/Reader concepts
Serializer/Deserializer replaced by Writer/Reader
Sep 18, 2023
…s to return CharSequences instead of Strings to avoid creating new Strings on the heap - Changed internal Base64 implementation to work with a CharSequence instead of a raw char[] to reduce need to create new arrays on the heap - Changed Base64Decoder generics signature from Decoder<String,byte[]> to Decoder<CharSequence,byte[]> - Decoders.BASE64 and Decoders.BASE64URL now reflect Decoder<CharSequence,byte[]> - Changed Strings#utf8 implementation to accept a CharSequence instead of a String - Added new Strings#wrap to wrap a CharSequence into a CharBuffer if necessary - Replaced not-yet-released JwtBuilder#serializer method with JwtBuilder#jsonWriter - Replaced not-yet-released JwtParserBuilder#deserializer method with JwtParserBuilder#jsonReader - Moved JwtDeserializer from io.jsonwebtoken.impl to io.jsonwebtoken.impl.io package, and updated its implementation to work with the new io.jsonwebtoken.io.Writer concept - Updated GsonSerializer, GsonDeserializer, JacksonSerializer, JacksonDeserializer, and OrgJsonSerializer and OrgJsonDeserializer implementations to use JDK 7+ 'try with resources' try block instead of try/finally
…throwing MalformedJwtException. Added two subclasses, JwkDeserializer and JwkSetDeserializer that throws JWK and JWK Set-specific exceptions. - Changed ParserBuilder#deserializer method name to ParserBuilder#jsonReader
…lize except for deprecated implementations. All other usages now use Writer/Reader concepts - Added Jwks#json and Jwks#UNSAFE_JSON for assistance in serializing JWKs to JSON (test cases, README examples, etc)
…of just byte arrays - Copied over necessary (Apache-licensed) code from Apache commons-codec to obtain Base64OutputStream and Base64InputStream capability for efficient encoding during compact JWT creation. Hopefully this is temporary and we can strip out most if not all of this and modify our existing Base64.java class for simpler support since we have many less use cases than what commons-codec supports.
…ent(InputStream), JwtBuilder#content(InputStream, String contentType), JwtBuilder#content(String, String contentType) - Added CountingInputStream as a way to check and assert that b64/unencoded payload InputStreams cannot be empty. - 100% code coverage checkpoint
- New JwtParser parseContentJws(String,InputStream) methods still need JavaDoc. - Still need to make AeadAlgorithm InputStream-based
- New JwtParser parseContentJws(String,InputStream) methods are JavaDoc'd - Decompression is streaming when payload is consumable Note: Still need to make AeadAlgorithm InputStream-based
lhazlewood
changed the title
Serializer/Deserializer replaced by Writer/Reader
Replace String/byte[] with (N)IO streams
Sep 25, 2023
…encode/decode/compress/decompress for better readability and to make clearer the intent of the method. Also to avoid name/text/search collisions with 'wrap' references.
…(ideally didn't want to expose this implementation detail to the API).
…hods in existing Serializer/Deserializer interfaces. This results in less change and is probably more intuitive for existing library users.
…o JwtBuilder#b64Url and JwtParserBuilder#b64Url for shorter method chains
remaining: change AeadAlgorithm#encrypt to receive AeadResult as a 2nd argument (like HttpServlet API)
- Changed AeadAlgorithm#decrypt to receive an OutputStream as a 2nd argument
…d it's not commonly referenced in the API, so the extra verbosity isn't needed)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #837
Replaced raw
String
andbyte[]
usages withCharSequence
,InputStream
/OutputStream
andCharBuffer
/ByteBuffer
concepts where possible to eliminate unnecessary creation of intermediate byte arrays and/or temporary Strings.