Refactoring before Spring-security