Class 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 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

      • refreshKeys

        public void refreshKeys()
        Description copied from interface: SessionKeySupplier
        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.

        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:
        refreshKeys in interface SessionKeySupplier
      • 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