Java Code Examples for org.springframework.security.oauth2.provider.code.AuthorizationCodeServices

The following examples show how to use org.springframework.security.oauth2.provider.code.AuthorizationCodeServices. These examples are extracted from open source projects. 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
/**
 * 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 2
/**
 * 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 3
Source Project: oauth2lab   Source File: OAuth2Configuration.java    License: MIT License 5 votes vote down vote up
@Bean
public TokenGranter tokenGranter() {

    DefaultOAuth2RequestFactory requestFactory = new DefaultOAuth2RequestFactory(clientDetailsService());

    AuthorizationCodeServices codeServices = authorizationCodeServices();

    AuthorizationServerTokenServices tokenServices = tokenServices();
    List<TokenGranter> tokenGranters = Arrays.asList(
            new AuthorizationCodeTokenGranter(tokenServices, codeServices, clientDetailsService(), requestFactory),
            new ResourceOwnerPasswordTokenGranter(authenticationManager, tokenServices, clientDetailsService(), requestFactory),
            new ImplicitTokenGranter(tokenServices, clientDetailsService(), requestFactory));

    return new CompositeTokenGranter(tokenGranters);
}
 
Example 4
Source Project: oauth2lab   Source File: AuthorizationServerConfiguration.java    License: MIT License 5 votes vote down vote up
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
    endpoints.authenticationManager(authenticationManager);
    endpoints.tokenStore(tokenStore);
    endpoints.tokenGranter(tokenGranter);

    AuthorizationCodeServices codeServices = authorizationCodeServices;

    endpoints.authorizationCodeServices(codeServices);
}
 
Example 5
Source Project: spring-cloud-shop   Source File: OAuth2SecurityConfiguration.java    License: MIT License 5 votes vote down vote up
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());
}
 
Example 6
Source Project: OAuth-2.0-Cookbook   Source File: OAuth2Configuration.java    License: MIT License 5 votes vote down vote up
@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);
}
 
Example 7
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
    endpoints.authenticationManager(authenticationManager);
    endpoints.tokenStore(tokenStore);
    endpoints.tokenGranter(tokenGranter);

    AuthorizationCodeServices codeServices = authorizationCodeServices;

    endpoints.authorizationCodeServices(codeServices);
}
 
Example 8
public LessStrictRedirectUriAuthorizationCodeTokenGranter(
        AuthorizationServerTokenServices tokenServices,
        AuthorizationCodeServices authorizationCodeServices,
        ClientDetailsService clientDetailsService,
        OAuth2RequestFactory requestFactory
) {
    super(tokenServices, clientDetailsService, requestFactory, GRANT_TYPE);
    this.authorizationCodeServices = authorizationCodeServices;
}
 
Example 9
private AuthorizationCodeServices authorizationCodeServices() {
    return new InMemoryAuthorizationCodeServices();
}
 
Example 10
Source Project: cola   Source File: AuthorizationServerConfiguration.java    License: MIT License 4 votes vote down vote up
@Bean
public AuthorizationCodeServices authorizationCodeServices() {
	return new JdbcAuthorizationCodeServices(dataSource);
}
 
Example 11
private AuthorizationCodeServices authorizationCodeServices() {
    return new InMemoryAuthorizationCodeServices();
}
 
Example 12
Source Project: pacbot   Source File: AuthorizationServerConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public AuthorizationCodeServices authorizationCodeServices() {
    return new JdbcAuthorizationCodeServices(dataSource);
}
 
Example 13
Source Project: oauth2lab   Source File: OAuth2Configuration.java    License: MIT License 4 votes vote down vote up
@Bean
public AuthorizationCodeServices authorizationCodeServices() {
    return new InMemoryAuthorizationCodeServices();
}
 
Example 14
Source Project: spring-cloud-shop   Source File: AuthApplication.java    License: MIT License 4 votes vote down vote up
@Bean
public AuthorizationCodeServices jdbcAuthorizationCodeServices(DataSource dataSource) {
    return new JdbcAuthorizationCodeServices(dataSource);
}
 
Example 15
Source Project: JetfireCloud   Source File: AuthenticationServerConfig.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * 授权码模式持久名授权码
 *
 * @return
 */
