Package br.com.seedgrid.privacy
Class EncryptedFieldAttributeConverter
java.lang.Object
br.com.seedgrid.privacy.EncryptedFieldAttributeConverter
public class EncryptedFieldAttributeConverter
extends Object
implements jakarta.persistence.AttributeConverter<String,String>
Cifra/decifra um campo
String de forma transparente (@Convert).
Respeita o modo global CryptoProvider.isEncryptionEnabled():
- Escrita: se a criptografia estiver ligada, cifra (exige
seedgrid.privacy.crypto.key); se desligada, grava o valor cru — a lib fica agnostica, sem exigir chave. - Leitura: segue o dado, nao o flag — se o valor no banco esta cifrado (
v1:...) ele e decifrado (exige a chave); se esta cru, volta como esta. Assim um banco em claro (modo desligado) le normal, e um dado cifrado sem chave configurada falha (erro real de config), nunca devolve texto cifrado como se fosse o valor.
O construtor com CryptoService (usado em teste/uso avancado) cifra sempre, ignorando
o flag — fornecer um service explicitamente ja e a intencao de cifrar.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvertToDatabaseColumn(String attribute) convertToEntityAttribute(String dbData)
-
Constructor Details
-
EncryptedFieldAttributeConverter
public EncryptedFieldAttributeConverter()
-
-
Method Details