|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.owasp.esapi.reference.DefaultValidator
public class DefaultValidator
Reference implementation of the Validator interface. This implementation relies on the ESAPI Encoder, Java Pattern (regex), Date, and several other classes to provide basic validation functions. This library has a heavy emphasis on whitelist validation and canonicalization.
Validator
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DefaultValidator()
public DefaultValidator(Encoder encoder)
encoder
- Method Detail |
---|
public static Validator getInstance()
public void addRule(ValidationRule rule)
addRule
in interface Validator
public ValidationRule getRule(String name)
getRule
in interface Validator
public boolean isValidInput(String context, String input, String type, int maxLength, boolean allowNull) throws IntrusionException
isValidInput
in interface Validator
context
- 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.
IntrusionException
public boolean isValidInput(String context, String input, String type, int maxLength, boolean allowNull, ValidationErrorList errors) throws IntrusionException
Validator
isValidInput
in interface Validator
IntrusionException
public boolean isValidInput(String context, String input, String type, int maxLength, boolean allowNull, boolean canonicalize) throws IntrusionException
Validator
isValidInput
in interface Validator
IntrusionException
public boolean isValidInput(String context, String input, String type, int maxLength, boolean allowNull, boolean canonicalize, ValidationErrorList errors) throws IntrusionException
Validator
isValidInput
in interface Validator
IntrusionException
public String getValidInput(String context, String input, String type, int maxLength, boolean allowNull) throws ValidationException
getValidInput
in interface Validator
context
- 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.
ValidationException
IntrusionException
public String getValidInput(String context, String input, String type, int maxLength, boolean allowNull, boolean canonicalize) throws ValidationException
getValidInput
in interface Validator
context
- 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 validation
ValidationException
IntrusionException
public String getValidInput(String context, String input, String type, int maxLength, boolean allowNull, ValidationErrorList errors) throws IntrusionException
getValidInput
in interface Validator
context
- 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 caller
IntrusionException
public String getValidInput(String context, String input, String type, int maxLength, boolean allowNull, boolean canonicalize, ValidationErrorList errors) throws IntrusionException
getValidInput
in interface Validator
context
- 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 caller
IntrusionException
public boolean isValidDate(String context, String input, DateFormat format, boolean allowNull) throws IntrusionException
isValidDate
in interface Validator
IntrusionException
public boolean isValidDate(String context, String input, DateFormat format, boolean allowNull, ValidationErrorList errors) throws IntrusionException
isValidDate
in interface Validator
IntrusionException
public Date getValidDate(String context, String input, DateFormat format, boolean allowNull) throws ValidationException, IntrusionException
getValidDate
in interface Validator
context
- 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.
ValidationException
IntrusionException
public Date getValidDate(String context, String input, DateFormat format, boolean allowNull, ValidationErrorList errors) throws IntrusionException
getValidDate
in interface Validator
IntrusionException
public boolean isValidSafeHTML(String context, String input, int maxLength, boolean allowNull) throws IntrusionException
isValidSafeHTML
in interface Validator
IntrusionException
public boolean isValidSafeHTML(String context, String input, int maxLength, boolean allowNull, ValidationErrorList errors) throws IntrusionException
isValidSafeHTML
in interface Validator
IntrusionException
public String getValidSafeHTML(String context, String input, int maxLength, boolean allowNull) throws ValidationException, IntrusionException
getValidSafeHTML
in interface Validator
context
- 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.
ValidationException
IntrusionException
public String getValidSafeHTML(String context, String input, int maxLength, boolean allowNull, ValidationErrorList errors) throws IntrusionException
getValidSafeHTML
in interface Validator
IntrusionException
public boolean isValidCreditCard(String context, String input, boolean allowNull) throws IntrusionException
isValidCreditCard
in interface Validator
IntrusionException
public boolean isValidCreditCard(String context, String input, boolean allowNull, ValidationErrorList errors) throws IntrusionException
isValidCreditCard
in interface Validator
IntrusionException
public String getValidCreditCard(String context, String input, boolean allowNull) throws ValidationException, IntrusionException
getValidCreditCard
in interface Validator
context
- 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.
ValidationException
IntrusionException
public String getValidCreditCard(String context, String input, boolean allowNull, ValidationErrorList errors) throws IntrusionException
getValidCreditCard
in interface Validator
IntrusionException
public 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 Validator
IntrusionException
public 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 Validator
IntrusionException
public String getValidDirectoryPath(String context, String input, File parent, boolean allowNull) throws ValidationException, IntrusionException
getValidDirectoryPath
in interface Validator
context
- 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.
ValidationException
IntrusionException
public String getValidDirectoryPath(String context, String input, File parent, boolean allowNull, ValidationErrorList errors) throws IntrusionException
getValidDirectoryPath
in interface Validator
IntrusionException
public boolean isValidFileName(String context, String input, boolean allowNull) throws IntrusionException
isValidFileName
in interface Validator
IntrusionException
public boolean isValidFileName(String context, String input, boolean allowNull, ValidationErrorList errors) throws IntrusionException
isValidFileName
in interface Validator
IntrusionException
public boolean isValidFileName(String context, String input, List<String> allowedExtensions, boolean allowNull) throws IntrusionException
isValidFileName
in interface Validator
IntrusionException
public boolean isValidFileName(String context, String input, List<String> allowedExtensions, boolean allowNull, ValidationErrorList errors) throws IntrusionException
isValidFileName
in interface Validator
IntrusionException
public String getValidFileName(String context, String input, List<String> allowedExtensions, boolean allowNull) throws ValidationException, IntrusionException
getValidFileName
in interface Validator
context
- 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.
ValidationException
IntrusionException
public String getValidFileName(String context, String input, List<String> allowedParameters, boolean allowNull, ValidationErrorList errors) throws IntrusionException
getValidFileName
in interface Validator
IntrusionException
public boolean isValidNumber(String context, String input, long minValue, long maxValue, boolean allowNull) throws IntrusionException
isValidNumber
in interface Validator
IntrusionException
public boolean isValidNumber(String context, String input, long minValue, long maxValue, boolean allowNull, ValidationErrorList errors) throws IntrusionException
isValidNumber
in interface Validator
IntrusionException
public Double getValidNumber(String context, String input, long minValue, long maxValue, boolean allowNull) throws ValidationException, IntrusionException
getValidNumber
in interface Validator
context
- 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.
ValidationException
IntrusionException
public Double getValidNumber(String context, String input, long minValue, long maxValue, boolean allowNull, ValidationErrorList errors) throws IntrusionException
getValidNumber
in interface Validator
IntrusionException
public boolean isValidDouble(String context, String input, double minValue, double maxValue, boolean allowNull) throws IntrusionException
isValidDouble
in interface Validator
IntrusionException
public boolean isValidDouble(String context, String input, double minValue, double maxValue, boolean allowNull, ValidationErrorList errors) throws IntrusionException
isValidDouble
in interface Validator
IntrusionException
public Double getValidDouble(String context, String input, double minValue, double maxValue, boolean allowNull) throws ValidationException, IntrusionException
getValidDouble
in interface Validator
context
- 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.
ValidationException
IntrusionException
public Double getValidDouble(String context, String input, double minValue, double maxValue, boolean allowNull, ValidationErrorList errors) throws IntrusionException
getValidDouble
in interface Validator
IntrusionException
public boolean isValidInteger(String context, String input, int minValue, int maxValue, boolean allowNull) throws IntrusionException
isValidInteger
in interface Validator
IntrusionException
public boolean isValidInteger(String context, String input, int minValue, int maxValue, boolean allowNull, ValidationErrorList errors) throws IntrusionException
isValidInteger
in interface Validator
IntrusionException
public Integer getValidInteger(String context, String input, int minValue, int maxValue, boolean allowNull) throws ValidationException, IntrusionException
getValidInteger
in interface Validator
context
- 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.
ValidationException
IntrusionException
public Integer getValidInteger(String context, String input, int minValue, int maxValue, boolean allowNull, ValidationErrorList errors) throws IntrusionException
getValidInteger
in interface Validator
IntrusionException
public boolean isValidFileContent(String context, byte[] input, int maxBytes, boolean allowNull) throws IntrusionException
isValidFileContent
in interface Validator
IntrusionException
public boolean isValidFileContent(String context, byte[] input, int maxBytes, boolean allowNull, ValidationErrorList errors) throws IntrusionException
isValidFileContent
in interface Validator
IntrusionException
public byte[] getValidFileContent(String context, byte[] input, int maxBytes, boolean allowNull) throws ValidationException, IntrusionException
getValidFileContent
in interface Validator
context
- 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.
ValidationException
IntrusionException
public byte[] getValidFileContent(String context, byte[] input, int maxBytes, boolean allowNull, ValidationErrorList errors) throws IntrusionException
getValidFileContent
in interface Validator
IntrusionException
public 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 Validator
IntrusionException
public 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 Validator
IntrusionException
public 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 Validator
context
- 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.
ValidationException
IntrusionException
public 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 Validator
IntrusionException
public boolean isValidListItem(String context, String input, List<String> list)
isValidListItem
in interface Validator
public boolean isValidListItem(String context, String input, List<String> list, ValidationErrorList errors)
isValidListItem
in interface Validator
public String getValidListItem(String context, String input, List<String> list) throws ValidationException, IntrusionException
getValidListItem
in interface Validator
context
- 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'.
ValidationException
IntrusionException
public String getValidListItem(String context, String input, List<String> list, ValidationErrorList errors) throws IntrusionException
getValidListItem
in interface Validator
errors
-
IntrusionException
public boolean isValidHTTPRequestParameterSet(String context, javax.servlet.http.HttpServletRequest request, Set<String> requiredNames, Set<String> optionalNames)
isValidHTTPRequestParameterSet
in interface Validator
public boolean isValidHTTPRequestParameterSet(String context, javax.servlet.http.HttpServletRequest request, Set<String> requiredNames, Set<String> optionalNames, ValidationErrorList errors)
isValidHTTPRequestParameterSet
in interface Validator
public void assertValidHTTPRequestParameterSet(String context, javax.servlet.http.HttpServletRequest request, Set<String> required, Set<String> optional) throws ValidationException, IntrusionException
assertValidHTTPRequestParameterSet
in interface Validator
context
- 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 request
ValidationException
IntrusionException
public void assertValidHTTPRequestParameterSet(String context, javax.servlet.http.HttpServletRequest request, Set<String> required, Set<String> optional, ValidationErrorList errors) throws IntrusionException
assertValidHTTPRequestParameterSet
in interface Validator
errors
-
IntrusionException
public boolean isValidPrintable(String context, char[] input, int maxLength, boolean allowNull) throws IntrusionException
isValidPrintable
in interface Validator
IntrusionException
public boolean isValidPrintable(String context, char[] input, int maxLength, boolean allowNull, ValidationErrorList errors) throws IntrusionException
isValidPrintable
in interface Validator
IntrusionException
public char[] getValidPrintable(String context, char[] input, int maxLength, boolean allowNull) throws ValidationException, IntrusionException
getValidPrintable
in interface Validator
context
- 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.
IntrusionException
ValidationException
public char[] getValidPrintable(String context, char[] input, int maxLength, boolean allowNull, ValidationErrorList errors) throws IntrusionException
getValidPrintable
in interface Validator
errors
-
IntrusionException
public boolean isValidPrintable(String context, String input, int maxLength, boolean allowNull) throws IntrusionException
isValidPrintable
in interface Validator
IntrusionException
public boolean isValidPrintable(String context, String input, int maxLength, boolean allowNull, ValidationErrorList errors) throws IntrusionException
isValidPrintable
in interface Validator
IntrusionException
public String getValidPrintable(String context, String input, int maxLength, boolean allowNull) throws ValidationException, IntrusionException
getValidPrintable
in interface Validator
context
- 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.
IntrusionException
ValidationException
public String getValidPrintable(String context, String input, int maxLength, boolean allowNull, ValidationErrorList errors) throws IntrusionException
getValidPrintable
in interface Validator
errors
-
IntrusionException
public boolean isValidRedirectLocation(String context, String input, boolean allowNull) throws IntrusionException
isValidRedirectLocation
in interface Validator
IntrusionException
public boolean isValidRedirectLocation(String context, String input, boolean allowNull, ValidationErrorList errors) throws IntrusionException
isValidRedirectLocation
in interface Validator
IntrusionException
public String getValidRedirectLocation(String context, String input, boolean allowNull) throws ValidationException, IntrusionException
getValidRedirectLocation
in interface Validator
context
- 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.
ValidationException
IntrusionException
public String getValidRedirectLocation(String context, String input, boolean allowNull, ValidationErrorList errors) throws IntrusionException
getValidRedirectLocation
in interface Validator
errors
-
IntrusionException
public String safeReadLine(InputStream in, int max) throws ValidationException
safeReadLine
in interface Validator
in
- max
-
ValidationException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |