-
-
Save tianying484/605a6c3c904b61aa7dc7df8e40f78939 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