datawave icon indicating copy to clipboard operation
datawave copied to clipboard

replace apache base64 with java base64

Open austin007008 opened this issue 1 year ago • 2 comments

continued from cbevard1

removed apache commons base64 encoding/decoding

removed unused commons-codec dependency

austin007008 avatar Jul 26 '24 13:07 austin007008

I'm pretty sure that org.apache.commons.codec.binary.Base64 as used here is based on the RFC2045 spec, which is not the same as java.util.Base64.getDecoder / java.util.Base64.getEncoder, which could cause issues for any existing data that we have encoded

I think you want java.util.Base64.getMimeDecoder / java.util.Base64.getMimeEncoder to remain backward-compatible with any existing data

I will double check but from what I see, the encoder we were using from apache does not cut the data up into 76 character lines: "encodeBase64(byte[] binaryData) Encodes binary data using the base64 algorithm but does not chunk the output." so the basic java encoder should work fine "Uses "The Base64 Alphabet" as specified in Table 1 of RFC 4648 and RFC 2045 for encoding and decoding operation. The encoder does not add any line feed (line separator) character."

austin007008 avatar Jul 30 '24 11:07 austin007008

I'm pretty sure that org.apache.commons.codec.binary.Base64 as used here is based on the RFC2045 spec, which is not the same as java.util.Base64.getDecoder / java.util.Base64.getEncoder, which could cause issues for any existing data that we have encoded

I think you want java.util.Base64.getMimeDecoder / java.util.Base64.getMimeEncoder to remain backward-compatible with any existing data

I ran a test and this is the output:

original:cGxjc2RyZmdkdmhlYmFleXR2cXRwdGh3amtld2txbXF6emhsY3ZkdWhobmJvbmxxaWNlY3l2Z25pcmJpZWFhdmF3bmV4d3d6anlydWhycG91d2Rydm1kdW9qZ3Ria2Jk java:cGxjc2RyZmdkdmhlYmFleXR2cXRwdGh3amtld2txbXF6emhsY3ZkdWhobmJvbmxxaWNlY3l2Z25pcmJpZWFhdmF3bmV4d3d6anlydWhycG91d2Rydm1kdW9qZ3Ria2Jk mime:cGxjc2RyZmdkdmhlYmFleXR2cXRwdGh3amtld2txbXF6emhsY3ZkdWhobmJvbmxxaWNlY3l2Z25p cmJpZWFhdmF3bmV4d3d6anlydWhycG91d2Rydm1kdW9qZ3Ria2Jk

the mime one split the text but the original apache and the java I replaced it with did not and have the same output so it should be ok.

austin007008 avatar Jul 30 '24 12:07 austin007008

Reopen and address conflicts as priorities allow

hlgp avatar Sep 23 '25 15:09 hlgp