Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
open-source
/
glsx-rest-admin-job-archetype
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 774018b4
authored
Mar 18, 2021
by
111-PC\111
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]代码整理
1 parent
85b4a03e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
34 deletions
glsx-rest-admin-job/src/main/java/cn/com/glsx/smartdevice/utils/HeaderParamUtils.java
glsx-rest-admin-job/src/main/java/cn/com/glsx/smartdevice/utils/TuyaUtils.java
glsx-rest-admin-job/src/main/java/cn/com/glsx/smartdevice/utils/HeaderParamUtils.java
View file @
774018b
...
@@ -20,15 +20,4 @@ public class HeaderParamUtils {
...
@@ -20,15 +20,4 @@ public class HeaderParamUtils {
return
headerParams
;
return
headerParams
;
}
}
public
static
Map
<
String
,
String
>
buildHeaderParams
(
String
client_id
,
String
secret
,
String
accessToken
){
long
timeMillis
=
System
.
currentTimeMillis
();
String
sign
=
TuyaUtils
.
getBussinessSign
(
timeMillis
,
client_id
,
secret
,
accessToken
);
Map
<
String
,
String
>
headerParams
=
new
HashMap
<>();
headerParams
.
put
(
"client_id"
,
client_id
);
headerParams
.
put
(
"t"
,
timeMillis
+
""
);
headerParams
.
put
(
"sign_method"
,
"HMAC-SHA256"
);
headerParams
.
put
(
"sign"
,
sign
);
headerParams
.
put
(
"access_token"
,
accessToken
);
return
headerParams
;
}
}
}
glsx-rest-admin-job/src/main/java/cn/com/glsx/smartdevice/utils/TuyaUtils.java
View file @
774018b
...
@@ -35,27 +35,4 @@ public class TuyaUtils {
...
@@ -35,27 +35,4 @@ public class TuyaUtils {
return
hash
;
return
hash
;
}
}
/**
* 获取业务的签名
*
* @param time 时间戳
* @param client_id client_id
* @param secret secret
* @param accessToken 令牌
* @return
*/
public
static
String
getBussinessSign
(
long
time
,
String
client_id
,
String
secret
,
String
accessToken
)
{
String
hash
=
null
;
try
{
String
message
=
client_id
+
accessToken
+
time
;
Mac
sha256_HMAC
=
Mac
.
getInstance
(
"HmacSHA256"
);
SecretKeySpec
secret_key
=
new
SecretKeySpec
(
secret
.
getBytes
(),
"HmacSHA256"
);
sha256_HMAC
.
init
(
secret_key
);
byte
[]
bytes
=
sha256_HMAC
.
doFinal
(
message
.
getBytes
());
hash
=
new
HexBinaryAdapter
().
marshal
(
bytes
).
toUpperCase
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
hash
;
}
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment