You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by ib...@apache.org on 2003/04/01 12:11:26 UTC
cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/lib WebdavSession.java WebdavResource.java
ib 2003/04/01 02:11:26
Modified: src/webdav/client/src/org/apache/webdav/lib
WebdavSession.java WebdavResource.java
Log:
Add support for authenticating proxies,
fix JavaDoc warnings
Revision Changes Path
1.27 +29 -13 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavSession.java
Index: WebdavSession.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavSession.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- WebdavSession.java 27 Feb 2003 11:55:54 -0000 1.26
+++ WebdavSession.java 1 Apr 2003 10:11:26 -0000 1.27
@@ -73,6 +73,7 @@
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.commons.httpclient.HostConfiguration;
/**
* This WebdavSession class is for the session management of WebDAV clients.
@@ -125,6 +126,10 @@
*/
protected int proxyPort = -1;
+ /**
+ * Credentials to use for an authenticating proxy
+ */
+ protected Credentials proxyCredentials = null;
/**
@@ -183,21 +188,23 @@
client = new HttpClient();
// Set a state which allows lock tracking
client.setState(new WebdavState());
- if(proxyHost != null && proxyPort > 0)
- client.startSession(httpURL.getHost(), httpURL.getPort(),
- proxyHost, proxyPort,
- httpURL.getEscapedHttpURL().startsWith("https"));
- else
- client.startSession(httpURL.getHost(), httpURL.getPort(),
- httpURL.getEscapedHttpURL().startsWith("https"));
-
+ HostConfiguration hostConfig = client.getHostConfiguration();
+ hostConfig.setHost(httpURL.getHost(), httpURL.getPort(),
+ httpURL.getScheme());
+ if (proxyHost != null && proxyPort > 0)
+ hostConfig.setProxy(proxyHost, proxyPort);
+
String userName = httpURL.getUserName();
if (userName != null && userName.length() > 0) {
String password = httpURL.getPassword();
client.getState().setCredentials(null,
- new UsernamePasswordCredentials(userName, password));
+ new UsernamePasswordCredentials(userName, password));
}
+
+ if (proxyCredentials != null) {
+ client.getState().setProxyCredentials(null, proxyCredentials);
+ }
}
return client;
@@ -210,7 +217,16 @@
this.proxyHost = host;
this.proxyPort = port;
}
-
+
+ /**
+ * Set credentials for authenticating against a proxy.
+ *
+ * @param credentials The credentials to use for authentication.
+ */
+ public void setProxyCredentials(Credentials credentials) {
+ proxyCredentials = credentials;
+ }
+
/**
* Close an session and delete the connection information.
*
1.57 +47 -5 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavResource.java
Index: WebdavResource.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavResource.java,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- WebdavResource.java 27 Feb 2003 13:40:51 -0000 1.56
+++ WebdavResource.java 1 Apr 2003 10:11:26 -0000 1.57
@@ -311,6 +311,27 @@
/**
* The constructor.
+ *
+ * @param httpURL The specified http URL.
+ * @param proxyHost The hostname of the proxy to use.
+ * @param proxyPort The port number of the proxy to use.
+ * @param proxyCredentials Credentials to use for proxy authentication.
+ * @exception HttpException
+ * @exception IOException
+ * @see #setDefaultAction(int)
+ */
+ public WebdavResource(HttpURL httpURL, String proxyHost, int proxyPort,
+ Credentials proxyCredentials)
+ throws HttpException, IOException {
+
+ setProxy(proxyHost, proxyPort);
+ setProxyCredentials(proxyCredentials);
+ setHttpURL(httpURL);
+ }
+
+
+ /**
+ * The constructor.
* It must be put an escaped http URL as an arguement.
*
* @param escapedHttpURL The escaped http URL string.
@@ -343,6 +364,27 @@
setHttpURL(escapedHttpURL);
}
+ /**
+ * The constructor.
+ * It must be put an escaped http URL as an arguement.
+ *
+ * @param escapedHttpURL The escaped http URL string.
+ * @param proxyHost The hostname of the proxy to use.
+ * @param proxyPort The port number of the proxy to use.
+ * @param proxyCredentials Credentials to use for proxy authentication.
+ * @exception HttpException
+ * @exception IOException
+ * @see #setDefaultAction(int)
+ */
+ public WebdavResource(String escapedHttpURL, String proxyHost,
+ int proxyPort, Credentials proxyCredentials)
+ throws HttpException, IOException {
+
+ setProxy(proxyHost, proxyPort);
+ setProxyCredentials(proxyCredentials);
+ setHttpURL(escapedHttpURL);
+ }
+
/**
* The constructor.
@@ -3819,7 +3861,7 @@
* Update this resource to the specified target
*
* @param target the path of the history element to update this resource to
- * @return
+ * @return true if the method has succeeded
* @exception HttpException
* @exception IOException
*/
@@ -3835,7 +3877,7 @@
*
* @param path the path of the resource to update
* @param target the target to update from (history resource)
- * @return
+ * @return true if the method has succeeded
* @exception HttpException
* @exception IOException
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org