@Override public OAuth2AccessToken grant(String grantType, TokenRequest tokenRequest) { if (delegate == null) { delegate = new CompositeTokenGranter(getDefaultTokenGranters()); } return delegate.grant(grantType, tokenRequest); } };
private TokenGranter tokenGranter(final AuthorizationServerEndpointsConfigurer endpoints) { List<TokenGranter> granters = new ArrayList<TokenGranter>(Arrays.asList(endpoints.getTokenGranter())); granters.add(new CustomTokenGranter(endpoints.getTokenServices(), endpoints.getClientDetailsService(), endpoints.getOAuth2RequestFactory(), "custom")); return new CompositeTokenGranter(granters); }
@Before public void setup() { compositeTokenGranter = new CompositeTokenGranter(emptyList()); userTokenGranter = new UserTokenGranter( mock(AuthorizationServerTokenServices.class), mock(ClientServicesExtension.class), mock(OAuth2RequestFactory.class), mock(RevocableTokenProvisioning.class) ); }
@Override public OAuth2AccessToken grant(String grantType, TokenRequest tokenRequest) { if (delegate == null) { delegate = new CompositeTokenGranter(getDefaultTokenGranters()); } return delegate.grant(grantType, tokenRequest); } };
@Bean public TokenGranter tokenGranter() { List<TokenGranter> tokenGranters = new ArrayList<TokenGranter>(); tokenGranters.add( new RefreshTokenGranter(tokenServices(), clientDetailsService, oauth2RequestFactory())); tokenGranters.add( new ResourceOwnerPasswordTokenGranter(authenticationManager, tokenServices(), clientDetailsService, oauth2RequestFactory())); return new CompositeTokenGranter(tokenGranters); }
@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); }