更改 sa-token-oauth2 实体类相关包位置

This commit is contained in:
click33
2024-08-14 13:27:35 +08:00
parent 890da5d934
commit 47cf8939cb
14 changed files with 202 additions and 187 deletions

View File

@@ -15,7 +15,7 @@
*/
package cn.dev33.satoken.oauth2.data.loader;
import cn.dev33.satoken.oauth2.model.SaClientModel;
import cn.dev33.satoken.oauth2.data.model.SaClientModel;
/**
* Sa-Token OAuth2 数据加载器

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.dev33.satoken.oauth2.model;
package cn.dev33.satoken.oauth2.data.model;
import java.io.Serializable;
import java.util.LinkedHashMap;

View File

@@ -1,96 +1,96 @@
/*
* Copyright 2020-2099 sa-token.cc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.dev33.satoken.oauth2.model;
import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* Model: Client-Token
*
* @author click33
* @since 1.23.0
*/
public class ClientTokenModel implements Serializable {
private static final long serialVersionUID = -6541180061782004705L;
/**
* Client-Token
*/
public String clientToken;
/**
* Client-Token 到期时间
*/
public long expiresTime;
/**
* 应用id
*/
public String clientId;
/**
* 授权范围
*/
public String scope;
public ClientTokenModel() {}
/**
* 构建一个
* @param accessToken accessToken
* @param clientId 应用id
* @param scope 请求授权范围
*/
public ClientTokenModel(String accessToken, String clientId, String scope) {
super();
this.clientToken = accessToken;
this.clientId = clientId;
this.scope = scope;
}
@Override
public String toString() {
return "ClientTokenModel [clientToken=" + clientToken + ", expiresTime=" + expiresTime + ", clientId="
+ clientId + ", scope=" + scope + "]";
}
/**
* 获取 Client-Token 的剩余有效期
* @return see note
*/
public long getExpiresIn() {
long s = (expiresTime - System.currentTimeMillis()) / 1000;
return s < 1 ? -2 : s;
}
/**
* 将所有属性转换为下划线形式的Map
* @return 属性转Map
*/
public Map<String, Object> toLineMap() {
Map<String, Object> map = new LinkedHashMap<>();
map.put("client_token", clientToken);
map.put("expires_in", getExpiresIn());
map.put("client_id", clientId);
map.put("scope", scope);
return map;
}
}
/*
* Copyright 2020-2099 sa-token.cc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.dev33.satoken.oauth2.data.model;
import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* Model: Client-Token
*
* @author click33
* @since 1.23.0
*/
public class ClientTokenModel implements Serializable {
private static final long serialVersionUID = -6541180061782004705L;
/**
* Client-Token
*/
public String clientToken;
/**
* Client-Token 到期时间
*/
public long expiresTime;
/**
* 应用id
*/
public String clientId;
/**
* 授权范围
*/
public String scope;
public ClientTokenModel() {}
/**
* 构建一个
* @param accessToken accessToken
* @param clientId 应用id
* @param scope 请求授权范围
*/
public ClientTokenModel(String accessToken, String clientId, String scope) {
super();
this.clientToken = accessToken;
this.clientId = clientId;
this.scope = scope;
}
@Override
public String toString() {
return "ClientTokenModel [clientToken=" + clientToken + ", expiresTime=" + expiresTime + ", clientId="
+ clientId + ", scope=" + scope + "]";
}
/**
* 获取 Client-Token 的剩余有效期
* @return see note
*/
public long getExpiresIn() {
long s = (expiresTime - System.currentTimeMillis()) / 1000;
return s < 1 ? -2 : s;
}
/**
* 将所有属性转换为下划线形式的Map
* @return 属性转Map
*/
public Map<String, Object> toLineMap() {
Map<String, Object> map = new LinkedHashMap<>();
map.put("client_token", clientToken);
map.put("expires_in", getExpiresIn());
map.put("client_id", clientId);
map.put("scope", scope);
return map;
}
}

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.dev33.satoken.oauth2.model;
package cn.dev33.satoken.oauth2.data.model;
import java.io.Serializable;

View File

