Last active
August 10, 2023 15:41
-
-
Save lishenzhi/c3bc1cc49d74da0039daf2f3fb0f953d to your computer and use it in GitHub Desktop.
jmeter sha256 signature
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
// beanshell preprocessor | |
import org.apache.commons.httpclient.auth.DigestScheme; // necessary imports | |
import org.apache.commons.codec.binary.Base64; | |
import org.apache.commons.codec.digest.DigestUtils; | |
import org.apache.jmeter.protocol.http.control.Header; | |
long timestamp = System.currentTimeMillis() / 1000L; | |
String clientID = "***"; | |
String clientSecret = "****"; | |
String authClient = "Doorman-SHA256 Credential=" + clientID; | |
String combined = clientID + clientSecret + String.valueOf(timestamp); | |
String sha256hex = DigestUtils.sha256Hex(combined); | |
sampler.getHeaderManager().add(new Header("Signature", sha256hex)); | |
sampler.getHeaderManager().add(new Header("Authorization", authClient)); | |
sampler.getHeaderManager().add(new Header("Timestamp", String.valueOf(timestamp))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment