java.lang.Object
java.lang.Enum<Hasher>
org.elasticsearch.xpack.core.security.authc.support.Hasher
All Implemented Interfaces:
Serializable, Comparable<Hasher>, Constable

public enum Hasher extends Enum<Hasher>
  • Enum Constant Details

    • BCRYPT

      public static final Hasher BCRYPT
    • BCRYPT4

      public static final Hasher BCRYPT4
    • BCRYPT5

      public static final Hasher BCRYPT5
    • BCRYPT6

      public static final Hasher BCRYPT6
    • BCRYPT7

      public static final Hasher BCRYPT7
    • BCRYPT8

      public static final Hasher BCRYPT8
    • BCRYPT9

      public static final Hasher BCRYPT9
    • BCRYPT10

      public static final Hasher BCRYPT10
    • BCRYPT11

      public static final Hasher BCRYPT11
    • BCRYPT12

      public static final Hasher BCRYPT12
    • BCRYPT13

      public static final Hasher BCRYPT13
    • BCRYPT14

      public static final Hasher BCRYPT14
    • PBKDF2

      public static final Hasher PBKDF2
    • PBKDF2_1000

      public static final Hasher PBKDF2_1000
    • PBKDF2_10000

      public static final Hasher PBKDF2_10000
    • PBKDF2_50000

      public static final Hasher PBKDF2_50000
    • PBKDF2_100000

      public static final Hasher PBKDF2_100000
    • PBKDF2_500000

      public static final Hasher PBKDF2_500000
    • PBKDF2_1000000

      public static final Hasher PBKDF2_1000000
    • PBKDF2_STRETCH

      public static final Hasher PBKDF2_STRETCH
    • PBKDF2_STRETCH_1000

      public static final Hasher PBKDF2_STRETCH_1000
    • PBKDF2_STRETCH_10000

      public static final Hasher PBKDF2_STRETCH_10000
    • PBKDF2_STRETCH_50000

      public static final Hasher PBKDF2_STRETCH_50000
    • PBKDF2_STRETCH_100000

      public static final Hasher PBKDF2_STRETCH_100000
    • PBKDF2_STRETCH_500000

      public static final Hasher PBKDF2_STRETCH_500000
    • PBKDF2_STRETCH_1000000

      public static final Hasher PBKDF2_STRETCH_1000000
    • SHA1

      public static final Hasher SHA1
    • MD5

      public static final Hasher MD5
    • SSHA256

      public static final Hasher SSHA256
    • SHA256

      public static final Hasher SHA256
    • NOOP

      public static final Hasher NOOP
  • Method Details

    • values

      public static Hasher[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Hasher valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • resolve

      public static Hasher resolve(String name)
      Returns a Hasher instance of the appropriate algorithm and associated cost as indicated by the name. Name identifiers for the default costs for BCRYPT and PBKDF2 return the default BCRYPT and PBKDF2 Hasher instead of the specific instances for the associated cost.
      Parameters:
      name - The name of the algorithm and cost combination identifier
      Returns:
      the hasher associated with the identifier
    • resolveFromHash

      public static Hasher resolveFromHash(char[] hash)
      Returns a Hasher instance that can be used to verify the hash by inspecting the hash prefix and determining the algorithm used for its generation. If no specific algorithm prefix, can be determined Hasher.NOOP is returned.
      Parameters:
      hash - the char array from which the hashing algorithm is to be deduced
      Returns:
      the hasher that can be used for validation
    • verifyHash

      public static boolean verifyHash(SecureString data, char[] hash)
      Verifies that the cryptographic hash of data is the same as hash. The hashing algorithm and its parameters(cost factor-iterations, salt) are deduced from the hash itself. The hash char array is not cleared after verification.
      Parameters:
      data - the SecureString to be hashed and verified
      hash - the char array with the hash against which the string is verified
      Returns:
      true if the hash corresponds to the data, false otherwise
    • getAvailableAlgoStoredPasswordHash

      public static List<String> getAvailableAlgoStoredPasswordHash()
      Returns a list of lower case String identifiers for the Hashing algorithm and parameter combinations that can be used for password hashing. The identifiers can be used to get an instance of the appropriate Hasher by using resolve()
    • getAvailableAlgoStoredSecureTokenHash

      public static List<String> getAvailableAlgoStoredSecureTokenHash()
      Returns a list of lower case String identifiers for the Hashing algorithm and parameter combinations that can be used for secure token hashing. The identifiers can be used to get an instance of the appropriate Hasher by using resolve()
    • getAvailableAlgoCacheHash

      public static List<String> getAvailableAlgoCacheHash()
      Returns a list of lower case String identifiers for the Hashing algorithm and parameter combinations that can be used for password hashing in the cache. The identifiers can be used to get an instance of the appropriate Hasher by using resolve()
    • hash

      public abstract char[] hash(SecureString data)
    • verify

      public abstract boolean verify(SecureString data, char[] hash)