Class ContentSeal
java.lang.Object
org.odpi.openmetadata.adapters.connectors.surveyaction.seal.ContentSeal
ContentSeal creates the manifest for sealed content and compares the content with its manifest later.
The members of sealed content are the regular files in the sealed directory and the directories beneath it, or the sealed file itself. Symbolic links are not followed and are not members. The manifest holds the relative path, size, last modified time and SHA-256 content hash of each member.
This class only reads the sealed content. The one file it writes is the manifest, and it refuses to write that inside the sealed content, or over an existing file.
The members of sealed content are the regular files in the sealed directory and the directories beneath it, or the sealed file itself. Symbolic links are not followed and are not members. The manifest holds the relative path, size, last modified time and SHA-256 content hash of each member.
This class only reads the sealed content. The one file it writes is the manifest, and it refuses to write that inside the sealed content, or over an existing file.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic SealManifestcreateManifest(File root, String sealedElementGUID, String rootPathName, String sealedBy, Date sealedTime) Read every member of the content and return the manifest that describes it.static StringReturn the hash of the content of a file.static SealVerificationverify(File root, File manifestFile, String manifestFingerprint, SealVerificationLevel level) Compare sealed content with its manifest.static StringwriteManifest(SealManifest manifest, File manifestFile, File root) Write a manifest to a new file.
-
Field Details
-
ALGORITHM
The algorithm used to hash the content of each member, and the manifest.- See Also:
-
-
Method Details
-
hashFile
Return the hash of the content of a file.- Parameters:
file- file to read- Returns:
- hash in hexadecimal
- Throws:
IOException- the file can not be read
-
createManifest
public static SealManifest createManifest(File root, String sealedElementGUID, String rootPathName, String sealedBy, Date sealedTime) throws IOException Read every member of the content and return the manifest that describes it.- Parameters:
root- file or directory to sealsealedElementGUID- unique identifier of the element that describes the contentrootPathName- path name of the content, as it is cataloguedsealedBy- who, or what, is sealing the contentsealedTime- when the content is sealed- Returns:
- manifest
- Throws:
IOException- a member can not be read - the content can not be sealed
-
writeManifest
public static String writeManifest(SealManifest manifest, File manifestFile, File root) throws IOException Write a manifest to a new file. The file must not exist and must not be inside the sealed content.- Parameters:
manifest- manifest to writemanifestFile- where to write itroot- the sealed file or directory- Returns:
- hash of the bytes written - the manifest fingerprint
- Throws:
IOException- the manifest can not be written
-
verify
public static SealVerification verify(File root, File manifestFile, String manifestFingerprint, SealVerificationLevel level) Compare sealed content with its manifest.- Parameters:
root- the sealed file or directorymanifestFile- the manifest filemanifestFingerprint- the hash of the manifest that was recorded when the content was sealedlevel- how thorough to be (QUICK or FULL)- Returns:
- what was found
-