Record Class OidcSession
java.lang.Object
java.lang.Record
org.apache.juneau.rest.server.auth.oidc.rp.OidcSession
- Record Components:
id- The opaque server-side session id. ForInMemorySessionStorethis is the cache key; forSignedCookieSessionStoreit is a stable identifier embedded in the signed cookie. Nevernull.subject- The ID-tokensubclaim. Nevernullor blank.sid- The ID-tokensid(session id) claim, if the IdP issued one. Used for back-channel logout targeting a single session rather than all of a subject's sessions.principal- The verified ID-token claims as aClaimsPrincipal. Nevernull.roles- The roles extracted from the configured roles claim. Nevernull; may be empty.token- The tokens returned from the token endpoint (access / refresh / id), if the store retains them.SignedCookieSessionStoredoes NOT retain tokens (stateless cookies don't carry them), so this isOptional.empty()for cookie-backed sessions.createdAt- The instant the session was created. Nevernull.expiresAt- The instant the session expires (bounded independently of token lifetime). Nevernull.
public record OidcSession(String id, String subject, Optional<String> sid, ClaimsPrincipal principal, Set<String> roles, Optional<OAuthToken> token, Instant createdAt, Instant expiresAt)
extends Record
Immutable record describing a logged-in OpenID Connect Relying Party session.
Created by OidcRelyingParty.completeLogin(jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse) after a successful login and persisted via a
SessionStore. The principal() carries the verified ID-token claims and is what the
OidcSessionAuthFilter surfaces to RoleBasedRestGuard / @Auth Principal.
Two fields support server-side (back-channel) revocation: subject() (the sub claim)
and sid() (the optional sid session-id claim). A server-side-indexed
SessionStore keys on these so an IdP-pushed logout token can invalidate the matching
session(s).
- Since:
- 10.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionOidcSession(String id, String subject, Optional<String> sid, ClaimsPrincipal principal, Set<String> roles, Optional<OAuthToken> token, Instant createdAt, Instant expiresAt) Compact constructor enforcing non-null fields and defensively copying the role set. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecreatedAtrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of theexpiresAtrecord component.final inthashCode()Returns a hash code value for this object.id()Returns the value of theidrecord component.booleanReturns whether this session is expired relative to the supplied instant.Returns the value of theprincipalrecord component.roles()Returns the value of therolesrecord component.sid()Returns the value of thesidrecord component.subject()Returns the value of thesubjectrecord component.token()Returns the value of thetokenrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
OidcSession
public OidcSession(String id, String subject, Optional<String> sid, ClaimsPrincipal principal, Set<String> roles, Optional<OAuthToken> token, Instant createdAt, Instant expiresAt) Compact constructor enforcing non-null fields and defensively copying the role set.
-
-
Method Details
-
isExpired
Returns whether this session is expired relative to the supplied instant.- Parameters:
now- The reference instant.- Returns:
true ifnowis at or afterexpiresAt().
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
id
Returns the value of theidrecord component.- Returns:
- the value of the
idrecord component
-
subject
Returns the value of thesubjectrecord component.- Returns:
- the value of the
subjectrecord component
-
sid
Returns the value of thesidrecord component.- Returns:
- the value of the
sidrecord component
-
principal
Returns the value of theprincipalrecord component.- Returns:
- the value of the
principalrecord component
-
roles
Returns the value of therolesrecord component.- Returns:
- the value of the
rolesrecord component
-
token
Returns the value of thetokenrecord component.- Returns:
- the value of the
tokenrecord component
-
createdAt
Returns the value of thecreatedAtrecord component.- Returns:
- the value of the
createdAtrecord component
-
expiresAt
Returns the value of theexpiresAtrecord component.- Returns:
- the value of the
expiresAtrecord component
-