Interface StatelessUtil
- 
- All Known Implementing Classes:
- StatelessUtilImpl
 
 public interface StatelessUtilUtility for JWT-based cookies - specifically those intended to drive stateless behavior, such as stateless sessions.- Author:
- Jeff Fischer
 
- 
- 
Method SummaryAll Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description org.springframework.http.ResponseCookiecreateSavedRequestCookie(String requestUrl, String redirectUrl)Create a cookie containing a JWT token identifying an originating request url and a redirect url.org.springframework.http.ResponseCookiecreateSavedRequestRemovalCookie()Create a cookie that can be passed to the response to clear any existing saved request cookie in the browser.javax.servlet.http.CookiecreateSessionCookie(OAuth2SessionToken sessionToken)Deprecated.in favor ofgetSessionCookie(OAuth2SessionToken)com.nimbusds.jwt.SignedJWTgenerateSignedJwt(String subject, Map<String,Object> claims, Long expiresInSeconds)Generate a signed JWT with issuer and audience values as well as optional additional claims.StringgetClientId(String savedRequestToken)Map<String,Object>getCookieClaims(String cookieValue)Get a Map of the claims from a SignedJWT cookie.StringgetIssuer()StringgetRedirectUrl(javax.servlet.http.Cookie savedRequestCookie)Verify the JWT token contained in the cookie and then return the redirect url contained therein.org.springframework.http.ResponseCookiegetRemovalCookie(javax.servlet.http.Cookie cookieToRemove)Returns a removal cookie for any arbitrary cookie.javax.servlet.http.CookiegetRemoveSavedRequestCookie()Deprecated.since 1.6, replaced bycreateSavedRequestRemovalCookie()javax.servlet.http.CookiegetRemoveSessionCookie(String clientId)Deprecated.in favor ofgetSessionRemovalCookie(String)StringgetRequestUrl(javax.servlet.http.Cookie savedRequestCookie)Verify the JWT token contained in the cookie and then return the original request url contained therein.javax.servlet.http.CookiegetSavedRequestCookie(String requestUrl, String redirectUrl)Deprecated.since 1.6, replaced bycreateSavedRequestCookie(String, String)StringgetSavedRequestCookieName()Get the standard name for a saved request cookieStringgetSavedRequestJwt(String requestUrl, String redirectUrl)org.springframework.http.ResponseCookiegetSessionCookie(OAuth2SessionToken sessionToken)Gets aResponseCookiefor theOAuth2SessionToken.StringgetSessionCookieName(AuthorizedClient client, AuthorizationServer server)StringgetSessionCookieName(String clientId)Get the standard name for a session cookieorg.springframework.http.ResponseCookiegetSessionRemovalCookie(String clientId)Gets aResponseCookiefor the removal of the session cookie.OAuth2SessionTokengetSessionToken(String clientId, String userId, String subject, Map<String,Object> additionalClaims)Creates aOAuth2SessionTokenfor the provided client ID and subject with the set of additional claims.OAuth2SessionTokenrefreshSessionToken(OAuth2SessionToken sessionToken)Returns aOAuth2SessionTokenwith a refreshed expiration time.com.nimbusds.jwt.SignedJWTverify(String token)Verify the signature of a signed JWT inside a cookie
 
- 
- 
- 
Method Detail- 
getSessionTokenOAuth2SessionToken getSessionToken(String clientId, String userId, String subject, Map<String,Object> additionalClaims) Creates aOAuth2SessionTokenfor the provided client ID and subject with the set of additional claims.- Parameters:
- clientId- the client ID
- userId-
- subject- the user subject
- additionalClaims- the additional session claims
- Returns:
 
 - 
refreshSessionTokenOAuth2SessionToken refreshSessionToken(OAuth2SessionToken sessionToken) Returns aOAuth2SessionTokenwith a refreshed expiration time.- Parameters:
- sessionToken- the session token
- Returns:
- the refreshed session token
 
 - 
getRedirectUrlString getRedirectUrl(javax.servlet.http.Cookie savedRequestCookie) Verify the JWT token contained in the cookie and then return the redirect url contained therein.- Parameters:
- savedRequestCookie- see- createSavedRequestCookie(String, String)
- Returns:
- a decoded URL set with createSavedRequestCookie(String, String)
 
 - 
getRequestUrlString getRequestUrl(javax.servlet.http.Cookie savedRequestCookie) Verify the JWT token contained in the cookie and then return the original request url contained therein.- Parameters:
- savedRequestCookie- see- createSavedRequestCookie(String, String)
- Returns:
- a decoded URL set with createSavedRequestCookie(String, String)
 
 - 
