Class BlueMindSessionStorage

java.lang.Object
org.exoplatform.bluemind.client.BlueMindSessionStorage

public class BlueMindSessionStorage extends Object
The BlueMind sessions the technical-account (bluemind-sudo) credentials provider spends, kept so that producing material does not cost two round-trips every time (EXO-89647). It spends the client's login and sudo doors (BlueMindAuthenticator), so there is one login path.

Two stores: the technical account's session, one per BlueMind server and technical login, shared by every user; and the session opened as a target account, one per server, technical login and target, shared by that user's CalDAV and mail connectors. The keys carry every input a session depends on as compared fields, so an administrator who points a connector at another server or another technical account gets fresh sessions at once. The technical secret is one of those inputs too, through a digest only: both stores file their entries and their loads in flight under the key and an HMAC-SHA256 of the secret, made with one random key drawn when this storage is created and shared by the two stores, so a target session's repair finds the technical entry its own load filed. Two connectors that name the same server and technical login with different secrets therefore never share a session nor wait on each other's login: one with a wrong secret fails alone, and a rotated secret takes effect at the next production. The secret itself is never kept, and its digest means nothing outside this node's memory.

Why this is not BlueMindSessionCache. Both keep BlueMind sessions in this node's memory and nowhere else, for the same reason (a session acts as a user and must not be reachable through the platform's cache layer nor replicated). Their rules differ where it matters: this store hands the session id out as credential material with a declared expiry and loads under single flight; the cache keeps the id in, retries a refused session inside the call, and closes what it does not keep. Merging them is a behaviour change on one side or the other, not a copy.

Bounded: a lifetime (default 300 s, exo.connector.credentials.bluemind.session.ttlSeconds on the provider) and a number of sessions per store (default 10000, …session.maxSessions); past that number a session is used but not kept. A zero lifetime keeps nothing. Residual bound: a load already in flight when its key is evicted still writes back; the lifetime is the backstop.

  • Field Details

    • DEFAULT_TTL_SECONDS

      public static final int DEFAULT_TTL_SECONDS
      Default entry lifetime, in seconds. Measured on BlueMind 5 (2026-09-23, a live instance): a session left idle 15 minutes still answered, one left idle 30 minutes was refused with a 401, and a session used every minute was still valid after an hour. A kept session can sit idle in this store, so the bound that matters is the inactivity timeout: the lifetime stays well below 15 minutes.
      See Also:
    • DEFAULT_MAX_SESSIONS

      public static final int DEFAULT_MAX_SESSIONS
      Default number of sessions kept per store and per node.
      See Also:
    • ORIGIN

      public static final String ORIGIN
      The origin the technical login names itself with in BlueMind's audit.
      See Also:
  • Constructor Details

    • BlueMindSessionStorage

      public BlueMindSessionStorage(BlueMindAuthenticator authenticator, int ttlSeconds, int maxSessions)
      A storage on the system clock.
      Parameters:
      authenticator - BlueMind's login and sudo doors
      ttlSeconds - how long a session is kept; zero keeps nothing
      maxSessions - how many sessions each store keeps at once
  • Method Details

    • technicalSession

      public BlueMindCachedSession technicalSession(BlueMindTechnicalKey key, String technicalSecret)
      The technical account's session on one BlueMind server, logged in once and kept.
      Parameters:
      key - the server and the technical login
      technicalSecret - the technical account's password, used on a miss only
      Returns:
      the session, with when it was opened
      Throws:
      BlueMindException - when BlueMind refuses the login or cannot be reached
    • sudoSession

      public BlueMindCachedSession sudoSession(BlueMindSudoKey key, String technicalSecret)
      The session opened as the target account, through the technical session.

      A kept technical session may have expired on BlueMind's side while still kept: when BlueMind refuses the sudo's own authentication (HTTP 401) with a technical session this call did not open, that session is dropped and the sudo tried once more with a fresh login. Any other failure — an account BlueMind does not know (status: Bad), a BlueMind that is down — is the answer and propagates as it is, without spending a login on it. Nothing is kept on a failure: the next call tries again.

      Parameters:
      key - the server, the technical login and the target account
      technicalSecret - the technical account's password, used when a login is needed
      Returns:
      the target's session, with when it was opened
      Throws:
      BlueMindException - when BlueMind refuses or cannot be reached
    • evictSudoSession

      public void evictSudoSession(BlueMindSudoKey key)
      Drops the session kept for one target, so the next production opens a new one - whatever secret it was opened with: the caller that invalidates does not hold the secret.
      Parameters:
      key - the server, the technical login and the target account
    • evictTechnicalSession

      public void evictTechnicalSession(BlueMindTechnicalKey key)
      Drops the technical session kept for one server and technical login, whatever secret it was opened with.
      Parameters:
      key - the server and the technical login
    • expiresAtMillis

      public Long expiresAtMillis(BlueMindCachedSession session)
      When material produced from a target session should be considered stale: the moment its entry expires, so a caller never holds material the store has already let go of. None when the store keeps nothing (zero lifetime): the session's own life is BlueMind's, and unknown here.
      Parameters:
      session - the target session
      Returns:
      the expiry, in epoch milliseconds, or null when the store keeps nothing