![]() |
filechampion4j 0.9.8.3
File validation library for Java
|

Public Member Functions | |
| ValidationsHelper (Extensions extensions) | |
| StringBuilder | getValidationResults (String fileCategory, String fileName, byte[] originalFile, String mimeString) throws IOException, SecurityException, NumberFormatException |
Private Member Functions | |
| StringBuilder | doValidations () throws IOException, SecurityException, NumberFormatException |
| void | logWarn (StringBuilder message) |
| void | logFine (StringBuilder message) |
| boolean | isBlank (String str) |
| StringBuilder | checkFileSize () |
| StringBuilder | checkMimeType () throws IOException, SecurityException |
| String | getFileExtension (String fileName) |
| StringBuilder | containsMagicBytes () |
| boolean | containsMagicBytesProcessor (byte[] originalFileBytes, String magicBytesPattern) throws NumberFormatException |
| StringBuilder | containsHeaderSignatures () |
| boolean | containsHeaderSignaturesProcessor (byte[] fileBytes, String headerSignaturesPattern) throws NumberFormatException |
| StringBuilder | containsFooterSignatures () |
| boolean | containsFooterSignaturesProcessor (byte[] fileBytes, String footerSignaturesPattern) throws NumberFormatException |
| Path | saveFileToTempDir (String fileExtension, byte[] originalFile) |
| Boolean | deleteTempDir (Path tempFilePath) |
Private Attributes | |
| Extensions | extensions |
| boolean | failFast = false |
| StringBuilder | sharedStringBuilder = new StringBuilder() |
| String | fileCategory |
| byte[] | originalFile |
| String | mimeString |
| String | fileExtension |
| String | commonLogString |
| int | responseMsgCountFail |
| StringBuilder | sbresponseAggregationFail |
| int | responseMsgCountSuccess |
| StringBuilder | sbresponseAggregationSuccess |
Static Private Attributes | |
| static final Logger | LOGGER = Logger.getLogger(ValidationsHelper.class.getName()) |
This class contains helper methods for the FileValidator class
Definition at line 17 of file ValidationsHelper.java.
| dev.filechampion.filechampion4j.ValidationsHelper.ValidationsHelper | ( | Extensions | extensions | ) |
This is the constructor for the ValidationsHelper class.
| extensions | (Extensions) the Extensions object containing the file validation configuration |
Definition at line 37 of file ValidationsHelper.java.
References dev.filechampion.filechampion4j.ValidationsHelper.extensions.
|
private |
Compare file size to the maximum allowed size
Definition at line 152 of file ValidationsHelper.java.
References dev.filechampion.filechampion4j.ValidationsHelper.commonLogString, dev.filechampion.filechampion4j.ValidationsHelper.extensions, dev.filechampion.filechampion4j.ValidationsHelper.fileCategory, dev.filechampion.filechampion4j.ValidationsHelper.fileExtension, dev.filechampion.filechampion4j.Extensions.getValidationValue(), dev.filechampion.filechampion4j.ValidationsHelper.logFine(), dev.filechampion.filechampion4j.ValidationsHelper.logWarn(), dev.filechampion.filechampion4j.ValidationsHelper.originalFile, dev.filechampion.filechampion4j.ValidationsHelper.responseMsgCountFail, dev.filechampion.filechampion4j.ValidationsHelper.responseMsgCountSuccess, dev.filechampion.filechampion4j.ValidationsHelper.sbresponseAggregationFail, and dev.filechampion.filechampion4j.ValidationsHelper.sbresponseAggregationSuccess.
Referenced by dev.filechampion.filechampion4j.ValidationsHelper.doValidations().


|
private |
Compare the file MIME type to the expected MIME type
| IOException | (IOException) if the file cannot be saved/deleted to/from a temporary directory |
| SecurityException | (SecurityException) if the accessed to file is denied for Files.probContentType |
Definition at line 187 of file ValidationsHelper.java.
References dev.filechampion.filechampion4j.ValidationsHelper.commonLogString, dev.filechampion.filechampion4j.ValidationsHelper.deleteTempDir(), dev.filechampion.filechampion4j.ValidationsHelper.extensions, dev.filechampion.filechampion4j.ValidationsHelper.fileCategory, dev.filechampion.filechampion4j.ValidationsHelper.fileExtension, dev.filechampion.filechampion4j.Extensions.getValidationValue(), dev.filechampion.filechampion4j.ValidationsHelper.isBlank(), dev.filechampion.filechampion4j.ValidationsHelper.logFine(), dev.filechampion.filechampion4j.ValidationsHelper.logWarn(), dev.filechampion.filechampion4j.ValidationsHelper.mimeString, dev.filechampion.filechampion4j.ValidationsHelper.originalFile, dev.filechampion.filechampion4j.ValidationsHelper.responseMsgCountFail, dev.filechampion.filechampion4j.ValidationsHelper.responseMsgCountSuccess, dev.filechampion.filechampion4j.ValidationsHelper.saveFileToTempDir(), dev.filechampion.filechampion4j.ValidationsHelper.sbresponseAggregationFail, dev.filechampion.filechampion4j.ValidationsHelper.sbresponseAggregationSuccess, and dev.filechampion.filechampion4j.ValidationsHelper.sharedStringBuilder.
Referenced by dev.filechampion.filechampion4j.ValidationsHelper.doValidations().


