keycloak
静的公開メンバ関数 | 全メンバ一覧
org.keycloak.common.util.Base64Url クラス
org.keycloak.common.util.Base64Url 連携図
Collaboration graph

静的公開メンバ関数

static String encode (byte[] bytes)
 
static byte [] decode (String s)
 

詳解

著者
Bill Burke
バージョン
Revision
1

関数詳解

◆ decode()

static byte [] org.keycloak.common.util.Base64Url.decode ( String  s)
inlinestatic
34  {
35  s = s.replace('-', '+'); // 62nd char of encoding
36  s = s.replace('_', '/'); // 63rd char of encoding
37  switch (s.length() % 4) // Pad with trailing '='s
38  {
39  case 0:
40  break; // No pad chars in this case
41  case 2:
42  s += "==";
43  break; // Two pad chars
44  case 3:
45  s += "=";
46  break; // One pad char
47  default:
48  throw new RuntimeException(
49  "Illegal base64url string!");
50  }
51  try {
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
53  return Base64.decode(s, Base64.DONT_GUNZIP);
54  } catch (Exception e) {
55  throw new RuntimeException(e);
56  }
57  }

◆ encode()

static String org.keycloak.common.util.Base64Url.encode ( byte []  bytes)
inlinestatic
26  {
27  String s = Base64.encodeBytes(bytes);
28  s = s.split("=")[0]; // Remove any trailing '='s
29  s = s.replace('+', '-'); // 62nd char of encoding
30  s = s.replace('/', '_'); // 63rd char of encoding
31  return s;
32  }

このクラス詳解は次のファイルから抽出されました: