refactor(core): decode base64url text through Base64Url (#6457)

Base64Url had encode but no decode, so 21 places in src/main decoded
base64url text by hand with new String(Base64.getUrlDecoder().decode(...),
UTF_8). Base64Url.decode now does that, and those callers use it. It is the
same JDK decoder, so padded and unpadded input still decode and invalid
input still throws IllegalArgumentException. The byte[] decodes of JWT
segments and keys are left as they are.
This commit is contained in:
Kenshin Okinaka authored and GitHub committed 2026-10-24 20:04:57 -04:00
1 parent a813720674
commit eb99ea6655
21 files changed
+49 -46

No files matched your search

@@ -3,6 +3,7 @@ package io.github.hectorvent.floci.core.common;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
class Base64UrlTest {
@@ -15,4 +16,19 @@ class Base64UrlTest {
void encodesTextAsUtf8() {
assertEquals("w6k", Base64Url.encode("é"));
}
@Test
void decodesUnpaddedTextAsUtf8() {
assertEquals("é", Base64Url.decode("w6k"));
}
@Test
void decodesPaddedText() {
assertEquals("é", Base64Url.decode("w6k="));
}
@Test
void refusesTextThatIsNotBase64Url() {
assertThrows(IllegalArgumentException.class, () -> Base64Url.decode("!!!"));
}
}