|
private |
Check if the file contains the expected footer signatures
Definition at line 344 of file ValidationsHelper.java.
References dev.filechampion.filechampion4j.ValidationsHelper.commonLogString, dev.filechampion.filechampion4j.ValidationsHelper.containsFooterSignaturesProcessor(), dev.filechampion.filechampion4j.ValidationsHelper.extensions, dev.filechampion.filechampion4j.ValidationsHelper.fileCategory, dev.filechampion.filechampion4j.ValidationsHelper.fileExtension, dev.filechampion.filechampion4j.Extensions.getValidationValue(), dev.filechampion.filechampion4j.ValidationsHelper.isBlank(), dev.filechampion.filechampion4j.ValidationsHelper.logFine(), dev.filechampion.filechampion4j.ValidationsHelper.logWarn(), dev.filechampion.filechampion4j.ValidationsHelper.originalFile, dev.filechampion.filechampion4j.ValidationsHelper.responseMsgCountFail, dev.filechampion.filechampion4j.ValidationsHelper.responseMsgCountSuccess, dev.filechampion.filechampion4j.ValidationsHelper.sbresponseAggregationFail, and dev.filechampion.filechampion4j.ValidationsHelper.sbresponseAggregationSuccess.
Referenced by dev.filechampion.filechampion4j.ValidationsHelper.doValidations().


|
private |
Check if the file contains the expected footer signatures
| fileBytes | (byte[]) the file bytes of the file being validated |
| footerSignaturesPattern | (String) the expected footer signatures of the file being validated |
Definition at line 367 of file ValidationsHelper.java.
References dev.filechampion.filechampion4j.ValidationsHelper.isBlank().
Referenced by dev.filechampion.filechampion4j.ValidationsHelper.containsFooterSignatures().


|
private |
Check if the file contains the expected header signatures
Definition at line 297 of file ValidationsHelper.java.
References dev.filechampion.filechampion4j.ValidationsHelper.commonLogString, dev.filechampion.filechampion4j.ValidationsHelper.containsHeaderSignaturesProcessor(), dev.filechampion.filechampion4j.ValidationsHelper.extensions, dev.filechampion.filechampion4j.ValidationsHelper.fileCategory, dev.filechampion.filechampion4j.ValidationsHelper.fileExtension, dev.filechampion.filechampion4j.Extensions.getValidationValue(), dev.filechampion.filechampion4j.ValidationsHelper.isBlank(), dev.filechampion.filechampion4j.ValidationsHelper.logFine(), dev.filechampion.filechampion4j.ValidationsHelper.logWarn(), dev.filechampion.filechampion4j.ValidationsHelper.originalFile, dev.filechampion.filechampion4j.ValidationsHelper.responseMsgCountFail, dev.filechampion.filechampion4j.ValidationsHelper.responseMsgCountSuccess, dev.filechampion.filechampion4j.ValidationsHelper.sbresponseAggregationFail, and dev.filechampion.filechampion4j.ValidationsHelper.sbresponseAggregationSuccess.
Referenced by dev.filechampion.filechampion4j.ValidationsHelper.doValidations().


|
private |
Check if the file contains the expected header signatures
| fileBytes | (byte[]) the file bytes of the file being validated |
| headerSignaturesPattern | (String) the expected header signatures of the file being validated |
Definition at line 320 of file ValidationsHelper.java.
References dev.filechampion.filechampion4j.ValidationsHelper.isBlank().
Referenced by dev.filechampion.filechampion4j.ValidationsHelper.containsHeaderSignatures().


