This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net | |
import ( | |
"errors" | |
"fmt" | |
"net/http" | |
"sync" | |
) | |
type Broker struct { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private String generateSASToken(String uri, String deviceKey, String policyName, Long expiry) { | |
String token = null; | |
try { | |
Long epoch = System.currentTimeMillis() / 1000L; | |
Long ttl = epoch + expiry; | |
String toSign = String.format("%s\n%d", URLEncoder.encode(uri, "utf-8"), ttl); | |
String signature = new String(hmac256Encode(deviceKey, toSign)); | |
String skn = ""; |