package com.saintdan.framework.config;

import com.saintdan.framework.component.CustomPasswordEncoder;
import com.saintdan.framework.component.LogHelper;
import com.saintdan.framework.config.custom.CustomAuthenticationProvider;
import com.saintdan.framework.domain.UserDomain;
import com.saintdan.framework.repo.OauthAccessTokenRepository;
import com.saintdan.framework.repo.OauthRefreshTokenRepository;
import com.saintdan.framework.repo.UserRepository;
import com.saintdan.framework.tools.Assert;
import javax.servlet.http.HttpServletRequest;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.web.config.EnableSpringDataWebSupport;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

/**
 * Spring web security config.
 * Extends {@link WebSecurityConfigurerAdapter}
 *
 * @author <a href="http://github.com/saintdan">Liao Yifan</a>
 * @date 6/25/15
 * @since JDK1.8
 */
@Configuration @EnableWebSecurity @EnableSpringDataWebSupport
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {

  private final UserRepository userRepository;

  private final OauthAccessTokenRepository accessTokenRepository;

  private final OauthRefreshTokenRepository refreshTokenRepository;

  private final HttpServletRequest request;

  private final UserDomain userDomain;

  private final LogHelper logHelper;

  private final CustomPasswordEncoder customPasswordEncoder;

  public WebSecurityConfiguration(UserRepository userRepository, OauthAccessTokenRepository accessTokenRepository, OauthRefreshTokenRepository refreshTokenRepository, HttpServletRequest request, UserDomain userDomain, LogHelper logHelper, CustomPasswordEncoder customPasswordEncoder) {
    Assert.defaultNotNull(userRepository);
    Assert.defaultNotNull(accessTokenRepository);
    Assert.defaultNotNull(refreshTokenRepository);
    Assert.defaultNotNull(request);
    Assert.defaultNotNull(userDomain);
    Assert.defaultNotNull(logHelper);
    Assert.defaultNotNull(customPasswordEncoder);
    this.userRepository = userRepository;
    this.accessTokenRepository = accessTokenRepository;
    this.refreshTokenRepository = refreshTokenRepository;
    this.request = request;
    this.userDomain = userDomain;
    this.logHelper = logHelper;
    this.customPasswordEncoder = customPasswordEncoder;
  }

  @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.authenticationProvider(authenticationProvider());
  }

  @Override @Bean public AuthenticationManager authenticationManagerBean() throws Exception {
    return super.authenticationManagerBean();
  }

  @Bean public AuthenticationProvider authenticationProvider() {
    return new CustomAuthenticationProvider(userRepository, accessTokenRepository, refreshTokenRepository, request, userDomain, logHelper, customPasswordEncoder);
  }

}

@@ -69,478 +69,91 @@
 k.co
-mponent.CustomPasswordEncoder;%0Aimport com.saintdan.framework.component.LogHelper;%0Aimport com.saintdan.framework.config.custom.CustomAuthenticationProvider;%0Aimport com.saintdan.framework.domain.UserDomain;%0Aimport com.saintdan.framework.repo.OauthAccessTokenRepository;%0Aimport com.saintdan.framework.repo.OauthRefreshTokenRepository;%0Aimport com.saintdan.framework.repo.UserRepository;%0Aimport com.saintdan.framework.tools.Assert;%0Aimport javax.servlet.http.HttpServletReques
+nfig.custom.CustomAuthenticationProvider;%0Aimport com.saintdan.framework.tools.Asser
 t;%0Ai
@@ -1133,826 +1133,162 @@
 nal 
-UserRepository userRepository;%0A%0A  private final OauthAccessTokenRepository accessTokenRepository;%0A%0A  private final OauthRefreshTokenRepository refreshTokenRepository;%0A%0A  private final HttpServletRequest request;%0A%0A  private final UserDomain userDomain;%0A%0A  private final LogHelper logHelper;%0A%0A  private final CustomPasswordEncoder customPasswordEncoder;%0A%0A  public WebSecurityConfiguration(UserRepository userRepository, OauthAccessTokenRepository accessTokenRepository, OauthRefreshTokenRepository refreshTokenRepository, HttpServletRequest request, UserDomain userDomain, LogHelper logHelper, CustomPasswordEncoder customPasswordEncoder) %7B%0A    Assert.defaultNotNull(userRepository);%0A    Assert.defaultNotNull(accessTokenRepository);%0A    Assert.defaultNotNull(refreshTokenRepository);%0A    Assert.defaultNotNull(request);
+CustomAuthenticationProvider customAuthenticationProvider;%0A%0A  public WebSecurityConfiguration(CustomAuthenticationProvider customAuthenticationProvider) %7B
 %0A   
@@ -1314,103 +1314,33 @@
 ull(
+c
 us
-erDomain);%0A    Assert.defaultNotNull(logHelper);%0A    Assert.defaultNotNull(customPasswordEnco
+tomAuthenticationProvi
 der)
@@ -1354,300 +1354,64 @@
 his.
+c
 us
-erRepository = userRepository;%0A    this.accessTokenRepository = accessTokenRepository;%0A    this.refreshTokenRepository = refreshTokenRepository;%0A    this.request = request;%0A    this.userDomain = userDomain;%0A    this.logHelper = logHelper;%0A    this.customPasswordEncoder = customPasswordEnco
+tomAuthenticationProvider = customAuthenticationProvi
 der;
@@ -1796,13 +1796,9 @@
 urn 
-new C
+c
 usto
@@ -1824,126 +1824,8 @@
 ider
-(userRepository, accessTokenRepository, refreshTokenRepository, request, userDomain, logHelper, customPasswordEncoder)
 ;%0A  

Modify injection.