Package org.apache.spark.security
Class UserContext
Object
org.apache.spark.security.UserContext
:: DeveloperApi ::
Represents the authenticated user's identity context on the driver side.
This class holds the OIDC token information used to derive short-lived
ServiceCredential instances via credential providers. It is intentionally
not Serializable and must never be transmitted to executors.
The rawToken field is always redacted in toString().
- Since:
- 4.4.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanEquality is based on identity fields (principal,issuer) and token validity window (issuedAt,expiresAt).Returns the token expiry time, ornullif not set.Returns the token issue time, ornullif not set.Returns theissclaim (token issuer).Returns thesubclaim (principal identifier).Returns the raw OIDC JWT.inthashCode()booleanReturnstrueif this context's token has expired relative to the given instant.toString()Returns a string representation with therawTokenredacted as[REDACTED].
-
Constructor Details
-
UserContext
public UserContext(String principal, String issuer, String rawToken, Instant issuedAt, Instant expiresAt) Constructs a newUserContext.- Parameters:
principal- thesubclaim from the JWT (must not be null)issuer- theissclaim from the JWT (must not be null)rawToken- the raw OIDC JWT string (must not be null)issuedAt- token issue time (may be null)expiresAt- token expiry time (may be null)
-
-
Method Details
-
getPrincipal
Returns thesubclaim (principal identifier). -
getIssuer
Returns theissclaim (token issuer). -
getRawToken
Returns the raw OIDC JWT. This value must never be logged or transmitted to executors. -
getIssuedAt
Returns the token issue time, ornullif not set. -
getExpiresAt
Returns the token expiry time, ornullif not set. -
isExpired
Returnstrueif this context's token has expired relative to the given instant. IfexpiresAtisnull, this method returnsfalse.- Parameters:
now- the current time to compare against (must not be null)- Returns:
- whether the token is expired
-
toString
Returns a string representation with therawTokenredacted as[REDACTED]. -
equals
Equality is based on identity fields (principal,issuer) and token validity window (issuedAt,expiresAt). The secretrawTokenis intentionally excluded:UserContextis driver-only and never used as a map key, so there is no need to compare secret material. -
hashCode
public int hashCode()
-