Class RequireFileChecksum
java.lang.Object
org.apache.maven.enforcer.rule.api.AbstractEnforcerRule
org.apache.maven.enforcer.rules.AbstractStandardEnforcerRule
org.apache.maven.enforcer.rules.checksum.RequireFileChecksum
- All Implemented Interfaces:
EnforcerRuleBase
- Direct Known Subclasses:
RequireTextFileChecksum
Rule to validate a binary file to match the specified checksum.
- Author:
- Edward Samson, Lyubomyr Shaydariv
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Stringprotected StringcalculateChecksum(InputStream inputStream) voidexecute()This is the interface into the rule.getFile()getLog()Provide anEnforcerLoggerinstance for RulegetType()voidsetChecksum(String checksum) The expected checksum value.voidThe file to check.voidsetLog(EnforcerLogger log) Used byEnforcerMojoto inject logger instancevoidsetNonexistentFileMessage(String nonexistentFileMessage) The friendly message to use when the file does not exist.voidThe checksum algorithm to use.toString()Methods inherited from class org.apache.maven.enforcer.rules.AbstractStandardEnforcerRule
formatLocation, getMessage, setMessageMethods inherited from class org.apache.maven.enforcer.rule.api.AbstractEnforcerRule
getCacheId, getLevel
-
Constructor Details
-
RequireFileChecksum
public RequireFileChecksum()
-
-
Method Details
-
execute
Description copied from class:AbstractEnforcerRuleThis is the interface into the rule. This method should throw an exception containing a reason message if the rule fails the check. The plugin will then decide based on the fail flag and rule level if it should stop or just log the message as a warning.- Specified by:
executein classAbstractEnforcerRule- Throws:
EnforcerRuleException- the enforcer rule exception
-
setFile
The file to check.- Parameters:
file- file
-
getFile
-
setChecksum
The expected checksum value.- Parameters:
checksum- checksum
-
getChecksum
-
setType
The checksum algorithm to use. Possible values: "md5", "sha1", "sha256", "sha384", "sha512".- Parameters:
type- algorithm
-
getType
-
setNonexistentFileMessage
The friendly message to use when the file does not exist.- Parameters:
nonexistentFileMessage- message
-
getNonexistentFileMessage
-
calculateChecksum
- Throws:
EnforcerRuleException
-
calculateChecksum
protected String calculateChecksum(InputStream inputStream) throws IOException, EnforcerRuleException - Throws:
IOExceptionEnforcerRuleException
-
toString
-
setLog
Used byEnforcerMojoto inject logger instance- Specified by:
setLogin interfaceEnforcerRuleBase- Parameters:
log- anEnforcerLoggerinstance
-
getLog
Provide anEnforcerLoggerinstance for RuleNOTICE A logger is not available in constructors.
- Returns:
- an
EnforcerLoggerinstance
-