|
@@ -26,6 +26,7 @@ import org.springframework.security.core.GrantedAuthority;
|
|
|
import org.springframework.security.core.CredentialsContainer;
|
|
|
import org.springframework.security.core.AuthenticatedPrincipal;
|
|
|
import org.springframework.security.core.authority.AuthorityUtils;
|
|
|
+import org.springframework.security.core.userdetails.UserDetails;
|
|
|
|
|
|
/**
|
|
|
* Base class for <code>Authentication</code> objects.
|
|
@@ -79,12 +80,14 @@ public abstract class AbstractAuthenticationToken implements Authentication,
|
|
|
}
|
|
|
|
|
|
public String getName() {
|
|
|
+ if (this.getPrincipal() instanceof UserDetails) {
|
|
|
+ return ((UserDetails) this.getPrincipal()).getUsername();
|
|
|
+ }
|
|
|
if (this.getPrincipal() instanceof AuthenticatedPrincipal) {
|
|
|
return ((AuthenticatedPrincipal) this.getPrincipal()).getName();
|
|
|
}
|
|
|
-
|
|
|
- if (getPrincipal() instanceof Principal) {
|
|
|
- return ((Principal) getPrincipal()).getName();
|
|
|
+ if (this.getPrincipal() instanceof Principal) {
|
|
|
+ return ((Principal) this.getPrincipal()).getName();
|
|
|
}
|
|
|
|
|
|
return (this.getPrincipal() == null) ? "" : this.getPrincipal().toString();
|