[jira] [Commented] (CODEC-279) Base64.decode fails on Java11 for certain valid base 64 encoded String
[ https://issues.apache.org/jira/browse/CODEC-279?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17022436#comment-17022436 ] Michael Osipov commented on CODEC-279: -- [~seakayone], why can't you share the "secret"? Unless we know what you are using it for the string will still remain useless for us. > Base64.decode fails on Java11 for certain valid base 64 encoded String > -- > > Key: CODEC-279 > URL: https://issues.apache.org/jira/browse/CODEC-279 > Project: Commons Codec > Issue Type: Bug >Affects Versions: 1.13, 1.14 > Environment: Java 11 >Reporter: Christian Kleinbölting >Priority: Major > > The following lines will fail for a specific String: > {code:java} > String sharedSecret = > "cannot_share_the_affected_string_because_it_is_a_secret"; > byte[] bytes = > org.apache.commons.codec.binary.Base64.decodeBase64(sharedSecret); {code} > The exception I get is > {code:java} > java.lang.IllegalArgumentException: Last encoded character (before the > paddings if any) is a valid base 64 alphabet but not a possible value at > org.apache.commons.codec.binary.Base64.validateCharacter(Base64.java:798) > at org.apache.commons.codec.binary.Base64.decode(Base64.java:472) > at > org.apache.commons.codec.binary.BaseNCodec.decode(BaseNCodec.java:412) > at > org.apache.commons.codec.binary.BaseNCodec.decode(BaseNCodec.java:395) > at org.apache.commons.codec.binary.Base64.decodeBase64(Base64.java:694) > at > com.rbmhtechnology.oidc.provider.spi.grants.jwt.thirdparty.rest.FooTest.foo(FooTest.java:17) > at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.base/java.lang.reflect.Method.invoke(Method.java:566) > at > org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:675) > at > org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:125) > at > org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:132) > at > org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:124) > at > org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:74) > at > org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115) > at > org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:104) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:62) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:43) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:35) > at > org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104) > at > org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98) > at > org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:202) > at > org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) > at > org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:198) > at > org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135) > at > org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:69) > at > org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135) > at > org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) > at > org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) > at > org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) > at >
[jira] [Commented] (CODEC-279) Base64.decode fails on Java11 for certain valid base 64 encoded String
[ https://issues.apache.org/jira/browse/CODEC-279?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17020228#comment-17020228 ] Alex Herbert commented on CODEC-279: Since the throwing of exceptions when decoding incorrectly encoded data is a behaviour change this will be made optional. The fix should restore codec to previous lenient decoding behaviour where trailing bits that should not be there are just ignored. See [Codec-280]. > Base64.decode fails on Java11 for certain valid base 64 encoded String > -- > > Key: CODEC-279 > URL: https://issues.apache.org/jira/browse/CODEC-279 > Project: Commons Codec > Issue Type: Bug >Affects Versions: 1.13, 1.14 > Environment: Java 11 >Reporter: Christian Kleinbölting >Priority: Major > > The following lines will fail for a specific String: > {code:java} > String sharedSecret = > "cannot_share_the_affected_string_because_it_is_a_secret"; > byte[] bytes = > org.apache.commons.codec.binary.Base64.decodeBase64(sharedSecret); {code} > The exception I get is > {code:java} > java.lang.IllegalArgumentException: Last encoded character (before the > paddings if any) is a valid base 64 alphabet but not a possible value at > org.apache.commons.codec.binary.Base64.validateCharacter(Base64.java:798) > at org.apache.commons.codec.binary.Base64.decode(Base64.java:472) > at > org.apache.commons.codec.binary.BaseNCodec.decode(BaseNCodec.java:412) > at > org.apache.commons.codec.binary.BaseNCodec.decode(BaseNCodec.java:395) > at org.apache.commons.codec.binary.Base64.decodeBase64(Base64.java:694) > at > com.rbmhtechnology.oidc.provider.spi.grants.jwt.thirdparty.rest.FooTest.foo(FooTest.java:17) > at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.base/java.lang.reflect.Method.invoke(Method.java:566) > at > org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:675) > at > org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:125) > at > org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:132) > at > org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:124) > at > org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:74) > at > org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115) > at > org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:104) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:62) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:43) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:35) > at > org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104) > at > org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98) > at > org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:202) > at > org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) > at > org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:198) > at > org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135) > at > org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:69) > at > org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135) > at > org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) > at > org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) > at >
[jira] [Commented] (CODEC-279) Base64.decode fails on Java11 for certain valid base 64 encoded String
[ https://issues.apache.org/jira/browse/CODEC-279?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17019527#comment-17019527 ] Alex Herbert commented on CODEC-279: Your stack trace is from codec 1.13. That had a bug in the validation of final bits so I will not cover that here. My working shows that the exception is expected: {noformat} Decode blocks of 4 characters as 4 * 6 bits = 24-bits = 3 bytes Trailing characters are decoded as: 1 = 6 bits => Ignored 2 = 12 bits => 8-bits discard 4 3 = 18 bits => 16-bits discard 2 The discarded bits are now required to be zero. 86 / 4 = 21remainder 2 Last two characters decoded to base64: j = 35 = 100011 E = 4 = 000100 Last 12-bits = 100011 000100 = 10001100 0100 This has 4 trailing bits which should be zeros but they are 0100 {noformat} Thus this is expected to throw. Can you change the final character to 'A' and see if it still throws. I expect this to be fine. Then you can check that Codec returns the same bytes as the java.util.Base64 class. You may ask what about 6 trailing bits when there is 1 trailing character? This is currently not validated. In [Codec-270] I suggested throwing an exception given that there should never be 6-bits left-over when decoding to 8-bit bytes. This would indicate a bad or truncated encoding. However this extra validation was not added and there is a comment in the code to determine if it should be validated. The validation of trailing bytes was to ensure a round trip of decoding->encoding bytes produces the same bytes (see [Codec-134]). So given this argument I think that validation could be made more strict given that both Base32 and Base64 allow an entire single trailing character to be discarded but will throw if there are multiple trailing characters and the trailing bits to be discarded are non-zero. > Base64.decode fails on Java11 for certain valid base 64 encoded String > -- > > Key: CODEC-279 > URL: https://issues.apache.org/jira/browse/CODEC-279 > Project: Commons Codec > Issue Type: Bug >Affects Versions: 1.13, 1.14 > Environment: Java 11 >Reporter: Christian Kleinbölting >Priority: Major > > The following lines will fail for a specific String: > {code:java} > String sharedSecret = > "cannot_share_the_affected_string_because_it_is_a_secret"; > byte[] bytes = > org.apache.commons.codec.binary.Base64.decodeBase64(sharedSecret); {code} > The exception I get is > {code:java} > java.lang.IllegalArgumentException: Last encoded character (before the > paddings if any) is a valid base 64 alphabet but not a possible value at > org.apache.commons.codec.binary.Base64.validateCharacter(Base64.java:798) > at org.apache.commons.codec.binary.Base64.decode(Base64.java:472) > at > org.apache.commons.codec.binary.BaseNCodec.decode(BaseNCodec.java:412) > at > org.apache.commons.codec.binary.BaseNCodec.decode(BaseNCodec.java:395) > at org.apache.commons.codec.binary.Base64.decodeBase64(Base64.java:694) > at > com.rbmhtechnology.oidc.provider.spi.grants.jwt.thirdparty.rest.FooTest.foo(FooTest.java:17) > at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.base/java.lang.reflect.Method.invoke(Method.java:566) > at > org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:675) > at > org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:125) > at > org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:132) > at > org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:124) > at > org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:74) > at > org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115) > at > org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:104) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:62) > at >
[jira] [Commented] (CODEC-279) Base64.decode fails on Java11 for certain valid base 64 encoded String
[ https://issues.apache.org/jira/browse/CODEC-279?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17019451#comment-17019451 ] Christian Kleinbölting commented on CODEC-279: -- > Other libraries may decode this but commons codec now throws an exception. Interestingly enough the same commons code versions work fine on Java 8 but fail with Java 11. > Base64.decode fails on Java11 for certain valid base 64 encoded String > -- > > Key: CODEC-279 > URL: https://issues.apache.org/jira/browse/CODEC-279 > Project: Commons Codec > Issue Type: Bug >Affects Versions: 1.13, 1.14 > Environment: Java 11 >Reporter: Christian Kleinbölting >Priority: Major > > The following lines will fail for a specific String: > {code:java} > String sharedSecret = > "cannot_share_the_affected_string_because_it_is_a_secret"; > byte[] bytes = > org.apache.commons.codec.binary.Base64.decodeBase64(sharedSecret); {code} > The exception I get is > {code:java} > java.lang.IllegalArgumentException: Last encoded character (before the > paddings if any) is a valid base 64 alphabet but not a possible value at > org.apache.commons.codec.binary.Base64.validateCharacter(Base64.java:798) > at org.apache.commons.codec.binary.Base64.decode(Base64.java:472) > at > org.apache.commons.codec.binary.BaseNCodec.decode(BaseNCodec.java:412) > at > org.apache.commons.codec.binary.BaseNCodec.decode(BaseNCodec.java:395) > at org.apache.commons.codec.binary.Base64.decodeBase64(Base64.java:694) > at > com.rbmhtechnology.oidc.provider.spi.grants.jwt.thirdparty.rest.FooTest.foo(FooTest.java:17) > at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.base/java.lang.reflect.Method.invoke(Method.java:566) > at > org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:675) > at > org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:125) > at > org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:132) > at > org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:124) > at > org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:74) > at > org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115) > at > org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:104) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:62) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:43) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:35) > at > org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104) > at > org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98) > at > org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:202) > at > org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) > at > org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:198) > at > org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135) > at > org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:69) > at > org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135) > at > org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) > at > org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) > at > org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) > at >
[jira] [Commented] (CODEC-279) Base64.decode fails on Java11 for certain valid base 64 encoded String
[ https://issues.apache.org/jira/browse/CODEC-279?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17019450#comment-17019450 ] Christian Kleinbölting commented on CODEC-279: -- > If you cannot share your entire string then can you provide the length of the > string in ascii and the last 4 characters. From that I will be able to decode > the trailing bits. The {{String.length() == 86}}. Last four characters are {color:#008000}6cjE{color}. > How did you create your encoded string? Was it using Commons Codec or another > base 64 encoder? I do not know how it was created. > Base64.decode fails on Java11 for certain valid base 64 encoded String > -- > > Key: CODEC-279 > URL: https://issues.apache.org/jira/browse/CODEC-279 > Project: Commons Codec > Issue Type: Bug >Affects Versions: 1.13, 1.14 > Environment: Java 11 >Reporter: Christian Kleinbölting >Priority: Major > > The following lines will fail for a specific String: > {code:java} > String sharedSecret = > "cannot_share_the_affected_string_because_it_is_a_secret"; > byte[] bytes = > org.apache.commons.codec.binary.Base64.decodeBase64(sharedSecret); {code} > The exception I get is > {code:java} > java.lang.IllegalArgumentException: Last encoded character (before the > paddings if any) is a valid base 64 alphabet but not a possible value at > org.apache.commons.codec.binary.Base64.validateCharacter(Base64.java:798) > at org.apache.commons.codec.binary.Base64.decode(Base64.java:472) > at > org.apache.commons.codec.binary.BaseNCodec.decode(BaseNCodec.java:412) > at > org.apache.commons.codec.binary.BaseNCodec.decode(BaseNCodec.java:395) > at org.apache.commons.codec.binary.Base64.decodeBase64(Base64.java:694) > at > com.rbmhtechnology.oidc.provider.spi.grants.jwt.thirdparty.rest.FooTest.foo(FooTest.java:17) > at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.base/java.lang.reflect.Method.invoke(Method.java:566) > at > org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:675) > at > org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:125) > at > org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:132) > at > org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:124) > at > org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:74) > at > org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115) > at > org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:104) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:62) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:43) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:35) > at > org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104) > at > org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98) > at > org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:202) > at > org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) > at > org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:198) > at > org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135) > at > org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:69) > at > org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135) > at > org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) > at >
[jira] [Commented] (CODEC-279) Base64.decode fails on Java11 for certain valid base 64 encoded String
[ https://issues.apache.org/jira/browse/CODEC-279?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17019449#comment-17019449 ] Alex Herbert commented on CODEC-279: Hi, This issue is related to [CODEC-270]. This occurs when there are unused bits left over from the input bytes. In this case it is unknown if the message has been truncated or badly encoded. The method requires that there are no unused bits left. If you cannot share your entire string then can you provide the length of the string in ascii and the last 4 characters. From that I will be able to decode the trailing bits. How did you create your encoded string. Was it using Commons Codec or another base 64 encoder? If it is a random string using characters from the base 64 alphabet then this is not a guarantee that the string will be a valid base64 encoding. Othe libraries may decode this but commons codec now throws an exception. > Base64.decode fails on Java11 for certain valid base 64 encoded String > -- > > Key: CODEC-279 > URL: https://issues.apache.org/jira/browse/CODEC-279 > Project: Commons Codec > Issue Type: Bug >Affects Versions: 1.13, 1.14 > Environment: Java 11 >Reporter: Christian Kleinbölting >Priority: Major > > The following lines will fail for a specific String: > {code:java} > String sharedSecret = > "cannot_share_the_affected_string_because_it_is_a_secret"; > byte[] bytes = > org.apache.commons.codec.binary.Base64.decodeBase64(sharedSecret); {code} > The exception I get is > {code:java} > java.lang.IllegalArgumentException: Last encoded character (before the > paddings if any) is a valid base 64 alphabet but not a possible value at > org.apache.commons.codec.binary.Base64.validateCharacter(Base64.java:798) > at org.apache.commons.codec.binary.Base64.decode(Base64.java:472) > at > org.apache.commons.codec.binary.BaseNCodec.decode(BaseNCodec.java:412) > at > org.apache.commons.codec.binary.BaseNCodec.decode(BaseNCodec.java:395) > at org.apache.commons.codec.binary.Base64.decodeBase64(Base64.java:694) > at > com.rbmhtechnology.oidc.provider.spi.grants.jwt.thirdparty.rest.FooTest.foo(FooTest.java:17) > at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.base/java.lang.reflect.Method.invoke(Method.java:566) > at > org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:675) > at > org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:125) > at > org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:132) > at > org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:124) > at > org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:74) > at > org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115) > at > org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:104) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:62) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:43) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:35) > at > org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104) > at > org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98) > at > org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:202) > at > org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) > at > org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:198) > at > org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135) > at >