Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
head_group
xyqb-user2
Commits
3da06fe4
Commit
3da06fe4
authored
Nov 24, 2017
by
技术部-任文超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成升级,兼容高密、低密级 加、解锁操作
parent
fe69e3a3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
19 deletions
+12
-19
UserController.java
...ntgroup/xyqb/controller/internal/user/UserController.java
+10
-4
ValidationUtil.java
src/main/java/cn/quantgroup/xyqb/util/ValidationUtil.java
+2
-3
TestValidUtil.java
src/test/java/user/TestValidUtil.java
+0
-12
No files found.
src/main/java/cn/quantgroup/xyqb/controller/internal/user/UserController.java
View file @
3da06fe4
...
@@ -100,10 +100,16 @@ public class UserController implements IBaseController {
...
@@ -100,10 +100,16 @@ public class UserController implements IBaseController {
}
}
// 操作标记
// 操作标记
boolean
lock
=
Objects
.
equals
(
Boolean
.
TRUE
.
toString
(),
act
);
boolean
lock
=
Objects
.
equals
(
Boolean
.
TRUE
.
toString
(),
act
);
Calendar
now
=
Calendar
.
getInstance
();
String
header_key
=
request
.
getHeader
(
Constants
.
IPV4_LOCK
.
replace
(
":"
,
""
));
int
hour
=
now
.
get
(
Calendar
.
HOUR_OF_DAY
);
if
(
Objects
.
equals
(
Constants
.
CLEAR_LOCK_FOR_IPV4
,
header_key
)){
boolean
valid
=
Objects
.
equals
(
Constants
.
CLEAR_LOCK_FOR_IPV4_KEY
+
hour
,
key
);
return
JsonResult
.
buildErrorStateResult
(
"Are you a robot monkey?(^_^)"
,
ValidationUtil
.
getMd5Key
(
lock
));
// Todo -- boolean valid = ValidationUtil.isValid(key, lock);
}
boolean
valid
=
ValidationUtil
.
isValid
(
key
,
lock
);
if
(!
valid
){
Calendar
now
=
Calendar
.
getInstance
();
int
hour
=
now
.
get
(
Calendar
.
HOUR_OF_DAY
);
valid
=
Objects
.
equals
(
Constants
.
CLEAR_LOCK_FOR_IPV4_KEY
+
hour
,
key
);
}
if
(
valid
){
if
(
valid
){
String
lockIpv4Key
=
getLockIpv4Key
(
ip
);
String
lockIpv4Key
=
getLockIpv4Key
(
ip
);
if
(
lock
){
if
(
lock
){
...
...
src/main/java/cn/quantgroup/xyqb/util/ValidationUtil.java
View file @
3da06fe4
...
@@ -66,17 +66,16 @@ public class ValidationUtil {
...
@@ -66,17 +66,16 @@ public class ValidationUtil {
* @return
* @return
*/
*/
public
static
boolean
isValid
(
String
key
,
boolean
lock
)
{
public
static
boolean
isValid
(
String
key
,
boolean
lock
)
{
return
Objects
.
equals
(
key
,
getMd5Key
(
key
,
lock
));
return
Objects
.
equals
(
key
,
getMd5Key
(
lock
));
}
}
/**
/**
* 计算密令
* 计算密令
* 私钥 + 操作 + 时
* 私钥 + 操作 + 时
* @param key - Md5密令
* @param lock - true or false
* @param lock - true or false
* @return 加密后的Md5
* @return 加密后的Md5
*/
*/
public
static
String
getMd5Key
(
String
key
,
boolean
lock
)
{
public
static
String
getMd5Key
(
boolean
lock
)
{
Calendar
today
=
Calendar
.
getInstance
();
Calendar
today
=
Calendar
.
getInstance
();
int
hour_24
=
today
.
get
(
Calendar
.
HOUR_OF_DAY
);
int
hour_24
=
today
.
get
(
Calendar
.
HOUR_OF_DAY
);
StringBuilder
_key
=
new
StringBuilder
();
StringBuilder
_key
=
new
StringBuilder
();
...
...
src/test/java/user/TestValidUtil.java
deleted
100644 → 0
View file @
fe69e3a3
package
user
;
import
cn.quantgroup.xyqb.util.ValidationUtil
;
public
class
TestValidUtil
{
public
static
void
main
(
String
[]
args
)
{
String
key
=
ValidationUtil
.
getMd5Key
(
"123"
,
true
);
System
.
out
.
println
(
key
);
}
}
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