SecretCache - Amazon Secrets Manager
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

SecretCache

适用于从 Secrets Manager 请求的密钥的内存中缓存。您使用 getSecretStringgetSecretBinary 从缓存中检索密钥。您可以通过传入构造函数中的 SecretCacheConfiguration 对象来配置缓存设置。

有关包括示例在内的更多信息,请参阅 检索 Java 应用程序中的 Amazon Secrets Manager 密钥

构造函数

public SecretCache()

适用于 SecretCache 对象的默认构造函数。

public SecretCache(AWSSecretsManagerClientBuilder builder)

使用 Secrets Manager 客户端(使用提供的 AWSSecretsManagerClientBuilder 创建)构造新缓存。使用此构造函数可自定义 Secrets Manager 客户端,例如使用某一特定区域或终端节点。

public SecretCache(AWSSecretsManager client)

请使用提供的 AWSSecretsManagerClient 构造新密钥缓存。使用此构造函数可自定义 Secrets Manager 客户端,例如使用某一特定区域或终端节点。

public SecretCache(SecretCacheConfiguration config)

请使用提供的 SecretCacheConfiguration 构造新密钥缓存。

方法

getSecretString

public String getSecretString(final String secretId)

从 Secrets Manager 中检索字符串密钥。返回 String

getSecretBinary

public ByteBuffer getSecretBinary(final String secretId)

从 Secrets Manager 中检索二进制密钥。返回 ByteBuffer

refreshNow

public boolean refreshNow(final String secretId) throws InterruptedException

强制刷新缓存。如果刷新完成没有错误,将返回 true,否则将返回 false

close

public void close()

关闭缓存。