All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.herodotus.engine.oauth2.data.jpa.configuration.OAuth2DataJpaConfiguration Maven / Gradle / Ivy

There is a newer version: 3.3.4.0
Show newest version
/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright (c) 2020-2030 郑庚伟 ZHENGGENGWEI (码匠君),  Licensed under the AGPL License
 *
 * This file is part of Herodotus Engine.
 *
 * Herodotus Engine is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Herodotus Engine is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see .
 */

package cn.herodotus.engine.oauth2.data.jpa.configuration;

import cn.herodotus.engine.oauth2.data.jpa.service.HerodotusAuthorizationConsentService;
import cn.herodotus.engine.oauth2.data.jpa.service.HerodotusAuthorizationService;
import cn.herodotus.engine.oauth2.data.jpa.service.HerodotusRegisteredClientService;
import cn.herodotus.engine.oauth2.data.jpa.storage.JpaOAuth2AuthorizationConsentService;
import cn.herodotus.engine.oauth2.data.jpa.storage.JpaOAuth2AuthorizationService;
import cn.herodotus.engine.oauth2.data.jpa.storage.JpaRegisteredClientRepository;
import jakarta.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationConsentService;
import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService;
import org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository;

/**
 * 

Description: OAuth2 Manager 模块配置

* * @author : gengwei.zheng * @date : 2022/3/1 18:25 */ @Configuration(proxyBeanMethods = false) @EntityScan(basePackages = { "cn.herodotus.engine.oauth2.data.jpa.entity" }) @EnableJpaRepositories(basePackages = { "cn.herodotus.engine.oauth2.data.jpa.repository", }) @ComponentScan(basePackages = { "cn.herodotus.engine.oauth2.data.jpa.service", }) public class OAuth2DataJpaConfiguration { private static final Logger log = LoggerFactory.getLogger(OAuth2DataJpaConfiguration.class); @PostConstruct public void postConstruct() { log.debug("[Herodotus] |- SDK [OAuth2 Data JPA] Auto Configure."); } @Bean @ConditionalOnMissingBean public RegisteredClientRepository registeredClientRepository(HerodotusRegisteredClientService herodotusRegisteredClientService, PasswordEncoder passwordEncoder) { JpaRegisteredClientRepository jpaRegisteredClientRepository = new JpaRegisteredClientRepository(herodotusRegisteredClientService, passwordEncoder); log.debug("[Herodotus] |- Bean [Jpa Registered Client Repository] Auto Configure."); return jpaRegisteredClientRepository; } @Bean @ConditionalOnMissingBean public OAuth2AuthorizationService authorizationService(HerodotusAuthorizationService herodotusAuthorizationService, RegisteredClientRepository registeredClientRepository) { JpaOAuth2AuthorizationService jpaOAuth2AuthorizationService = new JpaOAuth2AuthorizationService(herodotusAuthorizationService, registeredClientRepository); log.debug("[Herodotus] |- Bean [Jpa OAuth2 Authorization Service] Auto Configure."); return jpaOAuth2AuthorizationService; } @Bean @ConditionalOnMissingBean public OAuth2AuthorizationConsentService authorizationConsentService(HerodotusAuthorizationConsentService herodotusAuthorizationConsentService, RegisteredClientRepository registeredClientRepository) { JpaOAuth2AuthorizationConsentService jpaOAuth2AuthorizationConsentService = new JpaOAuth2AuthorizationConsentService(herodotusAuthorizationConsentService, registeredClientRepository); log.debug("[Herodotus] |- Bean [Jpa OAuth2 Authorization Consent Service] Auto Configure."); return jpaOAuth2AuthorizationConsentService; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy