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 ofSPDXFile
s. A class implementing the IFileChecksumGenerator is supplied as a parameter to the constructor. The methodgetFileChecksum
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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.spdx.library.model.v2.SpdxPackageVerificationCode
generatePackageVerificationCode(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.SpdxPackageVerificationCode
generatePackageVerificationCode(File sourceDirectory, org.spdx.storage.IModelStore modelStore, String documentUri)
protected org.spdx.library.model.v2.SpdxPackageVerificationCode
generatePackageVerificationCode(List<String> fileChecksums, String[] skippedFilePaths, org.spdx.storage.IModelStore modelStore, String documentUri)
org.spdx.library.model.v2.SpdxPackageVerificationCode
generatePackageVerificationCode(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 String
normalizeFilePath(String nonNormalizedFilePath)
Normalizes a file path per the SPDX spec
-
-
-
Constructor Detail
-
VerificationCodeGenerator
public VerificationCodeGenerator(IFileChecksumGenerator fileChecksumGenerator)
-
-
Method Detail
-
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
org.spdx.core.InvalidSPDXAnalysisException
-
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
-modelStore
- where the resultant VerificationCode is storedocumentUri
- document URI where the VerificationCode is stored- Returns:
- PackageVerificationCode based on the files in the sourceDirectory
- Throws:
NoSuchAlgorithmException
IOException
org.spdx.core.InvalidSPDXAnalysisException
-
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
- 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
org.spdx.core.InvalidSPDXAnalysisException
-
normalizeFilePath
public static String normalizeFilePath(String nonNormalizedFilePath)
Normalizes a file path per the SPDX spec- Parameters:
nonNormalizedFilePath
-- Returns:
-
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
- Parameters:
sourceDirectory
-modelStore
- where the resultant VerificationCode is storedocumentUri
- document URI where the VerificationCode is stored- Returns:
- Throws:
NoSuchAlgorithmException
IOException
org.spdx.core.InvalidSPDXAnalysisException
-
-