I've looked at various frameworks for input validations, including Hibernate Validator impl for JSR 303 bean validations, as well as ESAPI validator interface and its DefaultValidator implementation.
ESAPI input validation revolves around regex pattern matching through ESAPI.properties file.
ESAPI Route:
ESAPI.properties:
Validator.SafeString=[A-Za-z0-9]{0,1024}$
Java class:
ESAPI.validator().isValidInput("Name","darthvader", "SafeString", 255, false)
Hibernate Validator/Spring MVC Route
Hibernate involves annotating your bean with various constraint annotations (@NotNull, @Size, @Min, @Pattern, @Valid etc). And integrating Spring MVC for validations rules.
@RequestMapping(value = "/appointments", method = RequestMethod.POST)
public String add(@Valid User user, BindingResult result) {
....
}
It seems like using Hibernate Validator/Spring MVC provide similar functionality with regex matching etc. Are there any advantages of using ESAPI library over Hibernate validator api? Maybe for SQL injections/XSS or anything of that nature? Security against XSS/SQL injection provided out of box for ESAPI input validation framework? Any real advantages over using one or the other. Thanks in advance.
Answer to my own question: I think I came to my own solution for the post. Using Hibernate/Spring MVC allows pretty robust bean validation functionality. And Hibernate provides secure annotations such as @SafeHtml, @Pattern, etc. Basically we can set a composite set of annotations that provide the bean validation. http://docs.jboss.org/hibernate/validator/5.0/reference/en-US/html_single/