public class DefaultValidator extends Object implements Validator
Validator| Constructor and Description |
|---|
DefaultValidator()
Default constructor uses the ESAPI standard encoder for canonicalization.
|
DefaultValidator(Encoder encoder)
Construct a new DefaultValidator that will use the specified
Encoder for canonicalization.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addRule(ValidationRule rule)
Add a validation rule to the registry using the "type name" of the rule as the key.
|
void |
assertValidFileUpload(String context,
String directorypath,
String filename,
File parent,
byte[] content,
int maxBytes,
List<String> allowedExtensions,
boolean allowNull)
Validates the filepath, filename, and content of a file.
|
void |
assertValidFileUpload(String context,
String filepath,
String filename,
File parent,
byte[] content,
int maxBytes,
List<String> allowedExtensions,
boolean allowNull,
ValidationErrorList errors)
Calls getValidFileUpload with the supplied errorList to capture ValidationExceptions
|
void |
assertValidHTTPRequestParameterSet(String context,
javax.servlet.http.HttpServletRequest request,
Set<String> required,
Set<String> optional)
Validates that the parameters in the current request contain all required parameters and only optional ones in
addition.
|
void |
assertValidHTTPRequestParameterSet(String context,
javax.servlet.http.HttpServletRequest request,
Set<String> required,
Set<String> optional,
ValidationErrorList errors)
ValidationErrorList variant of assertIsValidHTTPRequestParameterSet
Uses current HTTPRequest saved in ESAPI Authenticator
|
static Validator |
getInstance() |
ValidationRule |
getRule(String name)
Get a validation rule from the registry with the "type name" of the rule as the key.
|
String |
getValidCreditCard(String context,
String input,
boolean allowNull)
Returns a canonicalized and validated credit card number as a String.
|
String |
getValidCreditCard(String context,
String input,
boolean allowNull,
ValidationErrorList errors)
Calls getValidCreditCard with the supplied errorList to capture ValidationExceptions
|
Date |
getValidDate(String context,
String input,
DateFormat format,
boolean allowNull)
Returns a valid date as a Date.
|
Date |
getValidDate(String context,
String input,
DateFormat format,
boolean allowNull,
ValidationErrorList errors)
Calls getValidDate with the supplied errorList to capture ValidationExceptions
|
String |
getValidDirectoryPath(String context,
String input,
File parent,
boolean allowNull)
Returns a canonicalized and validated directory path as a String, provided that the input
maps to an existing directory that is an existing subdirectory (at any level) of the specified parent.
|
String |
getValidDirectoryPath(String context,
String input,
File parent,
boolean allowNull,
ValidationErrorList errors)
Calls getValidDirectoryPath with the supplied errorList to capture ValidationExceptions
|
Double |
getValidDouble(String context,
String input,
double minValue,
double maxValue,
boolean allowNull)
Returns a validated real number as a double.
|
Double |
getValidDouble(String context,
String input,
double minValue,
double maxValue,
boolean allowNull,
ValidationErrorList errors)
Calls getValidDouble with the supplied errorList to capture ValidationExceptions
|
byte[] |
getValidFileContent(String context,
byte[] input,
int maxBytes,
boolean allowNull)
Returns validated file content as a byte array.
|
byte[] |
getValidFileContent(String context,
byte[] input,
int maxBytes,
boolean allowNull,
ValidationErrorList errors)
Calls getValidFileContent with the supplied errorList to capture ValidationExceptions
|
String |
getValidFileName(String context,
String input,
List<String> allowedExtensions,
boolean allowNull)
Returns a canonicalized and validated file name as a String.
|
String |
getValidFileName(String context,
String input,
List<String> allowedParameters,
boolean allowNull,
ValidationErrorList errors)
Calls getValidFileName with the supplied errorList to capture ValidationExceptions
|
String |
getValidInput(String context,
String input,
String type,
int maxLength,
boolean allowNull)
Validates data received from the browser and returns a safe version.
|
String |
getValidInput(String context,
String input,
String type,
int maxLength,
boolean allowNull,
boolean canonicalize)
Validates data received from the browser and returns a safe version.
|
String |
getValidInput(String context,
String input,
String type,
int maxLength,
boolean allowNull,
boolean canonicalize,
ValidationErrorList errors)
Validates data received from the browser and returns a safe version.
|
String |
getValidInput(String context,
String input,
String type,
int maxLength,
boolean allowNull,
ValidationErrorList errors)
Validates data received from the browser and returns a safe version.
|
Integer |
getValidInteger(String context,
String input,
int minValue,
int maxValue,
boolean allowNull)
Returns a validated integer.
|
Integer |
getValidInteger(String context,
String input,
int minValue,
int maxValue,
boolean allowNull,
ValidationErrorList errors)
Calls getValidInteger with the supplied errorList to capture ValidationExceptions
|
String |
getValidListItem(String context,
String input,
List<String> list)
Returns the list item that exactly matches the canonicalized input.
|
String |
getValidListItem(String context,
String input,
List<String> list,
ValidationErrorList errors)
ValidationErrorList variant of getValidListItem
|
Double |
getValidNumber(String context,
String input,
long minValue,
long maxValue,
boolean allowNull)
Returns a validated number as a double within the range of minValue to maxValue.
|
Double |
getValidNumber(String context,
String input,
long minValue,
long maxValue,
boolean allowNull,
ValidationErrorList errors)
Calls getValidSafeHTML with the supplied errorList to capture ValidationExceptions
|
char[] |
getValidPrintable(String context,
char[] input,
int maxLength,
boolean allowNull)
Returns canonicalized and validated printable characters as a byte array.
|
char[] |
getValidPrintable(String context,
char[] input,
int maxLength,
boolean allowNull,
ValidationErrorList errors)
ValidationErrorList variant of getValidPrintable
|
String |
getValidPrintable(String context,
String input,
int maxLength,
boolean allowNull)
Returns canonicalized and validated printable characters as a String.
|
String |
getValidPrintable(String context,
String input,
int maxLength,
boolean allowNull,
ValidationErrorList errors)
ValidationErrorList variant of getValidPrintable
|
String |
getValidRedirectLocation(String context,
String input,
boolean allowNull)
Returns a canonicalized and validated redirect location as a String.
|
String |
getValidRedirectLocation(String context,
String input,
boolean allowNull,
ValidationErrorList errors)
ValidationErrorList variant of getValidRedirectLocation
|
String |
getValidSafeHTML(String context,
String input,
int maxLength,
boolean allowNull)
Returns canonicalized and validated "safe" HTML that does not contain unwanted scripts in the body, attributes, CSS, URLs, or anywhere else.
|
String |
getValidSafeHTML(String context,
String input,
int maxLength,
boolean allowNull,
ValidationErrorList errors)
Calls getValidSafeHTML with the supplied errorList to capture ValidationExceptions
|
boolean |
isValidCreditCard(String context,
String input,
boolean allowNull)
Calls getValidCreditCard and returns true if no exceptions are thrown.
|
boolean |
isValidCreditCard(String context,
String input,
boolean allowNull,
ValidationErrorList errors)
Calls getValidCreditCard and returns true if no exceptions are thrown.
|
boolean |
isValidDate(String context,
String input,
DateFormat format,
boolean allowNull)
Calls isValidDate and returns true if no exceptions are thrown.
|
boolean |
isValidDate(String context,
String input,
DateFormat format,
boolean allowNull,
ValidationErrorList errors)
Calls isValidDate and returns true if no exceptions are thrown.
|
boolean |
isValidDirectoryPath(String context,
String input,
File parent,
boolean allowNull)
Calls getValidDirectoryPath and returns true if no exceptions are thrown.
|
boolean |
isValidDirectoryPath(String context,
String input,
File parent,
boolean allowNull,
ValidationErrorList errors)
Calls getValidDirectoryPath and returns true if no exceptions are thrown.
|
boolean |
isValidDouble(String context,
String input,
double minValue,
double maxValue,
boolean allowNull)
Calls getValidDouble and returns true if no exceptions are thrown.
|
boolean |
isValidDouble(String context,
String input,
double minValue,
double maxValue,
boolean allowNull,
ValidationErrorList errors)
Calls getValidDouble and returns true if no exceptions are thrown.
|
boolean |
isValidFileContent(String context,
byte[] input,
int maxBytes,
boolean allowNull)
Calls getValidFileContent and returns true if no exceptions are thrown.
|
boolean |
isValidFileContent(String context,
byte[] input,
int maxBytes,
boolean allowNull,
ValidationErrorList errors)
Calls getValidFileContent and returns true if no exceptions are thrown.
|
boolean |
isValidFileName(String context,
String input,
boolean allowNull)
Calls getValidFileName with the default list of allowedExtensions
|
boolean |
isValidFileName(String context,
String input,
boolean allowNull,
ValidationErrorList errors)
Calls getValidFileName with the default list of allowedExtensions
|
boolean |
isValidFileName(String context,
String input,
List<String> allowedExtensions,
boolean allowNull)
Calls getValidFileName and returns true if no exceptions are thrown.
|
boolean |
isValidFileName(String context,
String input,
List<String> allowedExtensions,
boolean allowNull,
ValidationErrorList errors)
Calls getValidFileName and returns true if no exceptions are thrown.
|
boolean |
isValidFileUpload(String context,
String directorypath,
String filename,
File parent,
byte[] content,
int maxBytes,
boolean allowNull)
Calls getValidFileUpload and returns true if no exceptions are thrown.
|
boolean |
isValidFileUpload(String context,
String directorypath,
String filename,
File parent,
byte[] content,
int maxBytes,
boolean allowNull,
ValidationErrorList errors)
Calls getValidFileUpload and returns true if no exceptions are thrown.
|
boolean |
isValidHTTPRequestParameterSet(String context,
javax.servlet.http.HttpServletRequest request,
Set<String> requiredNames,
Set<String> optionalNames)
Calls assertValidHTTPRequestParameterSet and returns true if no exceptions are thrown.
|
boolean |
isValidHTTPRequestParameterSet(String context,
javax.servlet.http.HttpServletRequest request,
Set<String> requiredNames,
Set<String> optionalNames,
ValidationErrorList errors)
Calls assertValidHTTPRequestParameterSet and returns true if no exceptions are thrown.
|
boolean |
isValidInput(String context,
String input,
String type,
int maxLength,
boolean allowNull)
Returns true if data received from browser is valid.
|
boolean |
isValidInput(String context,
String input,
String type,
int maxLength,
boolean allowNull,
boolean canonicalize)
Calls isValidInput and returns true if no exceptions are thrown.
|
boolean |
isValidInput(String context,
String input,
String type,
int maxLength,
boolean allowNull,
boolean canonicalize,
ValidationErrorList errors)
Calls isValidInput and returns true if no exceptions are thrown.
|
boolean |
isValidInput(String context,
String input,
String type,
int maxLength,
boolean allowNull,
ValidationErrorList errors)
Calls isValidInput and returns true if no exceptions are thrown.
|
boolean |
isValidInteger(String context,
String input,
int minValue,
int maxValue,
boolean allowNull)
Calls getValidInteger and returns true if no exceptions are thrown.
|
boolean |
isValidInteger(String context,
String input,
int minValue,
int maxValue,
boolean allowNull,
ValidationErrorList errors)
Calls getValidInteger and returns true if no exceptions are thrown.
|
boolean |
isValidListItem(String context,
String input,
List<String> list)
Calls getValidListItem and returns true if no exceptions are thrown.
|
boolean |
isValidListItem(String context,
String input,
List<String> list,
ValidationErrorList errors)
Calls getValidListItem and returns true if no exceptions are thrown.
|
boolean |
isValidNumber(String context,
String input,
long minValue,
long maxValue,
boolean allowNull)
Calls getValidNumber and returns true if no exceptions are thrown.
|
boolean |
isValidNumber(String context,
String input,
long minValue,
long maxValue,
boolean allowNull,
ValidationErrorList errors)
Calls getValidNumber and returns true if no exceptions are thrown.
|
boolean |
isValidPrintable(String context,
char[] input,
int maxLength,
boolean allowNull)
Calls getValidPrintable and returns true if no exceptions are thrown.
|
boolean |
isValidPrintable(String context,
char[] input,
int maxLength,
boolean allowNull,
ValidationErrorList errors)
Calls getValidPrintable and returns true if no exceptions are thrown.
|
boolean |
isValidPrintable(String context,
String input,
int maxLength,
boolean allowNull)
Calls getValidPrintable and returns true if no exceptions are thrown.
|
boolean |
isValidPrintable(String context,
String input,
int maxLength,
boolean allowNull,
ValidationErrorList errors)
Calls getValidPrintable and returns true if no exceptions are thrown.
|
boolean |
isValidRedirectLocation(String context,
String input,
boolean allowNull)
Returns true if input is a valid redirect location.
|
boolean |
isValidRedirectLocation(String context,
String input,
boolean allowNull,
ValidationErrorList errors)
Returns true if input is a valid redirect location.
|
boolean |
isValidSafeHTML(String context,
String input,
int maxLength,
boolean allowNull)
Calls getValidSafeHTML and returns true if no exceptions are thrown.
|
boolean |
isValidSafeHTML(String context,
String input,
int maxLength,
boolean allowNull,
ValidationErrorList errors)
Calls getValidSafeHTML and returns true if no exceptions are thrown.
|
String |
safeReadLine(InputStream in,
int max)
Reads from an input stream until end-of-line or a maximum number of
characters.
|
public DefaultValidator()
public DefaultValidator(Encoder encoder)
encoder - public static Validator getInstance()
public void addRule(ValidationRule rule)
public ValidationRule getRule(String name)
public boolean isValidInput(String context, String input, String type, int maxLength, boolean allowNull) throws IntrusionException
isValidInput in interface Validatorcontext - A descriptive name for the field to validate. This is used for error facing validation messages and element identification.input - The actual user input data to validate.type - The regular expression name while maps to the actual regular expression from "ESAPI.properties".maxLength - The maximum post-canonicalized String length allowed.allowNull - If allowNull is true then a input that is NULL or an empty string will be legal. If allowNull is false then NULL or an empty String will throw a ValidationException.IntrusionExceptionpublic boolean isValidInput(String context, String input, String type, int maxLength, boolean allowNull, ValidationErrorList errors) throws IntrusionException
ValidatorisValidInput in interface ValidatorIntrusionExceptionpublic boolean isValidInput(String context, String input, String type, int maxLength, boolean allowNull, boolean canonicalize) throws IntrusionException
ValidatorisValidInput in interface ValidatorIntrusionExceptionpublic boolean isValidInput(String context, String input, String type, int maxLength, boolean allowNull, boolean canonicalize, ValidationErrorList errors) throws IntrusionException
ValidatorisValidInput in interface ValidatorIntrusionExceptionpublic String getValidInput(String context, String input, String type, int maxLength, boolean allowNull) throws ValidationException
getValidInput in interface Validatorcontext - A descriptive name for the field to validate. This is used for error facing validation messages and element identification.input - The actual user input data to validate.type - The regular expression name which maps to the actual regular expression from "ESAPI.properties".maxLength - The maximum post-canonicalized String length allowed.allowNull - If allowNull is true then a input that is NULL or an empty string will be legal. If allowNull is false then NULL or an empty String will throw a ValidationException.ValidationExceptionIntrusionExceptionpublic String getValidInput(String context, String input, String type, int maxLength, boolean allowNull, boolean canonicalize) throws ValidationException
getValidInput in interface Validatorcontext - A descriptive name for the field to validate. This is used for error facing validation messages and element identification.input - The actual user input data to validate.type - The regular expression name which maps to the actual regular expression in the ESAPI validation configuration filemaxLength - The maximum String length allowed. If input is canonicalized per the canonicalize argument, then maxLength must be verified after canonicalizationallowNull - If allowNull is true then a input that is NULL or an empty string will be legal. If allowNull is false then NULL or an empty String will throw a ValidationException.canonicalize - If canonicalize is true then input will be canonicalized before validationValidationExceptionIntrusionExceptionpublic String getValidInput(String context, String input, String type, int maxLength, boolean allowNull, ValidationErrorList errors) throws IntrusionException
getValidInput in interface Validatorcontext - A descriptive name for the field to validate. This is used for error facing validation messages and element identification.input - The actual user input data to validate.type - The regular expression name while maps to the actual regular expression from "ESAPI.properties".maxLength - The maximum String length allowed. If input is canonicalized per the canonicalize argument, then maxLength must be verified after canonicalizationallowNull - If allowNull is true then a input that is NULL or an empty string will be legal. If allowNull is false then NULL or an empty String will throw a ValidationException.errors - If ValidationException is thrown, then add to error list instead of throwing out to callerIntrusionExceptionpublic String getValidInput(String context, String input, String type, int maxLength, boolean allowNull, boolean canonicalize, ValidationErrorList errors) throws IntrusionException
getValidInput in interface Validatorcontext - A descriptive name for the field to validate. This is used for error facing validation messages and element identification.input - The actual user input data to validate.type - The regular expression name while maps to the actual regular expression from "ESAPI.properties".maxLength - The maximum post-canonicalized String length allowedallowNull - If allowNull is true then a input that is NULL or an empty string will be legal. If allowNull is false then NULL or an empty String will throw a ValidationException.canonicalize - If canonicalize is true then input will be canonicalized before validationerrors - If ValidationException is thrown, then add to error list instead of throwing out to callerIntrusionExceptionpublic boolean isValidDate(String context, String input, DateFormat format, boolean allowNull) throws IntrusionException
isValidDate in interface ValidatorIntrusionExceptionpublic boolean isValidDate(String context, String input, DateFormat format, boolean allowNull, ValidationErrorList errors) throws IntrusionException
isValidDate in interface ValidatorIntrusionExceptionpublic Date getValidDate(String context, String input, DateFormat format, boolean allowNull) throws ValidationException, IntrusionException
getValidDate in interface Validatorcontext - A descriptive name of the parameter that you are validating (e.g., LoginPage_UsernameField). This value is used by any logging or error handling that is done with respect to the value passed in.input - The actual user input data to validate.format - Required formatting of date inputted.allowNull - If allowNull is true then an input that is NULL or an empty string will be legal. If allowNull is false then NULL or an empty String will throw a ValidationException.ValidationExceptionIntrusionExceptionpublic Date getValidDate(String context, String input, DateFormat format, boolean allowNull, ValidationErrorList errors) throws IntrusionException
getValidDate in interface ValidatorIntrusionExceptionpublic boolean isValidSafeHTML(String context, String input, int maxLength, boolean allowNull) throws IntrusionException
isValidSafeHTML in interface ValidatorIntrusionExceptionpublic boolean isValidSafeHTML(String context, String input, int maxLength, boolean allowNull, ValidationErrorList errors) throws IntrusionException
isValidSafeHTML in interface ValidatorIntrusionExceptionpublic String getValidSafeHTML(String context, String input, int maxLength, boolean allowNull) throws ValidationException, IntrusionException
getValidSafeHTML in interface Validatorcontext - A descriptive name of the parameter that you are validating (e.g., LoginPage_UsernameField). This value is used by any logging or error handling that is done with respect to the value passed in.input - The actual user input data to validate.maxLength - The maximum String length allowed.allowNull - If allowNull is true then an input that is NULL or an empty string will be legal. If allowNull is false then NULL or an empty String will throw a ValidationException.ValidationExceptionIntrusionExceptionpublic String getValidSafeHTML(String context, String input, int maxLength, boolean allowNull, ValidationErrorList errors) throws IntrusionException
getValidSafeHTML in interface ValidatorIntrusionExceptionpublic boolean isValidCreditCard(String context, String input, boolean allowNull) throws IntrusionException
isValidCreditCard in interface ValidatorIntrusionExceptionpublic boolean isValidCreditCard(String context, String input, boolean allowNull, ValidationErrorList errors) throws IntrusionException
isValidCreditCard in interface ValidatorIntrusionExceptionpublic String getValidCreditCard(String context, String input, boolean allowNull) throws ValidationException, IntrusionException
getValidCreditCard in interface Validatorcontext - A descriptive name of the parameter that you are validating (e.g., LoginPage_UsernameField). This value is used by any logging or error handling that is done with respect to the value passed in.input - The actual user input data to validate.allowNull - If allowNull is true then an input that is NULL or an empty string will be legal. If allowNull is false then NULL or an empty String will throw a ValidationException.ValidationExceptionIntrusionExceptionpublic String getValidCreditCard(String context, String input, boolean allowNull, ValidationErrorList errors) throws IntrusionException
getValidCreditCard in interface ValidatorIntrusionExceptionpublic boolean isValidDirectoryPath(String context, String input, File parent, boolean allowNull) throws IntrusionException
Note: On platforms that support symlinks, this function will fail canonicalization if directorypath is a symlink. For example, on MacOS X, /etc is actually /private/etc. If you mean to use /etc, use its real path (/private/etc), not the symlink (/etc).
isValidDirectoryPath in interface ValidatorIntrusionExceptionpublic boolean isValidDirectoryPath(String context, String input, File parent, boolean allowNull, ValidationErrorList errors) throws IntrusionException
Note: On platforms that support symlinks, this function will fail canonicalization if directorypath is a symlink. For example, on MacOS X, /etc is actually /private/etc. If you mean to use /etc, use its real path (/private/etc), not the symlink (/etc).
isValidDirectoryPath in interface ValidatorIntrusionExceptionpublic String getValidDirectoryPath(String context, String input, File parent, boolean allowNull) throws ValidationException, IntrusionException
getValidDirectoryPath in interface Validatorcontext - A descriptive name of the parameter that you are validating (e.g., LoginPage_UsernameField). This value is used by any logging or error handling that is done with respect to the value passed in.input - The actual input data to validate.allowNull - If allowNull is true then an input that is NULL or an empty string will be legal. If allowNull is false then NULL or an empty String will throw a ValidationException.ValidationExceptionIntrusionExceptionpublic String getValidDirectoryPath(String context, String input, File parent, boolean allowNull, ValidationErrorList errors) throws IntrusionException
getValidDirectoryPath in interface ValidatorIntrusionExceptionpublic boolean isValidFileName(String context, String input, boolean allowNull) throws IntrusionException
isValidFileName in interface ValidatorIntrusionExceptionpublic boolean isValidFileName(String context, String input, boolean allowNull, ValidationErrorList errors) throws IntrusionException
isValidFileName in interface ValidatorIntrusionExceptionpublic boolean isValidFileName(String context, String input, List<String> allowedExtensions, boolean allowNull) throws IntrusionException
isValidFileName in interface ValidatorIntrusionExceptionpublic boolean isValidFileName(String context, String input, List<String> allowedExtensions, boolean allowNull, ValidationErrorList errors) throws IntrusionException
isValidFileName in interface ValidatorIntrusionExceptionpublic String getValidFileName(String context, String input, List<String> allowedExtensions, boolean allowNull) throws ValidationException, IntrusionException
getValidFileName in interface Validatorcontext - A descriptive name of the parameter that you are validating (e.g., LoginPage_UsernameField). This value is used by any logging or error handling that is done with respect to the value passed in.input - The actual input data to validate.allowNull - If allowNull is true then an input that is NULL or an empty string will be legal. If allowNull is false then NULL or an empty String will throw a ValidationException.ValidationExceptionIntrusionExceptionpublic String getValidFileName(String context, String input, List<String> allowedParameters, boolean allowNull, ValidationErrorList errors) throws IntrusionException
getValidFileName in interface ValidatorIntrusionExceptionpublic boolean isValidNumber(String context, String input, long minValue, long maxValue, boolean allowNull) throws IntrusionException
isValidNumber in interface ValidatorIntrusionExceptionpublic boolean isValidNumber(String context, String input, long minValue, long maxValue, boolean allowNull, ValidationErrorList errors) throws IntrusionException
isValidNumber in interface ValidatorIntrusionExceptionpublic Double getValidNumber(String context, String input, long minValue, long maxValue, boolean allowNull) throws ValidationException, IntrusionException
getValidNumber in interface Validatorcontext - A descriptive name of the parameter that you are validating (e.g., LoginPage_UsernameField). This value is used by any logging or error handling that is done with respect to the value passed in.input - The actual input data to validate.minValue - Lowest legal value for input.maxValue - Highest legal value for input.allowNull - If allowNull is true then an input that is NULL or an empty string will be legal. If allowNull is false then NULL or an empty String will throw a ValidationException.ValidationExceptionIntrusionExceptionpublic Double getValidNumber(String context, String input, long minValue, long maxValue, boolean allowNull, ValidationErrorList errors) throws IntrusionException
getValidNumber in interface ValidatorIntrusionExceptionpublic boolean isValidDouble(String context, String input, double minValue, double maxValue, boolean allowNull) throws IntrusionException
isValidDouble in interface ValidatorIntrusionExceptionpublic boolean isValidDouble(String context, String input, double minValue, double maxValue, boolean allowNull, ValidationErrorList errors) throws IntrusionException
isValidDouble in interface ValidatorIntrusionExceptionpublic Double getValidDouble(String context, String input, double minValue, double maxValue, boolean allowNull) throws ValidationException, IntrusionException
getValidDouble in interface Validatorcontext - A descriptive name of the parameter that you are validating (e.g., LoginPage_UsernameField). This value is used by any logging or error handling that is done with respect to the value passed in.input - The actual input data to validate.minValue - Lowest legal value for input.maxValue - Highest legal value for input.allowNull - If allowNull is true then an input that is NULL or an empty string will be legal. If allowNull is false then NULL or an empty String will throw a ValidationException.ValidationExceptionIntrusionExceptionpublic Double getValidDouble(String context, String input, double minValue, double maxValue, boolean allowNull, ValidationErrorList errors) throws IntrusionException
getValidDouble in interface ValidatorIntrusionExceptionpublic boolean isValidInteger(String context, String input, int minValue, int maxValue, boolean allowNull) throws IntrusionException
isValidInteger in interface ValidatorIntrusionExceptionpublic boolean isValidInteger(String context, String input, int minValue, int maxValue, boolean allowNull, ValidationErrorList errors) throws IntrusionException
isValidInteger in interface ValidatorIntrusionExceptionpublic Integer getValidInteger(String context, String input, int minValue, int maxValue, boolean allowNull) throws ValidationException, IntrusionException
getValidInteger in interface Validatorcontext - A descriptive name of the parameter that you are validating (e.g., LoginPage_UsernameField). This value is used by any logging or error handling that is done with respect to the value passed in.input - The actual input data to validate.minValue - Lowest legal value for input.maxValue - Highest legal value for input.allowNull - If allowNull is true then an input that is NULL or an empty string will be legal. If allowNull is false then NULL or an empty String will throw a ValidationException.ValidationExceptionIntrusionExceptionpublic Integer getValidInteger(String context, String input, int minValue, int maxValue, boolean allowNull, ValidationErrorList errors) throws IntrusionException
getValidInteger in interface ValidatorIntrusionExceptionpublic boolean isValidFileContent(String context, byte[] input, int maxBytes, boolean allowNull) throws IntrusionException
isValidFileContent in interface ValidatorIntrusionExceptionpublic boolean isValidFileContent(String context, byte[] input, int maxBytes, boolean allowNull, ValidationErrorList errors) throws IntrusionException
isValidFileContent in interface ValidatorIntrusionExceptionpublic byte[] getValidFileContent(String context, byte[] input, int maxBytes, boolean allowNull) throws ValidationException, IntrusionException
getValidFileContent in interface Validatorcontext - A descriptive name of the parameter that you are validating (e.g., LoginPage_UsernameField). This value is used by any logging or error handling that is done with respect to the value passed in.input - The actual input data to validate.maxBytes - The maximum number of bytes allowed in a legal file.allowNull - If allowNull is true then an input that is NULL or an empty string will be legal. If allowNull is false then NULL or an empty String will throw a ValidationException.ValidationExceptionIntrusionExceptionpublic byte[] getValidFileContent(String context, byte[] input, int maxBytes, boolean allowNull, ValidationErrorList errors) throws IntrusionException
getValidFileContent in interface ValidatorIntrusionExceptionpublic boolean isValidFileUpload(String context, String directorypath, String filename, File parent, byte[] content, int maxBytes, boolean allowNull) throws IntrusionException
Note: On platforms that support symlinks, this function will fail canonicalization if directorypath is a symlink. For example, on MacOS X, /etc is actually /private/etc. If you mean to use /etc, use its real path (/private/etc), not the symlink (/etc).
isValidFileUpload in interface ValidatorIntrusionExceptionpublic boolean isValidFileUpload(String context, String directorypath, String filename, File parent, byte[] content, int maxBytes, boolean allowNull, ValidationErrorList errors) throws IntrusionException
Note: On platforms that support symlinks, this function will fail canonicalization if directorypath is a symlink. For example, on MacOS X, /etc is actually /private/etc. If you mean to use /etc, use its real path (/private/etc), not the symlink (/etc).
isValidFileUpload in interface ValidatorIntrusionExceptionpublic void assertValidFileUpload(String context, String directorypath, String filename, File parent, byte[] content, int maxBytes, List<String> allowedExtensions, boolean allowNull) throws ValidationException, IntrusionException
assertValidFileUpload in interface Validatorcontext - A descriptive name of the parameter that you are validating (e.g., LoginPage_UsernameField). This value is used by any logging or error handling that is done with respect to the value passed in.directorypath - The file path of the uploaded file.filename - The filename of the uploaded filecontent - A byte array containing the content of the uploaded file.maxBytes - The max number of bytes allowed for a legal file upload.allowNull - If allowNull is true then an input that is NULL or an empty string will be legal. If allowNull is false then NULL or an empty String will throw a ValidationException.ValidationExceptionIntrusionExceptionpublic void assertValidFileUpload(String context, String filepath, String filename, File parent, byte[] content, int maxBytes, List<String> allowedExtensions, boolean allowNull, ValidationErrorList errors) throws IntrusionException
assertValidFileUpload in interface ValidatorIntrusionExceptionpublic boolean isValidListItem(String context, String input, List<String> list)
isValidListItem in interface Validatorpublic boolean isValidListItem(String context, String input, List<String> list, ValidationErrorList errors)
isValidListItem in interface Validatorpublic String getValidListItem(String context, String input, List<String> list) throws ValidationException, IntrusionException
getValidListItem in interface Validatorcontext - A descriptive name of the parameter that you are validating (e.g., LoginPage_UsernameField). This value is used by any logging or error handling that is done with respect to the value passed in.input - The value to search 'list' for.list - The list to search for 'input'.ValidationExceptionIntrusionExceptionpublic String getValidListItem(String context, String input, List<String> list, ValidationErrorList errors) throws IntrusionException
getValidListItem in interface Validatorerrors - IntrusionExceptionpublic boolean isValidHTTPRequestParameterSet(String context, javax.servlet.http.HttpServletRequest request, Set<String> requiredNames, Set<String> optionalNames)
isValidHTTPRequestParameterSet in interface Validatorpublic boolean isValidHTTPRequestParameterSet(String context, javax.servlet.http.HttpServletRequest request, Set<String> requiredNames, Set<String> optionalNames, ValidationErrorList errors)
isValidHTTPRequestParameterSet in interface Validatorpublic void assertValidHTTPRequestParameterSet(String context, javax.servlet.http.HttpServletRequest request, Set<String> required, Set<String> optional) throws ValidationException, IntrusionException
assertValidHTTPRequestParameterSet in interface Validatorcontext - A descriptive name of the parameter that you are validating (e.g., LoginPage_UsernameField). This value is used by any logging or error handling that is done with respect to the value passed in.required - parameters that are required to be in HTTP requestoptional - additional parameters that may be in HTTP requestValidationExceptionIntrusionExceptionpublic void assertValidHTTPRequestParameterSet(String context, javax.servlet.http.HttpServletRequest request, Set<String> required, Set<String> optional, ValidationErrorList errors) throws IntrusionException
assertValidHTTPRequestParameterSet in interface Validatorerrors - IntrusionExceptionpublic boolean isValidPrintable(String context, char[] input, int maxLength, boolean allowNull) throws IntrusionException
isValidPrintable in interface ValidatorIntrusionExceptionpublic boolean isValidPrintable(String context, char[] input, int maxLength, boolean allowNull, ValidationErrorList errors) throws IntrusionException
isValidPrintable in interface ValidatorIntrusionExceptionpublic char[] getValidPrintable(String context, char[] input, int maxLength, boolean allowNull) throws ValidationException, IntrusionException
getValidPrintable in interface Validatorcontext - A descriptive name of the parameter that you are validating (e.g., LoginPage_UsernameField). This value is used by any logging or error handling that is done with respect to the value passed in.input - data to be returned as valid and printablemaxLength - Maximum number of bytes stored in 'input'allowNull - If allowNull is true then an input that is NULL or an empty string will be legal. If allowNull is false then NULL or an empty String will throw a ValidationException.IntrusionExceptionValidationExceptionpublic char[] getValidPrintable(String context, char[] input, int maxLength, boolean allowNull, ValidationErrorList errors) throws IntrusionException
getValidPrintable in interface Validatorerrors - IntrusionExceptionpublic boolean isValidPrintable(String context, String input, int maxLength, boolean allowNull) throws IntrusionException
isValidPrintable in interface ValidatorIntrusionExceptionpublic boolean isValidPrintable(String context, String input, int maxLength, boolean allowNull, ValidationErrorList errors) throws IntrusionException
isValidPrintable in interface ValidatorIntrusionExceptionpublic String getValidPrintable(String context, String input, int maxLength, boolean allowNull) throws ValidationException, IntrusionException
getValidPrintable in interface Validatorcontext - A descriptive name of the parameter that you are validating (e.g., LoginPage_UsernameField). This value is used by any logging or error handling that is done with respect to the value passed in.input - data to be returned as valid and printablemaxLength - Maximum number of bytes stored in 'input' after canonicalizationallowNull - If allowNull is true then an input that is NULL or an empty string will be legal. If allowNull is false then NULL or an empty String will throw a ValidationException.IntrusionExceptionValidationExceptionpublic String getValidPrintable(String context, String input, int maxLength, boolean allowNull, ValidationErrorList errors) throws IntrusionException
getValidPrintable in interface Validatorerrors - IntrusionExceptionpublic boolean isValidRedirectLocation(String context, String input, boolean allowNull) throws IntrusionException
isValidRedirectLocation in interface ValidatorIntrusionExceptionpublic boolean isValidRedirectLocation(String context, String input, boolean allowNull, ValidationErrorList errors) throws IntrusionException
isValidRedirectLocation in interface ValidatorIntrusionExceptionpublic String getValidRedirectLocation(String context, String input, boolean allowNull) throws ValidationException, IntrusionException
getValidRedirectLocation in interface Validatorcontext - A descriptive name of the parameter that you are validating (e.g., LoginPage_UsernameField). This value is used by any logging or error handling that is done with respect to the value passed in.input - redirect location to be returned as valid, according to encoding rules set in "ESAPI.properties"allowNull - If allowNull is true then an input that is NULL or an empty string will be legal. If allowNull is false then NULL or an empty String will throw a ValidationException.ValidationExceptionIntrusionExceptionpublic String getValidRedirectLocation(String context, String input, boolean allowNull, ValidationErrorList errors) throws IntrusionException
getValidRedirectLocation in interface Validatorerrors - IntrusionExceptionpublic String safeReadLine(InputStream in, int max) throws ValidationException
safeReadLine in interface Validatorin - max - ValidationExceptionCopyright © 2016 The Open Web Application Security Project (OWASP). All rights reserved.