Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YZG
yzg-util
Commits
12ed2d1a
Commit
12ed2d1a
authored
Jun 27, 2023
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
表结构修改
parent
99960763
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
3 deletions
+58
-3
RsaHelper.java
.../src/main/java/com/yanzuoguang/util/helper/RsaHelper.java
+2
-2
TokenData.java
...til-db/src/main/java/com/yanzuoguang/token/TokenData.java
+24
-0
TokenHelper.java
...l-db/src/main/java/com/yanzuoguang/token/TokenHelper.java
+32
-1
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/RsaHelper.java
View file @
12ed2d1a
...
...
@@ -499,12 +499,12 @@ public final class RsaHelper {
this
.
initFromWithTo
();
}
p
rivate
void
initToWithFrom
()
{
p
ublic
void
initToWithFrom
()
{
this
.
publicKey
=
encodeBase64
(
this
.
publicKeyFrom
.
getEncoded
());
this
.
privateKey
=
encodeBase64
(
this
.
privateKeyFrom
.
getEncoded
());
}
p
rivate
void
initFromWithTo
()
{
p
ublic
void
initFromWithTo
()
{
this
.
publicKeyFrom
=
RsaHelper
.
getPublicKey
(
this
.
publicKey
);
this
.
privateKeyFrom
=
RsaHelper
.
getPrivateKey
(
this
.
privateKey
);
}
...
...
yzg-util-db/src/main/java/com/yanzuoguang/token/TokenData.java
View file @
12ed2d1a
...
...
@@ -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
;
}
...
...
yzg-util-db/src/main/java/com/yanzuoguang/token/TokenHelper.java
View file @
12ed2d1a
...
...
@@ -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
);
}
/**
* 设置登录标记字符串(用于初始化设置,本次修改不会写入到数据库)
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment