| | |
| | | import org.springframework.security.authentication.BadCredentialsException; |
| | | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
| | | import org.springframework.security.authentication.dao.DaoAuthenticationProvider; |
| | | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; |
| | | import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
| | | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; |
| | | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; |
| | |
| | | * @param: httpServletRequest |
| | | **/ |
| | | private void verificationCode(HttpServletRequest httpServletRequest) throws VerificationCodeException { |
| | | String requestCode = httpServletRequest.getParameter("captcha"); |
| | | String requestCode = httpServletRequest.getParameter("code"); |
| | | HttpSession httpSession = httpServletRequest.getSession(); |
| | | String captcha = httpSession.getAttribute("captcha") + ""; |
| | | httpSession.removeAttribute("captcha"); |
| | |
| | | // http.addFilterBefore(new PreRequestVerifyFilter(), UsernamePasswordAuthenticationFilter.class); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | protected void configure(AuthenticationManagerBuilder auth) throws Exception { |
| | | auth.authenticationProvider(new MyAuthenticationProvider(new MyUserDetailsService(), new PasswordEncoder() { |
| | | @Override |
| | | public String encode(CharSequence charSequence) { |
| | | return charSequence.toString(); |
| | | } |
| | | |
| | | @Override |
| | | public boolean matches(CharSequence charSequence, String s) { |
| | | return s.equalsIgnoreCase(charSequence.toString()); |
| | | } |
| | | })); |
| | | |
| | | } |
| | | |
| | | class MyUserDetailsService implements UserDetailsService { |
| | | |
| | | @Override |