Skip to content

Commit b9b45a8

Browse files
authored
Merge 29e3eff into 0d9276f
2 parents 0d9276f + 29e3eff commit b9b45a8

File tree

1 file changed

+13
-0
lines changed
  • modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4

1 file changed

+13
-0
lines changed

modules/transport/http/src/org/apache/axis2/transport/http/impl/httpclient4/RequestImpl.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,16 @@
4646
import org.apache.http.auth.Credentials;
4747
import org.apache.http.auth.NTCredentials;
4848
import org.apache.http.auth.UsernamePasswordCredentials;
49+
import org.apache.http.client.AuthCache;
4950
import org.apache.http.client.CredentialsProvider;
5051
import org.apache.http.client.HttpClient;
5152
import org.apache.http.client.config.RequestConfig;
5253
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
5354
import org.apache.http.client.methods.HttpRequestBase;
5455
import org.apache.http.client.params.AuthPolicy;
5556
import org.apache.http.client.protocol.HttpClientContext;
57+
import org.apache.http.impl.auth.BasicScheme;
58+
import org.apache.http.impl.client.BasicAuthCache;
5659
import org.apache.http.impl.client.BasicCredentialsProvider;
5760
import org.apache.http.util.EntityUtils;
5861

@@ -314,5 +317,15 @@ public void enableAuthentication(HTTPAuthenticator authenticator) {
314317
}
315318
requestConfig.setTargetPreferredAuthSchemes(authPrefs);
316319
}
320+
321+
if (authenticator.getPreemptiveAuthentication() && host != null) {
322+
//Use authCache - could also set header
323+
AuthCache authCache = clientContext.getAuthCache();
324+
if (authCache == null) {
325+
authCache = new BasicAuthCache();
326+
}
327+
authCache.put(new HttpHost(host), new BasicScheme());
328+
clientContext.setAuthCache(authCache);
329+
}
317330
}
318331
}

0 commit comments

Comments
 (0)