Skip to content

Commit

Permalink
Revert "Support for additonal Authentication-Schemes (digest, negotia…
Browse files Browse the repository at this point in the history
…te) (#76)"

This reverts commit f5097d9.
  • Loading branch information
lukasj committed Mar 18, 2022
1 parent 140dffc commit 6877260
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 41 deletions.
Expand Up @@ -34,9 +34,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Authenticator;
import java.net.HttpURLConnection;
import java.net.PasswordAuthentication;
import java.util.List;
import java.util.Map;
import java.util.zip.GZIPOutputStream;
Expand All @@ -60,8 +58,6 @@ public class HttpClientTransport {
}
}

private final Authenticator auth;

/*package*/ int statusCode;
/*package*/ String statusMessage;
/*package*/ int contentLength;
Expand All @@ -76,17 +72,11 @@ public class HttpClientTransport {
private final Integer chunkSize;


public HttpClientTransport(@NotNull Packet packet, @NotNull Map<String, List<String>> reqHeaders) {
this(packet, reqHeaders, null);
}

public HttpClientTransport(@NotNull Packet packet, @NotNull Map<String, List<String>> reqHeaders,
@Nullable Authenticator auth) {
public HttpClientTransport(@NotNull Packet packet, @NotNull Map<String,List<String>> reqHeaders) {
endpoint = packet.endpointAddress;
context = packet;
this.reqHeaders = reqHeaders;
chunkSize = (Integer)context.invocationProperties.get(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE);
this.auth = auth;
}

/*
Expand Down Expand Up @@ -223,18 +213,14 @@ private void createHttpConnection() throws IOException {

if (httpConnection == null)
httpConnection = (HttpURLConnection) endpoint.openConnection();

if (auth != null) {
httpConnection.setAuthenticator(auth);
}

String scheme = endpoint.getURI().getScheme();
if (scheme.equals("https")) {
https = true;
}
if (checkHTTPS(httpConnection))
https = true;


// allow interaction with the web page - user may have to supply
// username, password id web page is accessed from web browser
httpConnection.setAllowUserInteraction(true);
Expand Down
Expand Up @@ -38,7 +38,6 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.Authenticator;
import java.net.CookieHandler;
import java.net.HttpURLConnection;
import java.util.ArrayList;
Expand Down Expand Up @@ -130,8 +129,8 @@ public NextAction processResponse(@NotNull Packet response) {
return doReturnWith(response);
}

protected HttpClientTransport getTransport(Packet request, Map<String, List<String>> reqHeaders, Authenticator authenticator) {
return new HttpClientTransport(request, reqHeaders, authenticator);
protected HttpClientTransport getTransport(Packet request, Map<String, List<String>> reqHeaders) {
return new HttpClientTransport(request, reqHeaders);
}

@Override
Expand All @@ -155,12 +154,10 @@ public Packet process(Packet request) {
reqHeaders.put("User-Agent", USER_AGENT);
}

addBasicAuth(request, reqHeaders);
addCookies(request, reqHeaders);

final Authenticator authentication = getAuthentication(request);


con = getTransport(request, reqHeaders, authentication);
con = getTransport(request, reqHeaders);
request.addSatellite(new HttpResponseProperties(con));

ContentType ct = codec.getStaticContentType(request);
Expand Down Expand Up @@ -219,23 +216,6 @@ public Packet process(Packet request) {
}
}

private Authenticator getAuthentication(Packet request) {
String user = (String) request.invocationProperties.get(BindingProvider.USERNAME_PROPERTY);
if (user != null) {
String pw = (String) request.invocationProperties.get(BindingProvider.PASSWORD_PROPERTY);
if (pw != null) {
return new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(user, pw.toCharArray());
}
};

}
}
return null;
}

private Packet createResponsePacket(Packet request, HttpClientTransport con) throws IOException {
con.readResponseCodeAndMessage(); // throws IOE
recordCookies(request, con);
Expand Down Expand Up @@ -392,7 +372,19 @@ private void recordCookies(Packet context, HttpClientTransport con) throws IOExc
}
}


private void addBasicAuth(Packet context, Map<String, List<String>> reqHeaders) {
String user = (String) context.invocationProperties.get(BindingProvider.USERNAME_PROPERTY);
if (user != null) {
String pw = (String) context.invocationProperties.get(BindingProvider.PASSWORD_PROPERTY);
if (pw != null) {
StringBuilder buf = new StringBuilder(user);
buf.append(":");
buf.append(pw);
String creds = DatatypeConverter.printBase64Binary(buf.toString().getBytes());
reqHeaders.put("Authorization", Collections.singletonList("Basic "+creds));
}
}
}

/*
* write SOAPAction header if the soapAction parameter is non-null or BindingProvider properties set.
Expand Down

0 comments on commit 6877260

Please sign in to comment.