Hi @Lim Kim Chang (AquaEasy) ,
Thank you for posting this question. I am following up to see if you are still stuck with this issue or arrived at a solution. Please let us know if you still need assistance on this issue and we would be glad to help you.
Here is a resource, Control Access with SAS, I found where you can generate SAS tokens by setting the custom expiration time.
Please find the below code snippet for reference
public static String generateSasToken(String resourceUri, String key) throws Exception {
// Token will expire in one hour
var expiry = Instant.now().getEpochSecond() + 3600;
String stringToSign = URLEncoder.encode(resourceUri, StandardCharsets.UTF_8) + "\n" + expiry;
byte[] decodedKey = Base64.getDecoder().decode(key);
Mac sha256HMAC = Mac.getInstance("HmacSHA256");
SecretKeySpec secretKey = new SecretKeySpec(decodedKey, "HmacSHA256");
sha256HMAC.init(secretKey);
Base64.Encoder encoder = Base64.getEncoder();
String signature = new String(encoder.encode(
sha256HMAC.doFinal(stringToSign.getBytes(StandardCharsets.UTF_8))), StandardCharsets.UTF_8);
String token = "SharedAccessSignature sr=" + URLEncoder.encode(resourceUri, StandardCharsets.UTF_8)
+ "&sig=" + URLEncoder.encode(signature, StandardCharsets.UTF_8.name()) + "&se=" + expiry;
return token;
}
Let us know if this helped you.