Refactor spring security layer to work with a database