35 s = s.replace('-', '+'); // 62nd char of encoding
36 s = s.replace('_', '/'); // 63rd char of encoding
37switch (s.length() % 4) // Pad with trailing '='s
38 {
39case 0:
40break; // No pad chars in this case
41case 2:
42 s += "==";
43break; // Two pad chars
44case 3:
45 s += "=";
46break; // One pad char
47default:
48thrownew RuntimeException(
49"Illegal base64url string!");
50 }
51try {
52// KEYCLOAK-2479 : Avoid to try gzip decoding as for some objects, it may display exception to STDERR. And we know that object wasn't encoded as GZIP