Class VerificationCodeGenerator
java.lang.Object
org.spdx.utility.verificationcode.VerificationCodeGenerator
public class VerificationCodeGenerator extends Object
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 Constructor Description VerificationCodeGenerator(IFileChecksumGenerator fileChecksumGenerator) -
Method Summary
Modifier and Type Method Description SpdxPackageVerificationCodegeneratePackageVerificationCode(File sourceDirectory, File[] skippedFiles, IModelStore modelStore, String documentUri)Generate the SPDX Package Verification Code from a directory of files included in the archiveSpdxPackageVerificationCodegeneratePackageVerificationCode(File sourceDirectory, IModelStore modelStore, String documentUri)protected SpdxPackageVerificationCodegeneratePackageVerificationCode(List<String> fileChecksums, String[] skippedFilePaths, IModelStore modelStore, String documentUri)SpdxPackageVerificationCodegeneratePackageVerificationCode(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
-
Method Details
-
generatePackageVerificationCode
public SpdxPackageVerificationCode generatePackageVerificationCode(SpdxFile[] spdxFiles, String[] skippedFilePaths, IModelStore modelStore, String documentUri) throws NoSuchAlgorithmException, InvalidSPDXAnalysisExceptionGenerate 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, InvalidSPDXAnalysisExceptionGenerate 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
-