/** * Encrypt value as jwt rsa oeap 256 aes 256 sha 512 string. * * @param key the key * @param value the value * @return the string */ public static String encryptValueAsJwtRsaOeap256Aes256Sha512(final Key key, final Serializable value) { return encryptValueAsJwt(key, value, KeyManagementAlgorithmIdentifiers.RSA_OAEP_256, CipherExecutor.DEFAULT_CONTENT_ENCRYPTION_ALGORITHM); }
/** * Encrypt value as jwt with direct algorithm and encryption content alg aes-128-sha-256. * * @param key the key * @param value the value * @return the string */ public static String encryptValueAsJwtDirectAes128Sha256(final Key key, final Serializable value) { return encryptValueAsJwt(key, value, KeyManagementAlgorithmIdentifiers.DIRECT, CipherExecutor.DEFAULT_CONTENT_ENCRYPTION_ALGORITHM); }
@Override public String encode(final Serializable value, final Object[] parameters) { val encoded = this.encryptionEnabled && this.secretKeyEncryptionKey != null ? EncodingUtils.encryptValueAsJwt(this.secretKeyEncryptionKey, value, this.encryptionAlgorithm, this.contentEncryptionAlgorithmIdentifier) : value.toString(); if (this.signingEnabled) { val signed = sign(encoded.getBytes(StandardCharsets.UTF_8)); return new String(signed, StandardCharsets.UTF_8); } return encoded; }