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 Details

  • 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 from
      skippedFilePaths - File path names to not include in the VerificationCode
      modelStore - where the resultant VerificationCode is store
      documentUri - 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 store
      documentUri - 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 value
      skippedFilePaths - list of files skipped when calculating the verification code
      modelStore - where the resultant VerificationCode is store
      documentUri - 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 store
      documentUri - document URI where the VerificationCode is stored
      Returns:
      Throws:
      NoSuchAlgorithmException
      IOException
      org.spdx.core.InvalidSPDXAnalysisException