Advertisement
andersonalmada2

Untitled

Aug 5th, 2022
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None | 0 0
  1. package br.ufc.mandacaru5.config.security;
  2.  
  3. import java.util.HashMap;
  4. import java.util.Map;
  5. import java.util.Random;
  6.  
  7. import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
  8. import org.springframework.security.oauth2.common.OAuth2AccessToken;
  9. import org.springframework.security.oauth2.provider.OAuth2Authentication;
  10. import org.springframework.security.oauth2.provider.token.TokenEnhancer;
  11.  
  12. public class CustomTokenEnhancer implements TokenEnhancer {
  13.  
  14.     @Override
  15.     public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentication authentication) {
  16.         Map<String, Object> additionalInfo = new HashMap<>();
  17.         additionalInfo.put("user_id", new Random().nextInt());
  18.         ((DefaultOAuth2AccessToken) accessToken).setAdditionalInformation(additionalInfo);
  19.         return accessToken;
  20.     }
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement