Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to authenticate MD5 password encyption in spring security 4

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.40k
    Comment on it

    Whenever we deal with password in an application, we go for some encryption. In spring the password it authenticated within the configuration.

    Here is the sample code where we have already saved the password in encrypted form and now during login the password is verified with encryption in the configuration file.

    @Configuration
    @EnableWebSecurity
    public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
    
         @Autowired
        // CustomUserDetailsService with service name @Service("userDetailsService")
        @Qualifier("userDetailsService") 
        private UserDetailsService userDetailsService;
    
        @Autowired
        public void configureGlobalSecurity(AuthenticationManagerBuilder auth) throws Exception {
            auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
        }
    
       //bean for md5 encryption 
        @Bean
        public Md5PasswordEncoder passwordEncoder() throws Exception {
            return new Md5PasswordEncoder();
        }
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: