Commit 774018b4 by 111-PC\111

[+]代码整理

1 parent 85b4a03e
...@@ -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;
}
} }
...@@ -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;
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!