Skip to content

Instantly share code, notes, and snippets.

@cemo
Created July 19, 2013 19:44
Show Gist options
  • Select an option

  • Save cemo/6041868 to your computer and use it in GitHub Desktop.

Select an option

Save cemo/6041868 to your computer and use it in GitHub Desktop.
org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper#getUserPrincipal
old:
public Principal getUserPrincipal() {
Authentication auth = getAuthentication();
if ((auth == null) || (auth.getPrincipal() == null)) {
return null;
}
return auth;
}
new:
public Principal getUserPrincipal() {
Authentication auth = getAuthentication();
if ((auth == null) || (auth.getPrincipal() == null)) {
return null;
}
Object principal = auth.getPrincipal();
return principal instanceof Principal ? (Principal)principal : auth;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment