Package de.otto.kafka.messaging.e2ee
Class AesEncryptedPayload
java.lang.Object
de.otto.kafka.messaging.e2ee.AesEncryptedPayload
record to hold all the data needed for an encrypted payload. But it can also hold an unencrypted
payload.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionAesEncryptedPayload(byte[] plainPayload) AesEncryptedPayload(byte[] encryptedPayload, byte[] initializationVector, int keyVersion) AesEncryptedPayload(byte[] encryptedPayload, byte[] initializationVector, int keyVersion, String encryptionKeyAttributeName) AesEncryptedPayload(byte[] encryptedPayload, String initializationVectorBase64, int keyVersion) AesEncryptedPayload(byte[] encryptedPayload, String initializationVectorBase64, int keyVersion, String encryptionKeyAttributeName) -
Method Summary
Modifier and TypeMethodDescriptionbyte[]byte[]booleanintstatic AesEncryptedPayloadofEncryptedPayload(byte[] encryptedPayload, byte[] initializationVector, EncryptionCipherSpec cipherSpec) static AesEncryptedPayloadofEncryptedPayload(byte[] encryptedPayload, byte[] initializationVector, EncryptionKeyProvider.KeyVersion keyVersion) static AesEncryptedPayloadofEncryptedPayload(byte[] encryptedPayload, String initializationVectorBase64, int keyVersion) static AesEncryptedPayloadofEncryptedPayload(byte[] encryptedPayload, String initializationVectorBase64, int keyVersion, String encryptionKeyAttributeName) static AesEncryptedPayloadofEncryptedPayload(byte[] encryptedPayload, String initializationVectorBase64, EncryptionCipherSpec cipherSpec) static AesEncryptedPayloadofUnencryptedPayload(byte[] plainPayload) toString()
-
Constructor Details
-
AesEncryptedPayload
public AesEncryptedPayload(byte[] plainPayload) - Parameters:
plainPayload- the plain text as byte array.
-
AesEncryptedPayload
public AesEncryptedPayload(byte[] encryptedPayload, byte[] initializationVector, int keyVersion) - Parameters:
encryptedPayload- an encrypted payload as byte arrayinitializationVector- the raw initialization vectorkeyVersion- the vault version of the encryption key entry
-
AesEncryptedPayload
public AesEncryptedPayload(byte[] encryptedPayload, byte[] initializationVector, int keyVersion, String encryptionKeyAttributeName) - Parameters:
encryptedPayload- an encrypted payload as byte arrayinitializationVector- the raw initialization vectorkeyVersion- the vault version of the encryption key entryencryptionKeyAttributeName- JSON property name of the key within Vault. Can benullfor Field-Level-Encryption.
-
AesEncryptedPayload
public AesEncryptedPayload(byte[] encryptedPayload, String initializationVectorBase64, int keyVersion) - Parameters:
encryptedPayload- an encrypted payload as byte arrayinitializationVectorBase64- the initialization vector base64 encodedkeyVersion- the vault version of the encryption key entry
-
AesEncryptedPayload
public AesEncryptedPayload(byte[] encryptedPayload, String initializationVectorBase64, int keyVersion, String encryptionKeyAttributeName) - Parameters:
encryptedPayload- an encrypted payload as byte arrayinitializationVectorBase64- the initialization vector base64 encodedkeyVersion- the vault version of the encryption key entryencryptionKeyAttributeName- JSON property name of the key within Vault. Can benullfor Field-Level-Encryption.
-
-
Method Details
-
ofUnencryptedPayload
- Parameters:
plainPayload- the plain payload as byte array- Returns:
- an AesEncryptedPayload of an unencrypted payload
-
ofEncryptedPayload
public static AesEncryptedPayload ofEncryptedPayload(byte[] encryptedPayload, byte[] initializationVector, EncryptionKeyProvider.KeyVersion keyVersion) - Parameters:
encryptedPayload- an encrypted payload as byte arrayinitializationVector- the raw initialization vectorkeyVersion- the vault data for the encryption key- Returns:
- an AesEncryptedPayload of an encrypted payload
-
ofEncryptedPayload
public static AesEncryptedPayload ofEncryptedPayload(byte[] encryptedPayload, String initializationVectorBase64, int keyVersion) - Parameters:
encryptedPayload- an encrypted payload as byte arrayinitializationVectorBase64- the initialization vector base64 encodedkeyVersion- the vault metadata for the encryption key- Returns:
- an AesEncryptedPayload of an encrypted payload
-
ofEncryptedPayload
public static AesEncryptedPayload ofEncryptedPayload(byte[] encryptedPayload, String initializationVectorBase64, int keyVersion, String encryptionKeyAttributeName) - Parameters:
encryptedPayload- an encrypted payload as byte arrayinitializationVectorBase64- the initialization vector base64 encodedkeyVersion- the vault version of the encryption key entryencryptionKeyAttributeName- JSON property name of the key within Vault. Can benullfor Field-Level-Encryption.- Returns:
- an AesEncryptedPayload of an encrypted payload
-
ofEncryptedPayload
public static AesEncryptedPayload ofEncryptedPayload(byte[] encryptedPayload, byte[] initializationVector, EncryptionCipherSpec cipherSpec) - Parameters:
encryptedPayload- an encrypted payload as byte arrayinitializationVector- the raw initialization vectorcipherSpec- the vault metadata for the encryption key- Returns:
- an AesEncryptedPayload of an encrypted payload
-
ofEncryptedPayload
public static AesEncryptedPayload ofEncryptedPayload(byte[] encryptedPayload, String initializationVectorBase64, EncryptionCipherSpec cipherSpec) - Parameters:
encryptedPayload- an encrypted payload as byte arrayinitializationVectorBase64- the initialization vector base64 encodedcipherSpec- the vault metadata for the encryption key- Returns:
- an AesEncryptedPayload of an encrypted payload
-
isEncrypted
public boolean isEncrypted()- Returns:
truewhen this object holds an encrypted value.falsewhen this object hold an unencrypted value.
-
encryptedPayload
public byte[] encryptedPayload()- Returns:
- the value - which might is encrypted
- See Also:
-
initializationVector
public byte[] initializationVector()- Returns:
- the raw initialization vector or
nullwhen the value is encrypted - See Also:
-
initializationVectorBase64
- Returns:
- the initialization vector base64 encoded or
nullwhen the value is encrypted - See Also:
-
keyVersion
public int keyVersion()- Returns:
- the vault version of the encryption key entry
-
encryptionKeyAttributeName
- Returns:
- name of the encryption key property within the vault. When
null, then the default value must be used.
-
toString
-