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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateChecksumFile(File file, HashAlgorithm algorithm) Creates a checksum file for a given file.hash(File file, HashAlgorithm algorithm) Get the hash for a given file.booleanisChecksumFile(File file) Test whether a givenFileis a file that is considered a checksum file based on its extension ending withHashAlgorithm.MD5,HashAlgorithm.SHA1,HashAlgorithm.SHA256orHashAlgorithm.SHA512.booleanisSignatureFile(File file) Test whether a givenFileis a file that is considered a signature file with .asc extensionMethods inherited from class org.codehaus.plexus.logging.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Constructor Details
-
HashUtilsImpl
public HashUtilsImpl()
-
-
Method Details
-
hash
Description copied from interface:HashUtilsGet the hash for a given file.- Specified by:
hashin interfaceHashUtils- Parameters:
file- -Filealgorithm- -HashAlgorithm- Returns:
- String or null if the file didn't exist or issues occurred reading it.
-
createChecksumFile
Description copied from interface:HashUtilsCreates a checksum file for a given file. The hash file will be created alongside the givenfilein the same parent directory. Example the the file /test/1.0.jar, after calling this method with, for exampleHashAlgorithm.SHA512, have alongside itself the file /test/1.0.jar.sha512- Specified by:
createChecksumFilein interfaceHashUtils- Parameters:
file- -Filealgorithm- -HashAlgorithm- Returns:
- File - the
Filewith the hash for the givenfile, or null if unable to create it.
-
isChecksumFile
Description copied from interface:HashUtilsTest whether a givenFileis a file that is considered a checksum file based on its extension ending withHashAlgorithm.MD5,HashAlgorithm.SHA1,HashAlgorithm.SHA256orHashAlgorithm.SHA512.- Specified by:
isChecksumFilein interfaceHashUtils- Parameters:
file- -File- Returns:
- true if the given file is considered a checksum file.
-
isSignatureFile
Description copied from interface:HashUtilsTest whether a givenFileis a file that is considered a signature file with .asc extension- Specified by:
isSignatureFilein interfaceHashUtils- Parameters:
file- -File- Returns:
- true if the given file is considered a signature file
-