Refactoring authentication handling to work with new servlet engine architecture