diff --git a/src/clj_http/core.clj b/src/clj_http/core.clj index fc9bc595..5e668ff7 100644 --- a/src/clj_http/core.clj +++ b/src/clj_http/core.clj @@ -11,7 +11,9 @@ HttpEntityEnclosingRequest HttpResponse Header HttpHost HttpResponseInterceptor) - (org.apache.http.auth UsernamePasswordCredentials AuthScope) + (org.apache.http.auth AuthScope + UsernamePasswordCredentials + NTCredentials) (org.apache.http.params CoreConnectionPNames) (org.apache.http.client HttpClient HttpRequestRetryHandler) (org.apache.http.client.methods HttpDelete @@ -211,7 +213,8 @@ [{:keys [request-method scheme server-name server-port uri query-string headers body multipart socket-timeout conn-timeout proxy-host proxy-ignore-hosts proxy-port as cookie-store retry-handler - response-interceptor digest-auth connection-manager client-params] + response-interceptor digest-auth ntlm-auth auth-schemes + connection-manager client-params] :as req}] (let [^ClientConnectionManager conn-mgr (or connection-manager @@ -241,6 +244,17 @@ (.getCredentialsProvider http-client) (AuthScope. nil -1 nil) (UsernamePasswordCredentials. user pass))) + + (when-let [[user pass host domain] ntlm-auth] + (.setCredentials + (.getCredentialsProvider http-client) + (AuthScope. nil -1 nil) + (NTCredentials. user pass host domain))) + + (doseq [[policy scheme-factory] auth-schemes] + (-> (.getAuthSchemes http-client) + (.register policy scheme-factory))) + (let [http-url (str scheme "://" server-name (when server-port (str ":" server-port)) uri