Skip to content

Preemptively send authentication credentials in WMSHttpHelper #1284

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -30,11 +30,14 @@
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.auth.AuthenticationException;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.auth.BasicScheme;
import org.apache.http.message.BasicNameValuePair;
import org.geotools.util.logging.Logging;
import org.geowebcache.GeoWebCacheException;
Expand Down Expand Up @@ -339,6 +342,16 @@ public HttpResponse executeRequest(
method = new HttpGet(urlString);
}

if (httpUsername != null) {
try {
UsernamePasswordCredentials creds =
new UsernamePasswordCredentials(httpUsername, httpPassword);
method.addHeader(new BasicScheme().authenticate(creds, method, null));
} catch (AuthenticationException e) {
throw new AssertionError("BasicScheme threw: " + e.getMessage());
}
}

// fire!
if (log.isLoggable(Level.FINER)) {
log.finer(method.toString());
Expand Down