I want to do something like that:
private static final String protocol = "http";
// host verification via http basic auth, http://username:passwort@url ...
private static final String host = "http://username:password@myservice.com";
private static final int port = 80;
private static final String path = "/";
@TestTarget
public final Target target = new HttpTarget(protocol, host, port, path);
The problem is: I want to analyse my connection via TCP/IP monitor and it seems it does not give a chance to use http basic auth. How can I forward the connection through TCP/IP monitor using http basic auth?
Can I set the necessary parameters per headers? Maybe something like that:
@TargetRequestFilter
public void exampleRequestFilter(HttpRequest request) {
request.addHeader("Authorization", "OAUTH hdsagasjhgdjashgdah...");
}
Or are there other options how I can use http basic auth + TCP/IP Monitor?
Thanks in advance!
I found out I can use http base authentication when I encode it via base64. The solution should look like this:
@TargetRequestFilter
public void exampleRequestFilter(HttpRequest request) {
// Authorization header Base64 encoded...
String encoded = Base64.getEncoder()
.encodeToString((username + ":" + password).getBytes(StandardCharsets.UTF_8));
request.addHeader("Authorization", "Basic " + encoded);
}