public void isPasswordEncoder() { try { String plainPassword = "******"; String expectedEncodedPassword = "******"; System.out.println("plainPassword: "******"expectedEncodedPassword: " + expectedEncodedPassword); assertTrue(passwordEncoder.isPasswordValid(expectedEncodedPassword, plainPassword, null)); } catch (Exception e) { e.printStackTrace(); fail(); } }
@Override protected void additionalAuthenticationChecks( UserDetails userDetails, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException { if (authentication.getCredentials() == null) { logger.debug("Authentication failed: no credentials provided"); throw new BadCredentialsException( messages.getMessage( "AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"), userDetails); } String presentedPassword = authentication.getCredentials().toString(); if (!passwordEncoder.isPasswordValid(userDetails.getPassword(), presentedPassword, null)) { logger.debug("Authentication failed: password does not match stored value"); throw new BadCredentialsException( messages.getMessage( "AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"), userDetails); } }