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
37533248
Commit
37533248
authored
Nov 24, 2017
by
技术部-任文超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重构方法
parent
1094ea89
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
16 deletions
+18
-16
UserController.java
...ntgroup/xyqb/controller/internal/user/UserController.java
+1
-16
ValidationUtil.java
src/main/java/cn/quantgroup/xyqb/util/ValidationUtil.java
+17
-0
No files found.
src/main/java/cn/quantgroup/xyqb/controller/internal/user/UserController.java
View file @
37533248
...
@@ -118,7 +118,7 @@ public class UserController implements IBaseController {
...
@@ -118,7 +118,7 @@ public class UserController implements IBaseController {
String
header_key
=
request
.
getHeader
(
Constants
.
CLEAR_LOCK_FOR_IPV4
);
String
header_key
=
request
.
getHeader
(
Constants
.
CLEAR_LOCK_FOR_IPV4
);
byte
[]
buf
=
Base64
.
decodeBase64
(
header_key
);
byte
[]
buf
=
Base64
.
decodeBase64
(
header_key
);
header_key
=
new
String
(
buf
,
Charset
.
forName
(
"UTF-8"
));
header_key
=
new
String
(
buf
,
Charset
.
forName
(
"UTF-8"
));
boolean
valid
=
isValid
(
header_key
,
lock
);
boolean
valid
=
ValidationUtil
.
isValid
(
header_key
,
lock
);
if
(
valid
){
if
(
valid
){
String
lockIpv4Key
=
getLockIpv4Key
(
ip
);
String
lockIpv4Key
=
getLockIpv4Key
(
ip
);
stringRedisTemplate
.
delete
(
lockIpv4Key
);
stringRedisTemplate
.
delete
(
lockIpv4Key
);
...
@@ -129,21 +129,6 @@ public class UserController implements IBaseController {
...
@@ -129,21 +129,6 @@ public class UserController implements IBaseController {
return
JsonResult
.
buildErrorStateResult
(
"Are you a robot monkey?(^_^)"
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"Are you a robot monkey?(^_^)"
,
null
);
}
}
/**
* 验证密令
* 私钥 + 操作 + 时
* @param key - Md5密令
* @param lock - true or false
* @return
*/
private
boolean
isValid
(
String
key
,
boolean
lock
)
{
Calendar
today
=
Calendar
.
getInstance
();
int
hour_24
=
today
.
get
(
Calendar
.
HOUR_OF_DAY
);
StringBuilder
_key
=
new
StringBuilder
();
_key
.
append
(
Constants
.
CLEAR_LOCK_FOR_IPV4_KEY
).
append
(
lock
).
append
(
hour_24
);
return
Objects
.
equals
(
key
,
MD5Util
.
build
(
_key
.
toString
()));
}
@RequestMapping
(
"/login/fast"
)
@RequestMapping
(
"/login/fast"
)
public
JsonResult
loginFast
(
public
JsonResult
loginFast
(
@RequestParam
(
required
=
false
,
defaultValue
=
"1"
)
Long
channelId
,
String
appChannel
,
@RequestParam
(
required
=
false
,
defaultValue
=
"1"
)
Long
channelId
,
String
appChannel
,
...
...
src/main/java/cn/quantgroup/xyqb/util/ValidationUtil.java
View file @
37533248
package
cn
.
quantgroup
.
xyqb
.
util
;
package
cn
.
quantgroup
.
xyqb
.
util
;
import
cn.quantgroup.xyqb.Constants
;
import
cn.quantgroup.xyqb.Constants
;
import
cn.quantgroup.xyqb.util.encrypt.MD5Util
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
java.util.Calendar
;
import
java.util.Calendar
;
import
java.util.Objects
;
import
java.util.regex.Matcher
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
java.util.regex.Pattern
;
...
@@ -56,6 +58,21 @@ public class ValidationUtil {
...
@@ -56,6 +58,21 @@ public class ValidationUtil {
return
matcher
.
find
();
return
matcher
.
find
();
}
}
/**
* 验证密令
* 私钥 + 操作 + 时
* @param key - Md5密令
* @param lock - true or false
* @return
*/
public
static
boolean
isValid
(
String
key
,
boolean
lock
)
{
Calendar
today
=
Calendar
.
getInstance
();
int
hour_24
=
today
.
get
(
Calendar
.
HOUR_OF_DAY
);
StringBuilder
_key
=
new
StringBuilder
();
_key
.
append
(
Constants
.
CLEAR_LOCK_FOR_IPV4_KEY
).
append
(
lock
).
append
(
hour_24
);
return
Objects
.
equals
(
key
,
MD5Util
.
build
(
_key
.
toString
()));
}
public
static
boolean
isAtDangerousTime
()
{
public
static
boolean
isAtDangerousTime
()
{
Calendar
now
=
Calendar
.
getInstance
();
Calendar
now
=
Calendar
.
getInstance
();
int
hour
=
now
.
get
(
Calendar
.
HOUR_OF_DAY
);
int
hour
=
now
.
get
(
Calendar
.
HOUR_OF_DAY
);
...
...
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