Added properties for base64 formatting #504
Open
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.
New feature
This PR continues the mailing list thread and suggests system properties to control base64Binary values formatting:
org.apache.xml.security.base64.lineSeparator
,org.apache.xml.security.base64.lineLength
- allows to override default MIME encoding settingsorg.apache.xml.security.base64.ignoreLineBreaks
- disables line wrapping for base64 value, but allows to keep the whole XML pretty-printed. Takes precedence over line wrapping settings above.org.apache.xml.security.ignoreLineBreaks
takes precedence over all new options.Default values result to CRLF line breaks with 76 chars in the line, making the whole thing fully compatible with previous implementation.
Other changes
Some of the logic is included to XMLUtils to provide better encapsulation:
XMLUtils.encodeElementValue
Base64OutputStream
from Commons, used in XML encryption, is replaced with ajava.util
implementation and provided byXMLUtils
, making it consistent with configured Base64 encoder.Base64.Encoder/Decoder
instances are thread-safe, so sharing a single instance should give us a little performance gain.Test coverage
As the base64 configuration takes place during class load, unit-tests leverage from custom
ClassLoader
and Reflection API to reinitialize the class in each test.Motivation
https://www.w3.org/TR/xmlschema-2/#base64Binary -
base64Binary
definition has note, that original RFC2045 line-length limitation must not be enforced. In current implementation it is only possible to remove all line breaks in the document usingorg.apache.xml.security.ignoreLineBreaks
, sacrificing human readability.Also, using LF instead of CRLF may be desired in systems where verifying side does not expect escape sequences in base64Binary values.
I would be thankful for your comments and suggestions.