use of org.springframework.security.access.SecurityConfig in project spring-security by spring-projects.
the class SecureChannelProcessorTests method testSupports.
@Test
public void testSupports() {
SecureChannelProcessor processor = new SecureChannelProcessor();
assertThat(processor.supports(new SecurityConfig("REQUIRES_SECURE_CHANNEL"))).isTrue();
assertThat(processor.supports(null)).isFalse();
assertThat(processor.supports(new SecurityConfig("NOT_SUPPORTED"))).isFalse();
}
use of org.springframework.security.access.SecurityConfig in project spring-security by spring-projects.
the class ChannelDecisionManagerImplTests method testDelegatesSupports.
@Test
public void testDelegatesSupports() throws Exception {
ChannelDecisionManagerImpl cdm = new ChannelDecisionManagerImpl();
MockChannelProcessor cpXyz = new MockChannelProcessor("xyz", false);
MockChannelProcessor cpAbc = new MockChannelProcessor("abc", false);
List list = new Vector();
list.add(cpXyz);
list.add(cpAbc);
cdm.setChannelProcessors(list);
cdm.afterPropertiesSet();
assertThat(cdm.supports(new SecurityConfig("xyz"))).isTrue();
assertThat(cdm.supports(new SecurityConfig("abc"))).isTrue();
assertThat(cdm.supports(new SecurityConfig("UNSUPPORTED"))).isFalse();
}
use of org.springframework.security.access.SecurityConfig in project spring-security-oauth by spring-projects.
the class ClientScopeVoterTests method testAccessDeniedNoException.
@Test
public void testAccessDeniedNoException() {
voter.setThrowException(false);
client.setScope(Arrays.asList("none"));
assertEquals(AccessDecisionVoter.ACCESS_DENIED, voter.vote(authentication, null, Arrays.<ConfigAttribute>asList(new SecurityConfig("CLIENT_HAS_SCOPE"))));
}
use of org.springframework.security.access.SecurityConfig in project spring-security-oauth by spring-projects.
the class ScopeVoterTests method testAccessGrantedIfScopesPresent.
@Test
public void testAccessGrantedIfScopesPresent() throws Exception {
OAuth2Request clientAuthentication = RequestTokenFactory.createOAuth2Request("foo", false, Collections.singleton("read"));
Authentication userAuthentication = null;
OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(clientAuthentication, userAuthentication);
assertEquals(AccessDecisionVoter.ACCESS_GRANTED, voter.vote(oAuth2Authentication, null, Collections.<ConfigAttribute>singleton(new SecurityConfig("SCOPE_READ"))));
}
use of org.springframework.security.access.SecurityConfig in project spring-security-oauth by spring-projects.
the class ScopeVoterTests method testAccessGrantedIfScopesPresentWithPrefix.
@Test
public void testAccessGrantedIfScopesPresentWithPrefix() throws Exception {
voter.setScopePrefix("scope=");
OAuth2Request clientAuthentication = RequestTokenFactory.createOAuth2Request("foo", false, Collections.singleton("read"));
Authentication userAuthentication = null;
OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(clientAuthentication, userAuthentication);
assertEquals(AccessDecisionVoter.ACCESS_GRANTED, voter.vote(oAuth2Authentication, null, Collections.<ConfigAttribute>singleton(new SecurityConfig("scope=read"))));
}
Aggregations