Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Digest Support: init first connection with null headers #431

Merged
merged 2 commits into from
Mar 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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