DelegatingPasswordEncoder supports applications that must retain existing password hashes while adopting a different algorithm for newly registered users. It implements PasswordEncoder but delegates encoding and matching to another encoder selected from an identifier embedded in the stored representation. section 4.1.4
Its routing model is explicit:
- Store a prefix such as {noop}, {bcrypt}, or {scrypt} before the encoded password. section 4.1.4
- Map each identifier to a PasswordEncoder implementation. section 4.1.4
Spring configuration
Create a map containing NoOpPasswordEncoder, BCryptPasswordEncoder, and SCryptPasswordEncoder, then return new DelegatingPasswordEncoder("bcrypt", encoders). Spring also provides PasswordEncoderFactories.createDelegatingPasswordEncoder() for creating a delegating encoder.
