当前位置: 首页>>代码示例>>Java>>正文


Java OAuth2ClientAuthenticationProcessingFilter类代码示例

本文整理汇总了Java中org.springframework.security.oauth2.client.filter.OAuth2ClientAuthenticationProcessingFilter的典型用法代码示例。如果您正苦于以下问题:Java OAuth2ClientAuthenticationProcessingFilter类的具体用法?Java OAuth2ClientAuthenticationProcessingFilter怎么用?Java OAuth2ClientAuthenticationProcessingFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


OAuth2ClientAuthenticationProcessingFilter类属于org.springframework.security.oauth2.client.filter包,在下文中一共展示了OAuth2ClientAuthenticationProcessingFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: general

import org.springframework.security.oauth2.client.filter.OAuth2ClientAuthenticationProcessingFilter; //导入依赖的package包/类
public static Filter general(AuthorizationCodeResourceDetails client, ResourceServerProperties resourceServerProperties, String path, OAuth2ClientContext oauth2ClientContext) {
	OAuth2ClientAuthenticationProcessingFilter oAuth2ClientAuthenticationFilter = new OAuth2ClientAuthenticationProcessingFilter(path){
		protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response,
		                                        FilterChain chain, Authentication authResult) throws IOException, ServletException {
			super.successfulAuthentication(request, response, chain, authResult);
			OAuth2AccessToken accessToken = restTemplate.getAccessToken();
			log.warn(new Gson().toJson(authResult));
			log.warn(new Gson().toJson(accessToken));
		}
	};
	OAuth2RestTemplate oAuth2RestTemplate = new OAuth2RestTemplate(client, oauth2ClientContext);
	oAuth2ClientAuthenticationFilter.setRestTemplate(oAuth2RestTemplate);
	UserInfoTokenServices tokenServices = new UserInfoTokenServices(resourceServerProperties.getUserInfoUri(), client.getClientId());
	tokenServices.setRestTemplate(oAuth2RestTemplate);
	oAuth2ClientAuthenticationFilter.setTokenServices(tokenServices);
	return oAuth2ClientAuthenticationFilter;
}
 
开发者ID:DataAgg,项目名称:DAFramework,代码行数:18,代码来源:OAuth2Util.java

示例2: configure

import org.springframework.security.oauth2.client.filter.OAuth2ClientAuthenticationProcessingFilter; //导入依赖的package包/类
@Override
public void configure(HttpSecurity builder) throws Exception {
	OAuth2ClientAuthenticationProcessingFilter ssoFilter = this.filter;
	ssoFilter.setSessionAuthenticationStrategy(
			builder.getSharedObject(SessionAuthenticationStrategy.class));
	builder.addFilterAfter(ssoFilter,
			AbstractPreAuthenticatedProcessingFilter.class);
}
 
开发者ID:spring-projects,项目名称:spring-security-oauth2-boot,代码行数:9,代码来源:SsoSecurityConfigurer.java

示例3: ssoFilter

import org.springframework.security.oauth2.client.filter.OAuth2ClientAuthenticationProcessingFilter; //导入依赖的package包/类
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;
}
 
开发者ID:scionaltera,项目名称:emergentmud,代码行数:20,代码来源:SecurityConfiguration.java

示例4: wechat

