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


Java ClientCredentialsResourceDetails.setGrantType方法代码示例

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


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

示例1: testAccessRootUrlWithOAuth2AccessToken

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

	final ClientCredentialsResourceDetails resourceDetails = new ClientCredentialsResourceDetails();
	resourceDetails.setClientId("myclient");
	resourceDetails.setClientSecret("mysecret");
	resourceDetails.setGrantType("client_credentials");
	resourceDetails
			.setAccessTokenUri("http://localhost:" + oAuth2ServerResource.getOauth2ServerPort() + "/oauth/token");

	final OAuth2RestTemplate oAuth2RestTemplate = new OAuth2RestTemplate(resourceDetails);
	final OAuth2AccessToken accessToken = oAuth2RestTemplate.getAccessToken();

	final String accessTokenAsString = accessToken.getValue();

	localSkipperResource.getMockMvc().perform(get("/api").header("Authorization", "bearer " + accessTokenAsString))
			.andDo(print()).andExpect(status().isOk());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-skipper,代码行数:19,代码来源:LocalServerSecurityWithOAuth2Tests.java

示例2: testAccessAboutUrlWithOAuth2AccessToken

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

	final ClientCredentialsResourceDetails resourceDetails = new ClientCredentialsResourceDetails();
	resourceDetails.setClientId("myclient");
	resourceDetails.setClientSecret("mysecret");
	resourceDetails.setGrantType("client_credentials");
	resourceDetails
			.setAccessTokenUri("http://localhost:" + oAuth2ServerResource.getOauth2ServerPort() + "/oauth/token");

	final OAuth2RestTemplate oAuth2RestTemplate = new OAuth2RestTemplate(resourceDetails);
	final OAuth2AccessToken accessToken = oAuth2RestTemplate.getAccessToken();

	final String accessTokenAsString = accessToken.getValue();

	localSkipperResource.getMockMvc()
			.perform(get("/api/about").header("Authorization", "bearer " + accessTokenAsString)).andDo(print())
			.andExpect(status().isOk())
			.andExpect(jsonPath("$.versionInfo.server.name", is("Spring Cloud Skipper Server")))
			.andExpect(jsonPath("$.versionInfo.server.version", notNullValue()));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-skipper,代码行数:22,代码来源:LocalServerSecurityWithOAuth2Tests.java

示例3: testAccessRootUrlWithOAuth2AccessToken

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

	final ClientCredentialsResourceDetails resourceDetails = new ClientCredentialsResourceDetails();
	resourceDetails.setClientId("myclient");
	resourceDetails.setClientSecret("mysecret");
	resourceDetails.setGrantType("client_credentials");
	resourceDetails
			.setAccessTokenUri("http://localhost:" + oAuth2ServerResource.getOauth2ServerPort() + "/oauth/token");

	final OAuth2RestTemplate oAuth2RestTemplate = new OAuth2RestTemplate(resourceDetails);
	final OAuth2AccessToken accessToken = oAuth2RestTemplate.getAccessToken();

	final String accessTokenAsString = accessToken.getValue();

	localDataflowResource.getMockMvc().perform(get("/").header("Authorization", "bearer " + accessTokenAsString))
			.andDo(print()).andExpect(status().isOk());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow,代码行数:19,代码来源:LocalServerSecurityWithOAuth2Tests.java

示例4: testAccessSecurityInfoUrlWithOAuth2AccessToken

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

	final ClientCredentialsResourceDetails resourceDetails = new ClientCredentialsResourceDetails();
	resourceDetails.setClientId("myclient");
	resourceDetails.setClientSecret("mysecret");
	resourceDetails.setGrantType("client_credentials");
	resourceDetails
			.setAccessTokenUri("http://localhost:" + oAuth2ServerResource.getOauth2ServerPort() + "/oauth/token");

	final OAuth2RestTemplate oAuth2RestTemplate = new OAuth2RestTemplate(resourceDetails);
	final OAuth2AccessToken accessToken = oAuth2RestTemplate.getAccessToken();

	final String accessTokenAsString = accessToken.getValue();

	localDataflowResource.getMockMvc()
			.perform(get("/security/info").header("Authorization", "bearer " + accessTokenAsString)).andDo(print())
			.andExpect(status().isOk()).andExpect(jsonPath("$.authorizationEnabled", is(Boolean.TRUE)))
			.andExpect(jsonPath("$.authenticated", is(Boolean.TRUE)))
			.andExpect(jsonPath("$.authenticationEnabled", is(Boolean.TRUE)))
			.andExpect(jsonPath("$.roles", hasSize(3)));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow,代码行数:23,代码来源:LocalServerSecurityWithOAuth2Tests.java

示例5: loadBalancedOauth2RestTemplate

import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails; //导入方法依赖的package包/类
@LoadBalanced
@Bean
public OAuth2RestTemplate loadBalancedOauth2RestTemplate(ClientCredentialsResourceDetails resource) {
    ClientCredentialsResourceDetails clientCredentialsResourceDetails = new ClientCredentialsResourceDetails();
    clientCredentialsResourceDetails.setAccessTokenUri(resource.getAccessTokenUri());
    clientCredentialsResourceDetails.setClientId(resource.getClientId());
    clientCredentialsResourceDetails.setClientSecret(resource.getClientSecret());
    clientCredentialsResourceDetails.setClientAuthenticationScheme(resource.getClientAuthenticationScheme());
    clientCredentialsResourceDetails.setScope(resource.getScope());
    clientCredentialsResourceDetails.setGrantType(resource.getGrantType());
    OAuth2RestTemplate auth2RestTemplate = new OAuth2RestTemplate(clientCredentialsResourceDetails);
    auth2RestTemplate.setAccessTokenProvider(new ClientCredentialsAccessTokenProvider());
    return auth2RestTemplate;
}
 
开发者ID:kbastani,项目名称:cloud-native-microservice-strangler-example,代码行数:15,代码来源:UserApplication.java

示例6: loadBalancedOauth2RestTemplate

import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails; //导入方法依赖的package包/类
@LoadBalanced
@Bean
public OAuth2RestTemplate loadBalancedOauth2RestTemplate(
        ClientCredentialsResourceDetails resource) {
    ClientCredentialsResourceDetails clientCredentialsResourceDetails = new ClientCredentialsResourceDetails();
    clientCredentialsResourceDetails.setAccessTokenUri(resource.getAccessTokenUri());
    clientCredentialsResourceDetails.setClientId(resource.getClientId());
    clientCredentialsResourceDetails.setClientSecret(resource.getClientSecret());
    clientCredentialsResourceDetails.setClientAuthenticationScheme(resource.getClientAuthenticationScheme());
    clientCredentialsResourceDetails.setScope(resource.getScope());
    clientCredentialsResourceDetails.setGrantType(resource.getGrantType());
    OAuth2RestTemplate auth2RestTemplate = new OAuth2RestTemplate(clientCredentialsResourceDetails);
    auth2RestTemplate.setAccessTokenProvider(new ClientCredentialsAccessTokenProvider());
    return auth2RestTemplate;
}
 
开发者ID:kbastani,项目名称:cloud-native-microservice-strangler-example,代码行数:16,代码来源:LegacyEdgeApplication.java

示例7: 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


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