jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1173118 - /jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
Date Tue, 20 Sep 2011 12:37:54 GMT
Author: jukka
Date: Tue Sep 20 12:37:54 2011
New Revision: 1173118

URL: http://svn.apache.org/viewvc?rev=1173118&view=rev
Log:
JCR-3076: Mandatory authentication prevents webdav client connections

Return an empty set of descriptors when the descriptor report method requires authentication.

Modified:
    jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java

Modified: jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java?rev=1173118&r1=1173117&r2=1173118&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/RepositoryServiceImpl.java
Tue Sep 20 12:37:54 2011
@@ -64,6 +64,7 @@ import org.apache.commons.httpclient.Hos
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpConnectionManager;
 import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.HttpStatus;
 import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
 import org.apache.commons.httpclient.URI;
 import org.apache.commons.httpclient.URIException;
@@ -239,7 +240,9 @@ public class RepositoryServiceImpl imple
 
     private final Map<Name, QNodeTypeDefinition> nodeTypeDefinitions = new HashMap<Name,
QNodeTypeDefinition>();
 
-    private Map<String, QValue[]> descriptors;
+    /** Repository descriptors. */
+    private final Map<String, QValue[]> descriptors =
+            new HashMap<String, QValue[]>();
 
     /**
      * Same as {@link #RepositoryServiceImpl(String, IdFactory, NameFactory, PathFactory,
QValueFactory, int, int)}
@@ -611,16 +614,25 @@ public class RepositoryServiceImpl imple
      * @see RepositoryService#getRepositoryDescriptors()
      */
     public Map<String, QValue[]> getRepositoryDescriptors() throws RepositoryException
{
-        if (descriptors == null) {
+        if (descriptors.isEmpty()) {
             ReportInfo info = new ReportInfo(JcrRemotingConstants.REPORT_REPOSITORY_DESCRIPTORS,
ItemResourceConstants.NAMESPACE);
             ReportMethod method = null;
             try {
                 method = new ReportMethod(uriResolver.getRepositoryUri(), info);
-                getClient(null).executeMethod(method);
+                int sc = getClient(null).executeMethod(method);
+                if (sc == HttpStatus.SC_UNAUTHORIZED
+                        || sc == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED) {
+                    // JCR-3076: Mandatory authentication prevents us from
+                    // accessing the descriptors on the server, so instead
+                    // of failing with an exception we simply return an empty
+                    // set of descriptors
+                    log.warn("Authentication required to access repository descriptors");
+                    return descriptors;
+                }
+
                 method.checkSuccess();
                 Document doc = method.getResponseBodyAsDocument();
 
-                descriptors = new HashMap<String, QValue[]>();
                 if (doc != null) {
                     Element rootElement = doc.getDocumentElement();
                     ElementIterator nsElems = DomUtil.getChildren(rootElement, JcrRemotingConstants.XML_DESCRIPTOR,
ItemResourceConstants.NAMESPACE);



Mime
View raw message