public void testwithSHA256AndA128GCM()
throws Exception {
JWEHeader header = new JWEHeader(JWEAlgorithm.RSA_OAEP_256, EncryptionMethod.A128GCM);
Payload payload = new Payload("Hello world!");
JWEObject jweObject = new JWEObject(header, payload);
assertEquals("State check", JWEObject.State.UNENCRYPTED, jweObject.getState());
JWEEncrypter encrypter = new RSAEncrypter(publicKey);
encrypter.setKeyEncryptionProvider(BouncyCastleProviderSingleton.getInstance());
jweObject.encrypt(encrypter);
assertEquals("State check", JWEObject.State.ENCRYPTED, jweObject.getState());
String jweString = jweObject.serialize();
jweObject = JWEObject.parse(jweString);
JWEDecrypter decrypter = new RSADecrypter(privateKey);
decrypter.setKeyEncryptionProvider(BouncyCastleProviderSingleton.getInstance());
assertEquals(privateKey, ((RSADecrypter)decrypter).getPrivateKey());
jweObject.decrypt(decrypter);
assertEquals("State check", JWEObject.State.DECRYPTED, jweObject.getState());
payload = jweObject.getPayload();
assertEquals("Hello world!", payload.toString());
}