Polish PrincipalSid

Remove reduntant UserDetails check and add tests
This commit is contained in:
Eleftheria Stein
2019-11-22 09:37:32 +01:00
parent ea148d5fee
commit c5b36664ce
2 changed files with 67 additions and 7 deletions

View File

@@ -17,7 +17,6 @@ package org.springframework.security.acls.domain;
import org.springframework.security.acls.model.Sid;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.util.Assert;
@@ -49,12 +48,7 @@ public class PrincipalSid implements Sid {
Assert.notNull(authentication, "Authentication required");
Assert.notNull(authentication.getPrincipal(), "Principal required");
if (authentication.getPrincipal() instanceof UserDetails) {
this.principal = ((UserDetails) authentication.getPrincipal()).getUsername();
}
else {
this.principal = authentication.getName();
}
this.principal = authentication.getName();
}
// ~ Methods