From the course: Secure Coding in Java
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Input validation - Java Tutorial
From the course: Secure Coding in Java
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.