import org.springframework.security.oauth2.client.filter.OAuth2ClientAuthenticationProcessingFilter; //导入依赖的package包/类
public static Filter wechat(AuthorizationCodeResourceDetails client, ResourceServerProperties resourceServerProperties, String path, OAuth2ClientContext oauth2ClientContext) {
	OAuth2ClientAuthenticationProcessingFilter oAuth2ClientAuthenticationFilter = new OAuth2ClientAuthenticationProcessingFilter(path);

	OAuth2RestTemplate oAuth2RestTemplate = new OAuth2RestTemplate(client, oauth2ClientContext);
	AuthorizationCodeAccessTokenProvider accessTokenProvider = new AuthorizationCodeAccessTokenProvider();
	accessTokenProvider.setAuthorizationRequestEnhancer((request, resource, form, headers) -> {
		form.set("appid", resource.getClientId());
		form.set("secret", resource.getClientSecret());
		form.set("scope", "snsapi_userinfo");
		form.set("response_type", "code");
		form.set("#wechat_redirect", "");
	});
	accessTokenProvider.setMessageConverters(converters());
	oAuth2RestTemplate.setAccessTokenProvider(accessTokenProvider);

	oAuth2RestTemplate.setRetryBadAccessTokens(true);
	oAuth2ClientAuthenticationFilter.setRestTemplate(oAuth2RestTemplate);

	UserInfoTokenServices tokenServices = new UserInfoTokenServices(resourceServerProperties.getUserInfoUri(), client.getClientId());
	tokenServices.setRestTemplate(oAuth2RestTemplate);
	oAuth2ClientAuthenticationFilter.setTokenServices(tokenServices);
	return oAuth2ClientAuthenticationFilter;
}
 
开发者ID:DataAgg,项目名称:DAFramework,代码行数:24,代码来源:OAuth2Util.java

示例5: ssoFilter

import org.springframework.security.oauth2.client.filter.OAuth2ClientAuthenticationProcessingFilter; //导入依赖的package包/类
private Filter ssoFilter(final String path) {
    final OAuth2ClientAuthenticationProcessingFilter oAuth2ClientAuthenticationFilter = new OAuth2ClientAuthenticationProcessingFilter(
            path);
    final SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
    oAuth2ClientAuthenticationFilter.setAuthenticationSuccessHandler(successHandler);
    successHandler.setAlwaysUseDefaultTargetUrl(true);
    successHandler.setDefaultTargetUrl("/UI");
    final OAuth2RestTemplate oAuth2RestTemplate = new OAuth2RestTemplate(uaaClientResources.getClient(),
            oauth2ClientContext);
    oAuth2ClientAuthenticationFilter.setRestTemplate(oAuth2RestTemplate);
    final UserPrincipalInfoTokenServices tokenServices = new UserPrincipalInfoTokenServices(
            uaaClientResources.getResource().getUserInfoUri(), uaaClientResources.getClient().getClientId(),
            oauth2ClientContext);
    tokenServices.setRestTemplate(oAuth2RestTemplate);
    tokenServices.setAuthoritiesExtractor(tokenServices);
    oAuth2ClientAuthenticationFilter.setTokenServices(tokenServices);
    return oAuth2ClientAuthenticationFilter;
}
 
开发者ID:eclipse,项目名称:hawkbit-extensions,代码行数:19,代码来源:UaaOAuthAutoConfiguration.java

示例6: postProcessAfterInitialization

import org.springframework.security.oauth2.client.filter.OAuth2ClientAuthenticationProcessingFilter; //导入依赖的package包/类
@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;
}
 
开发者ID:jhipster,项目名称:generator-jhipster,代码行数:20,代码来源:_OAuth2Configuration.java

示例7: oauth2SsoFilter

import org.springframework.security.oauth2.client.filter.OAuth2ClientAuthenticationProcessingFilter; //导入依赖的package包/类
private OAuth2ClientAuthenticationProcessingFilter oauth2SsoFilter(
		OAuth2SsoProperties sso) {
	OAuth2RestOperations restTemplate = this.applicationContext
			.getBean(UserInfoRestTemplateFactory.class).getUserInfoRestTemplate();
	ResourceServerTokenServices tokenServices = this.applicationContext
			.getBean(ResourceServerTokenServices.class);
	OAuth2ClientAuthenticationProcessingFilter filter = new OAuth2ClientAuthenticationProcessingFilter(
			sso.getLoginPath());
	filter.setRestTemplate(restTemplate);
	filter.setTokenServices(tokenServices);
	filter.setApplicationEventPublisher(this.applicationContext);
	return filter;
}
 
开发者ID:spring-projects,项目名称:spring-security-oauth2-boot,代码行数:14,代码来源:SsoSecurityConfigurer.java

