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


Java ClientCredentialsResourceDetails.setId方法代码示例

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


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

示例1: passwordResourceDetails

import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails; //导入方法依赖的package包/类
@Bean
public OAuth2ProtectedResourceDetails passwordResourceDetails() {
    //@formatter:off
ClientCredentialsResourceDetails details = new ClientCredentialsResourceDetails();

details.setId("oauth2server");
details.setTokenName("oauth_token");
details.setClientId("clientadmin");
details.setClientSecret("123");
details.setAccessTokenUri("http://localhost:8080/oauth/token");
details.setScope(Arrays.asList("admin"));

details.setClientAuthenticationScheme(AuthenticationScheme.header);
//@formatter:on

    return details;
}
 
开发者ID:PacktPublishing,项目名称:OAuth-2.0-Cookbook,代码行数:18,代码来源:ClientConfiguration.java

示例2: clientCredentialsRestTemplate

import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails; //导入方法依赖的package包/类
/**
 * 演示 grant_type=client_credentials 时,获取资源的方法
 *
 * @param client_id
 * @param client_secret    取决于 AuthorizationServer 设置,如果 client 设置了secret,则此项参数为必需,否则可以没有
 * @param access_token_uri
 * @param scope
 * @return
 */
public OAuth2RestOperations clientCredentialsRestTemplate(String client_id, String client_secret, String access_token_uri, String... scope) {

    // 防止 url 写错
    if (!access_token_uri.contains("token"))
        throw new RuntimeException("uri is wrong :  access_token_uri = " + access_token_uri);

    ClientCredentialsResourceDetails details = new ClientCredentialsResourceDetails();
    details.setId("4");
    details.setClientId(client_id);
    if (client_secret != null && !client_secret.isEmpty())
        details.setClientSecret(client_secret);
    details.setAccessTokenUri(access_token_uri);
    details.setScope(Arrays.asList(scope));
    return new OAuth2RestTemplate(details, oAuth2ClientContext);
}
 
开发者ID:h819,项目名称:spring-boot,代码行数:25,代码来源:Oauth2ClientRestTemplate.java

示例3: testClientCredentialsRestTemplate

import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails; //导入方法依赖的package包/类
@Test
public void testClientCredentialsRestTemplate() throws Exception {

    ClientCredentialsResourceDetails details = new ClientCredentialsResourceDetails();
     details.setId("4");
    details.setClientId(client_id);
    details.setClientSecret(client_secret);
    details.setAccessTokenUri(access_token_uri);
   // details.setScope(Arrays.asList("read write"));
    OAuth2RestTemplate operations = new OAuth2RestTemplate(details,new DefaultOAuth2ClientContext());
   // OAuth2RestTemplate oAuth2RestTemplate = new OAuth2RestTemplate(resourceDetails);
    operations.setAccessTokenProvider(new ClientCredentialsAccessTokenProvider());

  //  OAuth2RestTemplate restTemplate = new OAuth2RestTemplate(resourceDetails(),oAuth2ClientContext());
    DefaultOAuth2AccessToken token=(DefaultOAuth2AccessToken)operations.getAccessToken();
    token.setTokenType("Bearer");

    System.out.println("client_id : " + client_id);
    System.out.println("source_url : " + source_url);

  //  OAuth2RestOperations operations = restTemplate.clientCredentialsRestTemplate(client_id, client_secret, access_token_uri, scopes);  // getForObject 发送 get 方法
    System.out.println(JSON.toJSONString(operations.getForObject(source_url, JsonNode.class)));  // getForObject 发送 get 方法

}
 
开发者ID:h819,项目名称:spring-boot,代码行数:25,代码来源:Oauth2ClientRestTemplateTest.java

示例4: testConnectDirectlyToResourceServer

import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails; //导入方法依赖的package包/类
@Test
public void testConnectDirectlyToResourceServer() throws Exception {

	ClientCredentialsResourceDetails resource = new ClientCredentialsResourceDetails();

	resource.setAccessTokenUri(serverRunning.getUrl("/sparklr2/oauth/token"));
	resource.setClientId("my-client-with-registered-redirect");
	resource.setId("sparklr");
	resource.setScope(Arrays.asList("trust"));

	ClientCredentialsAccessTokenProvider provider = new ClientCredentialsAccessTokenProvider();
	OAuth2AccessToken accessToken = provider.obtainAccessToken(resource, new DefaultAccessTokenRequest());

	OAuth2RestTemplate template = new OAuth2RestTemplate(resource, new DefaultOAuth2ClientContext(accessToken));
	String result = template.getForObject(serverRunning.getUrl("/sparklr2/photos/trusted/message"), String.class);
	assertEquals("Hello, Trusted Client", result);

}
 
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:19,代码来源:ClientCredentialsGrantTests.java

