Package com.tnsai.server.security
Class SessionCapabilityStore
java.lang.Object
com.tnsai.server.security.SessionCapabilityStore
Per-session capability tokens (TNS-302).
The first request to touch a sessionId mints a random 32-byte token; the
server returns it via the X-Session-Capability response header (HTTP)
or via a WS upgrade response. Every subsequent request that targets the same
sessionId must present the same token, otherwise the request is rejected
with 403. This prevents a second client on the same listener from
attaching to an already-active session and reading another user's tool
outputs or driving their agent.
Tokens are in-memory only — a server restart invalidates every session
capability, which matches the in-memory nature of SessionManager sessions.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether a token has been minted for this session.mintIfAbsent(String sessionId) Returns the token forsessionId, minting one on first call.voidDrop the token when the session is removed.intsize()booleanConstant-time comparison ofpresentedagainst the stored token forsessionId.
-
Field Details
-
HEADER
- See Also:
-
-
Constructor Details
-
SessionCapabilityStore
public SessionCapabilityStore()
-
-
Method Details
-
mintIfAbsent
Returns the token forsessionId, minting one on first call. Same sessionId → same token across the server's lifetime. -
has
Whether a token has been minted for this session. -
verify
Constant-time comparison ofpresentedagainst the stored token forsessionId. Returnsfalseif the session has never been minted. -
remove
Drop the token when the session is removed. -
size
public int size()
-