Search in sources :

Example 1 with JdbcOAuth2AuthorizationService

use of org.springframework.security.oauth2.server.authorization.JdbcOAuth2AuthorizationService in project platform-base by SummerWindL.

the class AuthorizationConfig method authorizationService.

/**
 * 保存授权信息,授权服务器给我们颁发来token,那我们肯定需要保存吧,由这个服务来保存
 */
@Bean
public OAuth2AuthorizationService authorizationService(JdbcTemplate jdbcTemplate, RegisteredClientRepository registeredClientRepository) {
    JdbcOAuth2AuthorizationService authorizationService = new JdbcOAuth2AuthorizationService(jdbcTemplate, registeredClientRepository);
    class CustomOAuth2AuthorizationRowMapper extends JdbcOAuth2AuthorizationService.OAuth2AuthorizationRowMapper {

        public CustomOAuth2AuthorizationRowMapper(RegisteredClientRepository registeredClientRepository) {
            super(registeredClientRepository);
            getObjectMapper().configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
            this.setLobHandler(new DefaultLobHandler());
        }
    }
    CustomOAuth2AuthorizationRowMapper oAuth2AuthorizationRowMapper = new CustomOAuth2AuthorizationRowMapper(registeredClientRepository);
    authorizationService.setAuthorizationRowMapper(oAuth2AuthorizationRowMapper);
    return authorizationService;
}
Also used : RegisteredClientRepository(org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository) JdbcRegisteredClientRepository(org.springframework.security.oauth2.server.authorization.client.JdbcRegisteredClientRepository) DefaultLobHandler(org.springframework.jdbc.support.lob.DefaultLobHandler) Bean(org.springframework.context.annotation.Bean)

Example 2 with JdbcOAuth2AuthorizationService

use of org.springframework.security.oauth2.server.authorization.JdbcOAuth2AuthorizationService in project ordinaryroad by 1962247851.

the class AuthorizationServerConfig method authorizationService.

@Bean
public OAuth2AuthorizationService authorizationService(JdbcTemplate jdbcTemplate, RegisteredClientRepository registeredClientRepository) {
    JdbcOAuth2AuthorizationService jdbcOAuth2AuthorizationService = new JdbcOAuth2AuthorizationService(jdbcTemplate, registeredClientRepository);
    jdbcOAuth2AuthorizationService.setAuthorizationRowMapper(new CustomOAuth2AuthorizationRowMapper(registeredClientRepository));
    jdbcOAuth2AuthorizationService.setAuthorizationParametersMapper(new CustomOAuth2AuthorizationParametersMapper());
    return jdbcOAuth2AuthorizationService;
}
Also used : JdbcOAuth2AuthorizationService(org.springframework.security.oauth2.server.authorization.JdbcOAuth2AuthorizationService) Bean(org.springframework.context.annotation.Bean)

Example 3 with JdbcOAuth2AuthorizationService

use of org.springframework.security.oauth2.server.authorization.JdbcOAuth2AuthorizationService in project platform-base by SummerWindL.

the class AuthorizationConfig method authorizationService.

/**
 * 保存授权信息,授权服务器给我们颁发来token,那我们肯定需要保存吧,由这个服务来保存
 */
@Bean
public OAuth2AuthorizationService authorizationService(JdbcTemplate jdbcTemplate, RegisteredClientRepository registeredClientRepository) {
    JdbcOAuth2AuthorizationService authorizationService = new JdbcOAuth2AuthorizationService(jdbcTemplate, registeredClientRepository);
    class CustomOAuth2AuthorizationRowMapper extends JdbcOAuth2AuthorizationService.OAuth2AuthorizationRowMapper {

        public CustomOAuth2AuthorizationRowMapper(RegisteredClientRepository registeredClientRepository) {
            super(registeredClientRepository);
            getObjectMapper().configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
            this.setLobHandler(new DefaultLobHandler());
        }
    }
    CustomOAuth2AuthorizationRowMapper oAuth2AuthorizationRowMapper = new CustomOAuth2AuthorizationRowMapper(registeredClientRepository);
    authorizationService.setAuthorizationRowMapper(oAuth2AuthorizationRowMapper);
    return authorizationService;
}
Also used : RegisteredClientRepository(org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository) JdbcRegisteredClientRepository(org.springframework.security.oauth2.server.authorization.client.JdbcRegisteredClientRepository) DefaultLobHandler(org.springframework.jdbc.support.lob.DefaultLobHandler) Bean(org.springframework.context.annotation.Bean)

Example 4 with JdbcOAuth2AuthorizationService

use of org.springframework.security.oauth2.server.authorization.JdbcOAuth2AuthorizationService in project spring-authorization-server by spring-projects.

the class JdbcOAuth2AuthorizationServiceTests method setUp.

@Before
public void setUp() {
    this.db = createDb();
    this.jdbcOperations = new JdbcTemplate(this.db);
    this.registeredClientRepository = mock(RegisteredClientRepository.class);
    this.authorizationService = new JdbcOAuth2AuthorizationService(this.jdbcOperations, this.registeredClientRepository);
}
Also used : RegisteredClientRepository(org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository) JdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) Before(org.junit.Before)

Aggregations

Bean (org.springframework.context.annotation.Bean)3 RegisteredClientRepository (org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository)3 DefaultLobHandler (org.springframework.jdbc.support.lob.DefaultLobHandler)2 JdbcRegisteredClientRepository (org.springframework.security.oauth2.server.authorization.client.JdbcRegisteredClientRepository)2 Before (org.junit.Before)1 JdbcTemplate (org.springframework.jdbc.core.JdbcTemplate)1 JdbcOAuth2AuthorizationService (org.springframework.security.oauth2.server.authorization.JdbcOAuth2AuthorizationService)1