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

静的公開メンバ関数

static void verify (String privateKeyPem, String publicKeyPem) throws VerificationException
 

詳解

著者
Stian Thorgersen

関数詳解

◆ verify()

static void org.keycloak.KeyPairVerifier.verify ( String  privateKeyPem,
String  publicKeyPem 
) throws VerificationException
inlinestatic
34  {
35  PrivateKey privateKey;
36  try {
37  privateKey = PemUtils.decodePrivateKey(privateKeyPem);
38  } catch (Exception e) {
39  throw new VerificationException("Failed to decode private key");
40  }
41 
42  PublicKey publicKey;
43  try {
44  publicKey = PemUtils.decodePublicKey(publicKeyPem);
45  } catch (Exception e) {
46  throw new VerificationException("Failed to decode public key");
47  }
48 
49  try {
50  String jws = new JWSBuilder().content("content".getBytes()).rsa256(privateKey);
51  if (!RSAProvider.verify(new JWSInput(jws), publicKey)) {
52  throw new VerificationException("Keys don't match");
53  }
54  } catch (Exception e) {
55  throw new VerificationException("Keys don't match");
56  }
57  }

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