|
|
@@ -118,34 +118,4 @@ public class IotCommunication { |
|
|
|
log.error("InterruptedException:{}", e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
* userInfo组装 |
|
|
|
*/ |
|
|
|
private String getUserInfo() { |
|
|
|
//userInfo组装 |
|
|
|
String userInfo = clientId + "|authMode=aksign" |
|
|
|
+ ",signMethod=" + signMethod |
|
|
|
+ ",timestamp=" + timeStamp |
|
|
|
+ ",authId=" + accessKey |
|
|
|
+ ",iotInstanceId=" + iotInstanceId |
|
|
|
+ ",consumerGroupId=" + consumerGroupId |
|
|
|
+ "|"; |
|
|
|
//计算签名,password组装方法,请参见AMQP客户端接入说明文档。 |
|
|
|
return userInfo; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 计算签名,password组装方法,请参见AMQP客户端接入说明文档。 |
|
|
|
*/ |
|
|
|
private static String doSign(String toSignString, String secret, String signMethod) throws Exception { |
|
|
|
SecretKeySpec signingKey = new SecretKeySpec(secret.getBytes(), signMethod); |
|
|
|
Mac mac = Mac.getInstance(signMethod); |
|
|
|
mac.init(signingKey); |
|
|
|
byte[] rawHmac = mac.doFinal(toSignString.getBytes()); |
|
|
|
return Base64.encodeBase64String(rawHmac); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |