Java Code Examples for org.springframework.security.web.FilterChainProxy#getFilterChains()

The following examples show how to use org.springframework.security.web.FilterChainProxy#getFilterChains() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OAuth2Configuration.java    From okta-jhipster-microservices-oauth-example with Apache License 2.0 6 votes vote down vote up
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
    if (bean instanceof FilterChainProxy) {

        FilterChainProxy chains = (FilterChainProxy) bean;

        for (SecurityFilterChain chain : chains.getFilterChains()) {
            for (Filter filter : chain.getFilters()) {
                if (filter instanceof OAuth2ClientAuthenticationProcessingFilter) {
                    OAuth2ClientAuthenticationProcessingFilter oAuth2ClientAuthenticationProcessingFilter =
                        (OAuth2ClientAuthenticationProcessingFilter) filter;
                    oAuth2ClientAuthenticationProcessingFilter
                        .setAuthenticationSuccessHandler(new OAuth2AuthenticationSuccessHandler());
                }
            }
        }
    }
    return bean;
}
 
Example 2
Source File: MainController.java    From tutorials with MIT License 5 votes vote down vote up
@RequestMapping(method = RequestMethod.GET, value = "/filters")
@ResponseBody
public void getFilters() {
    FilterChainProxy filterChainProxy = (FilterChainProxy) springSecurityFilterChain;
    List<SecurityFilterChain> list = filterChainProxy.getFilterChains();
    list.stream()
          .flatMap(chain -> chain.getFilters().stream())
          .forEach(filter -> System.out.println(filter.getClass()));
}