refactored and simplified SecurityContext and Authenticator logic