Class UcpCredentialsUpdater
- All Implemented Interfaces:
com.maybeitssquid.rotatingsecrets.UpdatableCredential<String>
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
- Acquire a lock on the pool to ensure atomic credential updates
- Update the username and password on the
PoolDataSource - 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 Summary
ConstructorsConstructorDescriptionUcpCredentialsUpdater(oracle.ucp.jdbc.PoolDataSource poolDataSource) Creates a new credentials updater for the given Oracle UCP pool. -
Method Summary
Modifier and TypeMethodDescriptionvoidsetCredential(String username, String credential) Updates the credentials used by the Oracle UCP pool and refreshes connections if the pool exists.
-
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
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:
setCredentialin interfacecom.maybeitssquid.rotatingsecrets.UpdatableCredential<String>- Parameters:
username- the new database usernamecredential- the new database password- Throws:
RuntimeException- if the credentials cannot be updated or the pool cannot be refreshed
-