Class VerificationCodeGenerator
java.lang.Object
org.spdx.utility.verificationcode.VerificationCodeGenerator
Generates a package verification code from a directory of source code or an array of
SPDXFiles.
A class implementing the IFileChecksumGenerator is supplied as a parameter to the constructor.
The method getFileChecksum is called for each file in the directory. This can
be used as a hook to capture all files in the directory and capture the checksum values at
a file level.
- Author:
- Gary O'Neall
-
Constructor Summary
ConstructorsConstructorDescriptionVerificationCodeGenerator(IFileChecksumGenerator fileChecksumGenerator) Construct a newVerificationCodeGeneratorwith the specified file checksum generator -
Method Summary
Modifier and TypeMethodDescriptionorg.spdx.library.model.v2.SpdxPackageVerificationCodegeneratePackageVerificationCode(File sourceDirectory, File[] skippedFiles, org.spdx.storage.IModelStore modelStore, String documentUri) Generate the SPDX Package Verification Code from a directory of files included in the archiveorg.spdx.library.model.v2.SpdxPackageVerificationCodegeneratePackageVerificationCode(File sourceDirectory, org.spdx.storage.IModelStore modelStore, String documentUri) Generate the SPDX Package Verification Code from a directory of files included in the archiveprotected org.spdx.library.model.v2.SpdxPackageVerificationCodegeneratePackageVerificationCode(List<String> fileChecksums, String[] skippedFilePaths, org.spdx.storage.IModelStore modelStore, String documentUri) Generate the SPDX Package Verification Code from a list of file checksumsorg.spdx.library.model.v2.SpdxPackageVerificationCodegeneratePackageVerificationCode(org.spdx.library.model.v2.SpdxFile[] spdxFiles, String[] skippedFilePaths, org.spdx.storage.IModelStore modelStore, String documentUri) Generate the SPDX Package Verification Code from an array of SPDXFilesstatic StringnormalizeFilePath(String nonNormalizedFilePath) Normalizes a file path per the SPDX spec
-
Constructor Details
-
VerificationCodeGenerator
Construct a newVerificationCodeGeneratorwith the specified file checksum generatorThe file checksum generator is used to calculate checksums for files during the generation of the SPDX Package Verification Code.
- Parameters:
fileChecksumGenerator- An implementation ofIFileChecksumGeneratorused to calculate file checksums. Must not benull.
-
-
Method Details
-
generatePackageVerificationCode
public org.spdx.library.model.v2.SpdxPackageVerificationCode generatePackageVerificationCode(org.spdx.library.model.v2.SpdxFile[] spdxFiles, String[] skippedFilePaths, org.spdx.storage.IModelStore modelStore, String documentUri) throws NoSuchAlgorithmException, org.spdx.core.InvalidSPDXAnalysisException Generate the SPDX Package Verification Code from an array of SPDXFiles- Parameters:
spdxFiles- Files to generate the VerificationCode fromskippedFilePaths- File path names to not include in the VerificationCodemodelStore- where the resultant VerificationCode is storedocumentUri- document URI where the VerificationCode is stored- Returns:
- VerificationCode based on all files in spdxFiles minus the skippedFilePaths
- Throws:
NoSuchAlgorithmException- unexpected checksum calculation errororg.spdx.core.InvalidSPDXAnalysisException- on SPDX parsing error
-
generatePackageVerificationCode
public org.spdx.library.model.v2.SpdxPackageVerificationCode generatePackageVerificationCode(File sourceDirectory, File[] skippedFiles, org.spdx.storage.IModelStore modelStore, String documentUri) throws NoSuchAlgorithmException, IOException, org.spdx.core.InvalidSPDXAnalysisException Generate the SPDX Package Verification Code from a directory of files included in the archive- Parameters:
sourceDirectory- source directory for the package verification codemodelStore- where the resultant VerificationCode is storedocumentUri- document URI where the VerificationCode is stored- Returns:
- PackageVerificationCode based on the files in the sourceDirectory
- Throws:
NoSuchAlgorithmException- unexpected error creating checksumsIOException- on file or directory read errorsorg.spdx.core.InvalidSPDXAnalysisException- on SPDX parsing error
-
generatePackageVerificationCode
protected org.spdx.library.model.v2.SpdxPackageVerificationCode generatePackageVerificationCode(List<String> fileChecksums, String[] skippedFilePaths, org.spdx.storage.IModelStore modelStore, String documentUri) throws NoSuchAlgorithmException, org.spdx.core.InvalidSPDXAnalysisException Generate the SPDX Package Verification Code from a list of file checksums- Parameters:
fileChecksums- used to create the verification code valueskippedFilePaths- list of files skipped when calculating the verification codemodelStore- where the resultant VerificationCode is storedocumentUri- document URI where the VerificationCode is stored- Returns:
- a PackageVerificationCode with the value created from the fileChecksums
- Throws:
NoSuchAlgorithmException- unexpected error creating checksumsorg.spdx.core.InvalidSPDXAnalysisException- on SPDX parsing error
-
normalizeFilePath
-
generatePackageVerificationCode
public org.spdx.library.model.v2.SpdxPackageVerificationCode generatePackageVerificationCode(File sourceDirectory, org.spdx.storage.IModelStore modelStore, String documentUri) throws NoSuchAlgorithmException, IOException, org.spdx.core.InvalidSPDXAnalysisException Generate the SPDX Package Verification Code from a directory of files included in the archive- Parameters:
sourceDirectory- directory to create the verification code formodelStore- where the resultant VerificationCode is storedocumentUri- document URI where the VerificationCode is stored- Returns:
- SPDX package verification code
- Throws:
NoSuchAlgorithmException- unexpected error creating checksumsIOException- on IO error reading files or directoriesorg.spdx.core.InvalidSPDXAnalysisException- on SPDX parsing error
-