Class TMPasswordDeserializer

  • All Implemented Interfaces:
    com.fasterxml.jackson.databind.deser.NullValueProvider

    public class TMPasswordDeserializer
    extends com.fasterxml.jackson.databind.JsonDeserializer<String>
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.JsonDeserializer

        com.fasterxml.jackson.databind.JsonDeserializer.None
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      String deserialize​(@NotNull com.fasterxml.jackson.core.JsonParser jsonParser, com.fasterxml.jackson.databind.DeserializationContext context)
      When deserializing a JSON field containing a plaintext password validate it is strong enough and hash it with the default PasswordEncoder (bcrypt).
      static boolean validatePasswordStrength​(String password, int minLength, int minStrength)  
      • Methods inherited from class com.fasterxml.jackson.databind.JsonDeserializer

        deserialize, deserializeWithType, deserializeWithType, findBackReference, getAbsentValue, getDelegatee, getEmptyAccessPattern, getEmptyValue, getEmptyValue, getKnownPropertyNames, getNullAccessPattern, getNullValue, getNullValue, getObjectIdReader, handledType, isCachable, logicalType, replaceDelegatee, supportsUpdate, unwrappingDeserializer
    • Constructor Detail

      • TMPasswordDeserializer

        public TMPasswordDeserializer()
    • Method Detail

      • deserialize

        public String deserialize​(@NotNull
                                  @NotNull com.fasterxml.jackson.core.JsonParser jsonParser,
                                  com.fasterxml.jackson.databind.DeserializationContext context)
                           throws IOException
        When deserializing a JSON field containing a plaintext password validate it is strong enough and hash it with the default PasswordEncoder (bcrypt).
        Specified by:
        deserialize in class com.fasterxml.jackson.databind.JsonDeserializer<String>
        Parameters:
        jsonParser - parser
        context - context
        Returns:
        The bcrypt hashed password
        Throws:
        IOException - when JSON processing fails, InvalidPasswordException when the password is not strong enough
      • validatePasswordStrength

        public static boolean validatePasswordStrength​(String password,
                                                       int minLength,
                                                       int minStrength)