Skip to content

Instantly share code, notes, and snippets.

@netstart
Created March 9, 2020 13:00
Show Gist options
  • Save netstart/9ffa5b2bee1368adf2f2ec8889131885 to your computer and use it in GitHub Desktop.
Save netstart/9ffa5b2bee1368adf2f2ec8889131885 to your computer and use it in GitHub Desktop.
Password.java
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
public class Password {
public User changePassword(String newClearPassword) {
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
if (!passwordEncoder.matches(newClearPassword, this.getPassword())) {
throw new InvalidPasswordException();
}
this.password(passwordEncoder, newClearPassword);
return this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment