cmlenz 2002/08/01 01:25:24
Modified: src/webdav/server/org/apache/slide/webdav WebdavServlet.java
Log:
Fix an evil program flow error that ocurred when the namespace was being
initialized from outside the webdav-servlet
Thanks to Martin Holz (holz at fiz-chemie.de) for the report!
Revision Changes Path
1.49 +61 -60
jakarta-slide/src/webdav/server/org/apache/slide/webdav/WebdavServlet.java
Index: WebdavServlet.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/WebdavServlet.java,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- WebdavServlet.java 18 Jun 2002 15:44:37 -0000 1.48
+++ WebdavServlet.java 1 Aug 2002 08:25:24 -0000 1.49
@@ -322,32 +322,69 @@
throw new ServletException("Invalid XML parser");
}
+ String value = null;
+
// Lookup for the NAT using JNDI
// FIXME
// Lookup for the NAT using the servlet context
token = (NamespaceAccessToken)
getServletContext().getAttribute(ATTRIBUTE_NAME);
- if (token != null) {
+ if (token == null) {
+ // Dafault initialization
+ String namespaceName = null;
+ String domainConfigFile = null;
+ value = getInitParameter("namespace");
+ if (value != null) {
+ namespaceName = value;
+ }
+ value = getInitParameter("domain");
+ if (value != null) {
+ domainConfigFile = value;
+ }
+ try {
+
+ if (domainConfigFile != null) {
+ URL domainConfigFileURL =
+ getServletContext().getResource(domainConfigFile);
+ if (domainConfigFileURL != null) {
+ Domain.init(domainConfigFileURL);
+ }
+ }
+
+ if (namespaceName == null) {
+ namespaceName = Domain.getDefaultNamespace();
+ log("No namespace specified, will use default namespace: " +
+ namespaceName);
+ }
+
+ token = Domain.accessNamespace
+ (new SecurityToken(this), namespaceName);
+ if (token == null) {
+ log("Could not access namespace " + namespaceName + ".");
+ throw new UnavailableException("Namespace " + namespaceName +
+ " not accessible");
+ }
+ getServletContext().setAttribute(ATTRIBUTE_NAME, token);
+
+ } catch (DomainInitializationFailedError e) {
+ log("Could not initialize domain", e);
+ throw new UnavailableException(e.toString());
+ } catch (Throwable t) {
+ t.printStackTrace();
+ throw new ServletException(t.toString());
+ }
+ } else {
handleLifecycle = false;
- return;
}
+
+ // Setup the method factory
+ methodFactory =
+ WebdavMethodFactory.newInstance(
+ (WebdavServletConfig)getServletConfig());
- // Dafault initialization
-
- String namespaceName = null;
- String domainConfigFile = null;
-
- String value = null;
-
- value = getInitParameter("namespace");
- if (value != null)
- namespaceName = value;
-
- value = getInitParameter("domain");
- if (value != null)
- domainConfigFile = value;
-
+ // Check whether directory browsing is enabled, and how it should be
+ // accomplished
value = getInitParameter("directory-browsing");
if (value != null) {
if (value.startsWith("/")) {
@@ -360,44 +397,6 @@
directoryBrowsing = Boolean.valueOf(value).booleanValue();
}
}
-
- try {
-
- if (domainConfigFile != null) {
- URL domainConfigFileURL =
- getServletContext().getResource(domainConfigFile);
- if (domainConfigFileURL != null) {
- Domain.init(domainConfigFileURL);
- }
- }
-
- if (namespaceName == null) {
- namespaceName = Domain.getDefaultNamespace();
- log("No namespace specified, will use default namespace: " +
- namespaceName);
- }
-
- token = Domain.accessNamespace
- (new SecurityToken(this), namespaceName);
- if (token == null) {
- log("Could not access namespace " + namespaceName + ".");
- throw new UnavailableException("Namespace " + namespaceName +
- " not accessible");
- }
- getServletContext().setAttribute(ATTRIBUTE_NAME, token);
-
- } catch (DomainInitializationFailedError e) {
- log("Could not initialize domain", e);
- throw new UnavailableException(e.toString());
- } catch (Throwable t) {
- t.printStackTrace();
- throw new ServletException(t.toString());
- }
-
- methodFactory =
- WebdavMethodFactory.newInstance(
- (WebdavServletConfig)getServletConfig());
-
if (directoryBrowsing) {
directoryIndexGenerator =
new DirectoryIndexGenerator
@@ -410,8 +409,10 @@
* Destroy servlet.
*/
public void destroy() {
- if (handleLifecycle)
+
+ if (handleLifecycle) {
Domain.closeNamespace(token);
+ }
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>