I use Spring MVC + Security and to display bootstrap

@Configuration @EnableWebSecurity @EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = true) @ComponentScan("ru.skanerxxl.rambler") public class SecurityConfig extends WebSecurityConfigurerAdapter { @Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { auth.userDetailsService(serviceSecurity) .passwordEncoder(new ShaPasswordEncoder()); } } 

Here the user's password is decoded.

How to connect SHA1 in order to encode a password during registration?

    1 answer 1

    You need to get the user before saving, encrypt the password for him, for example by this method:

     public void encodeUserPassword(User user){ String hashString = user.getPassword(); ShaPasswordEncoder encoder = new ShaPasswordEncoder(); String hashOutput = encoder.encodePassword(hashString,null); user.setPassword(hashOutput); } 

    and save to db.