getCookieClaimsMap<String,Object> getCookieClaims(String cookieValue) Get a Map of the claims from a SignedJWT cookie. The values of the map are Base64 encoded.- Parameters:
- cookieValue-
- Returns:
 
 - 
createSessionCookie@Deprecated javax.servlet.http.Cookie createSessionCookie(OAuth2SessionToken sessionToken) Deprecated.in favor ofgetSessionCookie(OAuth2SessionToken)Creates a cookie for theOAuth2SessionToken.- Parameters:
- sessionToken- the session token
- Returns:
- the session cookie
 
 - 
getRemoveSessionCookie@Deprecated javax.servlet.http.Cookie getRemoveSessionCookie(String clientId) Deprecated.in favor ofgetSessionRemovalCookie(String)Create a cookie that can be passed to the response to clear any existing session cookie in the browser.- Parameters:
- clientId-
- Returns:
- the newly created cookie
 
 - 
getSessionCookieorg.springframework.http.ResponseCookie getSessionCookie(OAuth2SessionToken sessionToken) Gets aResponseCookiefor theOAuth2SessionToken.- Parameters:
- sessionToken- the session token
- Returns:
- the session cookie
 
 - 
getSessionRemovalCookieorg.springframework.http.ResponseCookie getSessionRemovalCookie(String clientId) Gets aResponseCookiefor the removal of the session cookie.- Parameters:
- clientId- the client ID
- Returns:
- the session removal cookie
 
 - 
getSavedRequestCookie@Deprecated javax.servlet.http.Cookie getSavedRequestCookie(String requestUrl, String redirectUrl) Deprecated.since 1.6, replaced bycreateSavedRequestCookie(String, String)Create a cookie containing a JWT token identifying an originating request url and a redirect url. This information is used to forward the user to an authentication url. Once authenticated, the original request is completed.- Parameters:
- requestUrl- the original request (e.g. /oauth/authorize)
- redirectUrl- the uri to redirect to for authentication (e.g. /login)
- Returns:
- a newly created session cookie
 
 - 
createSavedRequestCookieorg.springframework.http.ResponseCookie createSavedRequestCookie(String requestUrl, String redirectUrl) Create a cookie containing a JWT token identifying an originating request url and a redirect url. This information is used to forward the user to an authentication url. Once authenticated, the original request is completed.- Parameters:
- requestUrl- the original request (e.g. /oauth/authorize)
- redirectUrl- the uri to redirect to for authentication (e.g. /login)
- Returns:
- a newly created session cookie
 
 - 
getRemoveSavedRequestCookie@Deprecated javax.servlet.http.Cookie getRemoveSavedRequestCookie() Deprecated.since 1.6, replaced bycreateSavedRequestRemovalCookie()Create a cookie that can be passed to the response to clear any existing saved request cookie in the browser.- Returns:
- the newly created cookie
 
 - 
createSavedRequestRemovalCookieorg.springframework.http.ResponseCookie createSavedRequestRemovalCookie() Create a cookie that can be passed to the response to clear any existing saved request cookie in the browser.- Returns:
- the newly created cookie
- See Also:
- createSavedRequestCookie(String, String)
 
 - 
verifycom.nimbusds.jwt.SignedJWT verify(String token) Verify the signature of a signed JWT inside a cookie- Parameters:
- token- the cookie to verify
- Returns:
- a verified and signed JWT token, or null if the given cookie has no value
 
 - 
generateSignedJwtcom.nimbusds.jwt.SignedJWT generateSignedJwt(@Nullable String subject, @Nullable Map<String,Object> claims, @Nullable Long expiresInSeconds)Generate a signed JWT with issuer and audience values as well as optional additional claims.- Parameters:
- subject- The subject of the JWT
- claims- Additional claims to add to the JWT
- Returns:
- A signed JWT
 
 - 
getSessionCookieNameString getSessionCookieName(String clientId) Get the standard name for a session cookie- Parameters:
- clientId-
- Returns:
- the cookie name used to store the session
- See Also:
- #getSessionCookie(String, String)
 
 - 
getSessionCookieNameString getSessionCookieName(AuthorizedClient client, AuthorizationServer server) 
 - 
getIssuerString getIssuer() 
 - 
getSavedRequestCookieNameString getSavedRequestCookieName() Get the standard name for a saved request cookie- Returns:
- the saved request cookie name
- See Also:
- createSavedRequestCookie(String, String)
 
 - 
getRemovalCookieorg.springframework.http.ResponseCookie getRemovalCookie(javax.servlet.http.Cookie cookieToRemove) Returns a removal cookie for any arbitrary cookie.- Parameters:
- cookieToRemove- The cookie to target for removal
- Returns:
- A cookie that may be set on an HttpServletResponseto remove the supplied cookie.
 
 
- 
 
-