- Spring Security(Third Edition)
- Mick Knutson Robert Winch Peter Mularien
- 67字
- 2025-04-04 17:54:29
Updating DefaultCalendarUserService
The passwordEncoder() method we defined previously is smart enough to handle the new password encoder interface. However, DefaultCalendarUserService needs to update to the new interface. Make the following updates to the DefaultCalendarUserService class:
//src/main/java/com/packtpub/springsecurity/service/DefaultCalendarService.java
import org.springframework.security.authentication.encoding.PasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
// other imports omitted
public class DefaultCalendarService implements CalendarService {
...
public int createUser(CalendarUser user) {
String encodedPassword = passwordEncoder.encode(user.getPassword());
user.setPassword(encodedPassword);
...
return userId;
}
}