import com.wealdtech.hawk.HawkClient
import com.wealdtech.hawk.HawkCredentials
import com.wealdtech.hawk.HawkCredentials.Algorithm
//If you want your clients to authenticate using Hawk then you will need to start with a set of Hawk credentials:
HawkCredentials hawkCredentials = new HawkCredentials.Builder()
.keyId("dh37fgj492je")
.key("werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn")
.algorithm(Algorithm.SHA256)
.build();
//Once these have been configuration you can create a Hawk client:
HawkClient hawkClient = new HawkClient.Builder().credentials(hawkCredentials).build();
//And then for each request that you wish to send you need to generate an authorization header:
String authorizationHeader = hawkClient.generateAuthorizationHeader(uri, method, body, ext);
//This string needs to be added to the outgoing HTTP request as the content of the "Authorization" header.
//and JMeter specifics:
vars.put('authorizationHeader', authorizationHeader)
1条答案
按热度按时间6rqinv9w1#
请尝试Hawk Java API implementation,示例代码可在
Building Your Own -> Clients文档一章中提供了示例代码和说明,以防我在这里复制代码片段:
您需要将此代码放入JSR223预处理器中
之后,添加一个HTTP Header Manager,并将其配置为发送值为
${authorizationHeader}
的Authorization报头