content: package com.neroarc.blog.myblog.social.qq.config;
  
  import com.neroarc.blog.myblog.social.qq.connect.QQConnectionFactory;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.beans.factory.annotation.Value;
  import org.springframework.boot.autoconfigure.social.SocialAutoConfigurerAdapter;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.security.crypto.encrypt.Encryptors;
  import org.springframework.social.connect.ConnectionFactory;
  import org.springframework.social.connect.ConnectionFactoryLocator;
  import org.springframework.social.connect.ConnectionSignUp;
  import org.springframework.social.connect.UsersConnectionRepository;
  import org.springframework.social.connect.jdbc.JdbcUsersConnectionRepository;
  
  import javax.sql.DataSource;
  
  /**
   * @author: fjx
   * @date: 2019/1/24 15:35
   * Descripe:
   */
  @Configuration
  public class QQAutoConfig extends SocialAutoConfigurerAdapter {
  
      @Value("${fjx.security.social.qq.app-id}")
      private String qqAppId;
  
      @Value("${fjx.security.social.qq.app-secret}")
      private String qqAppSecret;
  
      @Value("${fjx.security.social.qq.provider-id}")
      private String qqProviderId;
  
      @Autowired
      private DataSource dataSource;
  
      @Autowired(required = false)
      private ConnectionSignUp connectionSignUp;
  
      @Override
      public UsersConnectionRepository getUsersConnectionRepository(ConnectionFactoryLocator connectionFactoryLocator) {
          JdbcUsersConnectionRepository jdbcUsersConnectionRepository = new JdbcUsersConnectionRepository(dataSource,connectionFactoryLocator, Encryptors.noOpText());
          jdbcUsersConnectionRepository.setConnectionSignUp(connectionSignUp);
          return jdbcUsersConnectionRepository;
      }
  
      @Override
      protected ConnectionFactory<?> createConnectionFactory() {
          return new QQConnectionFactory(qqProviderId,qqAppId,qqAppSecret);
      }
  }
  