java.lang.Object
com.nimbusds.openid.connect.sdk.assurance.evidences.attachment.Digest

@Immutable public final class Digest extends Object
Cryptographic digest.

Related specifications:

  • OpenID Connect for Identity Assurance 1.0, section 5.1.2.2.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Digest(HashAlgorithm alg, com.nimbusds.jose.util.Base64 value)
    Creates a new cryptographic digest.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Digest
    compute(HashAlgorithm alg, byte[] content)
    Computes the digest for the specified content.
    static Digest
    compute(HashAlgorithm alg, com.nimbusds.jose.util.Base64 content)
    Computes the digest for the specified content.
    boolean
     
    Returns the hash algorithm.
    com.nimbusds.jose.util.Base64
    Returns the hash value.
    int
     
    boolean
    matches(com.nimbusds.jose.util.Base64 content)
    Returns true if this digest matches the computed for the specified content.
    static Digest
    parse(net.minidev.json.JSONObject jsonObject)
    Parses a digest from the specified JSON object.
    net.minidev.json.JSONObject
    Returns a JSON object representation of this cryptographic digest.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Digest

      public Digest(HashAlgorithm alg, com.nimbusds.jose.util.Base64 value)
      Creates a new cryptographic digest.
      Parameters:
      alg - The hash algorithm. Must not be null.
      value - The hash value. Must not be null.
  • Method Details

    • getHashAlgorithm

      Returns the hash algorithm.
      Returns:
      The hash algorithm.
    • getValue

      public com.nimbusds.jose.util.Base64 getValue()
      Returns the hash value.
      Returns:
      the hash value.
    • matches

      public boolean matches(com.nimbusds.jose.util.Base64 content) throws NoSuchAlgorithmException
      Returns true if this digest matches the computed for the specified content.
      Parameters:
      content - The content. Must not be null.
      Returns:
      If true if the digest matches the content, else false.
      Throws:
      NoSuchAlgorithmException - If the hash algorithm isn't supported.
    • toJSONObject

      public net.minidev.json.JSONObject toJSONObject()
      Returns a JSON object representation of this cryptographic digest.
      Returns:
      The JSON object.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • compute

      public static Digest compute(HashAlgorithm alg, com.nimbusds.jose.util.Base64 content) throws NoSuchAlgorithmException
      Computes the digest for the specified content.
      Parameters:
      alg - The hash algorithm. Must not be null.
      content - The content. Must not be null.
      Returns:
      The digest.
      Throws:
      NoSuchAlgorithmException - If the hash algorithm isn't supported.
    • compute

      public static Digest compute(HashAlgorithm alg, byte[] content) throws NoSuchAlgorithmException
      Computes the digest for the specified content.
      Parameters:
      alg - The hash algorithm. Must not be null.
      content - The content. Must not be null.
      Returns:
      The digest.
      Throws:
      NoSuchAlgorithmException - If the hash algorithm isn't supported.
    • parse

      public static Digest parse(net.minidev.json.JSONObject jsonObject) throws ParseException
      Parses a digest from the specified JSON object.
      Parameters:
      jsonObject - The JSON object.
      Returns:
      The cryptographic digest.
      Throws:
      ParseException - If parsing failed.