Refactoring for spring security