Skip to content

Commit

Permalink
Digest Support: init first connection with null headers (#431)
Browse files Browse the repository at this point in the history
  • Loading branch information
mssfang authored and JamesBirdsall committed Mar 11, 2019
1 parent 6edab2c commit 07b4072
Showing 1 changed file with 1 addition and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ protected void addTransportLayers(final Event event, final TransportInternal tra
// after creating the socket to proxy
final String hostName = event.getConnection().getHostname();
final ProxyHandler proxyHandler = new ProxyHandlerImpl();
final Map<String, String> proxyHeader = getAuthorizationHeader();
proxy.configure(hostName, proxyHeader, proxyHandler, transport);
proxy.configure(hostName, null, proxyHandler, transport);

transport.addTransportLayer(proxy);

Expand Down Expand Up @@ -119,38 +118,6 @@ public int getRemotePort() {
return socketAddress.getPort();
}

private Map<String, String> getAuthorizationHeader() {
final PasswordAuthentication authentication = Authenticator.requestPasswordAuthentication(
getRemoteHostName(),
null,
getRemotePort(),
"https",
"Event Hubs client websocket proxy support",
"basic",
null,
Authenticator.RequestorType.PROXY);
if (authentication == null) {
return null;
}

final String proxyUserName = authentication.getUserName();
final String proxyPassword = authentication.getPassword() != null
? new String(authentication.getPassword())
: null;
if (StringUtil.isNullOrEmpty(proxyUserName)
|| StringUtil.isNullOrEmpty(proxyPassword)) {
return null;
}

final HashMap<String, String> proxyAuthorizationHeader = new HashMap<>();
// https://tools.ietf.org/html/rfc7617
final String usernamePasswordPair = proxyUserName + ":" + proxyPassword;
proxyAuthorizationHeader.put(
"Proxy-Authorization",
"Basic " + Base64.getEncoder().encodeToString(usernamePasswordPair.getBytes()));
return proxyAuthorizationHeader;
}

private InetSocketAddress getProxyAddress() {
final URI serviceUri = createURIFromHostNamePort(
this.getAmqpConnection().getHostName(),
Expand Down

0 comments on commit 07b4072

Please sign in to comment.