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


Java UserInfoTokenServices.setRestTemplate方法代码示例

本文整理汇总了Java中org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoTokenServices.setRestTemplate方法的典型用法代码示例。如果您正苦于以下问题:Java UserInfoTokenServices.setRestTemplate方法的具体用法?Java UserInfoTokenServices.setRestTemplate怎么用?Java UserInfoTokenServices.setRestTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoTokenServices的用法示例。


在下文中一共展示了UserInfoTokenServices.setRestTemplate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: general

import org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoTokenServices; //导入方法依赖的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: wechat

import org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoTokenServices; //导入方法依赖的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

示例3: ssoFilter

import org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoTokenServices; //导入方法依赖的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

示例4: ssoFilter

import org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoTokenServices; //导入方法依赖的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

示例5: customSSOFilter

import org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoTokenServices; //导入方法依赖的package包/类
/**
 * ## todo : describe.
 *
 * @param client     {@link ClientResources}
 * @param processUrl {@link String}
 * @return {@link Filter}
 */
private Filter customSSOFilter(final ClientResources client, final String processUrl) {
	final OAuth2ClientAuthenticationProcessingFilter filter = new OAuth2ClientAuthenticationProcessingFilter(processUrl);

	final OAuth2RestTemplate template = new OAuth2RestTemplate(client.getClient(), oauth2ClientContext);
	filter.setRestTemplate(template);

	final UserInfoTokenServices tokenServices = new UserInfoTokenServices(client.getResource().getUserInfoUri(), client.getClient().getClientId());
	tokenServices.setRestTemplate(template);
	filter.setTokenServices(tokenServices);

	return filter;
}
 
开发者ID:inspectIT,项目名称:marketplace,代码行数:20,代码来源:WebSecurityConfig.java

示例6: ssoFilter

import org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoTokenServices; //导入方法依赖的package包/类
private Filter ssoFilter(ClientResources client, String path) {
    OAuth2ClientAuthenticationProcessingFilter filter = new OAuth2ClientAuthenticationProcessingFilter(path);
    OAuth2RestTemplate template = new OAuth2RestTemplate(client.getClient(), oauth2ClientContext);
    filter.setRestTemplate(template);
    UserInfoTokenServices tokenServices =
        new UserInfoTokenServices(client.getResource().getUserInfoUri(), client.getClient().getClientId());
    tokenServices.setRestTemplate(template);
    filter.setTokenServices(tokenServices);
    return filter;
}
 
开发者ID:crispab,项目名称:codekvast,代码行数:11,代码来源:WebSecurityConfig.java

示例7: ssoFilter

import org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoTokenServices; //导入方法依赖的package包/类
private Filter ssoFilter(ClientResources client, String path) {
    OAuth2ClientAuthenticationProcessingFilter oAuth2ClientAuthenticationFilter =
            new OAuth2ClientAuthenticationProcessingFilter(path);
    OAuth2RestTemplate oAuth2RestTemplate = new OAuth2RestTemplate(client.getClient(),
            oAuth2ClientContext);
    oAuth2ClientAuthenticationFilter.setRestTemplate(oAuth2RestTemplate);
    UserInfoTokenServices tokenServices = new UserInfoTokenServices(
            client.getResource().getUserInfoUri(), client.getClient().getClientId());
    tokenServices.setRestTemplate(oAuth2RestTemplate);
    oAuth2ClientAuthenticationFilter.setTokenServices(tokenServices);
    return oAuth2ClientAuthenticationFilter;
}
 
开发者ID:dschadow,项目名称:JavaSecurity,代码行数:13,代码来源:SsoWithGitHubApplication.java


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