jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r899587 - in /jackrabbit/branches/2.0: jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/ jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/server/ jackrabbit-standalone/src/main/resources/WEB-INF/ jackrabbit-webapp/s...
Date Fri, 15 Jan 2010 10:48:51 GMT
Author: angela
Date: Fri Jan 15 10:48:50 2010
New Revision: 899587

URL: http://svn.apache.org/viewvc?rev=899587&view=rev
Log:
2.0: Merged revision 899583 (JCR-2045)

Modified:
    jackrabbit/branches/2.0/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/BasicCredentialsProvider.java
    jackrabbit/branches/2.0/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/server/BasicCredentialsProviderTest.java
    jackrabbit/branches/2.0/jackrabbit-standalone/src/main/resources/WEB-INF/web.xml
    jackrabbit/branches/2.0/jackrabbit-webapp/src/main/webapp/WEB-INF/web.xml

Modified: jackrabbit/branches/2.0/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/BasicCredentialsProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.0/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/BasicCredentialsProvider.java?rev=899587&r1=899586&r2=899587&view=diff
==============================================================================
--- jackrabbit/branches/2.0/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/BasicCredentialsProvider.java
(original)
+++ jackrabbit/branches/2.0/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/BasicCredentialsProvider.java
Fri Jan 15 10:48:50 2010
@@ -22,6 +22,7 @@
 import javax.jcr.Credentials;
 import javax.jcr.LoginException;
 import javax.jcr.SimpleCredentials;
+import javax.jcr.GuestCredentials;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import java.io.ByteArrayOutputStream;
@@ -33,6 +34,9 @@
  */
 public class BasicCredentialsProvider implements CredentialsProvider {
 
+    public static final String EMPTY_DEFAULT_HEADER_VALUE = "";
+    public static final String GUEST_DEFAULT_HEADER_VALUE = "guestcredentials";
+
     private final String defaultHeaderValue;
 
     /**
@@ -92,8 +96,10 @@
                 // check special handling
                 if (defaultHeaderValue == null) {
                     throw new LoginException();
-                } else if (defaultHeaderValue.equals("")) {
+                } else if (EMPTY_DEFAULT_HEADER_VALUE.equals(defaultHeaderValue)) {
                     return null;
+                } else if (GUEST_DEFAULT_HEADER_VALUE.equals(defaultHeaderValue)) {
+                    return new GuestCredentials();
                 } else {
                     int pos = defaultHeaderValue.indexOf(':');
                     if (pos < 0) {

Modified: jackrabbit/branches/2.0/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/server/BasicCredentialsProviderTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.0/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/server/BasicCredentialsProviderTest.java?rev=899587&r1=899586&r2=899587&view=diff
==============================================================================
--- jackrabbit/branches/2.0/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/server/BasicCredentialsProviderTest.java
(original)
+++ jackrabbit/branches/2.0/jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/server/BasicCredentialsProviderTest.java
Fri Jan 15 10:48:50 2010
@@ -27,6 +27,7 @@
 import javax.jcr.LoginException;
 import javax.jcr.Credentials;
 import javax.jcr.SimpleCredentials;
+import javax.jcr.GuestCredentials;
 import java.util.Enumeration;
 import java.util.Map;
 import java.util.Locale;
@@ -52,6 +53,20 @@
         }
     }
 
+    public void testGuestCredentialsDefaultHeader() throws ServletException, LoginException
{
+        CredentialsProvider cb = new BasicCredentialsProvider(BasicCredentialsProvider.GUEST_DEFAULT_HEADER_VALUE);
+        Credentials creds = cb.getCredentials(new RequestImpl(null));
+
+        assertTrue(creds instanceof GuestCredentials);
+    }
+
+    public void testEmptyDefaultHeader() throws ServletException, LoginException {
+        CredentialsProvider cb = new BasicCredentialsProvider(BasicCredentialsProvider.EMPTY_DEFAULT_HEADER_VALUE);
+        Credentials creds = cb.getCredentials(new RequestImpl(null));
+
+        assertNull(creds);
+    }
+
     public void testDefaultPassword() throws ServletException, LoginException {
         Map m = new HashMap();
         m.put("userId", new char[0]);

Modified: jackrabbit/branches/2.0/jackrabbit-standalone/src/main/resources/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.0/jackrabbit-standalone/src/main/resources/WEB-INF/web.xml?rev=899587&r1=899586&r2=899587&view=diff
==============================================================================
--- jackrabbit/branches/2.0/jackrabbit-standalone/src/main/resources/WEB-INF/web.xml (original)
+++ jackrabbit/branches/2.0/jackrabbit-standalone/src/main/resources/WEB-INF/web.xml Fri Jan
15 10:48:50 2010
@@ -77,14 +77,16 @@
             <description>
                 Defines how a missing authorization header should be handled.
                 1) If this init-param is missing, a 401 response is generated.
-                This is suiteable for clients (eg. webdav clients) for which
-                sending a proper authorization header is not possible if the
-                server never sent a 401.
+                   This is suiteable for clients (eg. webdav clients) for which
+                   sending a proper authorization header is not possible if the
+                   server never sent a 401.
                 2) If this init-param is present with an empty value,
-                null-credentials are returned, thus forcing an null login
-                on the repository.
-                3) If this init-param has a 'user:password' value, the respective
-                simple credentials are generated.
+                   null-credentials are returned, thus forcing an null login
+                   on the repository.
+                3) If this init-param is present with the value 'guestcredentials'
+                   java.jcr.GuestCredentials are used to login to the repository.
+                4) If this init-param has a 'user:password' value, the respective
+                   simple credentials are generated.
             </description>
         </init-param>
         <!--

Modified: jackrabbit/branches/2.0/jackrabbit-webapp/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.0/jackrabbit-webapp/src/main/webapp/WEB-INF/web.xml?rev=899587&r1=899586&r2=899587&view=diff
==============================================================================
--- jackrabbit/branches/2.0/jackrabbit-webapp/src/main/webapp/WEB-INF/web.xml (original)
+++ jackrabbit/branches/2.0/jackrabbit-webapp/src/main/webapp/WEB-INF/web.xml Fri Jan 15 10:48:50
2010
@@ -225,7 +225,9 @@
                  2) If this init-param is present with an empty value,
                     null-credentials are returned, thus forcing an null login
                     on the repository.
-                 3) If this init-param has a 'user:password' value, the respective
+                 3) If this init-param is present with the value 'guestcredentials'
+                    java.jcr.GuestCredentials are used to login to the repository.
+                 4) If this init-param has a 'user:password' value, the respective
                     simple credentials are generated.
              </description>
          </init-param>



Mime
View raw message