Package enterprises.iwakura.amber.impl
Class ChecksumValidatorImpl
java.lang.Object
enterprises.iwakura.amber.impl.ChecksumValidatorImpl
- All Implemented Interfaces:
ChecksumValidator
Default implementation of
ChecksumValidator. Uses MessageDigest to compute the checksum of a file.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringcalculateChecksum(ChecksumType checksumType, Path file) Calculate the checksum of a file using the specified checksum type.validate(ChecksumType checksumType, String checksum, Path file) Validates the checksum of the given file.
-
Constructor Details
-
ChecksumValidatorImpl
public ChecksumValidatorImpl()
-
-
Method Details
-
validate
public ChecksumResult validate(ChecksumType checksumType, String checksum, Path file) throws IOException Description copied from interface:ChecksumValidatorValidates the checksum of the given file. On unsupported algorithms, this method returns aChecksumResult.UNSUPPORTED- Specified by:
validatein interfaceChecksumValidator- Parameters:
checksumType- the type of checksum (e.g., MD5, SHA-1, SHA-256)checksum- the expected checksum valuefile- the file to validate- Returns:
- the result of the checksum validation
- Throws:
IOException- if an I/O error occurs
-
calculateChecksum
protected String calculateChecksum(ChecksumType checksumType, Path file) throws IOException, NoSuchAlgorithmException Calculate the checksum of a file using the specified checksum type.- Parameters:
checksumType- the type of checksum to calculatefile- the file to calculate the checksum for- Returns:
- the calculated checksum as a hexadecimal string
- Throws:
IOException- if an I/O error occursNoSuchAlgorithmException- if the specified checksum type is not supported
-