Interface UpdatableCredential<T>

Type Parameters:
T - the type of the credential (typically String for passwords)

public interface UpdatableCredential<T>
Interface for components that need to receive updated credentials when they change.

This interface enables a publish-subscribe pattern for credential rotation. When credentials are rotated (e.g., by reading new values from Kubernetes-mounted secret files), all registered UpdatableCredential implementations are notified with the new values.

Implementations typically wrap connection pools and handle the pool-specific logic for updating credentials and refreshing connections. For example:

  • HikariCredentialsUpdater in rotating-secrets-hikari - Updates HikariCP credentials and soft-evicts connections
  • UcpCredentialsUpdater in rotating-secrets-ucp - Updates Oracle UCP credentials and refreshes the pool
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    setCredential(String username, T credential)
    Updates the credentials used by this component.
  • Method Details

    • setCredential

      void setCredential(String username, T credential)
      Updates the credentials used by this component.

      Implementations should atomically update their stored credentials and trigger any necessary pool refresh operations. This method may be called from a scheduled background thread, so implementations must be thread-safe.

      Implementations must not log the credential argument, directly or through an exception message or a toString of their own state. The credential is a live secret, and anything written to a log is copied to every system that stores that log.

      Parameters:
      username - the new username to use for connections
      credential - the new credential (password) to use for connections