use of org.gluu.oxauth.model.crypto.encryption.KeyEncryptionAlgorithm in project oxAuth by GluuFederation.
the class CrossEncryptionTest method encryptWithGluuJweEncrypter.
private String encryptWithGluuJweEncrypter() {
try {
RSAKey recipientPublicJWK = (RSAKey) (JWK.parse(recipientJwkJson));
BlockEncryptionAlgorithm blockEncryptionAlgorithm = BlockEncryptionAlgorithm.A128GCM;
KeyEncryptionAlgorithm keyEncryptionAlgorithm = KeyEncryptionAlgorithm.RSA_OAEP;
Jwe jwe = new Jwe();
jwe.getHeader().setType(JwtType.JWT);
jwe.getHeader().setAlgorithm(keyEncryptionAlgorithm);
jwe.getHeader().setEncryptionMethod(blockEncryptionAlgorithm);
jwe.getClaims().setIssuer("https:devgluu.saminet.local");
jwe.getClaims().setSubjectIdentifier("testing");
jwe.getHeader().setKeyId("1");
JweEncrypterImpl encrypter = new JweEncrypterImpl(keyEncryptionAlgorithm, blockEncryptionAlgorithm, recipientPublicJWK.toPublicKey());
jwe = encrypter.encrypt(jwe);
// System.out.println("EncodedIntegrityValue: " + jwe.getEncodedIntegrityValue());
return jwe.toString();
} catch (Exception e) {
System.out.println("Error encryption with Gluu JweEncrypter: " + e.getMessage());
return null;
}
}
Aggregations