SEC-721: Call Principal.getName() in AbstractAuthenticationToken.getName() if principal instaceof Principal

This commit is contained in:
Luke Taylor 2008-03-18 18:06:56 +00:00
parent 2df2eaa169
commit 163fb1052f
1 changed files with 6 additions and 0 deletions

View File

@ -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();
}