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
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongeneratePackageVerificationCode(File sourceDirectory, File[] skippedFiles, IModelStore modelStore, String documentUri) Generate the SPDX Package Verification Code from a directory of files included in the archivegeneratePackageVerificationCode(File sourceDirectory, IModelStore modelStore, String documentUri) protected SpdxPackageVerificationCodegeneratePackageVerificationCode(List<String> fileChecksums, String[] skippedFilePaths, IModelStore modelStore, String documentUri) generatePackageVerificationCode(SpdxFile[] spdxFiles, String[] skippedFilePaths, 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
-
-
Method Details
-
generatePackageVerificationCode
public SpdxPackageVerificationCode generatePackageVerificationCode(SpdxFile[] spdxFiles, String[] skippedFilePaths, IModelStore modelStore, String documentUri) throws NoSuchAlgorithmException, 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:
NoSuchAlgorithmExceptionInvalidSPDXAnalysisException
-
generatePackageVerificationCode
public SpdxPackageVerificationCode generatePackageVerificationCode(File sourceDirectory, File[] skippedFiles, IModelStore modelStore, String documentUri) throws NoSuchAlgorithmException, IOException, InvalidSPDXAnalysisException Generate the SPDX Package Verification Code from a directory of files included in the archive- Parameters:
sourceDirectory-modelStore- where the resultant VerificationCode is storedocumentUri- document URI where the VerificationCode is stored- Returns:
- PackageVerificationCode based on the files in the sourceDirectory
- Throws:
NoSuchAlgorithmExceptionIOExceptionInvalidSPDXAnalysisException
-
generatePackageVerificationCode
protected SpdxPackageVerificationCode generatePackageVerificationCode(List<String> fileChecksums, String[] skippedFilePaths, IModelStore modelStore, String documentUri) throws NoSuchAlgorithmException, InvalidSPDXAnalysisException - 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:
NoSuchAlgorithmExceptionInvalidSPDXAnalysisException
-
normalizeFilePath
Normalizes a file path per the SPDX spec- Parameters:
nonNormalizedFilePath-- Returns:
-
generatePackageVerificationCode
public SpdxPackageVerificationCode generatePackageVerificationCode(File sourceDirectory, IModelStore modelStore, String documentUri) throws NoSuchAlgorithmException, IOException, InvalidSPDXAnalysisException - Parameters:
sourceDirectory-modelStore- where the resultant VerificationCode is storedocumentUri- document URI where the VerificationCode is stored- Returns:
- Throws:
NoSuchAlgorithmExceptionIOExceptionInvalidSPDXAnalysisException
-