Class UcpCredentialsUpdater

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

public class UcpCredentialsUpdater extends Object implements com.maybeitssquid.rotatingsecrets.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. If the pool is registered with the manager, call UniversalConnectionPoolManager.refreshConnectionPool(String) to gracefully replace connections with ones using the new credentials. A pool that has not been created yet already uses the new credentials when it is created, so there is nothing to refresh

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 if the pool exists.

      This method atomically updates the username and password on the pool, then refreshes the pool if it is registered with the manager. 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 com.maybeitssquid.rotatingsecrets.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