fix:支付宝小程序登录以及支付宝支付

This commit is contained in:
2026-06-16 16:55:49 +08:00
parent 815b0e3731
commit 0ac3bece42
80 changed files with 5841 additions and 30 deletions
@@ -0,0 +1,54 @@
package com.central.oauth2.common.token;
import lombok.Getter;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.oauth2.core.AuthorizationGrantType;
import java.util.Collection;
/**
* 支付宝小程序登录 Token(对标 TencentAuthenticationToken)
*
* @author duzhichao
* @date 2026-05-12
*/
@Getter
public class AlipayAuthenticationToken extends BaseAuthenticationToken {
public static final AuthorizationGrantType GRANT_TYPE = new AuthorizationGrantType("alipay");
private final Object principal;
private final String encryptedPhone;
private final String appCode;
/**
* 未认证构造(code 模式)
* <p>
* 不能在此构造函数中设置 authenticated=true:此时仅持有 code/encryptedPhone/appCode,
* 真正的用户身份必须由 AlipayAuthenticationProvider 调用支付宝接口换取后再产生。
*/
public AlipayAuthenticationToken(String code, String encryptedPhone, String appCode) {
super(GRANT_TYPE);
this.principal = code;
this.encryptedPhone = encryptedPhone;
this.appCode = appCode;
super.setAuthenticated(false);
}
/**
* 已认证构造(UserDetails 模式)
* <p>
* 由 Provider 在完成支付宝换登录态 + 用户加载后调用,标记为已认证。
*/
public AlipayAuthenticationToken(UserDetails user,
Collection<? extends GrantedAuthority> authorities,
String encryptedPhone,
String appCode) {
super(authorities);
this.principal = user;
this.encryptedPhone = encryptedPhone;
this.appCode = appCode;
super.setAuthenticated(true);
}
}