SEC-721: Call Principal.getName() in AbstractAuthenticationToken.getName() if principal instaceof Principal
This commit is contained in:
parent
2df2eaa169
commit
163fb1052f
|
@ -15,6 +15,8 @@
|
|||
|
||||
package org.springframework.security.providers;
|
||||
|
||||
import java.security.Principal;
|
||||
|
||||
import org.springframework.security.Authentication;
|
||||
import org.springframework.security.GrantedAuthority;
|
||||
import org.springframework.security.userdetails.UserDetails;
|
||||
|
@ -144,6 +146,10 @@ public abstract class AbstractAuthenticationToken implements Authentication {
|
|||
if (this.getPrincipal() instanceof UserDetails) {
|
||||
return ((UserDetails) this.getPrincipal()).getUsername();
|
||||
}
|
||||
|
||||
if (getPrincipal() instanceof Principal) {
|
||||
return ((Principal)getPrincipal()).getName();
|
||||
}
|
||||
|
||||
return (this.getPrincipal() == null) ? "" : this.getPrincipal().toString();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue