Use getAuthenticatedUsername method instead to avoid possible NPE.