org.springframework.security.oauth2.provider.refresh.RefreshTokenGranter Java Examples
The following examples show how to use
org.springframework.security.oauth2.provider.refresh.RefreshTokenGranter.
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: OAuth2Config.java From spring-auth-example with MIT License | 6 votes |
@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)); }
Example #3
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 #4
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 #5
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 #6
Source File: OAuth2Config.java From spring-cloud-gray with Apache License 2.0 | 4 votes |
@Bean public RefreshTokenGranter refreshTokenGranter(AuthorizationServerTokenServices tokenServices, ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory) { return new RefreshTokenGranter(tokenServices, clientDetailsService, requestFactory); }
Example #7
Source File: AuthorizationConfig.java From springcloud-oauth2 with MIT License | votes |
/** * 创建grant_type列表 * @param endpoints * @return */ private TokenGranter tokenGranter(AuthorizationServerEndpointsConfigurer endpoints) { List<TokenGranter> list = new ArrayList<>(); // 这里配置密码模式、刷新token模式、自定义手机号验证码模式、授权码模式、简化模式 list.add(new ResourceOwnerPasswordTokenGranter(authenticationManager, endpoints.getTokenServices(), endpoints.getClientDetailsService(), endpoints.getOAuth2RequestFactory())); list.add(new RefreshTokenGranter(endpoints.getTokenServices(), endpoints.getClientDetailsService(), endpoints.getOAuth2RequestFactory())); list.add(new MobileCodeTokenGranter(authenticationManager,endpoints.getTokenServices(), endpoints.getClientDetailsService(), endpoints.getOAuth2RequestFactory())); list.add(new AuthorizationCodeTokenGranter(endpoints.getTokenServices(),endpoints.getAuthorizationCodeServices(), endpoints.getClientDetailsService(), endpoints.getOAuth2RequestFactory())); list.add(new ImplicitTokenGranter(endpoints.getTokenServices(),endpoints.getClientDetailsService(),endpoints.getOAuth2RequestFactory())); return new CompositeTokenGranter(list); }