All Downloads are FREE. Search and download functionalities are using the official Maven repository.

in.hocg.sso2.server.sample.config.security.BootTokenEnhancer Maven / Gradle / Ivy

There is a newer version: 1.0.63
Show newest version
package in.hocg.sso2.server.sample.config.security;

import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.token.TokenEnhancer;
import org.springframework.stereotype.Component;

@Component
public class BootTokenEnhancer implements TokenEnhancer {

    private final static String CLIENT_CREDENTIALS = "client_credentials";


    @Override
    public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentication authentication) {
        if (CLIENT_CREDENTIALS.equals(authentication.getOAuth2Request().getGrantType())) {
            return accessToken;
        }

//        final Map additionalInfo = new HashMap<>(8);
//        Map info = new LinkedHashMap<>();
//        info.put("user", SecurityContextHolder.getContext().getAuthentication().getPrincipal());
//        additionalInfo.put("info", info);
//        ((DefaultOAuth2AccessToken) accessToken).setAdditionalInformation(additionalInfo);
        return accessToken;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy