Class UcpCredentialsUpdater

java.lang.Object
com.maybeitssquid.rotatingsecrets.ucp.UcpCredentialsUpdater
All Implemented Interfaces:
UpdatableCredential<String>

public class UcpCredentialsUpdater extends Object implements UpdatableCredential<String>
Handles credential updates for Oracle Universal Connection Pool (UCP) data sources.

This class implements the UpdatableCredential interface to receive credential change notifications from the CredentialsProviderService. When credentials are updated, it atomically updates the pool's username and password, then triggers a pool refresh to ensure new connections use the updated credentials.

Credential Update Process

  1. Acquire a lock on the pool to ensure atomic credential updates
  2. Update the username and password on the PoolDataSource
  3. Call UniversalConnectionPoolManager.refreshConnectionPool(String) to gracefully replace connections with ones using the new credentials

Thread Safety

This class is thread-safe. Credential updates are synchronized on the pool data source to ensure atomic username/password updates. The pool refresh operation is handled asynchronously by UCP.

See Also:
  • Constructor Details

    • UcpCredentialsUpdater

      public UcpCredentialsUpdater(oracle.ucp.jdbc.PoolDataSource poolDataSource)
      Creates a new credentials updater for the given Oracle UCP pool.
      Parameters:
      poolDataSource - the Oracle UCP PoolDataSource to manage
  • Method Details

    • setCredential

      public void setCredential(String username, String credential)
      Updates the credentials used by the Oracle UCP pool and refreshes connections.

      This method atomically updates the username and password on the pool, then triggers a pool refresh. The refresh operation gracefully replaces existing connections with new ones using the updated credentials. Active connections continue to work until they are returned to the pool.

      Specified by:
      setCredential in interface UpdatableCredential<String>
      Parameters:
      username - the new database username
      credential - the new database password
      Throws:
      RuntimeException - if the credentials cannot be updated or the pool cannot be refreshed