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 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
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
- 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
- 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
public static String normalizeFilePath(String nonNormalizedFilePath)
Normalizes a file path per the SPDX spec- Parameters:
nonNormalizedFilePath
- original file path - may be unix or DOS format- Returns:
- file path normalized per SPDX spec
-
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
- 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
-
-