- Spring Security(Third Edition)
- Mick Knutson Robert Winch Peter Mularien
- 91字
- 2025-04-04 17:54:29
Migrating existing passwords
Let's take a look at the following steps and learn about migrating existing passwords:
- We need to update our existing passwords to use the values produced by the new PasswordEncoder class. If you would like to generate your own passwords, you can use the following code snippet:
StandardPasswordEncoder encoder = new StandardPasswordEncoder();
String encodedPassword = encoder.encode("password");
- Remove the previously used calendar-sha256.sql file, and add the provided saltedsha256.sql file as follows:
//src/main/java/com/packtpub/springsecurity/configuration/
DataSourceConfig.java
@Bean
public DataSource dataSource() {
return new EmbeddedDatabaseBuilder()
.setName("dataSource")
.setType(EmbeddedDatabaseType.H2)
.addScript("/database/h2/calendar-schema.sql")
.addScript("/database/h2/calendar-data.sql"
.addScript("/database/h2/calendar-authorities.sql")
.addScript("/database/h2/calendar-saltedsha256.sql")
.build();
}