本文整理汇总了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");
}
}
示例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());
}
}
示例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;
}
示例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");
}
}
示例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");
}
}
示例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);
}
示例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);
}
示例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");
}
示例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);
}
示例11: build
import org.springframework.security.oauth2.client.resource.BaseOAuth2ProtectedResourceDetails; //导入依赖的package包/类
public OAuth2ProtectedResourceDetails build() {
return new BaseOAuth2ProtectedResourceDetails();
}
示例12: AccessTokenProviderChainTests
import org.springframework.security.oauth2.client.resource.BaseOAuth2ProtectedResourceDetails; //导入依赖的package包/类
public AccessTokenProviderChainTests() {
resource = new BaseOAuth2ProtectedResourceDetails();
resource.setId("resource");
}