Class Digest
- java.lang.Object
-
- com.nimbusds.openid.connect.sdk.assurance.evidences.attachment.Digest
-
-
Constructor Summary
Constructors Constructor Description Digest(HashAlgorithm alg, com.nimbusds.jose.util.Base64 value)Creates a new cryptographic digest.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Digestcompute(HashAlgorithm alg, byte[] content)Computes the digest for the specified content.static Digestcompute(HashAlgorithm alg, com.nimbusds.jose.util.Base64 content)Computes the digest for the specified content.booleanequals(Object o)HashAlgorithmgetHashAlgorithm()Returns the hash algorithm.com.nimbusds.jose.util.Base64getValue()Returns the hash value.inthashCode()booleanmatches(com.nimbusds.jose.util.Base64 content)Returnstrueif this digest matches the computed for the specified content.static Digestparse(net.minidev.json.JSONObject jsonObject)Parses a digest from the specified JSON object.net.minidev.json.JSONObjecttoJSONObject()Returns a JSON object representation of this cryptographic digest.
-
-
-
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 benull.value- The hash value. Must not benull.
-
-
Method Detail
-
getHashAlgorithm
public HashAlgorithm 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
Returnstrueif this digest matches the computed for the specified content.- Parameters:
content- The content. Must not benull.- Returns:
- If
trueif the digest matches the content, elsefalse. - 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 benull.content- The content. Must not benull.- 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 benull.content- The content. Must not benull.- 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.
-
-