use of org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter in project spring-security-oauth by spring-projects.
the class ResourceServerBeanDefinitionParserTests method testAuthenticationManager.
@Test
public void testAuthenticationManager() {
GenericXmlApplicationContext context = new GenericXmlApplicationContext(getClass(), "resource-server-authmanager-context.xml");
// System.err.println(Arrays.asList(context.getBeanDefinitionNames()));
assertTrue(context.containsBeanDefinition("oauth2ProviderFilter"));
OAuth2AuthenticationProcessingFilter filter = context.getBean(OAuth2AuthenticationProcessingFilter.class);
assertEquals(context.getBean(AuthenticationManager.class), ReflectionTestUtils.getField(filter, "authenticationManager"));
assertNotNull(ReflectionTestUtils.getField(filter, "tokenExtractor"));
context.close();
}
use of org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter in project spring-security-oauth by spring-projects.
the class ResourceServerSecurityConfigurer method configure.
@Override
public void configure(HttpSecurity http) throws Exception {
AuthenticationManager oauthAuthenticationManager = oauthAuthenticationManager(http);
resourcesServerFilter = new OAuth2AuthenticationProcessingFilter();
resourcesServerFilter.setAuthenticationEntryPoint(authenticationEntryPoint);
resourcesServerFilter.setAuthenticationManager(oauthAuthenticationManager);
if (eventPublisher != null) {
resourcesServerFilter.setAuthenticationEventPublisher(eventPublisher);
}
if (tokenExtractor != null) {
resourcesServerFilter.setTokenExtractor(tokenExtractor);
}
resourcesServerFilter = postProcess(resourcesServerFilter);
resourcesServerFilter.setStateless(stateless);
// @formatter:off
http.authorizeRequests().expressionHandler(expressionHandler).and().addFilterBefore(resourcesServerFilter, AbstractPreAuthenticatedProcessingFilter.class).exceptionHandling().accessDeniedHandler(accessDeniedHandler).authenticationEntryPoint(authenticationEntryPoint);
// @formatter:on
}
Aggregations