本文整理汇总了Java中org.springframework.security.oauth2.provider.password.ResourceOwnerPasswordTokenGranter类的典型用法代码示例。如果您正苦于以下问题:Java ResourceOwnerPasswordTokenGranter类的具体用法?Java ResourceOwnerPasswordTokenGranter怎么用?Java ResourceOwnerPasswordTokenGranter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResourceOwnerPasswordTokenGranter类属于org.springframework.security.oauth2.provider.password包,在下文中一共展示了ResourceOwnerPasswordTokenGranter类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCustomizedTokenGranters
import org.springframework.security.oauth2.provider.password.ResourceOwnerPasswordTokenGranter; //导入依赖的package包/类
private List<TokenGranter> getCustomizedTokenGranters() {
AuthorizationServerTokenServices tokenServices = tokenServices();
ClientDetailsService clientDetails = clientDetailsService();
AuthorizationCodeServices authorizationCodeServices = authorizationCodeServices();
OAuth2RequestFactory requestFactory = new DefaultOAuth2RequestFactory(clientDetails);
AuthorizationCodeTokenGranter authorizationCodeTokenGranter = new AuthorizationCodeTokenGranter(tokenServices, authorizationCodeServices, clientDetails, requestFactory);
RefreshTokenGranter refreshTokenGranter = new RefreshTokenGranter(tokenServices, clientDetails, requestFactory);
ImplicitTokenGranter implicit = new ImplicitTokenGranter(tokenServices, clientDetails, requestFactory);
ClientCredentialsTokenGranter clientCredentialsTokenGranter = new ClientCredentialsTokenGranter(tokenServices, clientDetails, requestFactory);
clientCredentialsTokenGranter.setAllowRefresh(true);//custom config, see AuthorizationServerEndpointsConfigurer.getDefaultTokenGranters
List<TokenGranter> tokenGranters = new ArrayList<>();
tokenGranters.add(authorizationCodeTokenGranter);
tokenGranters.add(refreshTokenGranter);
tokenGranters.add(implicit);
tokenGranters.add(clientCredentialsTokenGranter);
if (authenticationManager != null) {
tokenGranters.add(new ResourceOwnerPasswordTokenGranter(authenticationManager, tokenServices, clientDetails, requestFactory));
}
return tokenGranters;
}
示例2: configure
import org.springframework.security.oauth2.provider.password.ResourceOwnerPasswordTokenGranter; //导入依赖的package包/类
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
DefaultOAuth2RequestFactory requestFactory = new DefaultOAuth2RequestFactory(clientDetailsService);
endpoints
.tokenStore(tokenStore)
.authenticationManager(authenticationManager)
.tokenServices(authorizationServerTokenServices)
.requestFactory(requestFactory)
.tokenEnhancer(tokenEnhancer)
.tokenGranter(
new CompositeTokenGranter(Arrays.asList(
new ResourceOwnerPasswordTokenGranter(
authenticationManager,
authorizationServerTokenServices,
clientDetailsService,
requestFactory
),
new RefreshTokenGranter(
authorizationServerTokenServices,
clientDetailsService,
requestFactory)
))
)
;
}
示例3: getTokenGranter
import org.springframework.security.oauth2.provider.password.ResourceOwnerPasswordTokenGranter; //导入依赖的package包/类
protected TokenGranter getTokenGranter(String grantType) {
if ("authorization_code".equals(grantType)) {
return new AuthorizationCodeTokenGranter(tokenServices, authorizationCodeServices, clientDetailsService, this.oAuth2RequestFactory);
} else if ("password".equals(grantType)) {
return new ResourceOwnerPasswordTokenGranter(getAuthenticationManager(), tokenServices, clientDetailsService, this.oAuth2RequestFactory);
} else if ("refresh_token".equals(grantType)) {
return new RefreshTokenGranter(tokenServices, clientDetailsService, this.oAuth2RequestFactory);
} else if ("client_credentials".equals(grantType)) {
return new ClientCredentialsTokenGranter(tokenServices, clientDetailsService, this.oAuth2RequestFactory);
} else if ("implicit".equals(grantType)) {
return new ImplicitTokenGranter(tokenServices, clientDetailsService, this.oAuth2RequestFactory);
} else {
throw new UnsupportedGrantTypeException("Unsupport grant_type: " + grantType);
}
}
示例4: tokenGranter
import org.springframework.security.oauth2.provider.password.ResourceOwnerPasswordTokenGranter; //导入依赖的package包/类
@Bean
public TokenGranter tokenGranter() {
DefaultOAuth2RequestFactory requestFactory = new DefaultOAuth2RequestFactory(clientDetailsService());
AuthorizationCodeServices codeServices = authorizationCodeServices();
AuthorizationServerTokenServices tokenServices = tokenServices();
List<TokenGranter> tokenGranters = Arrays.asList(
new CustomAuthCodeTokenGranter(tokenServices, codeServices, clientDetailsService(), requestFactory),
new ResourceOwnerPasswordTokenGranter(authenticationManager, tokenServices, clientDetailsService(), requestFactory),
new ImplicitTokenGranter(tokenServices, clientDetailsService(), requestFactory));
return new CompositeTokenGranter(tokenGranters);
}
示例5: tokenGranter
import org.springframework.security.oauth2.provider.password.ResourceOwnerPasswordTokenGranter; //导入依赖的package包/类
@Bean
TokenGranter tokenGranter() {
List<TokenGranter> tokenGranters = Lists.newArrayList();
ResourceOwnerPasswordTokenGranter resourceOwnerPasswordTokenGranter = new ResourceOwnerPasswordTokenGranter(am,getDefaultTokenServices()
,getClientDetailsService(),new DefaultOAuth2RequestFactory(getClientDetailsService()));
ClientCredentialsTokenGranter clientCredentialsTokenGranter = new ClientCredentialsTokenGranter(getDefaultTokenServices(),getClientDetailsService(),new DefaultOAuth2RequestFactory(getClientDetailsService()));
AuthorizationCodeTokenGranter authorizationCodeTokenGranter = new AuthorizationCodeTokenGranter(getDefaultTokenServices(),authorizationCodeServices(),getClientDetailsService(),new DefaultOAuth2RequestFactory(getClientDetailsService()));
ImplicitTokenGranter implicitTokenGranter = new ImplicitTokenGranter(getDefaultTokenServices(),getClientDetailsService(),new DefaultOAuth2RequestFactory(getClientDetailsService()));
tokenGranters.add(resourceOwnerPasswordTokenGranter);
tokenGranters.add(clientCredentialsTokenGranter);
tokenGranters.add(authorizationCodeTokenGranter);
tokenGranters.add(implicitTokenGranter);
return new CompositeTokenGranter(tokenGranters);
}
示例6: compositeTokenGranter
import org.springframework.security.oauth2.provider.password.ResourceOwnerPasswordTokenGranter; //导入依赖的package包/类
private TokenGranter compositeTokenGranter(final ClientDetailsService clientService,
final AuthenticationManager manager,
final DefaultTokenServices tokenServices,
final OAuth2RequestFactory requestFactory,
final AuthorizationCodeServices authorizationCodeServices) {
List<TokenGranter> granters = new ArrayList<>();
granters.add(new ClientCredentialsTokenGranter(tokenServices, clientService, requestFactory));
granters.add(new ImplicitTokenGranter(tokenServices, clientService, requestFactory));
granters.add(new ResourceOwnerPasswordTokenGranter(manager, tokenServices, clientService, requestFactory));
granters.add(new RefreshTokenGranter(tokenServices, clientService, requestFactory));
granters.add(new AuthorizationCodeTokenGranter(tokenServices, authorizationCodeServices, clientService, requestFactory));
return new CompositeTokenGranter(granters);
}