package com.jeelowcode.service.system.config.social;

import cn.hutool.extra.spring.SpringUtil;
import com.xingyuv.jushauth.config.AuthSource;
import com.xingyuv.jushauth.request.AuthDefaultRequest;

/**
 * 中国星网办公网认证源
 * <p>
 * author: shelly chan
 * date: 2025/09/19
 */
public enum ChinaSatelliteAuthSource implements AuthSource {

    /**
     * 获取认证授权地址
     */
    CHINA_SATELLITE_NET {
        @Override
        public String authorize() {
            String profile = SpringUtil.getActiveProfile();
            if ("test".equals(profile)) {
                return "https://sso-sy.chinasatnet.com.cn/authn-api/v5/oauth/authorize";
            }
            // 默认返回生产环境地址
            return "https://sso-new.chinasatnet.com.cn/authn-api/v5/oauth/authorize";
        }

        @Override
        public String accessToken() {
            String profile = SpringUtil.getActiveProfile();
            if ("test".equals(profile)) {
                return "https://sso-sy.chinasatnet.com.cn/authn-api/v5/oauth/token";
            }
            return "https://sso-new.chinasatnet.com.cn/authn-api/v5/oauth/token";
        }

        @Override
        public String userInfo() {
            String profile = SpringUtil.getActiveProfile();
            if ("test".equals(profile)) {
                return "https://sso-sy.chinasatnet.com.cn/authn-api/v5/oauth/user-info";
            }
            return "https://sso-new.chinasatnet.com.cn/authn-api/v5/oauth/user-info";
        }

        @Override
        public Class<? extends AuthDefaultRequest> getTargetClass() {
            return ChinaSatelliteAuthRequest.class;
        }

    };

}