|
private |
Check if the file contains the expected magic bytes
Definition at line 243 of file ValidationsHelper.java.
References dev.filechampion.filechampion4j.ValidationsHelper.commonLogString, dev.filechampion.filechampion4j.ValidationsHelper.containsMagicBytesProcessor(), dev.filechampion.filechampion4j.ValidationsHelper.extensions, dev.filechampion.filechampion4j.ValidationsHelper.fileCategory, dev.filechampion.filechampion4j.ValidationsHelper.fileExtension, dev.filechampion.filechampion4j.Extensions.getValidationValue(), dev.filechampion.filechampion4j.ValidationsHelper.isBlank(), dev.filechampion.filechampion4j.ValidationsHelper.logFine(), dev.filechampion.filechampion4j.ValidationsHelper.logWarn(), dev.filechampion.filechampion4j.ValidationsHelper.originalFile, dev.filechampion.filechampion4j.ValidationsHelper.responseMsgCountFail, dev.filechampion.filechampion4j.ValidationsHelper.responseMsgCountSuccess, dev.filechampion.filechampion4j.ValidationsHelper.sbresponseAggregationFail, and dev.filechampion.filechampion4j.ValidationsHelper.sbresponseAggregationSuccess.
Referenced by dev.filechampion.filechampion4j.ValidationsHelper.doValidations().


|
private |
Check if the file contains the expected magic bytes
| originalFileBytes | (byte[]) the file bytes of the file being validated |
| magicBytesPattern | (String) the expected magic bytes of the file being validated |
Definition at line 266 of file ValidationsHelper.java.
Referenced by dev.filechampion.filechampion4j.ValidationsHelper.containsMagicBytes().

|
private |
Helper method to delete the temporary directory
| tempFilePath | (Path) the path to the temporary file |
Definition at line 417 of file ValidationsHelper.java.
References dev.filechampion.filechampion4j.ValidationsHelper.logWarn(), and dev.filechampion.filechampion4j.ValidationsHelper.sharedStringBuilder.
Referenced by dev.filechampion.filechampion4j.ValidationsHelper.checkMimeType().


|
private |
Following initial validations and before plugins, this method is used to execute the validations for the file.
| IOException | (IOException) if the file cannot be saved/deleted to/from a temporary directory |
| SecurityException | (SecurityException) if the accessed to file is denied for Files.probContentType |
Definition at line 73 of file ValidationsHelper.java.
References dev.filechampion.filechampion4j.ValidationsHelper.checkFileSize(), dev.filechampion.filechampion4j.ValidationsHelper.checkMimeType(), dev.filechampion.filechampion4j.ValidationsHelper.containsFooterSignatures(), dev.filechampion.filechampion4j.ValidationsHelper.containsHeaderSignatures(), dev.filechampion.filechampion4j.ValidationsHelper.containsMagicBytes(), dev.filechampion.filechampion4j.ValidationsHelper.failFast, dev.filechampion.filechampion4j.ValidationsHelper.logFine(), dev.filechampion.filechampion4j.ValidationsHelper.logWarn(), dev.filechampion.filechampion4j.ValidationsHelper.responseMsgCountFail, dev.filechampion.filechampion4j.ValidationsHelper.sbresponseAggregationFail, and dev.filechampion.filechampion4j.ValidationsHelper.sbresponseAggregationSuccess.
Referenced by dev.filechampion.filechampion4j.ValidationsHelper.getValidationResults().


|
private |
Parse the file extension from the file name
| fileName | (String) the name of the file being validated |
Definition at line 231 of file ValidationsHelper.java.
Referenced by dev.filechampion.filechampion4j.ValidationsHelper.getValidationResults().

| StringBuilder dev.filechampion.filechampion4j.ValidationsHelper.getValidationResults | ( | String | fileCategory, |
| String | fileName, | ||
| byte[] | originalFile, | ||
| String | mimeString | ||
| ) | throws IOException, SecurityException, NumberFormatException |
ValidationsHelper entry point for file validation
| fileCategory | (String) the file category of the file being validated |
| fileName | (String) the file name of the file being validated |
| originalFile | (byte[]) the byte of the file being validated |
| mimeString | (String) the mime type of the file being validated |
| IOException | (IOException) if the file cannot be saved/deleted to/from a temporary directory |
| SecurityException | (SecurityException) if the accessed to file is denied for Files.probContentType |
Definition at line 51 of file ValidationsHelper.java.
References dev.filechampion.filechampion4j.ValidationsHelper.doValidations(), dev.filechampion.filechampion4j.ValidationsHelper.extensions, dev.filechampion.filechampion4j.ValidationsHelper.fileCategory, dev.filechampion.filechampion4j.ValidationsHelper.fileExtension, dev.filechampion.filechampion4j.ValidationsHelper.getFileExtension(), dev.filechampion.filechampion4j.Extensions.getValidationValue(), dev.filechampion.filechampion4j.ValidationsHelper.mimeString, and dev.filechampion.filechampion4j.ValidationsHelper.originalFile.
Referenced by dev.filechampion.filechampion4j.FileValidator.doValidations().


