コード例 #1
0
  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();
    }
  }
コード例 #2
0
 @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);
   }
 }