I agree with the other answers that there is no silver bullet for security or a simple structure that you just plug in, and tada, you enable security. Browse the OWASP site, which is an excellent resource for learning security.
And a complete understanding of security (rather than security delegation for frameworks) will ultimately make your application more secure. For example, JSF prevents most (if not all?) Attacks of the XSS type by default, but you can override this function, perhaps without realizing the security implications, and suddenly your JSF code opens.
Since no one mentioned this, static code analysis can help. Check out things like Findbugs, PMD, and checkstyle among others for easy and free code analysis. Or go to something more difficult, like Fortify , which is designed specifically to detect security vulnerabilities in your application.
source share