kuzjka commented on code in PR #504:
URL:
https://github.com/apache/santuario-xml-security-java/pull/504#discussion_r2495007194
##########
src/main/java/org/apache/xml/security/utils/XMLUtils.java:
##########
@@ -1068,4 +1147,52 @@ public static byte[] getBytes(BigInteger big, int
bitlen) {
return resizedBytes;
}
+
+ /**
+ * Aggregates formatting options for base64Binary values.
+ */
+ static class Base64FormattingOptions {
+ private boolean ignoreLineBreaks = false;
+ private Base64LineSeparator lineSeparator = Base64LineSeparator.CRLF;
+ private int lineLength = 76;
+
+ public boolean isIgnoreLineBreaks() {
+ return ignoreLineBreaks;
+ }
+
+ public void setIgnoreLineBreaks(boolean ignoreLineBreaks) {
Review Comment:
Since we would like to retain meaningful log messages for invalid property
values, I couldn't find a better way than to move all properties reading
together with validation logic to the constructor of `Base64FormattingOptions`.
Added warnings in case a property is set, but ignored.
Added handling of `NumberFormatException` as suggested in the comment below.
Example log:
```
testIgnoreLineBreaksTakesPrecedence:
... org.apache.xml.security.ignoreLineBreaks property takes precedence over
org.apache.xml.security.base64.ignoreLineBreaks, line breaks will be ignored
... Property org.apache.xml.security.base64.lineSeparator has no effect
since line breaks are ignored
... Property org.apache.xml.security.base64.lineLength has no effect since
line breaks are ignored
testIllegalPropertiesAreIgnored:
... Illegal value of org.apache.xml.security.base64.lineSeparator property
is ignored: illegal
... Illegal value of org.apache.xml.security.base64.lineLength property is
ignored: illegal
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]