2013-04-08 41 views
1

A有一個應用程序,它從靜態url分析xml。直到最近,他們更新了對URL的訪問權限之後,應用程序纔開始工作。現在需要輸入一個NT用戶名/密碼。clojure中的HTTPS身份驗證

我很努力做到這一點,因爲我不能安裝除提供的庫之外的其他庫,其中一個庫不是clj-http。在clojure中有沒有其他解決方法?我將如何使用java.org.apachehttpclient作爲例子?

(ns Summary 
(:import [java.net URL]) 
(:use [clojure.java.io :only [input-stream]]) 
(:require [clojure.xml :as xml]) 
(:require [clojure.zip :as zip]) 
(:require [clojure.contrib.zip-filter.xml :as zf])) 



(defn get-field [element child] 
(zf/xml1-> element child zf/text)) 

(defn parse-record [rec-xml] 
(into {} 
    (map 
     #(vector % (get-field rec-xml %)) 
     [:sys_id :sys_updated ]))) 


(defn get-records [xml] 
(map 
    parse-record 
    (zf/xml-> (zip/xml-zip xml) 
       :Record         
      ))) 
(def viewDoc 
(with-open [is (input-stream  (URL. "https://www.test.com" "Domain/username" "password"))] 
    (let [recs (doall (get-records (xml/parse is)))] 


) 
)) 
+0

「現在需要輸入NT用戶名/密碼」 - 您是在談論基本身份驗證,還是? – mac 2013-04-09 09:47:59

+0

不,這是NTLM認證,windows - 域名/用戶名和密碼 – redhands 2013-04-09 13:04:29

回答

0

This應該讓你去。應該很容易轉換爲Clojure。