code from Spring Security 3.1 Packt book