Example usage for org.springframework.security.oauth2.common DefaultOAuth2AccessToken getValue

List of usage examples for org.springframework.security.oauth2.common DefaultOAuth2AccessToken getValue

Introduction

In this page you can find the example usage for org.springframework.security.oauth2.common DefaultOAuth2AccessToken getValue.

Prototype

public String getValue() 

Source Link

Document

The token value.

Usage

From source file:org.cloudfoundry.identity.uaa.oauth.JwtTokenEnhancer.java

public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentication authentication) {
    DefaultOAuth2AccessToken result = new DefaultOAuth2AccessToken(accessToken);
    String tokenId = result.getValue();
    result.setAdditionalInformation(Collections.<String, Object>singletonMap("token_id", tokenId));
    return result.setValue(createAccessTokenValue(accessToken, authentication));
}

From source file:org.springframework.security.oauth2.provider.token.JwtTokenEnhancer.java

public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentication authentication) {
    DefaultOAuth2AccessToken result = new DefaultOAuth2AccessToken(accessToken);
    Map<String, Object> info = new LinkedHashMap<String, Object>(accessToken.getAdditionalInformation());
    String tokenId = result.getValue();
    if (!info.containsKey(TOKEN_ID)) {
        info.put(TOKEN_ID, tokenId);// www  . ja va2  s. c o m
    }
    result.setAdditionalInformation(info);
    return result.setValue(encode(result, authentication));
}

From source file:org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter.java

public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentication authentication) {
    DefaultOAuth2AccessToken result = new DefaultOAuth2AccessToken(accessToken);
    Map<String, Object> info = new LinkedHashMap<String, Object>(accessToken.getAdditionalInformation());
    String tokenId = result.getValue();
    if (!info.containsKey(TOKEN_ID)) {
        info.put(TOKEN_ID, tokenId);//from   w  ww .  j  a v  a 2 s .c  o  m
    }
    result.setAdditionalInformation(info);
    result.setValue(encode(result, authentication));
    OAuth2RefreshToken refreshToken = result.getRefreshToken();
    if (refreshToken != null) {
        DefaultOAuth2AccessToken encodedRefreshToken = new DefaultOAuth2AccessToken(accessToken);
        DefaultOAuth2RefreshToken token = new DefaultOAuth2RefreshToken(
                encode(encodedRefreshToken, authentication));
        if (refreshToken instanceof ExpiringOAuth2RefreshToken) {
            Date expiration = ((ExpiringOAuth2RefreshToken) refreshToken).getExpiration();
            encodedRefreshToken.setExpiration(expiration);
            token = new DefaultExpiringOAuth2RefreshToken(encode(encodedRefreshToken, authentication),
                    expiration);
        }
        result.setRefreshToken(token);
    }
    return result;
}