Class AwsKmsClient
java.lang.Object
io.confluent.kafka.schemaregistry.encryption.aws.AwsKmsClient
- All Implemented Interfaces:
com.google.crypto.tink.KmsClient
An implementation of
KmsClient for AWS KMS.- Since:
- 1.0.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a generic AwsKmsClient that is not bound to any specific key.AwsKmsClient(String uri) Constructs a specific AwsKmsClient that is bound to a single key identified byuri. -
Method Summary
Modifier and TypeMethodDescriptionbooleandoesSupport(String uri) com.google.crypto.tink.Aeadstatic voidCreates and registers aAwsKmsClient(java.lang.String)with the Tink runtime.protected static StringremovePrefix(String expectedPrefix, String kmsKeyUri) com.google.crypto.tink.KmsClientwithCredentials(String credentialPath) Loads AWS credentials from a properties file.com.google.crypto.tink.KmsClientwithCredentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider provider) Loads AWS credentials from a provider.com.google.crypto.tink.KmsClientLoads default AWS credentials.
-
Field Details
-
PREFIX
The prefix of all keys stored in AWS KMS.- See Also:
-
-
Constructor Details
-
AwsKmsClient
public AwsKmsClient()Constructs a generic AwsKmsClient that is not bound to any specific key. This constructor should not be used. We recommend to register the client instead. -
AwsKmsClient
Constructs a specific AwsKmsClient that is bound to a single key identified byuri. This constructor should not be used. We recommend to register the client instead.
-
-
Method Details
-
doesSupport
- Specified by:
doesSupportin interfacecom.google.crypto.tink.KmsClient- Returns:
- true either if this client is a generic one and uri starts with
PREFIX, or the client is a specific one that is bound to the key identified byuri.
-
withCredentials
@CanIgnoreReturnValue public com.google.crypto.tink.KmsClient withCredentials(String credentialPath) throws GeneralSecurityException Loads AWS credentials from a properties file.The AWS access key ID is expected to be in the
accessKeyproperty and the AWS secret key is expected to be in thesecretKeyproperty.- Specified by:
withCredentialsin interfacecom.google.crypto.tink.KmsClient- Throws:
GeneralSecurityException- if the client initialization fails
-
withDefaultCredentials
@CanIgnoreReturnValue public com.google.crypto.tink.KmsClient withDefaultCredentials() throws GeneralSecurityExceptionLoads default AWS credentials.AWS credentials provider chain that looks for credentials in this order:
- Environment Variables - AWS_ACCESS_KEY_ID and AWS_SECRET_KEY
- Java System Properties - aws.accessKeyId and aws.secretKey
- Credential profiles file at the default location (~/.aws/credentials)
- Instance profile credentials delivered through the Amazon EC2 metadata service
- Specified by:
withDefaultCredentialsin interfacecom.google.crypto.tink.KmsClient- Throws:
GeneralSecurityException- if the client initialization fails
-
withCredentialsProvider
@CanIgnoreReturnValue public com.google.crypto.tink.KmsClient withCredentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider provider) throws GeneralSecurityException Loads AWS credentials from a provider.- Throws:
GeneralSecurityException
-
removePrefix
-
getAead
- Specified by:
getAeadin interfacecom.google.crypto.tink.KmsClient- Throws:
GeneralSecurityException
-
register
public static void register(Optional<String> keyUri, Optional<String> credentialPath) throws GeneralSecurityException Creates and registers aAwsKmsClient(java.lang.String)with the Tink runtime.If
keyUriis present, it is the only key that the new client will support. Otherwise the new client supports all AWS KMS keys.If
credentialPathis present, load the credentials from that. Otherwise use the default credentials.- Throws:
GeneralSecurityException
-