So great!

It works for me, thanks a lot Ingo!

But i'm a noob with cvs and i patch manually the code, there is another way 
(automatic), i suppose?


-----Original Message-----
From: Xavier Frisaye [mailto:[EMAIL PROTECTED]
Sent: mercredi 25 f�vrier 2004 15:32
To: Slide Developers Mailing List
Subject: RE: NTLM auth


Thank you Ingo, i'll give a try as soon as possible and i'll notice you.

-----Original Message-----
From: Ingo Brunberg [mailto:[EMAIL PROTECTED]
Sent: mercredi 25 f�vrier 2004 14:50
To: [EMAIL PROTECTED]
Subject: Re: NTLM auth


Here is a little patch that allows you to use whatever Credentials you
like for creating a WebdavResource.

Could you please try it out (should apply cleanly against
2.0-beta1). If it works for you I will commit it to HEAD and the
2_0-branch.

Ingo

Index: webdavclient/clientlib/src/java/org/apache/webdav/lib/WebdavResource.java
===================================================================
RCS file: 
/home/cvs/jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/WebdavResource.java,v
retrieving revision 1.3.2.2
diff -u -r1.3.2.2 WebdavResource.java
--- webdavclient/clientlib/src/java/org/apache/webdav/lib/WebdavResource.java   5 Feb 
2004 15:51:21 -0000       1.3.2.2
+++ webdavclient/clientlib/src/java/org/apache/webdav/lib/WebdavResource.java   25 Feb 
2004 13:41:29 -0000
@@ -210,6 +210,26 @@
      * The constructor.
      *
      * @param httpURL The specified http URL.
+     * @param credentials The credentials to use for authentication.
+     * @param action The action to set properties of this resource.
+     * @param depth The depth to find properties.
+     * @exception HttpException
+     * @exception IOException
+     * @see #setDefaultAction(int)
+     */
+    public WebdavResource(HttpURL httpURL, Credentials credentials, int action,
+                          int depth)
+        throws HttpException, IOException {
+
+        setCredentials(credentials);
+        setHttpURL(httpURL, action, depth);
+    }
+
+
+    /**
+     * The constructor.
+     *
+     * @param httpURL The specified http URL.
      * @param action The action to set properties of this resource.
      * @param depth The depth to find properties.
      * @exception HttpException
@@ -306,6 +326,24 @@
     public WebdavResource(String escapedHttpURL)
         throws HttpException, IOException {
 
+        setHttpURL(escapedHttpURL);
+    }
+
+
+    /**
+     * The constructor.
+     * It must be put an escaped http URL as an argument.
+     *
+     * @param escapedHttpURL The escaped http URL string.
+     * @param credentials The credentials used for Authentication.
+     * @exception HttpException
+     * @exception IOException
+     * @see #setDefaultAction(int)
+     */
+    public WebdavResource(String escapedHttpURL, Credentials credentials)
+        throws HttpException, IOException {
+
+        setCredentials(credentials);
         setHttpURL(escapedHttpURL);
     }
 
Index: webdavclient/clientlib/src/java/org/apache/webdav/lib/WebdavSession.java
===================================================================
RCS file: 
/home/cvs/jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/WebdavSession.java,v
retrieving revision 1.2.2.1
diff -u -r1.2.2.1 WebdavSession.java
--- webdavclient/clientlib/src/java/org/apache/webdav/lib/WebdavSession.java    5 Feb 
2004 15:51:21 -0000       1.2.2.1
+++ webdavclient/clientlib/src/java/org/apache/webdav/lib/WebdavSession.java    25 Feb 
2004 13:41:29 -0000
@@ -73,6 +73,11 @@
     protected HttpClient client;
 
     /**
+     * Credentials to use for authentication
+     */
+    protected Credentials hostCredentials = null;
+
+    /**
      * The hostname to use for the proxy, if any
      */
     protected String proxyHost = null;
@@ -146,12 +151,19 @@
             if (proxyHost != null && proxyPort > 0)
                 hostConfig.setProxy(proxyHost, proxyPort);
 
-            String userName = httpURL.getUser();
-            if (userName != null && userName.length() > 0) {
-                String password = httpURL.getPassword();
+            if (hostCredentials == null) {
+                String userName = httpURL.getUser();
+                if (userName != null && userName.length() > 0) {
+                    hostCredentials =
+                        new UsernamePasswordCredentials(userName,
+                                                        httpURL.getPassword());
+                }
+            }
+
+            if (hostCredentials != null) {
                 HttpState clientState = client.getState();
                 clientState.setCredentials(null, httpURL.getHost(),
-                    new UsernamePasswordCredentials(userName, password));
+                                           hostCredentials);
                 clientState.setAuthenticationPreemptive(true);
             }
 
@@ -162,6 +174,15 @@
         }
 
         return client;
+    }
+
+    /**
+     * Set credentials for authentication.
+     *
+     * @param credentials The credentials to use for authentication.
+     */
+    public void setCredentials(Credentials credentials) {
+        hostCredentials = credentials;
     }
 
     /** Set proxy info, to use proxying.


> Hi everybody,
> 
> I try slide 2.0 beta 1 and i have one question : is there a simply way =
> to connect to a webdav server using slide client and NTLM =
> authentication?
> 
> I know i must use NTCredentials and it works perfectly with a HttpClient =
> stand alone but i don't know where to set it in WebdavResource...
> 
> Thank in advance for your reply.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to