Class DelegatingPasswordEncoder

java.lang.Object
net.solarnetwork.central.security.DelegatingPasswordEncoder
All Implemented Interfaces:
net.solarnetwork.service.PasswordEncoder, org.springframework.security.crypto.password.PasswordEncoder

public class DelegatingPasswordEncoder extends Object implements net.solarnetwork.service.PasswordEncoder, org.springframework.security.crypto.password.PasswordEncoder
Password encoder that delegates to a configurable list of Spring Security org.springframework.security.crypto.password.PasswordEncoder instances, returning passwords with a prefix tag to be able to recognize what encryption technique was used.

The first entry in the map according to iteration order will be used as the primary encoder. Thus a map implementation like LinkedHashMap is recommended.

  • Constructor Details

    • DelegatingPasswordEncoder

      public DelegatingPasswordEncoder(Map<String,org.springframework.security.crypto.password.PasswordEncoder> encoders)
      Constructor.
      Parameters:
      encoders - the encoders to use
      Throws:
      IllegalArgumentException - if any argument is null
  • Method Details

    • isPasswordEncrypted

      public boolean isPasswordEncrypted(CharSequence password)
      Specified by:
      isPasswordEncrypted in interface net.solarnetwork.service.PasswordEncoder
    • encode

      public String encode(CharSequence rawPassword)
      Specified by:
      encode in interface net.solarnetwork.service.PasswordEncoder
      Specified by:
      encode in interface org.springframework.security.crypto.password.PasswordEncoder
    • matches

      public boolean matches(CharSequence rawPassword, String encodedPassword)
      Specified by:
      matches in interface net.solarnetwork.service.PasswordEncoder
      Specified by:
      matches in interface org.springframework.security.crypto.password.PasswordEncoder