本文整理汇总了Java中org.springframework.security.oauth2.provider.code.AuthorizationCodeTokenGranter类的典型用法代码示例。如果您正苦于以下问题:Java AuthorizationCodeTokenGranter类的具体用法?Java AuthorizationCodeTokenGranter怎么用?Java AuthorizationCodeTokenGranter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AuthorizationCodeTokenGranter类属于org.springframework.security.oauth2.provider.code包,在下文中一共展示了AuthorizationCodeTokenGranter类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCustomizedTokenGranters
import org.springframework.security.oauth2.provider.code.AuthorizationCodeTokenGranter; //导入依赖的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: getTokenGranter
import org.springframework.security.oauth2.provider.code.AuthorizationCodeTokenGranter; //导入依赖的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);
}
}
示例3: tokenGranter
import org.springframework.security.oauth2.provider.code.AuthorizationCodeTokenGranter; //导入依赖的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);
}
示例4: compositeTokenGranter
import org.springframework.security.oauth2.provider.code.AuthorizationCodeTokenGranter; //导入依赖的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);
}