title: Generate custom jwt-token and Authenticate user, Spring Security
body: <p><strong>Situation:</strong> I have a token from another API that contains user info and user is already logged. I want to authenticate this user info (already extracted) and generate a token with my spring security application.</p>
  
  <p><strong>Notes:</strong> I'm using Jwt custom enchancer and sorry for newbie way of posting.</p>
  
  <p>My security conf: </p>
  
  <pre><code>@Override
  public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
      TokenEnhancerChain tokenEnhancerChain = new TokenEnhancerChain();
      tokenEnhancerChain.setTokenEnhancers(Arrays.asList(tokenEnhancer(), accessTokenConverter()));
  
      endpoints.tokenStore(tokenStore()).tokenEnhancer(tokenEnhancerChain).reuseRefreshTokens(false)
              .exceptionTranslator(loggingExceptionTranslator()).authenticationManager(authenticationManager);
  }
  
  @Bean
  public JwtAccessTokenConverter accessTokenConverter() {
      JwtAccessTokenConverter accessTokenConverter = new JwtAccessTokenConverter();
      accessTokenConverter.setSigningKey(properties.getAuth().getSigningKey());
      return accessTokenConverter;
  }
  
  @Bean
  public TokenStore tokenStore() {
      return new JwtTokenStore(accessTokenConverter());
  }
  
  @Bean
  public TokenEnhancer tokenEnhancer() {
      return new PlaceTokenEnhancer();
  }
  </code></pre>