TRUNK-13: Move business logic for authentication into service layer