Class TokenEnhancerUtil


  • public final class TokenEnhancerUtil
    extends Object
    Convenience methods for common operations when enhancing tokens.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.springframework.security.oauth2.common.DefaultOAuth2AccessToken getEnhanceableToken​(org.springframework.security.oauth2.common.OAuth2AccessToken accessToken)
      Copies the supplied OAuth2AccessToken to a new DefaultOAuth2AccessToken instance and copies any existing values in OAuth2AccessToken.getAdditionalInformation() to a new modifiable map that may be retrieved and modified to add new claims.
      static OAuth2SessionToken getSessionToken​(org.springframework.security.oauth2.provider.OAuth2Authentication authentication)
      Returns the SessionToken associated with the OAuth2Authentication supplied
      static String readPrincipal​(org.springframework.security.oauth2.provider.OAuth2Authentication authentication)  
      static String readUserId​(org.springframework.security.oauth2.provider.OAuth2Authentication authentication)
      Reads the user ID associated with the Session Token.
    • Method Detail

      • readUserId

        public static String readUserId​(org.springframework.security.oauth2.provider.OAuth2Authentication authentication)
        Reads the user ID associated with the Session Token.
        Parameters:
        authentication - The OAuth2Authentication object passed to the Token enhancer
        Returns:
        The user id on the session
      • readPrincipal

        public static String readPrincipal​(org.springframework.security.oauth2.provider.OAuth2Authentication authentication)
      • getEnhanceableToken

        public static org.springframework.security.oauth2.common.DefaultOAuth2AccessToken getEnhanceableToken​(org.springframework.security.oauth2.common.OAuth2AccessToken accessToken)
        Copies the supplied OAuth2AccessToken to a new DefaultOAuth2AccessToken instance and copies any existing values in OAuth2AccessToken.getAdditionalInformation() to a new modifiable map that may be retrieved and modified to add new claims.
        Returns:
        An "enhanced" token with a modifiable map that may be retrieved and modified via OAuth2AccessToken.getAdditionalInformation()
      • getSessionToken

        public static OAuth2SessionToken getSessionToken​(org.springframework.security.oauth2.provider.OAuth2Authentication authentication)
        Returns the SessionToken associated with the OAuth2Authentication supplied
        Parameters:
        authentication - The OAuth2Authentication object passed to the Token enhancer