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
dd883009
Commit
dd883009
authored
Feb 06, 2018
by
技术部-任文超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善log,修复参数
parent
99bfb717
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5 additions
and
40 deletions
+5
-40
CaptchaNewValidateAdvisor.java
...tgroup/xyqb/aspect/captcha/CaptchaNewValidateAdvisor.java
+1
-1
GeetestLib.java
...n/java/cn/quantgroup/xyqb/service/captcha/GeetestLib.java
+0
-34
GeetestCaptchaServiceImpl.java
.../xyqb/service/captcha/impl/GeetestCaptchaServiceImpl.java
+2
-2
GeetestCaptchaServiceTest.java
src/test/java/service/GeetestCaptchaServiceTest.java
+2
-3
No files found.
src/main/java/cn/quantgroup/xyqb/aspect/captcha/CaptchaNewValidateAdvisor.java
View file @
dd883009
...
@@ -78,7 +78,7 @@ public class CaptchaNewValidateAdvisor {
...
@@ -78,7 +78,7 @@ public class CaptchaNewValidateAdvisor {
String
seccode
=
request
.
getParameter
(
Constants
.
FN_GEETEST_SECCODE
);
String
seccode
=
request
.
getParameter
(
Constants
.
FN_GEETEST_SECCODE
);
String
phoneNo
=
request
.
getParameter
(
"phoneNo"
);
String
phoneNo
=
request
.
getParameter
(
"phoneNo"
);
String
clientType
=
request
.
getParameter
(
"clientType"
);
String
clientType
=
request
.
getParameter
(
"clientType"
);
log
.
info
(
"使用极验二次验证,phoneNo:{}
"
,
phoneNo
);
log
.
info
(
"使用极验二次验证,phoneNo:{}
, clientType:{}, challenge:{}, validate:{}, seccode:{}"
,
phoneNo
,
clientType
,
challenge
,
validate
,
seccode
);
return
geetestCaptchaService
.
validGeetestCaptcha
(
PasswordUtil
.
MD5
(
phoneNo
),
IPUtil
.
getRemoteIP
(
request
),
ClientType
.
valueByName
(
clientType
),
challenge
,
validate
,
seccode
);
return
geetestCaptchaService
.
validGeetestCaptcha
(
PasswordUtil
.
MD5
(
phoneNo
),
IPUtil
.
getRemoteIP
(
request
),
ClientType
.
valueByName
(
clientType
),
challenge
,
validate
,
seccode
);
}
}
...
...
src/main/java/cn/quantgroup/xyqb/service/captcha/GeetestLib.java
View file @
dd883009
...
@@ -245,23 +245,16 @@ public class GeetestLib {
...
@@ -245,23 +245,16 @@ public class GeetestLib {
* @return 验证结果, 1表示验证成功0表示验证失败
* @return 验证结果, 1表示验证成功0表示验证失败
*/
*/
public
int
enhencedValidateRequest
(
String
challenge
,
String
validate
,
String
seccode
,
HashMap
<
String
,
String
>
data
)
{
public
int
enhencedValidateRequest
(
String
challenge
,
String
validate
,
String
seccode
,
HashMap
<
String
,
String
>
data
)
{
if
(!
resquestIsLegal
(
challenge
,
validate
,
seccode
))
{
if
(!
resquestIsLegal
(
challenge
,
validate
,
seccode
))
{
return
0
;
return
0
;
}
}
gtlog
(
"request legitimate"
);
gtlog
(
"request legitimate"
);
String
userId
=
data
.
get
(
"user_id"
);
String
userId
=
data
.
get
(
"user_id"
);
String
clientType
=
data
.
get
(
"client_type"
);
String
clientType
=
data
.
get
(
"client_type"
);
String
ipAddress
=
data
.
get
(
"ip_address"
);
String
ipAddress
=
data
.
get
(
"ip_address"
);
String
postUrl
=
this
.
apiUrl
+
this
.
validateUrl
;
String
postUrl
=
this
.
apiUrl
+
this
.
validateUrl
;
String
param
=
String
.
format
(
"challenge=%s&validate=%s&seccode=%s&json_format=%s"
,
String
param
=
String
.
format
(
"challenge=%s&validate=%s&seccode=%s&json_format=%s"
,
challenge
,
validate
,
seccode
,
this
.
json_format
);
challenge
,
validate
,
seccode
,
this
.
json_format
);
if
(
userId
!=
null
)
{
if
(
userId
!=
null
)
{
param
=
param
+
"&user_id="
+
userId
;
param
=
param
+
"&user_id="
+
userId
;
}
}
...
@@ -271,62 +264,35 @@ public class GeetestLib {
...
@@ -271,62 +264,35 @@ public class GeetestLib {
if
(
ipAddress
!=
null
)
{
if
(
ipAddress
!=
null
)
{
param
=
param
+
"&ip_address="
+
ipAddress
;
param
=
param
+
"&ip_address="
+
ipAddress
;
}
}
gtlog
(
"param:"
+
param
);
gtlog
(
"param:"
+
param
);
String
response
=
""
;
String
response
=
""
;
try
{
try
{
if
(
validate
.
length
()
<=
0
)
{
if
(
validate
.
length
()
<=
0
)
{
return
0
;
return
0
;
}
}
if
(!
checkResultByPrivate
(
challenge
,
validate
))
{
if
(!
checkResultByPrivate
(
challenge
,
validate
))
{
return
0
;
return
0
;
}
}
gtlog
(
"checkResultByPrivate"
);
gtlog
(
"checkResultByPrivate"
);
response
=
readContentFromPost
(
postUrl
,
param
);
response
=
readContentFromPost
(
postUrl
,
param
);
gtlog
(
"response: "
+
response
);
gtlog
(
"response: "
+
response
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
String
return_seccode
=
""
;
String
return_seccode
=
""
;
try
{
try
{
JSONObject
return_map
=
new
JSONObject
(
response
);
JSONObject
return_map
=
new
JSONObject
(
response
);
return_seccode
=
return_map
.
getString
(
"seccode"
);
return_seccode
=
return_map
.
getString
(
"seccode"
);
gtlog
(
"md5: "
+
md5Encode
(
return_seccode
));
gtlog
(
"md5: "
+
md5Encode
(
return_seccode
));
if
(
return_seccode
.
equals
(
md5Encode
(
seccode
)))
{
if
(
return_seccode
.
equals
(
md5Encode
(
seccode
)))
{
return
1
;
return
1
;
}
else
{
}
else
{
return
0
;
return
0
;
}
}
}
catch
(
JSONException
e
)
{
}
catch
(
JSONException
e
)
{
gtlog
(
"json load error"
);
gtlog
(
"json load error"
);
return
0
;
return
0
;
}
}
}
}
/**
/**
...
...
src/main/java/cn/quantgroup/xyqb/service/captcha/impl/GeetestCaptchaServiceImpl.java
View file @
dd883009
...
@@ -60,9 +60,9 @@ public class GeetestCaptchaServiceImpl implements IGeetestCaptchaService {
...
@@ -60,9 +60,9 @@ public class GeetestCaptchaServiceImpl implements IGeetestCaptchaService {
HashMap
<
String
,
String
>
param
=
new
HashMap
<>();
HashMap
<
String
,
String
>
param
=
new
HashMap
<>();
param
.
put
(
"user_id"
,
markId
);
param
.
put
(
"user_id"
,
markId
);
if
(
Objects
.
isNull
(
clientType
))
{
if
(
Objects
.
isNull
(
clientType
))
{
param
.
put
(
"client_type"
,
ClientType
.
APP
.
name
());
param
.
put
(
"client_type"
,
ClientType
.
APP
.
name
()
.
toLowerCase
()
);
}
else
{
}
else
{
param
.
put
(
"client_type"
,
clientType
.
name
());
param
.
put
(
"client_type"
,
clientType
.
name
()
.
toLowerCase
()
);
}
}
param
.
put
(
"ip_address"
,
remoteIp
);
param
.
put
(
"ip_address"
,
remoteIp
);
return
param
;
return
param
;
...
...
src/test/java/service/GeetestCaptchaServiceTest.java
View file @
dd883009
...
@@ -23,8 +23,8 @@ public class GeetestCaptchaServiceTest {
...
@@ -23,8 +23,8 @@ public class GeetestCaptchaServiceTest {
@Resource
@Resource
private
IGeetestCaptchaService
geetestCaptchaService
;
private
IGeetestCaptchaService
geetestCaptchaService
;
private
String
phoneNo
=
"18
010043006
"
;
private
String
phoneNo
=
"18
953309449
"
;
private
String
remoteIp
=
"1
27.0.0.1
"
;
private
String
remoteIp
=
"1
92.168.12.24
"
;
private
ClientType
clientType
=
ClientType
.
H5
;
private
ClientType
clientType
=
ClientType
.
H5
;
private
Map
<
String
,
String
>
data
=
null
;
private
Map
<
String
,
String
>
data
=
null
;
...
@@ -32,7 +32,6 @@ public class GeetestCaptchaServiceTest {
...
@@ -32,7 +32,6 @@ public class GeetestCaptchaServiceTest {
public
void
testFetchGeetestCaptcha
(){
public
void
testFetchGeetestCaptcha
(){
data
=
geetestCaptchaService
.
fetchGeetestCaptcha
(
PasswordUtil
.
MD5
(
phoneNo
),
remoteIp
,
clientType
);
data
=
geetestCaptchaService
.
fetchGeetestCaptcha
(
PasswordUtil
.
MD5
(
phoneNo
),
remoteIp
,
clientType
);
Assert
.
assertNotNull
(
data
);
Assert
.
assertNotNull
(
data
);
Assert
.
assertTrue
(
data
.
containsKey
(
Constants
.
VERIFY_PARAM
));
Assert
.
assertTrue
(
data
.
containsKey
(
"gt"
));
Assert
.
assertTrue
(
data
.
containsKey
(
"gt"
));
Assert
.
assertTrue
(
data
.
containsKey
(
"challenge"
));
Assert
.
assertTrue
(
data
.
containsKey
(
"challenge"
));
}
}
...
...
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