Class CachingSessionKeySupplier
- java.lang.Object
-
- com.oracle.bmc.auth.CachingSessionKeySupplier
-
- All Implemented Interfaces:
SessionKeySupplier
public class CachingSessionKeySupplier extends Object implements SessionKeySupplier
A standalone CachingSessionKeySupplier implementation that provides caching functionality for session keys while maintaining complete independence and modularity.This implementation decouples the caching of session keys from AbstractRequestingAuthenticationDetailsProvider, allowing any authentication provider to use caching functionality without creating dependencies on other authentication provider classes.
This implementation wraps another SessionKeySupplier and caches the private key bytes to avoid repeated expensive serialization operations. It uses thread-safe double-checked locking for optimal performance in concurrent environments.
-
-
Constructor Summary
Constructors Constructor Description CachingSessionKeySupplier(SessionKeySupplier delegate)Creates a new CachingSessionKeySupplier that wraps the provided delegate.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description KeyPairgetKeyPair()Returns the current RSA key pair.byte[]getPrivateKeyBytes()Returns the cached private key bytes, updating the cache if the key has changed.voidrefreshKeys()If the auth service-issued security token expires, the federation client will try to re-generate a new set of keys by calling this method.
-
-
-
Constructor Detail
-
CachingSessionKeySupplier
public CachingSessionKeySupplier(SessionKeySupplier delegate)
Creates a new CachingSessionKeySupplier that wraps the provided delegate.- Parameters:
delegate- the SessionKeySupplier to wrap and cache results for- Throws:
IllegalArgumentException- if delegate is null
-
-
Method Detail
-
getKeyPair
public KeyPair getKeyPair()
Description copied from interface:SessionKeySupplierReturns the current RSA key pair.- Specified by:
getKeyPairin interfaceSessionKeySupplier- Returns:
- The RSA key pair.
-
refreshKeys
public void refreshKeys()
Description copied from interface:SessionKeySupplierIf the auth service-issued security token expires, the federation client will try to re-generate a new set of keys by calling this method.The implementer should create a new pair of keys for security reasons.
Refreshing keys should not be a long-running blocking call. You can refresh keys in an async thread and return from this method immediately. When the async process is done refreshing the keys, the client code will automatically pick up the latest set of keys and update the security token accordingly
- Specified by:
refreshKeysin interfaceSessionKeySupplier
-
getPrivateKeyBytes
public byte[] getPrivateKeyBytes()
Returns the cached private key bytes, updating the cache if the key has changed.Uses double-checked locking pattern for thread safety and performance.
- Returns:
- the private key as byte array
-
-