mirror of
https://gitee.com/dromara/sa-token.git
synced 2026-02-27 16:50:24 +08:00
将converXxx相关方法名称改为convertXxx
This commit is contained in:
@@ -1,21 +1,16 @@
|
||||
package cn.dev33.satoken.oauth2.logic;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cn.dev33.satoken.SaManager;
|
||||
import cn.dev33.satoken.context.model.SaRequest;
|
||||
import cn.dev33.satoken.oauth2.SaOAuth2Manager;
|
||||
import cn.dev33.satoken.oauth2.exception.SaOAuth2Exception;
|
||||
import cn.dev33.satoken.oauth2.logic.SaOAuth2Consts.Param;
|
||||
import cn.dev33.satoken.oauth2.model.AccessTokenModel;
|
||||
import cn.dev33.satoken.oauth2.model.ClientTokenModel;
|
||||
import cn.dev33.satoken.oauth2.model.CodeModel;
|
||||
import cn.dev33.satoken.oauth2.model.RefreshTokenModel;
|
||||
import cn.dev33.satoken.oauth2.model.RequestAuthModel;
|
||||
import cn.dev33.satoken.oauth2.model.SaClientModel;
|
||||
import cn.dev33.satoken.oauth2.model.*;
|
||||
import cn.dev33.satoken.strategy.SaStrategy;
|
||||
import cn.dev33.satoken.util.SaFoxUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Sa-Token-OAuth2 模块 代码实现
|
||||
* @author kong
|
||||
@@ -153,8 +148,8 @@ public class SaOAuth2Template {
|
||||
deleteRefreshToken(getRefreshTokenValue(cm.clientId, cm.loginId));
|
||||
|
||||
// 3、生成token
|
||||
AccessTokenModel at = converCodeToAccessToken(cm);
|
||||
RefreshTokenModel rt = converAccessTokenToRefreshToken(at);
|
||||
AccessTokenModel at = convertCodeToAccessToken(cm);
|
||||
RefreshTokenModel rt = convertAccessTokenToRefreshToken(at);
|
||||
at.refreshToken = rt.refreshToken;
|
||||
at.refreshExpiresTime = rt.expiresTime;
|
||||
|
||||
@@ -188,7 +183,7 @@ public class SaOAuth2Template {
|
||||
deleteRefreshToken(rt.refreshToken);
|
||||
|
||||
// 创建并保持新的 Refresh-Token
|
||||
rt = converRefreshTokenToRefreshToken(rt);
|
||||
rt = convertRefreshTokenToRefreshToken(rt);
|
||||
saveRefreshToken(rt);
|
||||
saveRefreshTokenIndex(rt);
|
||||
}
|
||||
@@ -197,7 +192,7 @@ public class SaOAuth2Template {
|
||||
deleteAccessToken(getAccessTokenValue(rt.clientId, rt.loginId));
|
||||
|
||||
// 生成新 Access-Token
|
||||
AccessTokenModel at = converRefreshTokenToAccessToken(rt);
|
||||
AccessTokenModel at = convertRefreshTokenToAccessToken(rt);
|
||||
|
||||
// 保存新 Access-Token
|
||||
saveAccessToken(at);
|
||||
@@ -228,7 +223,7 @@ public class SaOAuth2Template {
|
||||
|
||||
// 3、生成&保存 Refresh-Token
|
||||
if(isCreateRt) {
|
||||
RefreshTokenModel rt = converAccessTokenToRefreshToken(at);
|
||||
RefreshTokenModel rt = convertAccessTokenToRefreshToken(at);
|
||||
saveRefreshToken(rt);
|
||||
saveRefreshTokenIndex(rt);
|
||||
}
|
||||
@@ -440,13 +435,13 @@ public class SaOAuth2Template {
|
||||
return at;
|
||||
}
|
||||
|
||||
// ------------------- conver 数据转换
|
||||
// ------------------- convert 数据转换
|
||||
/**
|
||||
* 将 Code 转换为 Access-Token
|
||||
* @param cm CodeModel对象
|
||||
* @return AccessToken对象
|
||||
*/
|
||||
public AccessTokenModel converCodeToAccessToken(CodeModel cm) {
|
||||
public AccessTokenModel convertCodeToAccessToken(CodeModel cm) {
|
||||
AccessTokenModel at = new AccessTokenModel();
|
||||
at.accessToken = randomAccessToken(cm.clientId, cm.loginId, cm.scope);
|
||||
// at.refreshToken = randomRefreshToken(cm.clientId, cm.loginId, cm.scope);
|
||||
@@ -463,7 +458,7 @@ public class SaOAuth2Template {
|
||||
* @param at .
|
||||
* @return .
|
||||
*/
|
||||
public RefreshTokenModel converAccessTokenToRefreshToken(AccessTokenModel at) {
|
||||
public RefreshTokenModel convertAccessTokenToRefreshToken(AccessTokenModel at) {
|
||||
RefreshTokenModel rt = new RefreshTokenModel();
|
||||
rt.refreshToken = randomRefreshToken(at.clientId, at.loginId, at.scope);
|
||||
rt.clientId = at.clientId;
|
||||
@@ -481,7 +476,7 @@ public class SaOAuth2Template {
|
||||
* @param rt .
|
||||
* @return .
|
||||
*/
|
||||
public AccessTokenModel converRefreshTokenToAccessToken(RefreshTokenModel rt) {
|
||||
public AccessTokenModel convertRefreshTokenToAccessToken(RefreshTokenModel rt) {
|
||||
AccessTokenModel at = new AccessTokenModel();
|
||||
at.accessToken = randomAccessToken(rt.clientId, rt.loginId, rt.scope);
|
||||
at.refreshToken = rt.refreshToken;
|
||||
@@ -498,7 +493,7 @@ public class SaOAuth2Template {
|
||||
* @param rt .
|
||||
* @return .
|
||||
*/
|
||||
public RefreshTokenModel converRefreshTokenToRefreshToken(RefreshTokenModel rt) {
|
||||
public RefreshTokenModel convertRefreshTokenToRefreshToken(RefreshTokenModel rt) {
|
||||
RefreshTokenModel newRt = new RefreshTokenModel();
|
||||
newRt.refreshToken = randomRefreshToken(rt.clientId, rt.loginId, rt.scope);
|
||||
newRt.expiresTime = System.currentTimeMillis() + (SaOAuth2Manager.getConfig().getRefreshTokenTimeout() * 1000);
|
||||
|
||||
Reference in New Issue
Block a user