Package org.forgerock.secrets.gcpkms
Class GoogleKmsSecretStore.Builder
java.lang.Object
org.forgerock.secrets.gcpkms.GoogleKmsSecretStore.Builder
- Enclosing class:
- GoogleKmsSecretStore
Builder class for
GoogleKmsSecretStore
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds theGoogleKmsSecretStore
instance.Sets the clock to use for determining how long keys should be cached for.credentials
(com.google.auth.Credentials credentials) Sets the fixed credentials to use for the connection to GCP.credentialsProvider
(com.google.api.gax.core.CredentialsProvider credentialsProvider) Set the provider for credentials for the connection to GCP.cryptoKeyCacheDuration
(Duration cryptoKeyCacheDuration) The amount of time to cache crypto keys retrieved from the KMS.cryptoKeyCacheMaxSize
(long cryptoKeyCacheMaxSize) The maximum size of the cache for crypto keys retrieved from the KMS.cryptoKeyMapping
(Function<Purpose<? extends CryptoKey>, String> cryptoKeyMapping) Sets the mapping from purposes to crypto key names in KMS.cryptoKeyMapping
(Map<Purpose<? extends CryptoKey>, String> mapping) Sets the mapping from purposes to crypto key names in KMS.cryptoKeyVersionCacheDuration
(Duration cryptoKeyVersionCacheDuration) The amount of time to cache crypto key versions retrieved from the KMS.cryptoKeyVersionCacheMaxSize
(long cryptoKeyVersionCacheMaxSize) The maximum size of the cache for crypto key versions retrieved from the KMS.keyRing
(com.google.cloud.kms.v1.KeyRingName keyRing) Sets the keyring to use as the basis for this secret store.Sets the name of a keyring to use as a basis for this secret store.Sets the key ring based on the given project, location, and key ring names.publicKeyCacheDuration
(Duration publicKeyCacheDuration) The amount of time to cache public keys retrieved from the KMS.publicKeyCacheMaxSize
(long publicKeyCacheMaxSize) The maximum size of the cache for public keys retrieved from the KMS.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
credentialsProvider
public GoogleKmsSecretStore.Builder credentialsProvider(com.google.api.gax.core.CredentialsProvider credentialsProvider) Set the provider for credentials for the connection to GCP. See javadoc oncredentials(Credentials)
for details on the available options.- Parameters:
credentialsProvider
- the credentials provider.- Returns:
- this builder.
-
credentials
Sets the fixed credentials to use for the connection to GCP. In most cases, usingGoogleCredentials.getApplicationDefault()
(orGoogleCredentials.getApplicationDefault(HttpTransportFactory)
making use ofChfHttpTransport
) is the right option as this will automatically pick up GCP credentials in many cases. If you need to manually specify credentials you can obtain these from the GCP Console and then either useServiceAccountCredentials
or else the Secrets API can also be used to obtain credentials by using theSecretsApiBearerTokenCredentials
(the latter allows the credentials to be rotated without recreating the secret store).- Parameters:
credentials
- the credentials.- Returns:
- this builder.
-
clock
Sets the clock to use for determining how long keys should be cached for.- Parameters:
clock
- the clock.- Returns:
- this builder.
-
keyRing
Sets the keyring to use as the basis for this secret store.- Parameters:
keyRing
- the KMS keyring.- Returns:
- this builder.
-
keyRing
Sets the name of a keyring to use as a basis for this secret store. The name must be fully-qualified and valid according to the syntax given byKeyRingName
.- Parameters:
keyRing
- the key ring name.- Returns:
- this builder.
- Throws:
com.google.api.pathtemplate.ValidationException
- if the name is invalid.
-
keyRing
Sets the key ring based on the given project, location, and key ring names.- Parameters:
project
- the project.location
- the location.keyRing
- the key ring name.- Returns:
- this builder.
-
cryptoKeyMapping
public GoogleKmsSecretStore.Builder cryptoKeyMapping(Function<Purpose<? extends CryptoKey>, String> cryptoKeyMapping) Sets the mapping from purposes to crypto key names in KMS. When looking for active or valid keys, this mapping is used to determine the key for that purpose.- Parameters:
cryptoKeyMapping
- the mapping from purpose to KMS key.- Returns:
- this builder.
-
cryptoKeyMapping
public GoogleKmsSecretStore.Builder cryptoKeyMapping(Map<Purpose<? extends CryptoKey>, String> mapping) Sets the mapping from purposes to crypto key names in KMS. When looking for active or valid keys, this mapping is used to determine the key for that purpose.- Parameters:
mapping
- the mapping from purpose to KMS key.- Returns:
- this builder.
-
publicKeyCacheMaxSize
The maximum size of the cache for public keys retrieved from the KMS. Defaults to 1000.- Parameters:
publicKeyCacheMaxSize
- the maximum size of the public key cache.- Returns:
- this builder.
-
publicKeyCacheDuration
The amount of time to cache public keys retrieved from the KMS. A longer duration reduces the number of API calls to the KMS to retrieve public keys (these calls are billable), but increases the time during which a disabled key will still be accepted as valid. Defaults to 1 hour. Note that public keys are cached per secret store instance and the secret stores are per server, so if you have 10 servers then there will still be 10 calls per hour to fetch the public key (one from each server).- Parameters:
publicKeyCacheDuration
- the duration to cache public keys for.- Returns:
- this builder.
-
cryptoKeyCacheMaxSize
The maximum size of the cache for crypto keys retrieved from the KMS. Defaults to 1000.- Parameters:
cryptoKeyCacheMaxSize
- the maximum size of the crypto key cache.- Returns:
- this builder.
-
cryptoKeyCacheDuration
The amount of time to cache crypto keys retrieved from the KMS. Defaults to 1 hour. Note that crypto keys are cached per secret store instance and the secret stores are per server, so if you have 10 servers then there will still be 10 calls per hour to fetch the crypto key (one from each server).- Parameters:
cryptoKeyCacheDuration
- the duration to cache crypto keys for.- Returns:
- this builder.
-
cryptoKeyVersionCacheMaxSize
The maximum size of the cache for crypto key versions retrieved from the KMS. Defaults to 1000.- Parameters:
cryptoKeyVersionCacheMaxSize
- the maximum size of the crypto key version cache.- Returns:
- this builder.
-
cryptoKeyVersionCacheDuration
public GoogleKmsSecretStore.Builder cryptoKeyVersionCacheDuration(Duration cryptoKeyVersionCacheDuration) The amount of time to cache crypto key versions retrieved from the KMS. Defaults to 1 hour. Note that crypto key versions are cached per secret store instance and the secret stores are per server, so if you have 10 servers then there will still be 10 calls per hour to fetch the crypto key version (one from each server).- Parameters:
cryptoKeyVersionCacheDuration
- the duration to cache crypto key versions for.- Returns:
- this builder.
-
build
Builds theGoogleKmsSecretStore
instance.- Returns:
- the secret store instance.
- Throws:
NullPointerException
- if a required field is not set.IllegalArgumentException
- if an invalid value has been configured.
-