示例8: ssoFilter

import org.springframework.security.oauth2.client.filter.OAuth2ClientAuthenticationProcessingFilter; //导入依赖的package包/类
private Filter ssoFilter() {
    OAuth2ClientAuthenticationProcessingFilter facebookFilter = new OAuth2ClientAuthenticationProcessingFilter("/login");
    OAuth2RestTemplate facebookTemplate = new OAuth2RestTemplate(facebook(), oauth2ClientContext);
    facebookFilter.setRestTemplate(facebookTemplate);
    UserInfoTokenServices tokenServices = new UserInfoTokenServices(facebookResource().getUserInfoUri(), facebook().getClientId());
    tokenServices.setRestTemplate(facebookTemplate);
    facebookFilter.setTokenServices(tokenServices);
    SavedRequestAwareAuthenticationSuccessHandler authenticationSuccessHandler = new SavedRequestAwareAuthenticationSuccessHandler();
    authenticationSuccessHandler.setUseReferer(true);
    authenticationSuccessHandler.setTargetUrlParameter("continue");
    facebookFilter.setAuthenticationSuccessHandler(authenticationSuccessHandler);
    return facebookFilter;
}
 
开发者ID:Microsoft,项目名称:movie-db-java-on-azure,代码行数:14,代码来源:SecurityConfig.java

示例9: ssoFilter

import org.springframework.security.oauth2.client.filter.OAuth2ClientAuthenticationProcessingFilter; //导入依赖的package包/类
private Filter ssoFilter(ClientResources client, String path, OAuth2RestTemplate oAuth2RestTemplate) {
    OAuth2ClientAuthenticationProcessingFilter oAuth2ClientAuthenticationFilter = new OAuth2ClientAuthenticationProcessingFilter(path);
    oAuth2ClientAuthenticationFilter.setRestTemplate(oAuth2RestTemplate);

    GitHubUserInfoTokenServices tokenServices = new GitHubUserInfoTokenServices(client.getResource().getUserInfoUri(), client.getClient().getClientId());
    tokenServices.setRestTemplate(oAuth2RestTemplate);
    tokenServices.setUserService(userService);
    oAuth2ClientAuthenticationFilter.setTokenServices(tokenServices);

    return oAuth2ClientAuthenticationFilter;
}
 
开发者ID:helloworldtang,项目名称:sns-todo,代码行数:12,代码来源:FormLoginSecurityConfig.java

示例10: qqSsoFilter

import org.springframework.security.oauth2.client.filter.OAuth2ClientAuthenticationProcessingFilter; //导入依赖的package包/类
private Filter qqSsoFilter(ClientResources client) {
    QQOAuth2RestTemplate oAuth2RestTemplate = new QQOAuth2RestTemplate(client.getClient(), oauth2ClientContext);

    OAuth2ClientAuthenticationProcessingFilter oAuth2ClientAuthenticationFilter = new OAuth2ClientAuthenticationProcessingFilter("/login/qq");
    oAuth2ClientAuthenticationFilter.setRestTemplate(oAuth2RestTemplate);

    QQUserInfoTokenServices tokenServices = new QQUserInfoTokenServices(client.getResource().getUserInfoUri(), client.getClient().getClientId());
    tokenServices.setUserService(userService);
    tokenServices.setRestTemplate(oAuth2RestTemplate);
    oAuth2ClientAuthenticationFilter.setTokenServices(tokenServices);
    return oAuth2ClientAuthenticationFilter;
}
 
开发者ID:helloworldtang,项目名称:sns-todo,代码行数:13,代码来源:FormLoginSecurityConfig.java

示例11: sinaSsoFilter

