Class HashUtilsImpl

java.lang.Object
org.codehaus.plexus.logging.AbstractLogEnabled
org.sonatype.central.publisher.plugin.utils.HashUtilsImpl
All Implemented Interfaces:
org.codehaus.plexus.logging.LogEnabled, HashUtils

@Component(role=HashUtils.class) public class HashUtilsImpl extends org.codehaus.plexus.logging.AbstractLogEnabled implements HashUtils
Implementation of HashUtils
  • Constructor Details

    • HashUtilsImpl

      public HashUtilsImpl()
  • Method Details

    • hash

      public String hash(File file, HashAlgorithm algorithm)
      Description copied from interface: HashUtils
      Get the hash for a given file.
      Specified by:
      hash in interface HashUtils
      Parameters:
      file - - File
      algorithm - - HashAlgorithm
      Returns:
      String or null if the file didn't exist or issues occurred reading it.
    • createChecksumFile

      public File createChecksumFile(File file, HashAlgorithm algorithm)
      Description copied from interface: HashUtils
      Creates a checksum file for a given file. The hash file will be created alongside the given file in the same parent directory. Example the the file /test/1.0.jar, after calling this method with, for example HashAlgorithm.SHA512, have alongside itself the file /test/1.0.jar.sha512
      Specified by:
      createChecksumFile in interface HashUtils
      Parameters:
      file - - File
      algorithm - - HashAlgorithm
      Returns:
      File - the File with the hash for the given file, or null if unable to create it.
    • isChecksumFile

      public boolean isChecksumFile(File file)
      Description copied from interface: HashUtils
      Test whether a given File is a file that is considered a checksum file based on its extension ending with HashAlgorithm.MD5, HashAlgorithm.SHA1,HashAlgorithm.SHA256 or HashAlgorithm.SHA512.
      Specified by:
      isChecksumFile in interface HashUtils
      Parameters:
      file - - File
      Returns:
      true if the given file is considered a checksum file.
    • isSignatureFile

      public boolean isSignatureFile(File file)
      Description copied from interface: HashUtils
      Test whether a given File is a file that is considered a signature file with .asc extension
      Specified by:
      isSignatureFile in interface HashUtils
      Parameters:
      file - - File
      Returns:
      true if the given file is considered a signature file