Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
ioc_sixiang_license
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
zengtianlai3
ioc_sixiang_license
Commits
67ae1d61
Commit
67ae1d61
authored
Sep 07, 2022
by
ma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
采用rsa加密
parent
c6481e69
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
7 deletions
+31
-7
pom.xml
license/pom.xml
+7
-0
LoginController.java
.../java/iot/sixiang/license/controller/LoginController.java
+8
-4
UserController.java
...n/java/iot/sixiang/license/controller/UserController.java
+5
-2
LoginVo.java
...e/src/main/java/iot/sixiang/license/model/vo/LoginVo.java
+3
-0
application.yml
license/src/main/resources/application.yml
+8
-1
No files found.
license/pom.xml
View file @
67ae1d61
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
<description>
Demo project for Spring Boot
</description>
<description>
Demo project for Spring Boot
</description>
<properties>
<properties>
<java.version>
1.8
</java.version>
<java.version>
1.8
</java.version>
<acc.secret.version>
1.0.4
</acc.secret.version>
</properties>
</properties>
<dependencies>
<dependencies>
...
@@ -144,6 +145,12 @@
...
@@ -144,6 +145,12 @@
<version>
1.9
</version>
<version>
1.9
</version>
</dependency>
</dependency>
<dependency>
<groupId>
com.acc
</groupId>
<artifactId>
secret
</artifactId>
<version>
${acc.secret.version}
</version>
</dependency>
<!--邮件-->
<!--邮件-->
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
...
...
license/src/main/java/iot/sixiang/license/controller/LoginController.java
View file @
67ae1d61
package
iot
.
sixiang
.
license
.
controller
;
package
iot
.
sixiang
.
license
.
controller
;
import
com.acc.secret.util.RSAUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiImplicitParams
;
...
@@ -47,8 +48,10 @@ public class LoginController {
...
@@ -47,8 +48,10 @@ public class LoginController {
@Value
(
"${spring.mail.to}"
)
@Value
(
"${spring.mail.to}"
)
private
String
account
;
private
String
account
;
@Value
(
"${other.md5.salt}"
)
@Value
(
"${rsa.private_key}"
)
private
String
salt
;
private
String
PRIVATE_KRY
;
@Value
(
"${rsa.public_key}"
)
private
String
PUBLIC_KEY
;
private
static
final
String
USER_NAME
=
"root"
;
private
static
final
String
USER_NAME
=
"root"
;
/**
/**
...
@@ -68,9 +71,9 @@ public class LoginController {
...
@@ -68,9 +71,9 @@ public class LoginController {
}
}
User
user
=
userMapper
.
getUserByUserName
(
USER_NAME
);
User
user
=
userMapper
.
getUserByUserName
(
USER_NAME
);
String
name
=
USER_NAME
;
String
name
=
USER_NAME
;
String
p
sw
=
user
.
getPassword
();
String
p
wd
=
user
.
getPassword
();
LoginUser
dbUser
=
new
LoginUser
(
String
.
valueOf
(
user
.
getUserId
()),
user
.
getUserName
(),
user
.
getPassword
());
LoginUser
dbUser
=
new
LoginUser
(
String
.
valueOf
(
user
.
getUserId
()),
user
.
getUserName
(),
user
.
getPassword
());
if
(
DigestUtils
.
md5DigestAsHex
((
salt
+
name
+
salt
).
getBytes
()).
equals
(
userName
)
&&
psw
.
equals
(
passwor
d
))
{
if
(
name
.
equals
(
userName
)
&&
RSAUtil
.
getDecryptString
(
password
,
PRIVATE_KRY
).
equals
(
pw
d
))
{
// 登录错误次数
// 登录错误次数
Integer
errCnt
=
UserUtils
.
getErrCnt
(
userName
);
Integer
errCnt
=
UserUtils
.
getErrCnt
(
userName
);
Date
countFreezeDate
=
UserUtils
.
getCountFreezeDate
(
userName
);
Date
countFreezeDate
=
UserUtils
.
getCountFreezeDate
(
userName
);
...
@@ -84,6 +87,7 @@ public class LoginController {
...
@@ -84,6 +87,7 @@ public class LoginController {
LoginVo
loginVo
=
new
LoginVo
();
LoginVo
loginVo
=
new
LoginVo
();
loginVo
.
setAuthorization
(
token
);
loginVo
.
setAuthorization
(
token
);
loginVo
.
setUpdateTime
(
user
.
getUpdateTime
());
loginVo
.
setUpdateTime
(
user
.
getUpdateTime
());
loginVo
.
setPubKey
(
PUBLIC_KEY
);
UserUtils
.
setToken
(
dbUser
.
getUserId
(),
token
);
UserUtils
.
setToken
(
dbUser
.
getUserId
(),
token
);
UserUtils
.
setTokenExp
(
dbUser
.
getUserId
(),
JwtUtil
.
getTokenExp
());
UserUtils
.
setTokenExp
(
dbUser
.
getUserId
(),
JwtUtil
.
getTokenExp
());
UserUtils
.
removeErrCnt
(
userName
);
UserUtils
.
removeErrCnt
(
userName
);
...
...
license/src/main/java/iot/sixiang/license/controller/UserController.java
View file @
67ae1d61
package
iot
.
sixiang
.
license
.
controller
;
package
iot
.
sixiang
.
license
.
controller
;
import
com.acc.secret.util.RSAUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.github.xiaoymin.knife4j.annotations.ApiOperationSupport
;
import
com.github.xiaoymin.knife4j.annotations.ApiOperationSupport
;
import
com.github.xiaoymin.knife4j.annotations.DynamicParameter
;
import
com.github.xiaoymin.knife4j.annotations.DynamicParameter
;
...
@@ -45,8 +46,8 @@ public class UserController {
...
@@ -45,8 +46,8 @@ public class UserController {
@Autowired
@Autowired
private
UserService
userService
;
private
UserService
userService
;
@Value
(
"${
other.md5.salt
}"
)
@Value
(
"${
rsa.private_key
}"
)
private
String
salt
;
private
String
PRIVATE_KRY
;
@InitBinder
@InitBinder
public
void
initBinder
(
WebDataBinder
binder
)
{
public
void
initBinder
(
WebDataBinder
binder
)
{
...
@@ -135,6 +136,8 @@ public class UserController {
...
@@ -135,6 +136,8 @@ public class UserController {
}
else
{
}
else
{
return
BaseResult
.
failed
();
return
BaseResult
.
failed
();
}
}
oldPassWord
=
RSAUtil
.
getDecryptString
(
oldPassWord
,
PRIVATE_KRY
);
newPassWord
=
RSAUtil
.
getDecryptString
(
newPassWord
,
PRIVATE_KRY
);
if
(
oldPassWord
.
equals
(
user
.
getPassword
()))
{
if
(
oldPassWord
.
equals
(
user
.
getPassword
()))
{
user
.
setPassword
(
newPassWord
);
user
.
setPassword
(
newPassWord
);
boolean
b
=
userService
.
updateUser
(
user
);
boolean
b
=
userService
.
updateUser
(
user
);
...
...
license/src/main/java/iot/sixiang/license/model/vo/LoginVo.java
View file @
67ae1d61
...
@@ -14,6 +14,9 @@ public class LoginVo {
...
@@ -14,6 +14,9 @@ public class LoginVo {
@ApiModelProperty
(
"token"
)
@ApiModelProperty
(
"token"
)
private
String
authorization
;
private
String
authorization
;
@ApiModelProperty
(
"pubKey"
)
private
String
pubKey
;
@ApiModelProperty
(
"更新时间"
)
@ApiModelProperty
(
"更新时间"
)
private
Date
updateTime
;
private
Date
updateTime
;
}
}
license/src/main/resources/application.yml
View file @
67ae1d61
...
@@ -32,5 +32,12 @@ server:
...
@@ -32,5 +32,12 @@ server:
cros
:
cros
:
# 需要设置访问白名单
# 需要设置访问白名单
cros_allowed_origins
:
http://192.168.1.88:8080, http://localhost:8868
cros_allowed_origins
:
http://192.168.1.88:8080, http://localhost:8868
, http://localhost:8080
cros_allowed_method
:
GET,POST
cros_allowed_method
:
GET,POST
other
:
md5
:
salt
:
PI7dBYlEfeP8IZ6vogqFL1U5pVnyCuNAGja3lsREx4M9r0SX
rsa
:
public_key
:
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA18W2H1hO98dUWf1PNKNWTWmxCyvvy0NOR7iSvp76J0LdzyMJxs8WH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drgLQwtmLlHhFxfFURPh6au8uatDgUA8HWcRACmhtTruytlFRGKKFwZxuQE/LOZh67Uts3GTs5eHN8xvZTL+en+n7B/cCRYrrg3+yAM/k0eezIlk65iW700o+icEHxkwTXhhVBmIROBzpXsVCwwKBgQDfS6kVhgZxLMQePbXUQ1NBr2KbfhXLzceINhsoyWLa1rIk8+9HLSxw8q0zma12Jqkd22OAgkbeLDy+niYPi3pUrWAm8O59Ot1aaOarxMTvEv7+eS+urKId57sli/hQTWsS+xghA4+VfW2+EY++pYyZIp+j+1/Q2ciXWVJy4iv9xwKBgFzW8+kxn2vWxz1WrPzBdtZOwothB0V6G1M7QXhONag+ylKHV4TAKexFn55Onky6mz6K0f7cVeBtsnEonKD0Gf5Xe1aHQEt225ndHMXCe60uFKxfr9y6vIVpvB1vmLkhfOSPsrmUJpDoVzkKr06RPJTCY0LRiag/YQa9XHxpSPcpAoGAKbsiJnudyJjtLhmqWbkbXjNA4n515FjY6YPzH3RDnVJyiKVuGoc+vv0bkYEvAd3HzWSq++FdDTiHQbictFsEyb59McnlSFIv/C2Orptfkq6iKTzMxIBO6/fa6fF2vss5L5rtr33S38VJNTRjAOY/mH74BtV72rRY4LA40G+keRECgYEAiGg0DYxcSGf2bEP1WESYPTTdgS5ke1niIwZ00SgtkIjPSVgTCmf4Tciys6lGSe/Oqnvk24VR6pz07wzcbH92AURVaeqiEvVuVonzA6Yl0jxeOIM31S1BSBJRT8kDijuvwoJu2tPoZG0306KF9L8pyy1Z6cTTmIfGR0NpZCHWPSg=
\ No newline at end of file
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