import org.springframework.security.oauth2.client.filter.OAuth2ClientAuthenticationProcessingFilter; //导入依赖的package包/类
private Filter sinaSsoFilter(ClientResources client, OAuth2RestTemplate oAuth2RestTemplate) {

        OAuth2ClientAuthenticationProcessingFilter oAuth2ClientAuthenticationFilter = new OAuth2ClientAuthenticationProcessingFilter("/login/sina");
        oAuth2ClientAuthenticationFilter.setRestTemplate(oAuth2RestTemplate);

        SinaUserInfoTokenServices tokenServices = new SinaUserInfoTokenServices(client.getResource().getUserInfoUri(), client.getClient().getClientId());
        tokenServices.setUserService(userService);
        tokenServices.setRestTemplate(oAuth2RestTemplate);
        oAuth2ClientAuthenticationFilter.setTokenServices(tokenServices);
        return oAuth2ClientAuthenticationFilter;
    }
 
开发者ID:helloworldtang,项目名称:sns-todo,代码行数:12,代码来源:FormLoginSecurityConfig.java

示例12: ssoFilter

import org.springframework.security.oauth2.client.filter.OAuth2ClientAuthenticationProcessingFilter; //导入依赖的package包/类
private Filter ssoFilter() {
    OAuth2ClientAuthenticationProcessingFilter facebookFilter = new OAuth2ClientAuthenticationProcessingFilter(
            "/login/facebook");
    OAuth2RestTemplate facebookTemplate = new OAuth2RestTemplate(facebook(), oauth2ClientContext);
    facebookFilter.setRestTemplate(facebookTemplate);
    UserInfoTokenServices tokenServices = new UserInfoTokenServices(facebookResource().getUserInfoUri(),
            facebook().getClientId());
    tokenServices.setRestTemplate(facebookTemplate);
    facebookFilter.setTokenServices(
            new UserInfoTokenServices(facebookResource().getUserInfoUri(), facebook().getClientId()));
    return facebookFilter;
}
 
开发者ID:arityllc,项目名称:referenceapp,代码行数:13,代码来源:OAuthService.java

示例13: configure

import org.springframework.security.oauth2.client.filter.OAuth2ClientAuthenticationProcessingFilter; //导入依赖的package包/类
@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
  }
 
开发者ID:reportportal,项目名称:service-authorization,代码行数:28,代码来源:OAuthSecurityConfig.java

示例14: getDefaultFilters

import org.springframework.security.oauth2.client.filter.OAuth2ClientAuthenticationProcessingFilter; //导入依赖的package包/类
private List<OAuth2ClientAuthenticationProcessingFilter> getDefaultFilters(
        OAuth2ClientContext oauth2ClientContext) {
    return authProviders.stream().map(provider -> {
        OAuth2ClientAuthenticationProcessingFilter filter = new OAuth2ClientAuthenticationProcessingFilter(
                provider.buildPath(SSO_LOGIN_PATH));
        filter.setRestTemplate(provider.getOAuthRestOperations(oauth2ClientContext));
        filter.setTokenServices(provider.getTokenServices());
        filter.setAuthenticationSuccessHandler(authSuccessHandler);
        return filter;
    }).collect(Collectors.toList());
}
 
开发者ID:reportportal,项目名称:service-authorization,代码行数:12,代码来源:OAuthSecurityConfig.java

示例15: ssoFilter

import org.springframework.security.oauth2.client.filter.OAuth2ClientAuthenticationProcessingFilter; //导入依赖的package包/类
private OAuth2ClientAuthenticationProcessingFilter ssoFilter(String provideName,
                                                             ClientResources clientResources) {
    OAuth2ClientAuthenticationProcessingFilter filter =
            new OAuth2ClientAuthenticationProcessingFilter(format("/login/%s", provideName));
    filter.setRestTemplate(new OAuth2RestTemplate(clientResources.getClient(), oauth2ClientContext));
    filter.setTokenServices(new UserInfoTokenServices(clientResources.getResource().getUserInfoUri(),
            clientResources.getClient().getClientId()));
    filter.setApplicationEventPublisher(applicationEventPublisher);
    return filter;
}
 
开发者ID:restbucks,项目名称:restbucks-member,代码行数:11,代码来源:WebSecurityConfiguration.java


注:本文中的org.springframework.security.oauth2.client.filter.OAuth2ClientAuthenticationProcessingFilter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。