Class ManifestCanonicalizer
java.lang.Object
com.marksayson.deletionchecker.manifest.ManifestCanonicalizer
Serializes a manifest to its canonical JSON form: keys in ascending order, no insignificant
whitespace, and the
manifestChecksum field omitted. Generation and verification both hash
this exact byte sequence, so they always agree regardless of how a manifest file is actually
formatted.
Manifest string values must not contain a quote, a backslash, or a control character — the generator's inputs (entity types, file names, versions, timestamps) never do, and forbidding them keeps the canonical form escape-free and unambiguous.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringAlgorithm prefix on amanifestChecksumvalue: "sha256:". -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringcanonicalize(DatasetManifest manifest) Returns the canonical JSON formanifest, without amanifestChecksumfield.static StringReturns themanifestChecksumvalue for the manifest whose checksum-free canonical form iscanonicalJson:CHECKSUM_PREFIXfollowed by the lowercase-hex SHA-256 of that form's UTF-8 bytes.
-
Field Details
-
CHECKSUM_PREFIX
Algorithm prefix on amanifestChecksumvalue: "sha256:".- See Also:
-
-
Method Details
-
checksum
Returns themanifestChecksumvalue for the manifest whose checksum-free canonical form iscanonicalJson:CHECKSUM_PREFIXfollowed by the lowercase-hex SHA-256 of that form's UTF-8 bytes. The writer stores this; verification recomputes it the same way, so both sides always agree.- Parameters:
canonicalJson- a manifest's canonical form, as returned bycanonicalize(com.marksayson.deletionchecker.manifest.DatasetManifest)- Returns:
- the
manifestChecksumvalue
-
canonicalize
Returns the canonical JSON formanifest, without amanifestChecksumfield.- Parameters:
manifest- the manifest to serialize- Returns:
- the canonical JSON string
- Throws:
IllegalArgumentException- if any string value contains a quote, backslash, or control character
-