in enforcer-rules/src/main/java/org/apache/maven/enforcer/rules/checksum/RequireFileChecksum.java [52:91]
public void execute() throws EnforcerRuleException {
if (this.file == null) {
throw new EnforcerRuleError("Input file unspecified");
}
if (this.type == null) {
throw new EnforcerRuleError("Hash type unspecified");
}
if (this.checksum == null) {
throw new EnforcerRuleError("Checksum unspecified");
}
if (!this.file.exists()) {
String message = nonexistentFileMessage;
if (message == null) {
message = "File does not exist: " + this.file.getAbsolutePath();
}
throw new EnforcerRuleException(message);
}
if (this.file.isDirectory()) {
throw new EnforcerRuleError("Cannot calculate the checksum of directory: " + this.file.getAbsolutePath());
}
if (!this.file.canRead()) {
throw new EnforcerRuleError("Cannot read file: " + this.file.getAbsolutePath());
}
String checksum = calculateChecksum();
if (!checksum.equalsIgnoreCase(this.checksum)) {
String exceptionMessage = getMessage();
if (exceptionMessage == null) {
exceptionMessage =
this.type + " hash of " + this.file + " was " + checksum + " but expected " + this.checksum;
}
throw new EnforcerRuleException(exceptionMessage);
}
}