
com.github.tomakehurst.wiremock.security.ClientBasicAuthenticator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of wiremock-standalone Show documentation
Show all versions of wiremock-standalone Show documentation
A web service test double for all occasions
package com.github.tomakehurst.wiremock.security;
import com.github.tomakehurst.wiremock.client.BasicCredentials;
import com.github.tomakehurst.wiremock.http.HttpHeader;
import java.util.List;
import static com.github.tomakehurst.wiremock.http.HttpHeader.httpHeader;
import static com.google.common.net.HttpHeaders.AUTHORIZATION;
import static java.util.Collections.singletonList;
public class ClientBasicAuthenticator implements ClientAuthenticator {
private final String username;
private final String password;
public ClientBasicAuthenticator(String username, String password) {
this.username = username;
this.password = password;
}
@Override
public List generateAuthHeaders() {
BasicCredentials basicCredentials = new BasicCredentials(username, password);
return singletonList(httpHeader(AUTHORIZATION, basicCredentials.asAuthorizationHeaderValue()));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy