本文整理汇总了Java中org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails.setScope方法的典型用法代码示例。如果您正苦于以下问题:Java ClientCredentialsResourceDetails.setScope方法的具体用法?Java ClientCredentialsResourceDetails.setScope怎么用?Java ClientCredentialsResourceDetails.setScope使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails
的用法示例。
在下文中一共展示了ClientCredentialsResourceDetails.setScope方法的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;
}
示例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);
}
示例3: 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);
}
示例4: 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;
}
示例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,代码行数:16,代码来源:LegacyEdgeApplication.java
示例6: getResourceDetails
import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails; //导入方法依赖的package包/类
@Bean
protected OAuth2ProtectedResourceDetails getResourceDetails() {
LOGGER.info("getResourceDetails()");
ClientCredentialsResourceDetails resource = new ClientCredentialsResourceDetails();
resource.setAccessTokenUri(customerAccountGatewayProperties.getOauth2().getTokenUrl());
resource.setClientId(customerAccountGatewayProperties.getOauth2().getClient().getId());
resource.setClientSecret(customerAccountGatewayProperties.getOauth2().getClient().getSecret());
resource.setScope(customerAccountGatewayProperties.getScopes());
return resource;
}
示例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;
}
示例8: 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);
}
示例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;
}
示例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;
}