本文整理汇总了Java中org.springframework.security.oauth2.client.token.grant.password.ResourceOwnerPasswordAccessTokenProvider类的典型用法代码示例。如果您正苦于以下问题:Java ResourceOwnerPasswordAccessTokenProvider类的具体用法?Java ResourceOwnerPasswordAccessTokenProvider怎么用?Java ResourceOwnerPasswordAccessTokenProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ResourceOwnerPasswordAccessTokenProvider类属于org.springframework.security.oauth2.client.token.grant.password包,在下文中一共展示了ResourceOwnerPasswordAccessTokenProvider类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MyOAuth2RestTemplate
import org.springframework.security.oauth2.client.token.grant.password.ResourceOwnerPasswordAccessTokenProvider; //导入依赖的package包/类
public MyOAuth2RestTemplate(OAuth2ProtectedResourceDetails resource, OAuth2ClientContext context) {
super(resource, context);
this.accessTokenProvider = new MyAccessTokenProviderChain(Arrays.asList(new AccessTokenProvider[]{new MyAuthorizationCodeAccessTokenProvider(),
new ImplicitAccessTokenProvider(),
new ResourceOwnerPasswordAccessTokenProvider(),
new ClientCredentialsAccessTokenProvider()}));
this.retryBadAccessTokens = true;
this.authenticator = new DefaultOAuth2RequestAuthenticator();
if(resource == null) {
throw new IllegalArgumentException("An OAuth2 resource must be supplied.");
} else {
this.resource = resource;
this.context = context;
this.setErrorHandler(new OAuth2ErrorHandler(resource));
}
}
示例2: createToken
import org.springframework.security.oauth2.client.token.grant.password.ResourceOwnerPasswordAccessTokenProvider; //导入依赖的package包/类
private OAuth2AccessToken createToken(String username, String password, String clientId, String clientSecret) {
OAuth2ProtectedResourceDetails resource = getResourceDetails(username, password, clientId, clientSecret);
AccessTokenRequest request = createAccessTokenRequest(username, password);
ResourceOwnerPasswordAccessTokenProvider provider = createResourceOwnerPasswordAccessTokenProvider();
try {
return provider.obtainAccessToken(resource, request);
} catch (OAuth2AccessDeniedException oauthEx) {
HttpStatus status = HttpStatus.valueOf(oauthEx.getHttpErrorCode());
throw new CloudFoundryException(status, oauthEx.getMessage(), oauthEx.getSummary());
}
}
示例3: refreshToken
import org.springframework.security.oauth2.client.token.grant.password.ResourceOwnerPasswordAccessTokenProvider; //导入依赖的package包/类
private OAuth2AccessToken refreshToken(OAuth2AccessToken currentToken, String username, String password, String clientId,
String clientSecret) {
OAuth2ProtectedResourceDetails resource = getResourceDetails(username, password, clientId, clientSecret);
AccessTokenRequest request = createAccessTokenRequest(username, password);
ResourceOwnerPasswordAccessTokenProvider provider = createResourceOwnerPasswordAccessTokenProvider();
return provider.refreshAccessToken(resource, currentToken.getRefreshToken(), request);
}
示例4: FeignOAuthInterceptor
import org.springframework.security.oauth2.client.token.grant.password.ResourceOwnerPasswordAccessTokenProvider; //导入依赖的package包/类
public FeignOAuthInterceptor(OAuth2ClientContext oAuth2ClientContext) {
super(oAuth2ClientContext, null);
this.oAuth2ClientContext = oAuth2ClientContext;
this.accessTokenProvider = new AccessTokenProviderChain(Arrays.asList(new AuthorizationCodeAccessTokenProvider(),
new ImplicitAccessTokenProvider(), new ResourceOwnerPasswordAccessTokenProvider(),
new ClientCredentialsAccessTokenProvider()));
}
示例5: accessTokenProviderChain
import org.springframework.security.oauth2.client.token.grant.password.ResourceOwnerPasswordAccessTokenProvider; //导入依赖的package包/类
@Bean
public AccessTokenProvider accessTokenProviderChain() {
return new AccessTokenProviderChain(Arrays.<AccessTokenProvider> asList(
new OpenIDTokenProvider(),
new AuthorizationCodeAccessTokenProvider(), new ImplicitAccessTokenProvider(),
new ResourceOwnerPasswordAccessTokenProvider(), new ClientCredentialsAccessTokenProvider()));
}
示例6: createResourceOwnerPasswordAccessTokenProvider
import org.springframework.security.oauth2.client.token.grant.password.ResourceOwnerPasswordAccessTokenProvider; //导入依赖的package包/类
protected ResourceOwnerPasswordAccessTokenProvider createResourceOwnerPasswordAccessTokenProvider() {
ResourceOwnerPasswordAccessTokenProvider resourceOwnerPasswordAccessTokenProvider = new ResourceOwnerPasswordAccessTokenProvider();
resourceOwnerPasswordAccessTokenProvider.setRequestFactory(restTemplate.getRequestFactory()); // copy the http proxy along
return resourceOwnerPasswordAccessTokenProvider;
}
示例7: oauth2RestTemplate
import org.springframework.security.oauth2.client.token.grant.password.ResourceOwnerPasswordAccessTokenProvider; //导入依赖的package包/类
@Bean
public OAuth2RestTemplate oauth2RestTemplate() {
OAuth2ProtectedResourceDetails resourceDetails = passwordResourceDetails();
OAuth2RestTemplate template = new OAuth2RestTemplate(resourceDetails,
oauth2ClientContext);
AccessTokenProviderChain provider = new AccessTokenProviderChain(
Arrays.asList(new ResourceOwnerPasswordAccessTokenProvider()));
provider.setClientTokenServices(clientTokenServices);
template.setAccessTokenProvider(provider);
return template;
}
示例8: userAccessTokenProvider
import org.springframework.security.oauth2.client.token.grant.password.ResourceOwnerPasswordAccessTokenProvider; //导入依赖的package包/类
public AccessTokenProvider userAccessTokenProvider() {
ResourceOwnerPasswordAccessTokenProvider accessTokenProvider = new ResourceOwnerPasswordAccessTokenProvider();
return accessTokenProvider;
}
示例9: accessTokenProvider
import org.springframework.security.oauth2.client.token.grant.password.ResourceOwnerPasswordAccessTokenProvider; //导入依赖的package包/类
@Bean
AccessTokenProvider accessTokenProvider() {
ResourceOwnerPasswordAccessTokenProvider tokenProvider = new ResourceOwnerPasswordAccessTokenProvider();
return tokenProvider;
}
示例10: setupAccessTokenProvider
import org.springframework.security.oauth2.client.token.grant.password.ResourceOwnerPasswordAccessTokenProvider; //导入依赖的package包/类
@BeforeOAuth2Context
public void setupAccessTokenProvider() {
ResourceOwnerPasswordAccessTokenProvider accessTokenProvider = helper.createAccessTokenProvider();
context.setAccessTokenProvider(accessTokenProvider);
}