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

Support basic auth credentials embedded in the schema.registry.url #507

Merged
merged 1 commit into from Nov 3, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -43,6 +43,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.xml.bind.DatatypeConverter;

/**
* Rest access layer for sending requests to the schema registry.
Expand Down Expand Up @@ -132,9 +133,13 @@ private <T> T sendHttpRequest(String requestUrl, String method, byte[] requestBo
HttpURLConnection connection = null;
try {
URL url = new URL(requestUrl);
String userInfo = url.getUserInfo();
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod(method);

if (userInfo != null) {
String authHeader = DatatypeConverter.printBase64Binary(userInfo.getBytes());
connection.setRequestProperty("Authorization", "Basic " + authHeader);
}
// connection.getResponseCode() implicitly calls getInputStream, so always set to true.
// On the other hand, leaving this out breaks nothing.
connection.setDoInput(true);
Expand Down