Class SecretCacheObject<T>

java.lang.Object
com.amazonaws.secretsmanager.caching.cache.SecretCacheObject<T>
Direct Known Subclasses:
SecretCacheItem, SecretCacheVersion

public abstract class SecretCacheObject<T> extends Object
Basic secret caching object.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final software.amazon.awssdk.services.secretsmanager.SecretsManagerClient
    The AWS Secrets Manager client to use for requesting secrets.
    protected final SecretCacheConfiguration
    The Secret Cache Configuration.
    If the last request to AWS Secrets Manager resulted in an exception, that exception will be thrown back to the caller when requesting secret data.
    protected final Object
    A private object to synchronize access to certain methods.
    protected final String
    The secret identifier for this cached object.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SecretCacheObject(String secretId, software.amazon.awssdk.services.secretsmanager.SecretsManagerClient client, SecretCacheConfiguration config)
    Construct a new cached item for the secret.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract boolean
     
    protected abstract T
    Execute the actual refresh of the cached secret state.
    software.amazon.awssdk.services.secretsmanager.model.GetSecretValueResponse
    Return the cached result from AWS Secrets Manager for GetSecretValue.
    protected abstract software.amazon.awssdk.services.secretsmanager.model.GetSecretValueResponse
    getSecretValue(T result)
    Execute the actual refresh of the cached secret state.
    abstract int
     
    protected boolean
    Determine if the secret object should be refreshed.
    boolean
    Method to force the refresh of a cached secret state.
    abstract String
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • secretId

      protected final String secretId
      The secret identifier for this cached object.
    • lock

      protected final Object lock
      A private object to synchronize access to certain methods.
    • client

      protected final software.amazon.awssdk.services.secretsmanager.SecretsManagerClient client
      The AWS Secrets Manager client to use for requesting secrets.
    • config

      protected final SecretCacheConfiguration config
      The Secret Cache Configuration.
    • exception

      protected RuntimeException exception
      If the last request to AWS Secrets Manager resulted in an exception, that exception will be thrown back to the caller when requesting secret data.
  • Constructor Details

    • SecretCacheObject

      public SecretCacheObject(String secretId, software.amazon.awssdk.services.secretsmanager.SecretsManagerClient client, SecretCacheConfiguration config)
      Construct a new cached item for the secret.
      Parameters:
      secretId - The secret identifier. This identifier could be the full ARN or the friendly name for the secret.
      client - The AWS Secrets Manager client to use for requesting the secret.
      config - The secret cache configuration.
  • Method Details

    • executeRefresh

      protected abstract T executeRefresh()
      Execute the actual refresh of the cached secret state.
      Returns:
      The result of the refresh
    • getSecretValue

      protected abstract software.amazon.awssdk.services.secretsmanager.model.GetSecretValueResponse getSecretValue(T result)
      Execute the actual refresh of the cached secret state.
      Parameters:
      result - The AWS Secrets Manager result for the secret state.
      Returns:
      The cached GetSecretValue result based on the current cached state.
    • equals

      public abstract boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public abstract int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public abstract String toString()
      Overrides:
      toString in class Object
    • isRefreshNeeded

      protected boolean isRefreshNeeded()
      Determine if the secret object should be refreshed.
      Returns:
      True if the secret item should be refreshed.
    • refreshNow

      public boolean refreshNow() throws InterruptedException
      Method to force the refresh of a cached secret state.
      Returns:
      True if the refresh completed without error.
      Throws:
      InterruptedException - If the thread is interrupted while waiting for the refresh.
    • getSecretValue

      public software.amazon.awssdk.services.secretsmanager.model.GetSecretValueResponse getSecretValue()
      Return the cached result from AWS Secrets Manager for GetSecretValue.
      Returns:
      The cached GetSecretValue result.