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 je...@apache.org on 2001/02/28 13:47:54 UTC
cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/lib WebdavException.java WebdavClient.java Authenticator.java
jericho 01/02/28 04:47:53
Modified: src/webdav/client/src/org/apache/webdav/lib
WebdavException.java WebdavClient.java
Authenticator.java
Log:
- The response status code should be delivered.
Revision Changes Path
1.3 +34 -34 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavException.java
Index: WebdavException.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavException.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- WebdavException.java 2001/02/06 06:26:48 1.2
+++ WebdavException.java 2001/02/28 12:47:50 1.3
@@ -1,13 +1,13 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavException.java,v 1.2 2001/02/06 06:26:48 remm Exp $
- * $Revision: 1.2 $
- * $Date: 2001/02/06 06:26:48 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavException.java,v 1.3 2001/02/28 12:47:50 jericho Exp $
+ * $Revision: 1.3 $
+ * $Date: 2001/02/28 12:47:50 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -15,7 +15,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -23,15 +23,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
- * from this software without prior written permission. For written
+ * from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
@@ -59,39 +59,39 @@
*
* [Additional notices, if required by prior licensing conditions]
*
- */
+ */
package org.apache.webdav.lib;
/**
* Webdav exception class.
*/
-public class WebdavException
+public class WebdavException
extends Exception {
-
-
+
+
// ----------------------------------------------------- Instance Variables
-
-
- protected int statusCode;
-
-
+
+
+ protected int statusCode = -1;
+
+
protected String message = "";
-
-
+
+
// ----------------------------------------------------------- Constructors
-
-
+
+
/**
* Constructor.
- *
+ *
* @param message Exception message
*/
public WebdavException(String message) {
this.message = message;
}
-
-
+
+
/**
* Constructor.
*
@@ -103,8 +103,8 @@
if (message != null)
this.message = message;
}
-
-
+
+
/**
* Constructor.
*
@@ -115,25 +115,25 @@
this(message);
this.statusCode = statusCode;
}
-
-
+
+
// ------------------------------------------------------------- Properties
-
-
+
+
/**
* getStatusCode
*/
public int getStatusCode() {
return statusCode;
}
-
-
+
+
/**
* getMessage
*/
public String getMessage() {
return message;
}
-
-
+
+
}
1.28 +8 -4 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavClient.java
Index: WebdavClient.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavClient.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- WebdavClient.java 2001/02/26 13:49:39 1.27
+++ WebdavClient.java 2001/02/28 12:47:51 1.28
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavClient.java,v 1.27 2001/02/26 13:49:39 jericho Exp $
- * $Revision: 1.27 $
- * $Date: 2001/02/26 13:49:39 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavClient.java,v 1.28 2001/02/28 12:47:51 jericho Exp $
+ * $Revision: 1.28 $
+ * $Date: 2001/02/28 12:47:51 $
*
* ====================================================================
*
@@ -374,6 +374,9 @@
}
openConnection();
} catch (WebdavException e) {
+ // During communication, save the status code.
+ if (e.getStatusCode() > 0)
+ method.setStatusCode(e.getStatusCode());
if (debug > 1)
e.printStackTrace();
// If something goes wrong, disconnect, then reconnect
@@ -390,7 +393,8 @@
}
if (retries == 5) {
- throw new WebdavException("Unable to process request");
+ throw new WebdavException
+ ("Unable to process request", method.getStatusCode());
}
method.processResponseHeaders(responseHeaders);
1.6 +42 -41 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/Authenticator.java
Index: Authenticator.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/Authenticator.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Authenticator.java 2001/02/15 17:40:11 1.5
+++ Authenticator.java 2001/02/28 12:47:52 1.6
@@ -1,13 +1,13 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/Authenticator.java,v 1.5 2001/02/15 17:40:11 remm Exp $
- * $Revision: 1.5 $
- * $Date: 2001/02/15 17:40:11 $
+ * $Header: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/Authenticator.java,v 1.6 2001/02/28 12:47:52 jericho Exp $
+ * $Revision: 1.6 $
+ * $Date: 2001/02/28 12:47:52 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -15,7 +15,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -23,15 +23,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
- * from this software without prior written permission. For written
+ * from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
@@ -59,7 +59,7 @@
*
* [Additional notices, if required by prior licensing conditions]
*
- */
+ */
package org.apache.webdav.lib;
@@ -67,84 +67,85 @@
/**
* Authenticate helper.
- *
+ *
* @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
*/
public class Authenticator {
-
-
+
+
// ----------------------------------------------------- Instance Variables
-
-
+
+
/**
* Base 64 encoder.
*/
protected static Base64 base64 = new Base64();
-
-
+
+
// ------------------------------------------------------------- Properties
-
-
+
+
/**
* Generate a response to the given challenge.
- *
+ *
* @param state State
* @param credentials Credentials to use to answser the challenge
* @return String response to the challenge
*/
public static String challengeResponse(State state,
- Credentials credentials)
+ Credentials credentials)
throws WebdavException {
-
+
if (credentials == null)
- throw new WebdavException("No credentials given");
-
+ throw new WebdavException
+ ("No credentials given", WebdavStatus.SC_UNAUTHORIZED);
+
String challenge = state.getAuthenticateToken();
if (challenge == null)
return null;
-
+
int space = challenge.indexOf(' ');
if (space < 0)
return null;
-
+
String challengeName = challenge.substring(0, space);
-
+
if (challengeName.equalsIgnoreCase("basic")) {
return basic(state, credentials);
} else if (challengeName.equalsIgnoreCase("digest")) {
return digest(state, credentials);
} else {
-
+
}
return null;
-
+
}
-
-
+
+
/**
* Generate a basic response.
- *
+ *
* @param credentials Credentials to use to answser the challenge
*/
public static String basic(State state, Credentials credentials) {
-
- String authString = credentials.getUserName() + ":"
+
+ String authString = credentials.getUserName() + ":"
+ credentials.getPassword();
return "Basic " + new String(base64.encode(authString.getBytes()));
-
+
}
-
-
+
+
/**
* Generate a basic response.
- *
+ *
* @param credentials Credentials to use to answser the challenge
*/
public static String digest(State state, Credentials credentials) {
-
+
return null;
-
+
}
-
-
+
+
}