Class 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 Detail

      • 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 Detail

      • 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.
      • 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.
      • 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.