Class SpringSecurityContext
java.lang.Object
com.sap.cloud.security.adapter.spring.SpringSecurityContext
This is an alternative way of accessing jwt tokens of type
Token
or
AccessToken
in context of an application using
spring-security-oauth2.
It uses the SecurityContextHolder
to access Spring's
SecurityContext
and 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
Modifier and TypeMethodDescriptionstatic void
clear()
Clears the context value from the current thread.static AccessToken
Returns the token usingSecurityContextHolder
.static Token
getToken()
Returns the token usingSecurityContextHolder
.
-
Method Details
-
getToken
Returns the token usingSecurityContextHolder
.- Returns:
- the token or
null
ifSecurityContext
is empty or does not contain a token of this type.
-
getAccessToken
Returns the token usingSecurityContextHolder
.- Returns:
- the token or
null
ifSecurityContext
is empty or does not contain a token of this type.
-
clear
public static void clear()Clears the context value from the current thread.
-