Class SpringSecurityContext

java.lang.Object
com.sap.cloud.security.xsuaa.token.SpringSecurityContext

public class SpringSecurityContext extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Cleans up the Spring Security Context SecurityContextHolder and release thread locals for Garbage Collector to avoid memory leaks resources.
    static Token
    Obtain the Token object from the Spring Security Context SecurityContextHolder
    static void
    init(String encodedJwtToken, org.springframework.security.oauth2.jwt.JwtDecoder xsuaaJwtDecoder, AuthoritiesExtractor authoritiesExtractor)
    Initializes the Spring Security Context SecurityContextHolder and extracts the authorities.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getToken

      public static Token getToken()
      Obtain the Token object from the Spring Security Context SecurityContextHolder
      Returns:
      Token object
      Throws:
      org.springframework.security.access.AccessDeniedException - in case there is no token, user is not authenticated

      Note: This method is introduced with xsuaa spring client lib.

    • init

      public static void init(String encodedJwtToken, org.springframework.security.oauth2.jwt.JwtDecoder xsuaaJwtDecoder, AuthoritiesExtractor authoritiesExtractor)
      Initializes the Spring Security Context SecurityContextHolder and extracts the authorities. With version 1.5.0 you can configure your own AuthoritiesExtractor to specify how to extract the authorities.
      Parameters:
      encodedJwtToken - the jwt token that is decoded with the given JwtDecoder
      xsuaaJwtDecoder - the decoder of type XsuaaJwtDecoder
      authoritiesExtractor - the extractor used to turn Jwt scopes into Spring Security authorities.
    • clear

      public static void clear()
      Cleans up the Spring Security Context SecurityContextHolder and release thread locals for Garbage Collector to avoid memory leaks resources.