本文整理汇总了Java中org.springframework.security.oauth2.provider.TokenGranter类的典型用法代码示例。如果您正苦于以下问题:Java TokenGranter类的具体用法?Java TokenGranter怎么用?Java TokenGranter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TokenGranter类属于org.springframework.security.oauth2.provider包,在下文中一共展示了TokenGranter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCustomizedTokenGranters
import org.springframework.security.oauth2.provider.TokenGranter; //导入依赖的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.TokenGranter; //导入依赖的package包/类
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints)
throws Exception {
endpoints.tokenStore(tokenStore())
.tokenEnhancer(jwtTokenEnhancer())
.authenticationManager(authenticationManager)
.userDetailsService(userDetailsService);
List<TokenGranter> tokenGranters = new ArrayList<>();
tokenGranters
.add(new CustomResourceOwnerPasswordTokenGranter(authenticationManager,
endpoints.getTokenServices(), endpoints.getClientDetailsService(),
endpoints.getOAuth2RequestFactory()));
tokenGranters.add(new RefreshTokenGranter(endpoints.getTokenServices(),
endpoints.getClientDetailsService(),
endpoints.getOAuth2RequestFactory()));
endpoints.tokenGranter(new CompositeTokenGranter(tokenGranters));
}
示例3: tokenGranter
import org.springframework.security.oauth2.provider.TokenGranter; //导入依赖的package包/类
@Bean
public TokenGranter tokenGranter() throws Exception {
return new CompositeTokenGranter(Arrays.asList(new TokenGranter[]{
new ClientCredentialsTokenGranter(
tokenServices(), osiamClientDetailsService, oAuth2RequestFactory()
),
new OsiamResourceOwnerPasswordTokenGranter(
authenticationManager, tokenServices(), osiamClientDetailsService, oAuth2RequestFactory()
),
new RefreshTokenGranter(
tokenServices(), osiamClientDetailsService, oAuth2RequestFactory()
),
new LessStrictRedirectUriAuthorizationCodeTokenGranter(
tokenServices(), authorizationCodeServices(), osiamClientDetailsService, oAuth2RequestFactory()
)
}));
}
示例4: init
import org.springframework.security.oauth2.provider.TokenGranter; //导入依赖的package包/类
@Before
public void init() throws Exception {
client = new BaseClientDetails();
client.setRegisteredRedirectUri(Collections.singleton("http://anywhere.com"));
client.setAuthorizedGrantTypes(Arrays.asList("authorization_code", "implicit"));
endpoint.setClientDetailsService(new ClientDetailsService() {
public ClientDetails loadClientByClientId(String clientId) throws OAuth2Exception {
return client;
}
});
endpoint.setTokenGranter(new TokenGranter() {
public OAuth2AccessToken grant(String grantType, TokenRequest tokenRequest) {
return null;
}
});
endpoint.setRedirectResolver(new DefaultRedirectResolver());
endpoint.afterPropertiesSet();
}
示例5: tokenGranter
import org.springframework.security.oauth2.provider.TokenGranter; //导入依赖的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);
}
示例6: compositeTokenGranter
import org.springframework.security.oauth2.provider.TokenGranter; //导入依赖的package包/类
private TokenGranter compositeTokenGranter(AuthorizationServerEndpointsConfigurer endpoints) {
TokenGranter mobileIdTokenGranter = mobileIdTokenGranter(endpoints);
TokenGranter idCardTokenGranter = idCardTokenGranter(endpoints);
TokenGranter refreshTokenGranter = new RefreshTokenGranter(
endpoints.getTokenServices(), clientDetailsService(), endpoints.getOAuth2RequestFactory());
TokenGranter clientCredentialsTokenGranter =
new ClientCredentialsTokenGranter(
endpoints.getTokenServices(), clientDetailsService(), endpoints.getOAuth2RequestFactory());
return new CompositeTokenGranter(asList(mobileIdTokenGranter, idCardTokenGranter,
refreshTokenGranter, clientCredentialsTokenGranter));
}
示例7: tokenGranter
import org.springframework.security.oauth2.provider.TokenGranter; //导入依赖的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);
}
示例8: tokenGranter
import org.springframework.security.oauth2.provider.TokenGranter; //导入依赖的package包/类
private TokenGranter tokenGranter(final AuthorizationServerEndpointsConfigurer endpoints) {
List<TokenGranter> granters = new ArrayList<>(Arrays.asList(endpoints.getTokenGranter()));
extensionGrantManager.providers().forEach((id, tokenGranterProvider) -> {
CustomTokenGranter customTokenGranter = new CustomTokenGranter(endpoints.getTokenServices(), endpoints.getClientDetailsService(), endpoints.getOAuth2RequestFactory(), extensionGrantManager.getTokenGranter(id));
customTokenGranter.setExtensionGrantProvider(tokenGranterProvider);
customTokenGranter.setAuthenticationEventPublisher(new DefaultAuthenticationEventPublisher(applicationEventPublisher));
granters.add(customTokenGranter);
});
return new CompositeTokenGranter(granters);
}
开发者ID:gravitee-io,项目名称:graviteeio-access-management,代码行数:11,代码来源:AuthorizationServerConfiguration.java
示例9: compositeTokenGranter
import org.springframework.security.oauth2.provider.TokenGranter; //导入依赖的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);
}
示例10: TokenEndpoint
import org.springframework.security.oauth2.provider.TokenGranter; //导入依赖的package包/类
public TokenEndpoint(AuthenticationManager authenticationManager,
ClientDetailsService clientDetailsService, TokenGranter tokenGranter) {
this.clientDetailsService = clientDetailsService;
this.tokenGranter = tokenGranter;
this.basicAuthenticator = new BasicAuthenticator(authenticationManager);
this.requestFactory = new DefaultOAuth2RequestFactory(clientDetailsService);
}
示例11: AuthorizationEndpoint
import org.springframework.security.oauth2.provider.TokenGranter; //导入依赖的package包/类
public AuthorizationEndpoint(AuthorizationCodeServices authorizationCodeServices,
ClientDetailsService clientDetailsService,
TokenGranter tokenGranter,
TokenStoreUserApprovalHandler userApprovalHandler,
OAuth2RequestFactory requestFactory) {
this.userApprovalHandler = userApprovalHandler;
this.authorizationCodeServices = authorizationCodeServices;
this.clientDetailsService = clientDetailsService;
this.tokenGranter = tokenGranter;
this.requestFactory = requestFactory;
}
示例12: testImplicitUnapproved
import org.springframework.security.oauth2.provider.TokenGranter; //导入依赖的package包/类
@Test
public void testImplicitUnapproved() throws Exception {
endpoint.setTokenGranter(new TokenGranter() {
public OAuth2AccessToken grant(String grantType, TokenRequest tokenRequest) {
return null;
}
});
AuthorizationRequest authorizationRequest = getAuthorizationRequest("foo", "http://anywhere.com", "mystate",
"myscope", Collections.singleton("token"));
ModelAndView result = endpoint.authorize(model, authorizationRequest.getRequestParameters(),
sessionStatus, principal);
assertEquals("forward:/oauth/confirm_access", result.getViewName());
}
示例13: init
import org.springframework.security.oauth2.provider.TokenGranter; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void init(InitContext context, BeanFactory beanFactory) {
AuthorizationServerConfiguration authServerConfig = beanFactory.get(AuthorizationServerConfiguration.class);
TokenStore tokenStore = authServerConfig.getTokenStore();
UserDetailsService userService = authServerConfig.getUserDetailsService();
ClientDetailsService clientService = authServerConfig.getClientDetailsService();
DataSource dataSource = authServerConfig.getDataSource();
PreAuthenticatedAuthenticationProvider preProvider = new PreAuthenticatedAuthenticationProvider();
preProvider.setPreAuthenticatedUserDetailsService(new UserDetailsByNameServiceWrapper(userService));
DaoAuthenticationProvider clientAuthProvider = new DaoAuthenticationProvider();
clientAuthProvider.setUserDetailsService(new ClientDetailsUserDetailsService(clientService));
DaoAuthenticationProvider userAuthProvider = new DaoAuthenticationProvider();
userAuthProvider.setUserDetailsService(userService);
ProviderManager clientManager = new ProviderManager(singletonList(clientAuthProvider));
ProviderManager userManager = new ProviderManager(asList(userAuthProvider, preProvider));
AuthorizationCodeServices authServices = new InMemoryAuthorizationCodeServices();
OAuth2RequestFactory requestFactory = new DefaultOAuth2RequestFactory(clientService);
DefaultTokenServices tokenServices = tokenServices(clientService, userManager, tokenStore, dataSource);
TokenGranter tokenGranter = compositeTokenGranter(clientService, userManager, tokenServices, requestFactory,
authServices);
TokenEndpoint tokenEndpoint = new TokenEndpoint(clientManager, clientService, tokenGranter);
TokenStoreUserApprovalHandler userApprovalHandler = new TokenStoreUserApprovalHandler();
userApprovalHandler.setClientDetailsService(clientService);
userApprovalHandler.setRequestFactory(requestFactory);
userApprovalHandler.setTokenStore(tokenStore);
AuthorizationEndpoint authorizationEndpoint = new AuthorizationEndpoint(
authServices, clientService, tokenGranter, userApprovalHandler, requestFactory);
context.addControllerConfiguration(tokenEndpoint);
context.addControllerConfiguration(authorizationEndpoint);
context.addExceptionConfiguration(new OAuthExceptionConfiguration());
context.addInterceptor(new AuthenticationInterceptor(clientManager));
context.addInterceptor(new AuthorizationInterceptor());
}
示例14: setTokenGranter
import org.springframework.security.oauth2.provider.TokenGranter; //导入依赖的package包/类
public void setTokenGranter(TokenGranter tokenGranter) {
this.tokenGranter = tokenGranter;
}
示例15: getTokenGranter
import org.springframework.security.oauth2.provider.TokenGranter; //导入依赖的package包/类
protected TokenGranter getTokenGranter() {
return tokenGranter;
}