Search in sources :

Example 1 with SecretCacheItem

use of com.amazonaws.secretsmanager.caching.cache.SecretCacheItem in project aws-secretsmanager-caching-java by aws.

the class SecretCache method getCachedSecret.

/**
 * Method to retrieve the cached secret item.
 *
 * @param secretId
 *        The identifier for the secret being requested.
 * @return The cached secret item
 */
private SecretCacheItem getCachedSecret(final String secretId) {
    SecretCacheItem secret = this.cache.get(secretId);
    if (null == secret) {
        this.cache.putIfAbsent(secretId, new SecretCacheItem(secretId, this.client, this.config));
        secret = this.cache.get(secretId);
    }
    return secret;
}
Also used : SecretCacheItem(com.amazonaws.secretsmanager.caching.cache.SecretCacheItem)

Example 2 with SecretCacheItem

use of com.amazonaws.secretsmanager.caching.cache.SecretCacheItem in project aws-secretsmanager-caching-java by aws.

the class SecretCache method getSecretBinary.

/**
 * Method to retrieve a binary secret from AWS Secrets Manager.
 *
 * @param secretId
 *        The identifier for the secret being requested.
 * @return The binary secret
 */
public ByteBuffer getSecretBinary(final String secretId) {
    SecretCacheItem secret = this.getCachedSecret(secretId);
    GetSecretValueResult gsv = secret.getSecretValue();
    if (null == gsv) {
        return null;
    }
    return gsv.getSecretBinary();
}
Also used : GetSecretValueResult(com.amazonaws.services.secretsmanager.model.GetSecretValueResult) SecretCacheItem(com.amazonaws.secretsmanager.caching.cache.SecretCacheItem)

Example 3 with SecretCacheItem

use of com.amazonaws.secretsmanager.caching.cache.SecretCacheItem in project aws-secretsmanager-caching-java by aws.

the class SecretCache method getSecretString.

/**
 * Method to retrieve a string secret from AWS Secrets Manager.
 *
 * @param secretId
 *        The identifier for the secret being requested.
 * @return The string secret
 */
public String getSecretString(final String secretId) {
    SecretCacheItem secret = this.getCachedSecret(secretId);
    GetSecretValueResult gsv = secret.getSecretValue();
    if (null == gsv) {
        return null;
    }
    return gsv.getSecretString();
}
Also used : GetSecretValueResult(com.amazonaws.services.secretsmanager.model.GetSecretValueResult) SecretCacheItem(com.amazonaws.secretsmanager.caching.cache.SecretCacheItem)

Aggregations

SecretCacheItem (com.amazonaws.secretsmanager.caching.cache.SecretCacheItem)3 GetSecretValueResult (com.amazonaws.services.secretsmanager.model.GetSecretValueResult)2