Class SpringSecurityContext
- java.lang.Object
-
- com.sap.cloud.security.adapter.spring.SpringSecurityContext
-
public class SpringSecurityContext extends Object
This is an alternative way of accessing jwt tokens of typeTokenorAccessTokenin context of an application using spring-security-oauth2. It uses theSecurityContextHolderto access Spring'sSecurityContextand can therefore used also in context of asynchronous threads. Use this class in case your application sets Spring's security context via one of these libraries:
- @code{org.springframework.security.oauth:spring-security-oauth2} or
- @code{com.sap.cloud.security.xsuaa:spring-xsuaa} client library.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidclear()Clears the context value from the current thread.static AccessTokengetAccessToken()Returns the token usingSecurityContextHolder.static TokengetToken()Returns the token usingSecurityContextHolder.
-
-
-
Method Detail
-
getToken
@Nullable public static Token getToken()
Returns the token usingSecurityContextHolder.- Returns:
- the token or
nullifSecurityContextis empty or does not contain a token of this type.
-
getAccessToken
@Nullable public static AccessToken getAccessToken()
Returns the token usingSecurityContextHolder.- Returns:
- the token or
nullifSecurityContextis empty or does not contain a token of this type.
-
clear
public static void clear()
Clears the context value from the current thread.
-
-