update 格式化全部代码

This commit is contained in:
疯狂的狮子Li
2026-06-04 16:08:04 +08:00
parent e08160afb6
commit 2d4d7b6fb1
190 changed files with 795 additions and 845 deletions
@@ -31,15 +31,15 @@ public abstract class AbstractAuthWeChatEnterpriseRequest extends AuthDefaultReq
* @param source 授权来源
*/
public AbstractAuthWeChatEnterpriseRequest(AuthConfig config, AuthSource source) {
super(config,source);
super(config, source);
}
/**
* 创建企业微信认证请求。
*
* @param config 授权配置
* @param source 授权来源
* @param config 授权配置
* @param source 授权来源
* @param authStateCache 授权状态缓存
*/
public AbstractAuthWeChatEnterpriseRequest(AuthConfig config, AuthSource source, AuthStateCache authStateCache) {
@@ -38,7 +38,7 @@ public class AuthDingTalkV2Request extends AuthDefaultRequest {
/**
* 创建钉钉 V2 认证请求。
*
* @param config 授权配置
* @param config 授权配置
* @param authStateCache 授权状态缓存
*/
public AuthDingTalkV2Request(AuthConfig config, AuthStateCache authStateCache) {
@@ -35,7 +35,7 @@ public class AuthGiteaRequest extends AuthDefaultRequest {
/**
* 创建 Gitea 认证请求。
*
* @param config 授权配置
* @param config 授权配置
* @param authStateCache 授权状态缓存
*/
public AuthGiteaRequest(AuthConfig config, AuthStateCache authStateCache) {
@@ -61,12 +61,12 @@ public class AuthGiteaRequest extends AuthDefaultRequest {
throw new AuthException(object.getStr("message"));
}
return AuthToken.builder()
.accessToken(object.getStr("access_token"))
.refreshToken(object.getStr("refresh_token"))
.idToken(object.getStr("id_token"))
.tokenType(object.getStr("token_type"))
.scope(object.getStr("scope"))
.build();
.accessToken(object.getStr("access_token"))
.refreshToken(object.getStr("refresh_token"))
.idToken(object.getStr("id_token"))
.tokenType(object.getStr("token_type"))
.scope(object.getStr("scope"))
.build();
}
/**
@@ -78,11 +78,11 @@ public class AuthGiteaRequest extends AuthDefaultRequest {
@Override
protected String doPostAuthorizationCode(String code) {
HttpRequest request = HttpRequest.post(source.accessToken())
.form("client_id", config.getClientId())
.form("client_secret", config.getClientSecret())
.form("grant_type", "authorization_code")
.form("code", code)
.form("redirect_uri", config.getRedirectUri());
.form("client_id", config.getClientId())
.form("client_secret", config.getClientSecret())
.form("grant_type", "authorization_code")
.form("code", code)
.form("redirect_uri", config.getRedirectUri());
HttpResponse response = request.execute();
return response.body();
}
@@ -106,14 +106,14 @@ public class AuthGiteaRequest extends AuthDefaultRequest {
throw new AuthException(object.getStr("message"));
}
return AuthUser.builder()
.uuid(object.getStr("sub"))
.username(object.getStr("name"))
.nickname(object.getStr("preferred_username"))
.avatar(object.getStr("picture"))
.email(object.getStr("email"))
.token(authToken)
.source(source.toString())
.build();
.uuid(object.getStr("sub"))
.username(object.getStr("name"))
.nickname(object.getStr("preferred_username"))
.avatar(object.getStr("picture"))
.email(object.getStr("email"))
.token(authToken)
.source(source.toString())
.build();
}
}
@@ -12,7 +12,7 @@ import org.dromara.common.core.utils.SpringUtils;
import org.dromara.common.json.utils.JsonUtils;
/**
* @author 长春叭哥 2023年03月26日
* @author 长春叭哥 2023年03月26日
*/
public class AuthMaxKeyRequest extends AuthDefaultRequest {
@@ -31,7 +31,7 @@ public class AuthMaxKeyRequest extends AuthDefaultRequest {
/**
* 创建 MaxKey 认证请求。
*
* @param config 授权配置
* @param config 授权配置
* @param authStateCache 授权状态缓存
*/
public AuthMaxKeyRequest(AuthConfig config, AuthStateCache authStateCache) {
@@ -45,7 +45,7 @@ public class AuthTopIamRequest extends AuthDefaultRequest {
/**
* 创建 TopIAM 认证请求。
*
* @param config 授权配置
* @param config 授权配置
* @param authStateCache 授权状态缓存
*/
public AuthTopIamRequest(AuthConfig config, AuthStateCache authStateCache) {
@@ -124,7 +124,6 @@ public class AuthTopIamRequest extends AuthDefaultRequest {
.add("Authorization", "Bearer " + authToken.getAccessToken()), false).getBody();
}
/**
* 生成 TopIAM 授权地址。
*
@@ -19,16 +19,16 @@ import org.dromara.common.social.topiam.AuthTopIamRequest;
*
* @author thiszhc
*/
public class SocialUtils {
public class SocialUtils {
private static final AuthRedisStateCache STATE_CACHE = SpringUtils.getBean(AuthRedisStateCache.class);
/**
* 执行第三方登录授权回调。
*
* @param source 社交平台类型
* @param code 授权码
* @param state 状态值
* @param source 社交平台类型
* @param code 授权码
* @param state 状态值
* @param socialProperties 社交平台配置
* @return 授权响应
* @throws AuthException 授权异常
@@ -45,14 +45,14 @@ public class SocialUtils {
/**
* 根据平台类型构建授权请求实例。
*
* @param source 社交平台类型
* @param source 社交平台类型
* @param socialProperties 社交平台配置
* @return 授权请求
* @throws AuthException 授权异常
*/
public static AuthRequest getAuthRequest(String source, SocialProperties socialProperties) throws AuthException {
SocialLoginConfigProperties obj = socialProperties.getType().get(source);
if (ObjectUtil.isNull(obj)) {
if (ObjectUtil.isNull(obj)) {
throw new AuthException("不支持的第三方登录类型");
}
AuthConfig.AuthConfigBuilder builder = AuthConfig.builder()
@@ -69,7 +69,8 @@ public class SocialUtils {
case "coding" -> new AuthCodingRequest(builder.build(), STATE_CACHE);
case "oschina" -> new AuthOschinaRequest(builder.build(), STATE_CACHE);
// 支付宝在创建回调地址时,不允许使用localhost或者127.0.0.1,所以这儿的回调地址使用的局域网内的ip
case "alipay_wallet" -> new AuthAlipayRequest(builder.build(), socialProperties.getType().get("alipay_wallet").getAlipayPublicKey(), STATE_CACHE);
case "alipay_wallet" ->
new AuthAlipayRequest(builder.build(), socialProperties.getType().get("alipay_wallet").getAlipayPublicKey(), STATE_CACHE);
case "qq" -> new AuthQqRequest(builder.build(), STATE_CACHE);
case "wechat_open" -> new AuthWeChatOpenRequest(builder.build(), STATE_CACHE);
case "taobao" -> new AuthTaobaoRequest(builder.build(), STATE_CACHE);
@@ -77,9 +78,11 @@ public class SocialUtils {
case "linkedin" -> new AuthLinkedinRequest(builder.build(), STATE_CACHE);
case "microsoft" -> new AuthMicrosoftRequest(builder.tenantId(obj.getTenantId()).build(), STATE_CACHE);
case "renren" -> new AuthRenrenRequest(builder.build(), STATE_CACHE);
case "stack_overflow" -> new AuthStackOverflowRequest(builder.stackOverflowKey(obj.getStackOverflowKey()).build(), STATE_CACHE);
case "stack_overflow" ->
new AuthStackOverflowRequest(builder.stackOverflowKey(obj.getStackOverflowKey()).build(), STATE_CACHE);
case "huawei" -> new AuthHuaweiV3Request(builder.build(), STATE_CACHE);
case "wechat_enterprise" -> new AuthWeChatEnterpriseQrcodeV2Request(builder.agentId(obj.getAgentId()).build(), STATE_CACHE);
case "wechat_enterprise" ->
new AuthWeChatEnterpriseQrcodeV2Request(builder.agentId(obj.getAgentId()).build(), STATE_CACHE);
case "gitlab" -> new AuthGitlabRequest(builder.build(), STATE_CACHE);
case "wechat_mp" -> new AuthWeChatMpRequest(builder.build(), STATE_CACHE);
case "aliyun" -> new AuthAliyunRequest(builder.build(), STATE_CACHE);