@Bean
protected AuthorizationCodeServices authorizationCodeServices() {
    //授权码存储等处理方式类,使用jdbc,操作oauth_code表
    return new JdbcAuthorizationCodeServices(dataSource);
}
 
Example 16
Source Project: OAuth-2.0-Cookbook   Source File: CustomAuthCodeTokenGranter.java    License: MIT License 4 votes vote down vote up
public CustomAuthCodeTokenGranter(AuthorizationServerTokenServices tokenServices,
                                     AuthorizationCodeServices authorizationCodeServices, ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory) {
    this(tokenServices, authorizationCodeServices, clientDetailsService, requestFactory, GRANT_TYPE);
}
 
Example 17
Source Project: OAuth-2.0-Cookbook   Source File: CustomAuthCodeTokenGranter.java    License: MIT License 4 votes vote down vote up
protected CustomAuthCodeTokenGranter(AuthorizationServerTokenServices tokenServices, AuthorizationCodeServices authorizationCodeServices,
                                        ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory, String grantType) {
    super(tokenServices, clientDetailsService, requestFactory, grantType);
    this.authorizationCodeServices = authorizationCodeServices;
}
 
Example 18
Source Project: OAuth-2.0-Cookbook   Source File: OAuth2Configuration.java    License: MIT License 4 votes vote down vote up
@Bean
public AuthorizationCodeServices authorizationCodeServices() {
    return new InMemoryAuthorizationCodeServices();
}
 
Example 19
Source Project: SpringCloud   Source File: AuthorizationServerConfig.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * 授权码模式持久化授权码code
 *
 * @return JdbcAuthorizationCodeServices
 */
@Bean
protected AuthorizationCodeServices authorizationCodeServices() {
    // 授权码存储等处理方式类,使用jdbc,操作oauth_code表
    return new JdbcAuthorizationCodeServices(dataSource);
}
 
Example 20
@Bean
protected AuthorizationCodeServices authorizationCodeServices() {
    return new JdbcAuthorizationCodeServices(dataSource);
}
 
Example 21
Source Project: moserp   Source File: AuthorizationServerConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
protected AuthorizationCodeServices authorizationCodeServices() {
    return new InMemoryAuthorizationCodeServices();
}
 
Example 22
Source Project: osiam   Source File: OAuth2AuthorizationServerConfig.java    License: MIT License 4 votes vote down vote up
@Bean
public AuthorizationCodeServices authorizationCodeServices() {
    return new InMemoryAuthorizationCodeServices();
}
 
Example 23
@Bean
protected AuthorizationCodeServices authorizationCodeServices() {
	return new JdbcAuthorizationCodeServices(dataSource);
}
 
Example 24
@Bean
public AuthorizationCodeServices authorizationCodeServices(DataSource dataSource) {
    return new JdbcAuthorizationCodeServices(dataSource);
}
 
Example 25
Source Project: spring-oauth-example   Source File: OAuthConfiguration.java    License: MIT License 4 votes vote down vote up
@Bean
public AuthorizationCodeServices authorizationCodeServices() {
    return new JdbcAuthorizationCodeServices(oauthDataSource());
}
 
Example 26
Source Project: open-cloud   Source File: AuthorizationServerConfiguration.java    License: MIT License 2 votes vote down vote up
/**
 * 授权码存放
 *
 * @return
 */
@Bean
public AuthorizationCodeServices authorizationCodeServices() {
    return new JdbcAuthorizationCodeServices(dataSource);
}
 
Example 27
Source Project: open-cloud   Source File: AuthorizationServerConfiguration.java    License: MIT License 2 votes vote down vote up
/**
 * 授权码
 *
 * @return
 */
@Bean
public AuthorizationCodeServices authorizationCodeServices() {
    return new JdbcAuthorizationCodeServices(dataSource);
}
 
Example 28
Source Project: springcloud-oauth2   Source File: AuthorizationConfig.java    License: MIT License votes vote down vote up
/**
     * 配置授权码模式授权码服务,不配置默认为内存模式
     * @return
     */
    @Primary
    @Bean
    public AuthorizationCodeServices authorizationCodeServices() {
        return new RedisAuthorizationCodeServices(redisConnectionFactory);
    }