Class CryptoService

java.lang.Object
org.forgerock.selfservice.core.crypto.CryptoService

public class CryptoService extends Object
Cryptography Service for the user self service project.
Since:
0.2.0
  • Constructor Details

    • CryptoService

      public CryptoService()
  • Method Details

    • hash

      public JsonValue hash(String plainTextValue, String algorithm) throws JsonCryptoException
      Hashes a string value. Generates a new salt value.
      Parameters:
      plainTextValue - the string value to be hashed.
      algorithm - the hashing algorithm to use.
      Returns:
      a copy of the value, hashed with the specified algorithm and salt.
      Throws:
      JsonCryptoException - if an exception occurred while hashing
    • hash

      public JsonValue hash(String plainTextValue, String algorithm, JsonValue config) throws JsonCryptoException
      Hashes a string value. Generates a new salt value.
      Parameters:
      plainTextValue - the string value to be hashed.
      algorithm - the hashing algorithm to use.
      config - additional configuration data for the algorithm
      Returns:
      a copy of the value, hashed with the specified algorithm and salt.
      Throws:
      JsonCryptoException - if an exception occurred while hashing
    • isHashed

      public boolean isHashed(JsonValue value)
      Detects if a String is hashed.
      Parameters:
      value - the JSON value to check.
      Returns:
      true if hashed, false otherwise.
    • matches

      public boolean matches(String plainTextValue, JsonValue value) throws JsonCryptoException
      Returns true if the supplied plain text value of a field matches the supplied hashed value.
      Parameters:
      plainTextValue - a String representing the plain text value of a field
      value - a JsonValue representing the hashed and encoded value of a field
      Returns:
      true if the fields values match, false otherwise.
      Throws:
      JsonCryptoException - if an exception occurred while matching