"7Cc2GxgvI7zqWo0YIEc7aCflLG1-8BboVWFdZKLK9vNoycrYHumwzKluLWEbSV" +
"maPpOslY2n525DxDfWaVFUfKQxMF56vn4B9QMpWAbnypNimbM8zVOw" +
"." +
"UCGiqJxhBI3IFVdPalHHvA";
PublicJsonWebKey jwk = PublicJsonWebKey.Factory.newPublicJwk(figure62RsaJwkJsonString);
// verify that we can decrypt the encrypted key
JsonWebEncryption jwe = new JsonWebEncryption();
jwe.setCompactSerialization(jweCompactSerialization);
jwe.setKey(jwk.getPrivateKey());
KeyManagementAlgorithm keyManagementModeAlg = jwe.getKeyManagementModeAlgorithm();
ContentEncryptionKeyDescriptor cekDesc = new ContentEncryptionKeyDescriptor(32, AesKey.ALGORITHM);
Key cek = keyManagementModeAlg.manageForDecrypt(jwe.getKey(), jwe.getEncryptedKey(), cekDesc, jwe.getHeaders());
String encodedExampleCek = "mYMfsggkTAm0TbvtlFh2hyoXnbEzJQjMxmgLN3d8xXA";
assertArrayEquals(cek.getEncoded(), Base64Url.decode(encodedExampleCek));
// and that we can decrypt the whole thing
assertThat(jwePlaintext, equalTo(jwe.getPlaintextString()));
// verify that we can reproduce it (most/some of it) from the inputs
jwe = new JsonWebEncryption();
jwe.setPlaintext(jwePlaintext);
jwe.setKey(jwk.getPublicKey());
jwe.setAlgorithmHeaderValue(KeyManagementAlgorithmIdentifiers.RSA_OAEP);
jwe.setKeyIdHeaderValue(jwk.getKeyId());
jwe.setEncryptionMethodHeaderParameter(ContentEncryptionAlgorithmIdentifiers.AES_256_GCM);
// set the IV and cek per the example (you wouldn't usually do this but it makes the output more deterministic)
jwe.setEncodedIv("-nBoKLH0YkLZPSI9");
jwe.setEncodedContentEncryptionKey(encodedExampleCek);