Package com.google.cloud.spring.kms
Class KmsTemplate
java.lang.Object
com.google.cloud.spring.kms.KmsTemplate
- All Implemented Interfaces:
KmsOperations
Offers convenience methods for performing common operations on KMS including encrypting and
decrypting text.
-
Constructor Summary
ConstructorDescriptionKmsTemplate
(com.google.cloud.kms.v1.KeyManagementServiceClient keyManagementServiceClient, GcpProjectIdProvider projectIdProvider) -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
decryptBytes
(String cryptoKey, byte[] cipherText) Decrypt the text using the specified KMS resource stringcryptoKey
decryptText
(String cryptoKey, byte[] cipherText) Decrypt the text using the specified KMS resource stringcryptoKey
byte[]
encryptBytes
(String cryptoKey, byte[] bytes) Encrypt thebytes
using the specified KMS resource stringcryptoKey
.byte[]
encryptText
(String cryptoKey, String text) Encrypt thetext
using the specified KMS resource stringcryptoKey
.
-
Constructor Details
-
KmsTemplate
public KmsTemplate(com.google.cloud.kms.v1.KeyManagementServiceClient keyManagementServiceClient, GcpProjectIdProvider projectIdProvider)
-
-
Method Details
-
encryptText
Description copied from interface:KmsOperations
Encrypt thetext
using the specified KMS resource stringcryptoKey
.An encryption request will be issued using GCP KMS.
- Specified by:
encryptText
in interfaceKmsOperations
- Parameters:
cryptoKey
- The KMS resource stringtext
- UTF-8 encoded text to encrypt- Returns:
- The encrypted bytes
-
encryptBytes
Description copied from interface:KmsOperations
Encrypt thebytes
using the specified KMS resource stringcryptoKey
.An encryption request will be issued using GCP KMS.
- Specified by:
encryptBytes
in interfaceKmsOperations
- Parameters:
cryptoKey
- The KMS resource stringbytes
- The bytes to encrypt- Returns:
- The encrypted bytes
-
decryptText
Description copied from interface:KmsOperations
Decrypt the text using the specified KMS resource stringcryptoKey
A decryption request will be issued using GCP KMS.
- Specified by:
decryptText
in interfaceKmsOperations
- Parameters:
cryptoKey
- The KMS resource stringcipherText
- The encrypted bytes- Returns:
- The decrypted bytes UTF-8 encoded
-
decryptBytes
Description copied from interface:KmsOperations
Decrypt the text using the specified KMS resource stringcryptoKey
A decryption request will be issued using GCP KMS.
- Specified by:
decryptBytes
in interfaceKmsOperations
- Parameters:
cryptoKey
- The KMS resource stringcipherText
- The encrypted bytes- Returns:
- The decrypted bytes
-