java.lang.Object
java.lang.Record
org.htmlunit.csp.value.Hash
- Record Components:
algorithm- the hash algorithm (SHA-256, SHA-384, or SHA-512)base64ValuePart- the Base64-encoded hash value (case-sensitive)
Represents a CSP hash-source value, e.g.
'sha256-abc123...'.
A hash-source pairs a hash Hash.Algorithm with a Base64-encoded digest value.
The algorithm prefix (sha256, sha384, sha512) is parsed
case-insensitively, but the Base64 digest itself is case-sensitive.
- Author:
- Salvation Team
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumerates the hash algorithms supported by CSP hash-sources. -
Constructor Summary
ConstructorsConstructorDescriptionHash(Hash.Algorithm algorithm, String base64ValuePart) Creates an instance of aHashrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thealgorithmrecord component.Returns the value of thebase64ValuePartrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the hash algorithm.Returns the Base64-encoded hash value.final inthashCode()Returns a hash code value for this object.Parses a hash-source from its CSP string representation.toString()Returns the CSP string representation of this hash-source, e.g.
-
Constructor Details
-
Hash
Creates an instance of aHashrecord class.- Parameters:
algorithm- the value for thealgorithmrecord componentbase64ValuePart- the value for thebase64ValuePartrecord component
-
-
Method Details
-
getAlgorithm
Returns the hash algorithm.- Returns:
- the
Hash.Algorithmfor this hash-source
-
getBase64ValuePart
Returns the Base64-encoded hash value.This value is case-sensitive and may use standard Base64 or Base64url encoding.
- Returns:
- the Base64-encoded digest string
-
parseHash
Parses a hash-source from its CSP string representation.The input must be a single-quoted string of the form
'sha256-<base64>','sha384-<base64>', or'sha512-<base64>'. The algorithm prefix is matched case-insensitively; the Base64 portion is preserved as-is. -
toString
Returns the CSP string representation of this hash-source, e.g.'sha256-abc123...'. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
algorithm
Returns the value of thealgorithmrecord component.- Returns:
- the value of the
algorithmrecord component
-
base64ValuePart
Returns the value of thebase64ValuePartrecord component.- Returns:
- the value of the
base64ValuePartrecord component
-