mirror of
https://gitee.com/dromara/sa-token.git
synced 2025-05-03 04:13:46 +08:00
更改 sa-token-oauth2 实体类相关包位置
This commit is contained in:
parent
890da5d934
commit
47cf8939cb
@ -96,7 +96,7 @@ public class SaSession implements SaSetValueInterface, Serializable {
|
||||
/**
|
||||
* 所有挂载数据
|
||||
*/
|
||||
private final Map<String, Object> dataMap = new ConcurrentHashMap<>();
|
||||
private Map<String, Object> dataMap = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
// ----------------------- 构建相关
|
||||
@ -522,14 +522,26 @@ public class SaSession implements SaSetValueInterface, Serializable {
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据挂载集合 (改变底层对象引用,将 dataMap 整个对象替换)
|
||||
* @param dataMap 数据集合
|
||||
*
|
||||
* @return 对象自身
|
||||
*/
|
||||
public SaSession setDataMap(Map<String, Object> dataMap) {
|
||||
this.dataMap = dataMap;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入数据集合 (不改变底层对象引用,只将此 dataMap 所有数据进行替换)
|
||||
* @param dataMap 数据集合
|
||||
*/
|
||||
public void refreshDataMap(Map<String, Object> dataMap) {
|
||||
public SaSession refreshDataMap(Map<String, Object> dataMap) {
|
||||
this.dataMap.clear();
|
||||
this.dataMap.putAll(dataMap);
|
||||
this.update();
|
||||
return this;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -1,7 +1,8 @@
|
||||
package com.pj.oauth2;
|
||||
|
||||
import cn.dev33.satoken.oauth2.data.loader.SaOAuth2DataLoader;
|
||||
import cn.dev33.satoken.oauth2.model.SaClientModel;
|
||||
import cn.dev33.satoken.oauth2.data.model.SaClientModel;
|
||||
import cn.dev33.satoken.secure.SaSecureUtil;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
@ -31,7 +32,9 @@ public class SaOAuth2DataLoaderImpl implements SaOAuth2DataLoader {
|
||||
@Override
|
||||
public String getOpenid(String clientId, Object loginId) {
|
||||
// 此为模拟数据,真实环境需要从数据库查询
|
||||
return "gr_SwoIN0MC1ewxHX_vfCW3BothWDZMMtx__";
|
||||
// return "gr_SwoIN0MC1ewxHX_vfCW3BothWDZMMtx__";
|
||||
String prefix = "grSwoIN0MC1ewxHXvfCW3BothWDZMMtx";
|
||||
return SaSecureUtil.md5(prefix + "_" + clientId + "_" + loginId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 数据加载器
|
||||
|
@ -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;
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user