private Filter ssoFilter() { CompositeFilter filter = new CompositeFilter(); List<Filter> filters = new ArrayList<>(); OAuth2ClientAuthenticationProcessingFilter facebookFilter = new OAuth2ClientAuthenticationProcessingFilter("/login/facebook"); OAuth2RestTemplate facebookTemplate = new OAuth2RestTemplate(facebook(), oAuth2ClientContext); facebookFilter.setRestTemplate(facebookTemplate); facebookFilter.setTokenServices(new UserInfoTokenServices(facebookResource().getUserInfoUri(), facebook().getClientId())); filters.add(facebookFilter); OAuth2ClientAuthenticationProcessingFilter googleFilter = new OAuth2ClientAuthenticationProcessingFilter("/login/google"); OAuth2RestTemplate googleTemplate = new OAuth2RestTemplate(google(), oAuth2ClientContext); googleFilter.setRestTemplate(googleTemplate); googleFilter.setTokenServices(new UserInfoTokenServices(googleResource().getUserInfoUri(), google().getClientId())); filters.add(googleFilter); filter.setFilters(filters); return filter; }
private Filter ssoFilter() { CompositeFilter filter = new CompositeFilter(); List<Filter> filters = new ArrayList<>(); ClientResources github = github(); filters.add(ssoFilter(github, "/login/github", new OAuth2RestTemplate(github.getClient(), oauth2ClientContext))); ClientResources sina = sina(); filters.add(sinaSsoFilter(sina, new OAuth2RestTemplate(sina.getClient(), oauth2ClientContext))); filters.add(qqSsoFilter(qq())); filter.setFilters(filters); return filter; }
@Bean public Filter ssoFilter() { CompositeFilter filter = new CompositeFilter(); List<Filter> filters = new ArrayList<>(); filters.add(ssoFilter(wechat(), "/login/wechat")); filter.setFilters(filters); return filter; }
@Override protected final void configure(HttpSecurity http) throws Exception { //@formatter:off http .antMatcher("/**") .authorizeRequests() .antMatchers(SSO_LOGIN_PATH + "/**", "/webjars/**", "/index.html", "/epam/**", "/info", "/health", "/api-docs/**") .permitAll() .anyRequest() .authenticated() .and().csrf().disable() .sessionManagement() .sessionCreationPolicy(SessionCreationPolicy.STATELESS); CompositeFilter authCompositeFilter = new CompositeFilter(); List<OAuth2ClientAuthenticationProcessingFilter> additionalFilters = ImmutableList.<OAuth2ClientAuthenticationProcessingFilter>builder() .addAll(getDefaultFilters(oauth2ClientContext)) .addAll(getAdditionalFilters(oauth2ClientContext)).build(); /* make sure filters have correct exception handler */ additionalFilters.forEach(filter -> filter.setAuthenticationFailureHandler(OAUTH_ERROR_HANDLER)); authCompositeFilter.setFilters(additionalFilters); //install additional OAuth Authentication filters http.addFilterAfter(authCompositeFilter, BasicAuthenticationFilter.class); //@formatter:on }
private Filter ssoFilter() { CompositeFilter filter = new CompositeFilter(); filter.setFilters(new ArrayList<Filter>() { { add(ssoFilter("google", google())); add(ssoFilter("github", github())); } }); return filter; }
private Filter ssoFilter() { CompositeFilter filter = new CompositeFilter(); List<Filter> filters = new ArrayList<Filter>(); filters.add(this.ssoFilter(facebook(), "/login/facebook")); filters.add(this.ssoFilter(github(), "/login/github")); filter.setFilters(filters); return filter; }
private Filter ssoFilter() { CompositeFilter filter = new CompositeFilter(); List<Filter> filters = new ArrayList<>(); filters.add(this.ssoFilter(this.facebook(), "/login/facebook", OAuthSource.Facebook)); filters.add(this.ssoFilter(this.github(), "/login/github", OAuthSource.GitHub)); filters.add(this.ssoFilter(this.microsoft(), "/login/microsoft", OAuthSource.Microsoft)); filter.setFilters(filters); return filter; }
/** * Create custom SSO Filter for oauth providers, like GitHub. * * @return Filter {@link Filter} */ private Filter ssoFilter() { final CompositeFilter filter = new CompositeFilter(); final List<Filter> filters = new ArrayList<>(); filters.add(customSSOFilter(github(), "/login/github")); filter.setFilters(filters); return filter; }
@Bean public Filter ssoFilters() { CompositeFilter filter = new CompositeFilter(); List<Filter> filters = Lists.newArrayList(); filters.add(ssoFilter(facebook(), "/login/facebook", "Facebook")); filters.add(ssoFilter(github(), "/login/github", "GitHub")); filter.setFilters(filters); return filter; }
private Filter createOAuth2Filter() { CompositeFilter filter = new CompositeFilter(); filter.setFilters(Arrays.asList( createOAuth2Filter(facebook(), facebookSuccessHandler(), "/login/facebook"), createOAuth2Filter(google(), googleSuccessHandler(), "/login/google")) ); return filter; }
private Filter ssoFilter() { CompositeFilter filter = new CompositeFilter(); List<Filter> filters = new ArrayList<>(); filters.add(ssoFilter(facebook(), "/login/facebook")); filters.add(ssoFilter(github(), "/login/github")); filters.add(ssoFilter(google(), "/login/google")); filter.setFilters(filters); return filter; }
private Filter ssoFilter() { CompositeFilter filter = new CompositeFilter(); List<Filter> filters = new ArrayList<>(); filters.add(ssoFilter(github(), "/login/github")); filter.setFilters(filters); return filter; }
@Test public void testProfileServlet() throws Exception { Filter filter = new CompositeFilter(); final CallStackElement total = Profiler.activateProfiling("total"); filter.doFilter(new MockHttpServletRequest(), new MockHttpServletResponse(), new MockFilterChain()); Profiler.stop(); final CallStackElement serviceCall = total.getChildren().iterator().next(); assertEquals("CompositeFilter#doFilter", serviceCall.getShortSignature()); }