mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-12 13:23:29 +00:00
SEC-693: RoleVoter can improve performance
http://jira.springframework.org/browse/SEC-693
This commit is contained in:
parent
5ec8aa797c
commit
89415e3ee5
@ -20,6 +20,7 @@ import java.util.Iterator;
|
|||||||
import org.springframework.security.Authentication;
|
import org.springframework.security.Authentication;
|
||||||
import org.springframework.security.ConfigAttribute;
|
import org.springframework.security.ConfigAttribute;
|
||||||
import org.springframework.security.ConfigAttributeDefinition;
|
import org.springframework.security.ConfigAttributeDefinition;
|
||||||
|
import org.springframework.security.GrantedAuthority;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Votes if any {@link ConfigAttribute#getAttribute()} starts with a prefix
|
* Votes if any {@link ConfigAttribute#getAttribute()} starts with a prefix
|
||||||
@ -101,9 +102,10 @@ public class RoleVoter implements AccessDecisionVoter {
|
|||||||
if (this.supports(attribute)) {
|
if (this.supports(attribute)) {
|
||||||
result = ACCESS_DENIED;
|
result = ACCESS_DENIED;
|
||||||
|
|
||||||
|
GrantedAuthority[] authorities = authentication.getAuthorities();
|
||||||
// Attempt to find a matching granted authority
|
// Attempt to find a matching granted authority
|
||||||
for (int i = 0; i < authentication.getAuthorities().length; i++) {
|
for (int i = 0; i < authorities.length; i++) {
|
||||||
if (attribute.getAttribute().equals(authentication.getAuthorities()[i].getAuthority())) {
|
if (attribute.getAttribute().equals(authorities[i].getAuthority())) {
|
||||||
return ACCESS_GRANTED;
|
return ACCESS_GRANTED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user