Class StorageAwareCookieManager

All Implemented Interfaces:
Component, DestructableComponent, InitializableComponent

public class StorageAwareCookieManager extends CookieManager
An extended CookieManager that allows use of a StorageService.

Reads are backed up by a read into the storage service, while writes are passed through to it.

The cookie path and domain, and the username (as obtained by a lookup function) are used to construct the storage context and key to maintain the expected isolation. Notably, the function operates by obtaining the ProfileRequestContext from the bound request attribute to address the fact that the API does not directly include it.

This is NOT suitable for use cases in which consistency of data is critical, as there are few if any storage options (other than the client itself) that will provide sufficient reliability and locking to avoid problems. It's best used for advisory cookies whose absence does not create issues with security or expected behavior.

Since:
5.1.0
  • Field Details

    • log

      @Nonnull private org.slf4j.Logger log
      Class logger.
    • storageService

      @Nullable private StorageService storageService
      Optional storage service to backstop the cookie.
    • usernameLookupStrategy

      @Nullable private Function<ProfileRequestContext,String> usernameLookupStrategy
      Lookup strategy for username.
    • storageContext

      @NonnullAfterInit private String storageContext
      Storage context based on fixed value and cookie attributes.
  • Constructor Details

    • StorageAwareCookieManager

      public StorageAwareCookieManager()
  • Method Details