Commit 12ed2d1a authored by yanzg's avatar yanzg

表结构修改

parent 99960763
......@@ -499,12 +499,12 @@ public final class RsaHelper {
this.initFromWithTo();
}
private void initToWithFrom() {
public void initToWithFrom() {
this.publicKey = encodeBase64(this.publicKeyFrom.getEncoded());
this.privateKey = encodeBase64(this.privateKeyFrom.getEncoded());
}
private void initFromWithTo() {
public void initFromWithTo() {
this.publicKeyFrom = RsaHelper.getPublicKey(this.publicKey);
this.privateKeyFrom = RsaHelper.getPrivateKey(this.privateKey);
}
......
......@@ -19,6 +19,14 @@ public class TokenData {
* 数据密钥
*/
private String dataPwd;
/**
* 私钥
*/
private String privateKey;
/**
* 公钥
*/
private String publicKey;
/**
* 有效时间
......@@ -78,6 +86,22 @@ public class TokenData {
this.data = data;
}
public String getPrivateKey() {
return privateKey;
}
public void setPrivateKey(String privateKey) {
this.privateKey = privateKey;
}
public String getPublicKey() {
return publicKey;
}
public void setPublicKey(String publicKey) {
this.publicKey = publicKey;
}
public boolean isWrite() {
return write;
}
......
......@@ -4,6 +4,7 @@ import com.yanzuoguang.util.YzgError;
import com.yanzuoguang.util.base.ObjectHelper;
import com.yanzuoguang.util.cache.MemoryCache;
import com.yanzuoguang.util.helper.JsonHelper;
import com.yanzuoguang.util.helper.RsaHelper;
import com.yanzuoguang.util.helper.StringHelper;
import com.yanzuoguang.util.vo.MapRow;
......@@ -170,7 +171,6 @@ public class TokenHelper {
write(token, StringHelper.EMPTY, expire, data);
}
/**
* 缓存数据
*
......@@ -198,6 +198,37 @@ public class TokenHelper {
tokenData.setWrite(true);
}
/**
* 缓存数据
*
* @param token 标记
* @param rsaInfo RSA信息,包含公钥和私钥
* @param expire 有效期
* @param dataPwd 数据密码
* @param data 数据时间
*/
public static void write(String token, String dataPwd, RsaHelper.RsaInfo rsaInfo, long expire, Object data) {
String id = getCurrentId();
TokenData tokenData = cache.get(id);
if (tokenData == null) {
tokenData = new TokenData();
cache.put(id, tokenData);
}
tokenData.setToken(token);
tokenData.setDataPwd(dataPwd);
tokenData.setPublicKey(rsaInfo.getPublicKey());
tokenData.setPrivateKey(rsaInfo.getPrivateKey());
if (expire > 0) {
tokenData.setExpire(expire);
}
if (tokenData.getData() == null) {
tokenData.setData(new MapRow());
}
ObjectHelper.writeWithFrom(tokenData.getData(), data);
tokenData.setWrite(true);
}
/**
* 设置登录标记字符串(用于初始化设置,本次修改不会写入到数据库)
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment