1- package org .woehlke .simpleworklist .application . config ;
1+ package org .woehlke .simpleworklist .config ;
22
33import org .springframework .beans .factory .annotation .Autowired ;
44import org .springframework .boot .autoconfigure .ImportAutoConfiguration ;
1616import org .springframework .security .core .userdetails .UserDetailsService ;
1717import org .springframework .security .crypto .bcrypt .BCryptPasswordEncoder ;
1818import org .springframework .security .crypto .password .PasswordEncoder ;
19- import org .springframework .security .web . authentication . AuthenticationSuccessHandler ;
19+ import org .springframework .security .crypto . password . Pbkdf2PasswordEncoder ;
2020import org .springframework .security .web .authentication .UsernamePasswordAuthenticationFilter ;
2121import org .springframework .web .servlet .config .annotation .EnableWebMvc ;
22- import org .woehlke .simpleworklist .application .ApplicationProperties ;
23- import org .woehlke .simpleworklist .user .login .LoginSuccessHandler ;
24- import org .woehlke .simpleworklist .user .services .UserAccountSecurityService ;
22+ import org .woehlke .simpleworklist .application .SimpleworklistProperties ;
23+ import org .woehlke .simpleworklist .user .services .SimpleworklistUserAccountSecurityService ;
2524
2625
2726@ Configuration
3433 WebMvcConfig .class
3534})
3635@ EnableConfigurationProperties ({
37- ApplicationProperties .class
36+ SimpleworklistProperties .class
3837})
3938public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
4039
4140 private final AuthenticationManagerBuilder authenticationManagerBuilder ;
42- private final AuthenticationSuccessHandler loginSuccessHandler ;
43- private final UserAccountSecurityService userAccountSecurityService ;
44- private final ApplicationProperties applicationProperties ;
41+ // private final AuthenticationSuccessHandler loginSuccessHandler;
42+ private final SimpleworklistUserAccountSecurityService simpleworklistUserAccountSecurityService ;
43+ private final SimpleworklistProperties simpleworklistProperties ;
4544
4645 @ Autowired
4746 public WebSecurityConfig (
48- AuthenticationManagerBuilder authenticationManagerBuilder ,
49- LoginSuccessHandler loginSuccessHandler ,
50- UserAccountSecurityService userAccountSecurityService ,
51- ApplicationProperties applicationProperties ) {
52- this .authenticationManagerBuilder = authenticationManagerBuilder ;
53- this .loginSuccessHandler = loginSuccessHandler ;
54- this .userAccountSecurityService = userAccountSecurityService ;
55- this .applicationProperties = applicationProperties ;
47+ AuthenticationManagerBuilder auth ,
48+ // LoginSuccessHandler loginSuccessHandler,
49+ SimpleworklistUserAccountSecurityService simpleworklistUserAccountSecurityService ,
50+ SimpleworklistProperties simpleworklistProperties ) {
51+ this .authenticationManagerBuilder = auth ;
52+ // this.loginSuccessHandler = loginSuccessHandler;
53+ this .simpleworklistUserAccountSecurityService = simpleworklistUserAccountSecurityService ;
54+ this .simpleworklistProperties = simpleworklistProperties ;
5655 }
5756
5857 @ Override
@@ -61,35 +60,35 @@ protected void configure(HttpSecurity http) throws Exception {
6160 .headers ()
6261 .disable ()
6362 .authorizeRequests ()
64- .antMatchers (applicationProperties .getWebSecurity ().getAntPatternsPublic ())
63+ .antMatchers (simpleworklistProperties .getWebSecurity ().getAntPatternsPublic ())
6564 .permitAll ()
6665 .anyRequest ()
6766 .fullyAuthenticated ()
6867 .and ()
6968 .csrf ()
7069 .and ()
7170 .formLogin ()
72- .loginPage (applicationProperties .getWebSecurity ().getLoginPage ())
73- .usernameParameter (applicationProperties .getWebSecurity ().getUsernameParameter ())
74- .passwordParameter (applicationProperties .getWebSecurity ().getPasswordParameter ())
75- .loginProcessingUrl (applicationProperties .getWebSecurity ().getLoginProcessingUrl ())
76- .failureForwardUrl (applicationProperties .getWebSecurity ().getFailureForwardUrl ())
77- .defaultSuccessUrl (applicationProperties .getWebSecurity ().getDefaultSuccessUrl ())
78- .successHandler (loginSuccessHandler )
71+ .loginPage (simpleworklistProperties .getWebSecurity ().getLoginPage ())
72+ .usernameParameter (simpleworklistProperties .getWebSecurity ().getUsernameParameter ())
73+ .passwordParameter (simpleworklistProperties .getWebSecurity ().getPasswordParameter ())
74+ .loginProcessingUrl (simpleworklistProperties .getWebSecurity ().getLoginProcessingUrl ())
75+ .failureForwardUrl (simpleworklistProperties .getWebSecurity ().getFailureForwardUrl ())
76+ .defaultSuccessUrl (simpleworklistProperties .getWebSecurity ().getDefaultSuccessUrl ())
77+ // .successHandler(loginSuccessHandler)
7978 .permitAll ()
8079 .and ()
8180 .csrf ()
8281 .and ()
8382 .logout ()
84- .logoutUrl (applicationProperties .getWebSecurity ().getLogoutUrl ())
85- .deleteCookies (applicationProperties .getWebSecurity ().getCookieNamesToClear ())
86- .invalidateHttpSession (applicationProperties .getWebSecurity ().getInvalidateHttpSession ())
83+ .logoutUrl (simpleworklistProperties .getWebSecurity ().getLogoutUrl ())
84+ .deleteCookies (simpleworklistProperties .getWebSecurity ().getCookieNamesToClear ())
85+ .invalidateHttpSession (simpleworklistProperties .getWebSecurity ().getInvalidateHttpSession ())
8786 .permitAll ();
8887 }
8988
9089 @ Bean
9190 public UserDetailsService userDetailsService (){
92- return this .userAccountSecurityService ;
91+ return this .simpleworklistUserAccountSecurityService ;
9392 }
9493
9594 /**
@@ -98,8 +97,16 @@ public UserDetailsService userDetailsService(){
9897 */
9998 @ Bean
10099 public PasswordEncoder encoder (){
101- int strength = applicationProperties .getWebSecurity ().getStrengthBCryptPasswordEncoder ();
100+ int strength = simpleworklistProperties .getWebSecurity ().getStrengthBCryptPasswordEncoder ();
102101 return new BCryptPasswordEncoder (strength );
102+ /*Ü
103+ CharSequence secret=this.simpleworklistProperties.getWebSecurity().getSecret();
104+ int iterations=this.simpleworklistProperties.getWebSecurity().getIterations();
105+ int hashWidth=this.simpleworklistProperties.getWebSecurity().getHashWidth();
106+ Pbkdf2PasswordEncoder encoder = (new Pbkdf2PasswordEncoder(secret,iterations,hashWidth));
107+ encoder.setEncodeHashAsBase64(true);
108+ return encoder;
109+ */
103110 }
104111
105112 @ Bean
@@ -113,7 +120,7 @@ public AuthenticationManager authenticationManager() throws Exception {
113120 public UsernamePasswordAuthenticationFilter authenticationFilter () throws Exception {
114121 UsernamePasswordAuthenticationFilter filter = new UsernamePasswordAuthenticationFilter ();
115122 filter .setAuthenticationManager (authenticationManager ());
116- filter .setFilterProcessesUrl (applicationProperties .getWebSecurity ().getLoginProcessingUrl ());
123+ filter .setFilterProcessesUrl (simpleworklistProperties .getWebSecurity ().getLoginProcessingUrl ());
117124 return filter ;
118125 }
119126}
0 commit comments