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


Java BaseOAuth2ProtectedResourceDetails类代码示例

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


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

示例1: getMap

import org.springframework.security.oauth2.client.resource.BaseOAuth2ProtectedResourceDetails; //导入依赖的package包/类
@SuppressWarnings({ "unchecked" })
private Map<String, Object> getMap(String path, String accessToken) {
	this.logger.info("Getting user info from: " + path);
	try {
		OAuth2RestOperations restTemplate = this.restTemplate;
		if (restTemplate == null) {
			BaseOAuth2ProtectedResourceDetails resource = new BaseOAuth2ProtectedResourceDetails();
			resource.setClientId(this.clientId);
			restTemplate = new OAuth2RestTemplate(resource);
		}
		DefaultOAuth2AccessToken token = new DefaultOAuth2AccessToken(accessToken);
		token.setTokenType(this.tokenType);
		restTemplate.getOAuth2ClientContext().setAccessToken(token);
		return restTemplate.getForEntity(path, Map.class).getBody();
	}
	catch (Exception ex) {
		this.logger.info("Could not fetch user details: " + ex.getClass() + ", "
				+ ex.getMessage());
		return Collections.<String, Object>singletonMap("error",
				"Could not fetch user details");
	}
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:23,代码来源:UserInfoTokenServices.java

示例2: fixPaths

import org.springframework.security.oauth2.client.resource.BaseOAuth2ProtectedResourceDetails; //导入依赖的package包/类
@BeforeOAuth2Context
public void fixPaths() {
	String prefix = server.getServletPrefix();
	http.setPort(port);
	http.setPrefix(prefix);
	BaseOAuth2ProtectedResourceDetails resource = (BaseOAuth2ProtectedResourceDetails) context.getResource();
	List<HttpMessageConverter<?>> converters = new ArrayList<>(context.getRestTemplate().getMessageConverters());
	converters.addAll(getAdditionalConverters());
	context.getRestTemplate().setMessageConverters(converters);
	context.getRestTemplate().setInterceptors(getInterceptors());
	resource.setAccessTokenUri(http.getUrl(tokenPath()));
	if (resource instanceof AbstractRedirectResourceDetails) {
		((AbstractRedirectResourceDetails) resource).setUserAuthorizationUri(http.getUrl(authorizePath()));
	}
	if (resource instanceof ImplicitResourceDetails) {
		resource.setAccessTokenUri(http.getUrl(authorizePath()));
	}
	if (resource instanceof ResourceOwnerPasswordResourceDetails && !(resource instanceof DoNotOverride)) {
		((ResourceOwnerPasswordResourceDetails) resource).setUsername(getUsername());
		((ResourceOwnerPasswordResourceDetails) resource).setPassword(getPassword());
	}
}
 
开发者ID:jfcorugedo,项目名称:spring-oauth2-samples,代码行数:23,代码来源:AbstractIntegrationTests.java

示例3: getBeanClass

import org.springframework.security.oauth2.client.resource.BaseOAuth2ProtectedResourceDetails; //导入依赖的package包/类
@Override
protected Class<?> getBeanClass(Element element) {
	String type = element.getAttribute("type");
	if ("authorization_code".equals(type)) {
		return AuthorizationCodeResourceDetails.class;
	}
	if ("implicit".equals(type)) {
		return ImplicitResourceDetails.class;
	}
	if ("client_credentials".equals(type)) {
		return ClientCredentialsResourceDetails.class;
	}
	if ("password".equals(type)) {
		return ResourceOwnerPasswordResourceDetails.class;
	}
	return BaseOAuth2ProtectedResourceDetails.class;
}
 
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:18,代码来源:ResourceBeanDefinitionParser.java

示例4: getMap

import org.springframework.security.oauth2.client.resource.BaseOAuth2ProtectedResourceDetails; //导入依赖的package包/类
@SuppressWarnings({ "unchecked" })
private Map<String, Object> getMap(String path, String accessToken) {
	this.logger.debug("Getting user info from: " + path);
	try {
		OAuth2RestOperations restTemplate = this.restTemplate;
		if (restTemplate == null) {
			BaseOAuth2ProtectedResourceDetails resource = new BaseOAuth2ProtectedResourceDetails();
			resource.setClientId(this.clientId);
			restTemplate = new OAuth2RestTemplate(resource);
		}
		OAuth2AccessToken existingToken = restTemplate.getOAuth2ClientContext()
				.getAccessToken();
		if (existingToken == null || !accessToken.equals(existingToken.getValue())) {
			DefaultOAuth2AccessToken token = new DefaultOAuth2AccessToken(
					accessToken);
			token.setTokenType(this.tokenType);
			restTemplate.getOAuth2ClientContext().setAccessToken(token);
		}
		return restTemplate.getForEntity(path, Map.class).getBody();
	}
	catch (Exception ex) {
		this.logger.info("Could not fetch user details: " + ex.getClass() + ", "
				+ ex.getMessage());
		return Collections.<String, Object>singletonMap("error",
				"Could not fetch user details");
	}
}
 
开发者ID:dins-heisenbug-2016,项目名称:piggymetrics,代码行数:28,代码来源:CustomUserInfoTokenServices.java

示例5: getMap

import org.springframework.security.oauth2.client.resource.BaseOAuth2ProtectedResourceDetails; //导入依赖的package包/类
@SuppressWarnings({ "unchecked" })
private Map<String, Object> getMap(String path, String accessToken) {
	this.logger.info("Getting user info from {} with access token {}", path, accessToken);
	try {
		OAuth2RestOperations restTemplate = this.restTemplate;
		if (restTemplate == null) {
			BaseOAuth2ProtectedResourceDetails resource = new BaseOAuth2ProtectedResourceDetails();
			resource.setClientId(this.clientId);
			restTemplate = new OAuth2RestTemplate(resource);
		}
		OAuth2AccessToken existingToken = restTemplate.getOAuth2ClientContext()
				.getAccessToken();
		if (existingToken == null || !accessToken.equals(existingToken.getValue())) {
			DefaultOAuth2AccessToken token = new DefaultOAuth2AccessToken(
					accessToken);
			token.setTokenType(this.tokenType);
			logger.info("==========================================================");
			logger.info("USER INFO FETCH, using NEW access token: {}", accessToken);
			logger.info("==========================================================");
			restTemplate.getOAuth2ClientContext().setAccessToken(token);
		} else {
			logger.info("==========================================================");
			logger.info("USER INFO FETCH, using EXISTING access token: {}", existingToken.getValue());
			logger.info("==========================================================");
		}
		return restTemplate.getForEntity(path, Map.class).getBody();
	}
	catch (Exception ex) {
		this.logger.info("Could not fetch user details: " + ex.getClass() + ", "
				+ ex.getMessage());
		return Collections.<String, Object>singletonMap("error",
				"Could not fetch user details");
	}
}
 
开发者ID:nicodewet,项目名称:template-spring-boot-oauth2-wso2-is,代码行数:35,代码来源:AppUserInfoTokenServices.java

示例6: getMap

import org.springframework.security.oauth2.client.resource.BaseOAuth2ProtectedResourceDetails; //导入依赖的package包/类
@SuppressWarnings({ "unchecked" })
private Map<String, Object> getMap(String path, String accessToken) {
	this.logger.info("Getting user info from: " + path);
	try {
		OAuth2RestOperations restTemplate = this.restTemplate;
		if (restTemplate == null) {
			BaseOAuth2ProtectedResourceDetails resource = new BaseOAuth2ProtectedResourceDetails();
			resource.setClientId(this.clientId);
			restTemplate = new OAuth2RestTemplate(resource);
		}
		OAuth2AccessToken existingToken = restTemplate.getOAuth2ClientContext()
				.getAccessToken();
		if (existingToken == null || !accessToken.equals(existingToken.getValue())) {
			DefaultOAuth2AccessToken token = new DefaultOAuth2AccessToken(
					accessToken);
			token.setTokenType(this.tokenType);
			restTemplate.getOAuth2ClientContext().setAccessToken(token);
		}
		return restTemplate.getForEntity(path, Map.class).getBody();
	}
	catch (Exception ex) {
		this.logger.info("Could not fetch user details: " + ex.getClass() + ", "
				+ ex.getMessage());
		return Collections.<String, Object>singletonMap("error",
				"Could not fetch user details");
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:28,代码来源:UserInfoTokenServices.java

示例7: open

import org.springframework.security.oauth2.client.resource.BaseOAuth2ProtectedResourceDetails; //导入依赖的package包/类
@Before
public void open() throws Exception {
	resource = new BaseOAuth2ProtectedResourceDetails();
	// Facebook and older specs:
	resource.setTokenName("bearer_token");
	restTemplate = new OAuth2RestTemplate(resource);
	restTemplate.setAccessTokenProvider(accessTokenProvider);
	request = Mockito.mock(ClientHttpRequest.class);
	headers = new HttpHeaders();
	Mockito.when(request.getHeaders()).thenReturn(headers);
	ClientHttpResponse response = Mockito.mock(ClientHttpResponse.class);
	HttpStatus statusCode = HttpStatus.OK;
	Mockito.when(response.getStatusCode()).thenReturn(statusCode);
	Mockito.when(request.execute()).thenReturn(response);
}
 
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:16,代码来源:OAuth2RestTemplateTests.java

示例8: oauth2FeignRequestInterceptor

import org.springframework.security.oauth2.client.resource.BaseOAuth2ProtectedResourceDetails; //导入依赖的package包/类
@Bean
@Autowired
public RequestInterceptor oauth2FeignRequestInterceptor(
        OAuth2ClientContext oauth2ClientContext, BaseOAuth2ProtectedResourceDetails resource) {
    return new OAuth2FeignRequestInterceptor(oauth2ClientContext, resource);
}
 
开发者ID:javaguru,项目名称:tcloud-microservices,代码行数:7,代码来源:TcloudClientApplication.java

示例9: setUp

import org.springframework.security.oauth2.client.resource.BaseOAuth2ProtectedResourceDetails; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	oAuth2FeignRequestInterceptor = new OAuth2FeignRequestInterceptor(new MockOAuth2ClientContext("Fancy"), new BaseOAuth2ProtectedResourceDetails());
	requestTemplate = new RequestTemplate().method("GET");
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-security,代码行数:6,代码来源:OAuth2FeignRequestInterceptorTests.java

示例10: tryToAcquireToken

import org.springframework.security.oauth2.client.resource.BaseOAuth2ProtectedResourceDetails; //导入依赖的package包/类
@Test(expected = OAuth2AccessDeniedException.class)
public void tryToAcquireToken() {
	oAuth2FeignRequestInterceptor = new OAuth2FeignRequestInterceptor(new DefaultOAuth2ClientContext(), new BaseOAuth2ProtectedResourceDetails());
	OAuth2AccessToken oAuth2AccessToken = oAuth2FeignRequestInterceptor.getToken();
	Assert.assertTrue(oAuth2AccessToken.getValue() + " Must be null", oAuth2AccessToken.getValue() == null);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-security,代码行数:7,代码来源:OAuth2FeignRequestInterceptorTests.java

示例11: build

import org.springframework.security.oauth2.client.resource.BaseOAuth2ProtectedResourceDetails; //导入依赖的package包/类
public OAuth2ProtectedResourceDetails build() {
    return new BaseOAuth2ProtectedResourceDetails();
}
 
开发者ID:caelwinner,项目名称:spring-security-mongo,代码行数:4,代码来源:OAuth2ProtectedResourceDetailsBuilder.java

示例12: AccessTokenProviderChainTests

import org.springframework.security.oauth2.client.resource.BaseOAuth2ProtectedResourceDetails; //导入依赖的package包/类
public AccessTokenProviderChainTests() {
	resource = new BaseOAuth2ProtectedResourceDetails();
	resource.setId("resource");
}
 
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:5,代码来源:AccessTokenProviderChainTests.java


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