mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-28 06:42:49 +00:00
SEC-999: Fix broken test which was failing due to use of incorrect authentication object.
This commit is contained in:
parent
56141e9c5f
commit
a207acf7cb
@ -4,6 +4,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
import org.springframework.security.Authentication;
|
import org.springframework.security.Authentication;
|
||||||
import org.springframework.security.AuthenticationTrustResolver;
|
import org.springframework.security.AuthenticationTrustResolver;
|
||||||
|
import org.springframework.security.GrantedAuthority;
|
||||||
import org.springframework.security.util.AuthorityUtils;
|
import org.springframework.security.util.AuthorityUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,7 +42,13 @@ public class SecurityExpressionRoot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final boolean hasRole(String role) {
|
public final boolean hasRole(String role) {
|
||||||
return AuthorityUtils.userHasAuthority(role);
|
for (GrantedAuthority authority : authentication.getAuthorities()) {
|
||||||
|
if (role.equals(authority.getAuthority())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean hasAnyRole(String... roles) {
|
public final boolean hasAnyRole(String... roles) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user