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
ae182cb4
Commit
ae182cb4
authored
Mar 20, 2018
by
技术部-任文超
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '20180130-geetest' into 20180316-UserStatistics
parents
965350b4
dd08c85a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
7 deletions
+13
-7
Constants.java
src/main/java/cn/quantgroup/xyqb/Constants.java
+1
-0
CaptchaNewValidateAdvisor.java
...tgroup/xyqb/aspect/captcha/CaptchaNewValidateAdvisor.java
+3
-2
NewCaptchaController.java
...yqb/controller/external/captcha/NewCaptchaController.java
+9
-5
No files found.
src/main/java/cn/quantgroup/xyqb/Constants.java
View file @
ae182cb4
...
...
@@ -98,6 +98,7 @@ public interface Constants {
// -- Start -- 验证码常量组
int
GT_CAPTCHA_VALIDATE_SUCCESS
=
1
;
String
GT_UNIQUE_KEY
=
"uniqueKey"
;
String
FN_GEETEST_CHALLENGE
=
"geetest_challenge"
;
String
FN_GEETEST_VALIDATE
=
"geetest_validate"
;
String
FN_GEETEST_SECCODE
=
"geetest_seccode"
;
...
...
src/main/java/cn/quantgroup/xyqb/aspect/captcha/CaptchaNewValidateAdvisor.java
View file @
ae182cb4
...
...
@@ -77,13 +77,14 @@ public class CaptchaNewValidateAdvisor {
* @throws Throwable
*/
private
boolean
gtValid
(
HttpServletRequest
request
)
{
String
uniqueKey
=
request
.
getParameter
(
Constants
.
GT_UNIQUE_KEY
);
String
phoneNo
=
request
.
getParameter
(
Constants
.
PHONE_NO
);
String
clientType
=
request
.
getParameter
(
Constants
.
CLIENT_TYPE
);
String
challenge
=
request
.
getParameter
(
Constants
.
FN_GEETEST_CHALLENGE
);
String
validate
=
request
.
getParameter
(
Constants
.
FN_GEETEST_VALIDATE
);
String
seccode
=
request
.
getParameter
(
Constants
.
FN_GEETEST_SECCODE
);
log
.
info
(
"Geetest - 极验二次校验, phoneNo:{},
clientType:{}, ip:{}, challenge:{}, validate:{}, seccode:{}"
,
phoneNo
,
clientType
,
IPUtil
.
getRemoteIP
(
request
),
challenge
,
validate
,
seccode
);
return
geetestCaptchaService
.
validGeetestCaptcha
(
PasswordUtil
.
MD5
(
phoneNo
)
,
IPUtil
.
getRemoteIP
(
request
),
ClientType
.
valueByName
(
clientType
),
challenge
,
validate
,
seccode
);
log
.
info
(
"Geetest - 极验二次校验, phoneNo:{},
uniqueKey:{}, clientType:{}, ip:{}, challenge:{}, validate:{}, seccode:{}"
,
phoneNo
,
uniqueKey
,
clientType
,
IPUtil
.
getRemoteIP
(
request
),
challenge
,
validate
,
seccode
);
return
geetestCaptchaService
.
validGeetestCaptcha
(
uniqueKey
,
IPUtil
.
getRemoteIP
(
request
),
ClientType
.
valueByName
(
clientType
),
challenge
,
validate
,
seccode
);
}
/**
...
...
src/main/java/cn/quantgroup/xyqb/controller/external/captcha/NewCaptchaController.java
View file @
ae182cb4
...
...
@@ -17,9 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.*
;
/**
* @author xufei on 2018/1/30.
...
...
@@ -41,15 +39,20 @@ public class NewCaptchaController {
public
JsonResult
getCaptcha
(
String
phoneNo
,
String
clientType
,
HttpServletRequest
request
)
{
String
remoteIp
=
IPUtil
.
getRemoteIP
(
request
);
log
.
info
(
"获取验证码, phoneNo:{}, clientType:{}, ip:{}, verifyType-qg:{}"
,
phoneNo
,
clientType
,
remoteIp
,
geetestClose
);
if
(!
ValidationUtil
.
validatePhoneNo
(
phoneNo
))
{
if
(
Objects
.
nonNull
(
phoneNo
)
&&
!
ValidationUtil
.
validatePhoneNo
(
phoneNo
))
{
return
JsonResult
.
buildErrorStateResult
(
"手机号格式错误"
,
null
);
}
// 唯一key,用于初始化极验
String
key
=
Optional
.
ofNullable
(
phoneNo
).
orElse
(
UUID
.
randomUUID
().
toString
());
// key指纹
String
keyMd5
=
PasswordUtil
.
MD5
(
key
);
log
.
info
(
"获取验证码, phoneNo:{}, keyMd5:{}, clientType:{}, ip:{}, verifyType-qg:{}"
,
phoneNo
,
keyMd5
,
clientType
,
remoteIp
,
geetestClose
);
// 数据容器
Map
<
String
,
String
>
data
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
imgMap
=
null
;
// 优先获取极验
if
(!
Boolean
.
valueOf
(
geetestClose
)){
imgMap
=
geetestCaptchaService
.
fetchGeetestCaptcha
(
PasswordUtil
.
MD5
(
phoneNo
)
,
remoteIp
,
ClientType
.
valueByName
(
clientType
));
imgMap
=
geetestCaptchaService
.
fetchGeetestCaptcha
(
keyMd5
,
remoteIp
,
ClientType
.
valueByName
(
clientType
));
data
.
put
(
Constants
.
VERIFY_PARAM
,
Constants
.
VERIFY_TYPE_GT
);
}
// 备选方案:量化派图形验证码
...
...
@@ -63,6 +66,7 @@ public class NewCaptchaController {
}
// 填充数据并返回
data
.
putAll
(
imgMap
);
data
.
put
(
Constants
.
GT_UNIQUE_KEY
,
keyMd5
);
return
JsonResult
.
buildSuccessResult
(
""
,
data
);
}
...
...
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