org.springframework.security.oauth2.provider.client.ClientCredentialsTokenGranter Java Examples
The following examples show how to use
org.springframework.security.oauth2.provider.client.ClientCredentialsTokenGranter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OAuthRestController.java From spring-oauth-server with GNU General Public License v2.0 | 7 votes |
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); } }
Example #2
Source File: OAuth2AuthorizationServerConfig.java From osiam with MIT License | 6 votes |
@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() ) })); }
Example #3
Source File: ApiBootAuthorizationServerConfiguration.java From beihu-boot with Apache License 2.0 | 5 votes |
/** * Return all granters within oauth2 * Contains custom * * @return TokenGranter */ private List<TokenGranter> getDefaultTokenGranters() { ClientDetailsService clientDetails = clientDetailsService; AuthorizationServerTokenServices tokenServices = tokenServices(); AuthorizationCodeServices authorizationCodeServices = authorizationCodeServices(); OAuth2RequestFactory requestFactory = requestFactory(); List<TokenGranter> tokenGranters = new ArrayList<TokenGranter>(); // code tokenGranters.add(new AuthorizationCodeTokenGranter(tokenServices, authorizationCodeServices, clientDetails, requestFactory)); // refresh token tokenGranters.add(new RefreshTokenGranter(tokenServices, clientDetails, requestFactory)); // implicit ImplicitTokenGranter implicit = new ImplicitTokenGranter(tokenServices, clientDetails, requestFactory); tokenGranters.add(implicit); // client tokenGranters.add(new ClientCredentialsTokenGranter(tokenServices, clientDetails, requestFactory)); // password if (authenticationManager != null) { tokenGranters.add(new ResourceOwnerPasswordTokenGranter(authenticationManager, tokenServices, clientDetails, requestFactory)); } // have custom token granter if (!ObjectUtils.isEmpty(apiBootOauthTokenGranters)) { apiBootOauthTokenGranters.stream().forEach(apiBootOauthTokenGranter -> tokenGranters.add(new DefaultApiBootOauthTokenGranter(tokenServices, clientDetailsService, requestFactory, apiBootOauthTokenGranter))); } return tokenGranters; }
Example #4
Source File: ApiBootAuthorizationServerConfiguration.java From api-boot with Apache License 2.0 | 5 votes |
/** * Return all granters within oauth2 * Contains custom * * @return TokenGranter */ private List<TokenGranter> getDefaultTokenGranters() { ClientDetailsService clientDetails = clientDetailsService; AuthorizationServerTokenServices tokenServices = tokenServices(); AuthorizationCodeServices authorizationCodeServices = authorizationCodeServices(); OAuth2RequestFactory requestFactory = requestFactory(); List<TokenGranter> tokenGranters = new ArrayList<TokenGranter>(); // code tokenGranters.add(new AuthorizationCodeTokenGranter(tokenServices, authorizationCodeServices, clientDetails, requestFactory)); // refresh token tokenGranters.add(new RefreshTokenGranter(tokenServices, clientDetails, requestFactory)); // implicit ImplicitTokenGranter implicit = new ImplicitTokenGranter(tokenServices, clientDetails, requestFactory); tokenGranters.add(implicit); // client tokenGranters.add(new ClientCredentialsTokenGranter(tokenServices, clientDetails, requestFactory)); // password if (authenticationManager != null) { tokenGranters.add(new ResourceOwnerPasswordTokenGranter(authenticationManager, tokenServices, clientDetails, requestFactory)); } // have custom token granter if (!ObjectUtils.isEmpty(apiBootOauthTokenGranters)) { apiBootOauthTokenGranters.stream().forEach(apiBootOauthTokenGranter -> tokenGranters.add(new DefaultApiBootOauthTokenGranter(tokenServices, clientDetailsService, requestFactory, apiBootOauthTokenGranter))); } return tokenGranters; }
Example #5
Source File: OAuth2SecurityConfiguration.java From spring-cloud-shop with MIT License | 5 votes |
private List<TokenGranter> getTokenGranters(AuthorizationCodeServices authorizationCodeServices, AuthorizationServerTokenServices tokenServices, ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory) { return Stream.of( new ClientCredentialsTokenGranter(tokenServices, clientDetailsService, requestFactory), new ResourceOwnerPasswordTokenGranter(authenticationManager, tokenServices, clientDetailsService, requestFactory), new PhonePasswordTokenGranter(authenticationManager, tokenServices, clientDetailsService, requestFactory), new AuthorizationCodeTokenGranter(tokenServices, authorizationCodeServices, clientDetailsService, requestFactory), new SmsTokenGranter(userServiceImpl, tokenServices, clientDetailsService, requestFactory)) .collect(Collectors.toList()); }