| | |
| | | import com.kidgrow.oauth2.handler.SingleTokenServices; |
| | | import com.kidgrow.oauth2.service.impl.RedisClientDetailsService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Qualifier; |
| | | import org.springframework.boot.autoconfigure.AutoConfigureAfter; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.context.annotation.Primary; |
| | | import org.springframework.security.authentication.AuthenticationManager; |
| | | import org.springframework.security.authentication.AuthenticationProvider; |
| | |
| | | private RandomValueAuthorizationCodeServices authorizationCodeServices; |
| | | @Autowired |
| | | private AuthenticationProvider daoAuhthenticationOauthProvider; |
| | | @Autowired |
| | | private SingleTokenServices tokenServices; |
| | | // @Autowired |
| | | // private SingleTokenServices tokenServices; |
| | | |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public Authentication authenticate(Authentication authentication) throws AuthenticationException { |
| | | String token = (String) authentication.getPrincipal(); |
| | | OAuth2Authentication auth = tokenServices.loadAuthentication(token); |
| | | OAuth2Authentication auth = KidgrowTokenServices().loadAuthentication(token); |
| | | if (auth == null) { |
| | | throw new InvalidTokenException("Invalid token: " + token); |
| | | } |
| | |
| | | |
| | | @Bean |
| | | @Primary |
| | | @Lazy |
| | | public SingleTokenServices KidgrowTokenServices(){ |
| | | SingleTokenServices tokenServices = new SingleTokenServices(); |
| | | tokenServices.setTokenStore(tokenStore); |