示例5: resourceDetails

import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails; //导入方法依赖的package包/类
@Bean("practiceClientCredentialsResourceDetails")
public ClientCredentialsResourceDetails resourceDetails() {
    ClientCredentialsResourceDetails details = new ClientCredentialsResourceDetails();
    details.setId(oauth2ClientProperties.getId());
    details.setAccessTokenUri(oauth2ClientProperties.getAccessTokenUrl());
    details.setClientId(oauth2ClientProperties.getClientId());
    details.setClientSecret(oauth2ClientProperties.getClientSecret());
    details.setAuthenticationScheme(AuthenticationScheme.valueOf(oauth2ClientProperties.getClientAuthenticationScheme()));
    return details;
}
 
开发者ID:sdcuike,项目名称:spring-boot-oauth2-demo,代码行数:11,代码来源:Oauth2ClientConfig.java

示例6: ConfigClientCredentialsResourceDetails

import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails; //导入方法依赖的package包/类
@Bean
public ClientCredentialsResourceDetails ConfigClientCredentialsResourceDetails() {
	
	ClientCredentialsResourceDetails resource = new ClientCredentialsResourceDetails();
	resource.setAccessTokenUri("http://localhost:8080/uaa/oauth/token");
	resource.setClientId("fortressdemo2");
	resource.setClientSecret("hard2guess!");
	resource.setId("fortressdemo2");
	resource.setGrantType("client_credentials");
	resource.setScope(Arrays.asList("fortressdemo2.read", "fortressdemo2.write"));

	return resource;
	
}
 
开发者ID:johnpfield,项目名称:oauth2-cli,代码行数:15,代码来源:ConfigRestResources.java

示例7: vootRestTemplate

import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails; //导入方法依赖的package包/类
private OAuth2RestTemplate vootRestTemplate() {
    ClientCredentialsResourceDetails details = new ClientCredentialsResourceDetails();
    details.setId("pdp");
    details.setClientId(clientId);
    details.setClientSecret(clientSecret);
    details.setAccessTokenUri(accessTokenUri);
    details.setScope((spaceDelimitedScopes != null) ? asList(spaceDelimitedScopes.split(" ")) : Collections.emptyList());
    return new OAuth2RestTemplate(details);
}
 
开发者ID:OpenConext,项目名称:OpenConext-pdp,代码行数:10,代码来源:VootClientConfig.java

示例8: bookingClientCredentialClient

import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails; //导入方法依赖的package包/类
@Bean
public OAuth2RestOperations bookingClientCredentialClient() {
  ClientCredentialsResourceDetails resourceDetails = new ClientCredentialsResourceDetails();
  resourceDetails.setId("2");
  resourceDetails.setClientId("Foosball Booking Read Client");
  resourceDetails.setClientSecret("secret");
  resourceDetails.setAccessTokenUri(ACCESS_TOKEN_URI);

  OAuth2RestTemplate oAuth2RestTemplate = new OAuth2RestTemplate(resourceDetails);
  oAuth2RestTemplate.setAccessTokenProvider(new ClientCredentialsAccessTokenProvider());
  return oAuth2RestTemplate;
}
 
开发者ID:KaiHofstetter,项目名称:foosball-booking-client,代码行数:13,代码来源:OAuth2RestTemplatesConfig.java

示例9: trusted

import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails; //导入方法依赖的package包/类
@Bean
public OAuth2ProtectedResourceDetails trusted() {
	ClientCredentialsResourceDetails details = new ClientCredentialsResourceDetails();
	details.setId("sparklr/trusted");
	details.setClientId("my-client-with-registered-redirect");
	details.setAccessTokenUri(accessTokenUri);
	details.setScope(Arrays.asList("trust"));
	return details;
}
 
开发者ID:jungyang,项目名称:oauth-client-master,代码行数:10,代码来源:WebMvcConfig.java

示例10: vootConfiguration

import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails; //导入方法依赖的package包/类
private OAuth2ProtectedResourceDetails vootConfiguration(String accessTokenUri, String clientId, String clientSecret, List<String> scopes) {
  ClientCredentialsResourceDetails details = new ClientCredentialsResourceDetails();
  details.setId("bod-voot-client");
  details.setClientId(clientId);
  details.setClientSecret(clientSecret);
  details.setAccessTokenUri(accessTokenUri);
  details.setScope(scopes);
  return details;
}
 
开发者ID:BandwidthOnDemand,项目名称:bandwidth-on-demand,代码行数:10,代码来源:VootGroupService.java


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