|
private |
isBlank wrapper method for support of Java 8
| str | (String) the string to check if empty or null |
Definition at line 144 of file ValidationsHelper.java.
Referenced by dev.filechampion.filechampion4j.ValidationsHelper.checkMimeType(), dev.filechampion.filechampion4j.ValidationsHelper.containsFooterSignatures(), dev.filechampion.filechampion4j.ValidationsHelper.containsFooterSignaturesProcessor(), dev.filechampion.filechampion4j.ValidationsHelper.containsHeaderSignatures(), dev.filechampion.filechampion4j.ValidationsHelper.containsHeaderSignaturesProcessor(), and dev.filechampion.filechampion4j.ValidationsHelper.containsMagicBytes().

|
private |
LOGGER.fine wrapper
| message | (StringBuilder) - message to log |
Definition at line 133 of file ValidationsHelper.java.
References dev.filechampion.filechampion4j.ValidationsHelper.LOGGER.
Referenced by dev.filechampion.filechampion4j.ValidationsHelper.checkFileSize(), dev.filechampion.filechampion4j.ValidationsHelper.checkMimeType(), dev.filechampion.filechampion4j.ValidationsHelper.containsFooterSignatures(), dev.filechampion.filechampion4j.ValidationsHelper.containsHeaderSignatures(), dev.filechampion.filechampion4j.ValidationsHelper.containsMagicBytes(), and dev.filechampion.filechampion4j.ValidationsHelper.doValidations().

|
private |
LOGGER.warning wrapper
| message | (String) - message to log |
Definition at line 123 of file ValidationsHelper.java.
References dev.filechampion.filechampion4j.ValidationsHelper.LOGGER.
Referenced by dev.filechampion.filechampion4j.ValidationsHelper.checkFileSize(), dev.filechampion.filechampion4j.ValidationsHelper.checkMimeType(), dev.filechampion.filechampion4j.ValidationsHelper.containsFooterSignatures(), dev.filechampion.filechampion4j.ValidationsHelper.containsHeaderSignatures(), dev.filechampion.filechampion4j.ValidationsHelper.containsMagicBytes(), dev.filechampion.filechampion4j.ValidationsHelper.deleteTempDir(), dev.filechampion.filechampion4j.ValidationsHelper.doValidations(), and dev.filechampion.filechampion4j.ValidationsHelper.saveFileToTempDir().

|
private |
Helper method to save the file to a temporary directory
| fileExtension | (String) the file extension of the file being validated |
| originalFile | (byte[]) the file bytes of the file being validated |
Definition at line 397 of file ValidationsHelper.java.
References dev.filechampion.filechampion4j.ValidationsHelper.fileExtension, dev.filechampion.filechampion4j.ValidationsHelper.logWarn(), dev.filechampion.filechampion4j.ValidationsHelper.originalFile, and dev.filechampion.filechampion4j.ValidationsHelper.sharedStringBuilder.
Referenced by dev.filechampion.filechampion4j.ValidationsHelper.checkMimeType().