@@ -1,75 +1,75 @@
/*
* Copyright 2020-2099 sa-token.cc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.dev33.satoken.oauth2.model;
import java.io.Serializable;
/**
* Model: Refresh-Token
*
* @author click33
* @since 1.23.0
*/
public class RefreshTokenModel implements Serializable {
private static final long serialVersionUID = -6541180061782004705L;
/**
* Refresh-Token
*/
public String refreshToken;
/**
* Refresh-Token 到期时间
*/
public long expiresTime;
/**
* 应用id
*/
public String clientId;
/**
* 授权范围
*/
public String scope;
/**
* 对应账号id
*/
public Object loginId;
/**
* 对应账号id
*/
public String openid;
@Override
public String toString() {
return "RefreshTokenModel [refreshToken=" + refreshToken + ", expiresTime=" + expiresTime
+ ", clientId=" + clientId + ", scope=" + scope + ", loginId=" + loginId + ", openid=" + openid + "]";
}
/**
* 获取 Refresh-Token 的剩余有效期
* @return see note
*/
public long getExpiresIn() {
long s = (expiresTime - System.currentTimeMillis()) / 1000;
return s < 1 ? -2 : s;
}
}
/*
* Copyright 2020-2099 sa-token.cc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.dev33.satoken.oauth2.data.model;
import java.io.Serializable;
/**
* Model: Refresh-Token
*
* @author click33
* @since 1.23.0
*/
public class RefreshTokenModel implements Serializable {
private static final long serialVersionUID = -6541180061782004705L;
/**
* Refresh-Token
*/
public String refreshToken;
/**
* Refresh-Token 到期时间
*/
public long expiresTime;
/**
* 应用id
*/
public String clientId;
/**
* 授权范围
*/
public String scope;
/**
* 对应账号id
*/
public Object loginId;
/**
* 对应账号id
*/
public String openid;
@Override
public String toString() {
return "RefreshTokenModel [refreshToken=" + refreshToken + ", expiresTime=" + expiresTime
+ ", clientId=" + clientId + ", scope=" + scope + ", loginId=" + loginId + ", openid=" + openid + "]";
}
/**
* 获取 Refresh-Token 的剩余有效期
* @return see note
*/
public long getExpiresIn() {
long s = (expiresTime - System.currentTimeMillis()) / 1000;
return s < 1 ? -2 : s;
}
}

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.dev33.satoken.oauth2.model;
package cn.dev33.satoken.oauth2.data.model;
import java.io.Serializable;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.dev33.satoken.oauth2.model;
package cn.dev33.satoken.oauth2.data.model;
import java.io.Serializable;

View File

@@ -15,8 +15,8 @@
*/
package cn.dev33.satoken.oauth2.data.resolver;
import cn.dev33.satoken.oauth2.model.AccessTokenModel;
import cn.dev33.satoken.oauth2.model.ClientTokenModel;
import cn.dev33.satoken.oauth2.data.model.AccessTokenModel;
import cn.dev33.satoken.oauth2.data.model.ClientTokenModel;
import cn.dev33.satoken.util.SaResult;
import java.util.Map;

View File

@@ -16,8 +16,8 @@
package cn.dev33.satoken.oauth2.data.resolver;
import cn.dev33.satoken.oauth2.consts.SaOAuth2Consts.TokenType;
import cn.dev33.satoken.oauth2.model.AccessTokenModel;
import cn.dev33.satoken.oauth2.model.ClientTokenModel;
import cn.dev33.satoken.oauth2.data.model.AccessTokenModel;
import cn.dev33.satoken.oauth2.data.model.ClientTokenModel;
import cn.dev33.satoken.util.SaResult;
import java.util.LinkedHashMap;

View File

@@ -26,9 +26,9 @@ import cn.dev33.satoken.oauth2.consts.SaOAuth2Consts.Api;
import cn.dev33.satoken.oauth2.consts.SaOAuth2Consts.GrantType;
import cn.dev33.satoken.oauth2.consts.SaOAuth2Consts.Param;
import cn.dev33.satoken.oauth2.consts.SaOAuth2Consts.ResponseType;
import cn.dev33.satoken.oauth2.data.model.*;
import cn.dev33.satoken.oauth2.error.SaOAuth2ErrorCode;
import cn.dev33.satoken.oauth2.exception.SaOAuth2Exception;
import cn.dev33.satoken.oauth2.model.*;
import cn.dev33.satoken.oauth2.template.SaOAuth2Template;
import cn.dev33.satoken.stp.StpLogic;
import cn.dev33.satoken.stp.StpUtil;

View File

@@ -19,9 +19,9 @@ import cn.dev33.satoken.SaManager;
import cn.dev33.satoken.context.model.SaRequest;
import cn.dev33.satoken.oauth2.SaOAuth2Manager;
import cn.dev33.satoken.oauth2.consts.SaOAuth2Consts.Param;
import cn.dev33.satoken.oauth2.data.model.*;
import cn.dev33.satoken.oauth2.error.SaOAuth2ErrorCode;
import cn.dev33.satoken.oauth2.exception.SaOAuth2Exception;
import cn.dev33.satoken.oauth2.model.*;
import cn.dev33.satoken.strategy.SaStrategy;
import cn.dev33.satoken.util.SaFoxUtil;

View File

@@ -16,7 +16,7 @@
package cn.dev33.satoken.oauth2.template;
import cn.dev33.satoken.context.model.SaRequest;
import cn.dev33.satoken.oauth2.model.*;
import cn.dev33.satoken.oauth2.data.model.*;
import cn.dev33.satoken.oauth2.processor.SaOAuth2ServerProcessor;
/**