Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
ShenghuoquanBusiness
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
bp
ShenghuoquanBusiness
Commits
bb9af6db
Commit
bb9af6db
authored
Jul 10, 2021
by
shiyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
混淆配置更细 、加密工具类增加log
parent
4ef5920b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
84 deletions
+85
-84
HttpParamsUtils.kt
...n/src/main/java/com/yidian/common/http/HttpParamsUtils.kt
+84
-83
proguard-rules.pro
app/proguard-rules.pro
+1
-1
No files found.
CommonLib/Common/src/main/java/com/yidian/common/http/HttpParamsUtils.kt
View file @
bb9af6db
...
...
@@ -11,9 +11,9 @@ import com.yidian.utils.ToastUtil
import
com.yidian.yac.ftdevicefinger.core.FtDeviceFingerManager
import
java.lang.reflect.Type
class
HttpParamsUtils
{
companion
object
{
fun
getPublicParamsMap
(
timeStamp
:
Long
):
HashMap
<
String
,
String
>
{
class
HttpParamsUtils
{
companion
object
{
fun
getPublicParamsMap
(
timeStamp
:
Long
):
HashMap
<
String
,
String
>
{
val
networkType
=
NetWorkUtils
.
getNetWorkType
(
YdBaseApplication
.
context
)
val
queryParamsMap
=
HashMap
<
String
,
String
>()
queryParamsMap
[
"appid"
]
=
AppConfig
.
appid
...
...
@@ -27,8 +27,8 @@ class HttpParamsUtils{
return
queryParamsMap
}
fun
getPrivateParamsMap
(
paramsMap
:
HashMap
<
String
,
String
?
>,
timeStamp
:
Long
):
HashMap
<
String
,
String
?
>
{
return
if
(
AppConfig
.
IS_ENCRYPT
)
{
fun
getPrivateParamsMap
(
paramsMap
:
HashMap
<
String
,
String
?
>,
timeStamp
:
Long
):
HashMap
<
String
,
String
?
>
{
return
if
(
AppConfig
.
IS_ENCRYPT
)
{
val
reqId
=
getRequestId
(
timeStamp
)
paramsMap
[
"secret"
]
=
getSignString
(
reqId
,
timeStamp
)
paramsMap
[
"ts"
]
=
timeStamp
.
toString
()
...
...
@@ -38,54 +38,55 @@ class HttpParamsUtils{
val
queryParamsMap
=
HashMap
<
String
,
String
?>()
queryParamsMap
[
"tok"
]
=
tok
queryParamsMap
}
else
{
}
else
{
paramsMap
}
}
fun
<
T
>
rsaDecryptResult
(
res
:
HttpResult
<
Any
?
>,
type
:
Type
):
HttpResult
<
T
>
{
fun
<
T
>
rsaDecryptResult
(
res
:
HttpResult
<
Any
?
>,
type
:
Type
):
HttpResult
<
T
>
{
val
rsaResult
=
res
.
result
val
decodeResult
=
HttpResult
<
T
>()
decodeResult
.
code
=
res
.
code
decodeResult
.
reason
=
res
.
reason
decodeResult
.
status
=
res
.
status
if
(
rsaResult
!=
null
)
{
if
(
rsaResult
!=
null
)
{
val
gson
=
Gson
()
if
(
AppConfig
.
IS_ENCRYPT
)
{
if
(
AppConfig
.
IS_ENCRYPT
)
{
val
result
=
SecretUtil
.
rsaDecrypt
(
rsaResult
as
String
)
LogUtil
.
show
(
"返回参数:$result"
)
val
decryptResult
=
gson
.
fromJson
<
HttpDecryptResult
<
T
>>(
result
,
object
:
TypeToken
<
HttpDecryptResult
<
T
>>()
{}.
type
)
val
decryptResult
=
gson
.
fromJson
<
HttpDecryptResult
<
T
>>(
result
,
object
:
TypeToken
<
HttpDecryptResult
<
T
>>()
{}.
type
)
val
verifyParams
=
decryptResult
.
reqid
+
decryptResult
.
ts
val
secretNet
=
decryptResult
.
secret
val
verify
=
SecretUtil
.
verifySign
(
verifyParams
,
secretNet
)
return
if
(
verify
)
{
return
if
(
verify
)
{
LogUtil
.
show
(
"===============验签成功=================="
)
val
resultJson
=
gson
.
toJson
(
decryptResult
.
data
)
decodeResult
.
result
=
gson
.
fromJson
<
T
>(
resultJson
,
type
)
decodeResult
}
else
{
}
else
{
ToastUtil
.
showToast
(
YdBaseApplication
.
context
,
"验签失败"
)
decodeResult
}
}
else
{
}
else
{
val
resultJson
=
gson
.
toJson
(
rsaResult
)
decodeResult
.
result
=
gson
.
fromJson
<
T
>(
resultJson
,
type
)
return
decodeResult
}
}
LogUtil
.
show
(
"===============rsaResult为空了=================="
)
return
decodeResult
}
private
fun
getDeviceFinger
():
String
{
private
fun
getDeviceFinger
():
String
{
var
deviceFinger
=
""
val
tempId
=
FtDeviceFingerManager
.
getDeviceFinger
()
if
(
tempId
!=
null
)
{
if
(
tempId
!=
null
)
{
deviceFinger
=
tempId
}
return
deviceFinger
}
private
fun
getRequestId
(
timeStamp
:
Long
):
String
{
private
fun
getRequestId
(
timeStamp
:
Long
):
String
{
val
sb
=
StringBuilder
()
sb
.
append
(
AppConfig
.
appid
)
sb
.
append
(
'_'
)
...
...
@@ -95,7 +96,7 @@ class HttpParamsUtils{
return
sb
.
toString
()
}
private
fun
getSignString
(
reqId
:
String
,
timeStamp
:
Long
):
String
?
{
private
fun
getSignString
(
reqId
:
String
,
timeStamp
:
Long
):
String
?
{
val
sb
=
StringBuilder
()
sb
.
append
(
reqId
).
append
(
timeStamp
)
return
SecretUtil
.
sign
(
sb
.
toString
())
...
...
app/proguard-rules.pro
View file @
bb9af6db
...
...
@@ -279,7 +279,7 @@ public static final int *;
-keep class com.yidian.http.
*
*{*;}
-keep class com.yidian.common.bean.
*
*{*;}
-keep class com.yidian.common.http.bean.
*
*{*;}
-keep class com.yidian.shenghuoquan.newscontent.http.
*
*{*;}
-keep class com.yidian.shenghuoquan.newscontent.http.
httpbean.
*
*{*;}
-keep class com.yidian.common.utils.*{*;}
-keep class com.yidian.shenghuoquan.newscontent.utils.*{*;}
-keep class com.yidian.shenghuoquan.newscontent.bean.
*
*{*;}
...
...
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