|
private |
Definition at line 26 of file ValidationsHelper.java.
Referenced by dev.filechampion.filechampion4j.ValidationsHelper.checkFileSize(), dev.filechampion.filechampion4j.ValidationsHelper.checkMimeType(), dev.filechampion.filechampion4j.ValidationsHelper.containsFooterSignatures(), dev.filechampion.filechampion4j.ValidationsHelper.containsHeaderSignatures(), and dev.filechampion.filechampion4j.ValidationsHelper.containsMagicBytes().
|
private |
Definition at line 19 of file ValidationsHelper.java.
Referenced by dev.filechampion.filechampion4j.ValidationsHelper.ValidationsHelper(), dev.filechampion.filechampion4j.ValidationsHelper.checkFileSize(), dev.filechampion.filechampion4j.ValidationsHelper.checkMimeType(), dev.filechampion.filechampion4j.ValidationsHelper.containsFooterSignatures(), dev.filechampion.filechampion4j.ValidationsHelper.containsHeaderSignatures(), dev.filechampion.filechampion4j.ValidationsHelper.containsMagicBytes(), and dev.filechampion.filechampion4j.ValidationsHelper.getValidationResults().
|
private |
Definition at line 20 of file ValidationsHelper.java.
Referenced by dev.filechampion.filechampion4j.ValidationsHelper.doValidations().
|
private |
Definition at line 22 of file ValidationsHelper.java.
Referenced by dev.filechampion.filechampion4j.ValidationsHelper.checkFileSize(), dev.filechampion.filechampion4j.ValidationsHelper.checkMimeType(), dev.filechampion.filechampion4j.ValidationsHelper.containsFooterSignatures(), dev.filechampion.filechampion4j.ValidationsHelper.containsHeaderSignatures(), dev.filechampion.filechampion4j.ValidationsHelper.containsMagicBytes(), and dev.filechampion.filechampion4j.ValidationsHelper.getValidationResults().
|
private |
Definition at line 25 of file ValidationsHelper.java.
Referenced by dev.filechampion.filechampion4j.ValidationsHelper.checkFileSize(), dev.filechampion.filechampion4j.ValidationsHelper.checkMimeType(), dev.filechampion.filechampion4j.ValidationsHelper.containsFooterSignatures(), dev.filechampion.filechampion4j.ValidationsHelper.containsHeaderSignatures(), dev.filechampion.filechampion4j.ValidationsHelper.containsMagicBytes(), dev.filechampion.filechampion4j.ValidationsHelper.getValidationResults(), and dev.filechampion.filechampion4j.ValidationsHelper.saveFileToTempDir().
|
staticprivate |
Definition at line 18 of file ValidationsHelper.java.
Referenced by dev.filechampion.filechampion4j.ValidationsHelper.logFine(), and dev.filechampion.filechampion4j.ValidationsHelper.logWarn().
|
private |
Definition at line 24 of file ValidationsHelper.java.
Referenced by dev.filechampion.filechampion4j.ValidationsHelper.checkMimeType(), and dev.filechampion.filechampion4j.ValidationsHelper.getValidationResults().
|
private |
Definition at line 23 of file ValidationsHelper.java.
Referenced by dev.filechampion.filechampion4j.ValidationsHelper.checkFileSize(), dev.filechampion.filechampion4j.ValidationsHelper.checkMimeType(), dev.filechampion.filechampion4j.ValidationsHelper.containsFooterSignatures(), dev.filechampion.filechampion4j.ValidationsHelper.containsHeaderSignatures(), dev.filechampion.filechampion4j.ValidationsHelper.containsMagicBytes(), dev.filechampion.filechampion4j.ValidationsHelper.getValidationResults(), and dev.filechampion.filechampion4j.ValidationsHelper.saveFileToTempDir().
|
private |
Definition at line 27 of file ValidationsHelper.java.
Referenced by dev.filechampion.filechampion4j.ValidationsHelper.checkFileSize(), dev.filechampion.filechampion4j.ValidationsHelper.checkMimeType(), dev.filechampion.filechampion4j.ValidationsHelper.containsFooterSignatures(), dev.filechampion.filechampion4j.ValidationsHelper.containsHeaderSignatures(), dev.filechampion.filechampion4j.ValidationsHelper.containsMagicBytes(), and dev.filechampion.filechampion4j.ValidationsHelper.doValidations().
|
private |
Definition at line 29 of file ValidationsHelper.java.
Referenced by dev.filechampion.filechampion4j.ValidationsHelper.checkFileSize(), dev.filechampion.filechampion4j.ValidationsHelper.checkMimeType(), dev.filechampion.filechampion4j.ValidationsHelper.containsFooterSignatures(), dev.filechampion.filechampion4j.ValidationsHelper.containsHeaderSignatures(), and dev.filechampion.filechampion4j.ValidationsHelper.containsMagicBytes().
|
private |
Definition at line 28 of file ValidationsHelper.java.
Referenced by dev.filechampion.filechampion4j.ValidationsHelper.checkFileSize(), dev.filechampion.filechampion4j.ValidationsHelper.checkMimeType(), dev.filechampion.filechampion4j.ValidationsHelper.containsFooterSignatures(), dev.filechampion.filechampion4j.ValidationsHelper.containsHeaderSignatures(), dev.filechampion.filechampion4j.ValidationsHelper.containsMagicBytes(), and dev.filechampion.filechampion4j.ValidationsHelper.doValidations().
|
private |
Definition at line 30 of file ValidationsHelper.java.
Referenced by dev.filechampion.filechampion4j.ValidationsHelper.checkFileSize(), dev.filechampion.filechampion4j.ValidationsHelper.checkMimeType(), dev.filechampion.filechampion4j.ValidationsHelper.containsFooterSignatures(), dev.filechampion.filechampion4j.ValidationsHelper.containsHeaderSignatures(), dev.filechampion.filechampion4j.ValidationsHelper.containsMagicBytes(), and dev.filechampion.filechampion4j.ValidationsHelper.doValidations().
|
private |