use of org.springframework.security.access.SecurityConfig in project spring-security-oauth by spring-projects.
the class ScopeVoterTests method testExceptionThrownIfWrongScopesPresent.
@Test(expected = AccessDeniedException.class)
public void testExceptionThrownIfWrongScopesPresent() throws Exception {
OAuth2Request clientAuthentication = RequestTokenFactory.createOAuth2Request("foo", false, Collections.singleton("read"));
Authentication userAuthentication = null;
OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(clientAuthentication, userAuthentication);
assertEquals(AccessDecisionVoter.ACCESS_DENIED, voter.vote(oAuth2Authentication, null, Collections.<ConfigAttribute>singleton(new SecurityConfig("SCOPE_WRITE"))));
}
use of org.springframework.security.access.SecurityConfig in project spring-security-oauth by spring-projects.
the class ScopeVoterTests method testAccessDeniedIfWrongScopesPresent.
@Test
public void testAccessDeniedIfWrongScopesPresent() throws Exception {
OAuth2Request clientAuthentication = RequestTokenFactory.createOAuth2Request("foo", false, Collections.singleton("read"));
Authentication userAuthentication = null;
OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(clientAuthentication, userAuthentication);
voter.setThrowException(false);
assertEquals(AccessDecisionVoter.ACCESS_DENIED, voter.vote(oAuth2Authentication, null, Collections.<ConfigAttribute>singleton(new SecurityConfig("SCOPE_WRITE"))));
}
use of org.springframework.security.access.SecurityConfig in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method createConfigAttributes.
protected Collection<ConfigAttribute> createConfigAttributes(String action) {
Collection<ConfigAttribute> attrs = new ArrayList<ConfigAttribute>();
attrs.add(new SecurityConfig(action));
return attrs;
}
use of org.springframework.security.access.SecurityConfig in project spring-security by spring-projects.
the class ChannelSecurityConfigurer method addAttribute.
private ChannelRequestMatcherRegistry addAttribute(String attribute, List<? extends RequestMatcher> matchers) {
for (RequestMatcher matcher : matchers) {
Collection<ConfigAttribute> attrs = Arrays.<ConfigAttribute>asList(new SecurityConfig(attribute));
requestMap.put(matcher, attrs);
}
return REGISTRY;
}
use of org.springframework.security.access.SecurityConfig in project spring-security by spring-projects.
the class GlobalMethodSecurityBeanDefinitionParser method parseProtectPointcuts.
private Map<String, List<ConfigAttribute>> parseProtectPointcuts(ParserContext parserContext, List<Element> protectPointcutElts) {
Map<String, List<ConfigAttribute>> pointcutMap = new LinkedHashMap<String, List<ConfigAttribute>>();
for (Element childElt : protectPointcutElts) {
String accessConfig = childElt.getAttribute(ATT_ACCESS);
String expression = childElt.getAttribute(ATT_EXPRESSION);
if (!StringUtils.hasText(accessConfig)) {
parserContext.getReaderContext().error("Access configuration required", parserContext.extractSource(childElt));
}
if (!StringUtils.hasText(expression)) {
parserContext.getReaderContext().error("Pointcut expression required", parserContext.extractSource(childElt));
}
String[] attributeTokens = StringUtils.commaDelimitedListToStringArray(accessConfig);
List<ConfigAttribute> attributes = new ArrayList<ConfigAttribute>(attributeTokens.length);
for (String token : attributeTokens) {
attributes.add(new SecurityConfig(token));
}
pointcutMap.put(expression, attributes);
}
return pointcutMap;
}
Aggregations