*/
public int vote(Authentication authentication, Object object, Collection<ConfigAttribute> configAttributes) {
int result = ACCESS_ABSTAIN;
if (authentication.getDetails() instanceof OAuthAuthenticationDetails) {
OAuthAuthenticationDetails details = (OAuthAuthenticationDetails) authentication.getDetails();
for (Object configAttribute : configAttributes) {
ConfigAttribute attribute = (ConfigAttribute) configAttribute;
if (ConsumerSecurityConfig.PERMIT_ALL_ATTRIBUTE.equals(attribute)) {
return ACCESS_GRANTED;
}
else if (ConsumerSecurityConfig.DENY_ALL_ATTRIBUTE.equals(attribute)) {
return ACCESS_DENIED;
}
else if (supports(attribute)) {
ConsumerSecurityConfig config = (ConsumerSecurityConfig) attribute;
if ((config.getSecurityType() == ConsumerSecurityConfig.ConsumerSecurityType.CONSUMER_KEY)
&& (config.getAttribute().equals(details.getConsumerDetails().getConsumerKey()))) {
return ACCESS_GRANTED;
}
else if (config.getSecurityType() == ConsumerSecurityConfig.ConsumerSecurityType.CONSUMER_ROLE) {
List<GrantedAuthority> authorities = details.getConsumerDetails().getAuthorities();
if (authorities != null) {
for (GrantedAuthority authority : authorities) {
if (authority.getAuthority().equals(config.getAttribute())) {
return ACCESS_GRANTED;
}