From the course: Secure Coding in Java

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Input validation

Input validation - Java Tutorial

From the course: Secure Coding in Java

Start my 1-month free trial

Input validation

- [Instructor] Now, we've talked a little bit about this topic already, but I want to spend a bit more time talking about this because many security risks can be avoided by simple input validation. We're talking about a couple of different strategies. Now, there are a few general thoughts about validation that can be applied to Java applications. First and foremost, your validation logic in Java should be reusable if at all possible. Embedded input validation in each method is messy, repetitive, and quite frankly, error prone, so consolidating it and reusing it is definitely your best bet. In a similar vein, the validation logic should be clean and easy to read. Obviously, this is subjective, but validation must be understandable by your entire team. Part of the desire with validation logic, especially from a reusability perspective, is to have consistent error messages. Utilizing validation exceptions, and doing so in…

Contents