incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r947108 - in /sling/trunk/bundles/commons/auth/src: main/java/org/apache/sling/commons/auth/impl/ main/java/org/apache/sling/commons/auth/impl/engine/ main/java/org/apache/sling/commons/auth/spi/ test/java/org/apache/sling/commons/auth/spi/
Date Fri, 21 May 2010 18:12:35 GMT
Author: cziegeler
Date: Fri May 21 18:12:35 2010
New Revision: 947108

URL: http://svn.apache.org/viewvc?rev=947108&view=rev
Log:
SLING-1447 : support for resource paths containing workspace name - remove workspace support
from commons auth again

Modified:
    sling/trunk/bundles/commons/auth/src/main/java/org/apache/sling/commons/auth/impl/SlingAuthenticator.java
    sling/trunk/bundles/commons/auth/src/main/java/org/apache/sling/commons/auth/impl/engine/EngineAuthenticationHandlerHolder.java
    sling/trunk/bundles/commons/auth/src/main/java/org/apache/sling/commons/auth/spi/AuthenticationInfo.java
    sling/trunk/bundles/commons/auth/src/test/java/org/apache/sling/commons/auth/spi/AuthenticationInfoTest.java

Modified: sling/trunk/bundles/commons/auth/src/main/java/org/apache/sling/commons/auth/impl/SlingAuthenticator.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/auth/src/main/java/org/apache/sling/commons/auth/impl/SlingAuthenticator.java?rev=947108&r1=947107&r2=947108&view=diff
==============================================================================
--- sling/trunk/bundles/commons/auth/src/main/java/org/apache/sling/commons/auth/impl/SlingAuthenticator.java
(original)
+++ sling/trunk/bundles/commons/auth/src/main/java/org/apache/sling/commons/auth/impl/SlingAuthenticator.java
Fri May 21 18:12:35 2010
@@ -659,7 +659,7 @@ public class SlingAuthenticator implemen
         // try to connect
         try {
             Session session = repository.login(getCredentials(authInfo),
-                (String)authInfo.get(AuthenticationInfo.WORKSPACE));
+                null);
 
             // handle impersonation
             session = handleImpersonation(request, response, session);
@@ -719,7 +719,7 @@ public class SlingAuthenticator implemen
 
             try {
 
-                Session session = repository.login((String)anonInfo.get(AuthenticationInfo.WORKSPACE));
+                Session session = repository.login();
 
                 // check whether the client asked for redirect after
                 // authentication and/or impersonation

Modified: sling/trunk/bundles/commons/auth/src/main/java/org/apache/sling/commons/auth/impl/engine/EngineAuthenticationHandlerHolder.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/auth/src/main/java/org/apache/sling/commons/auth/impl/engine/EngineAuthenticationHandlerHolder.java?rev=947108&r1=947107&r2=947108&view=diff
==============================================================================
--- sling/trunk/bundles/commons/auth/src/main/java/org/apache/sling/commons/auth/impl/engine/EngineAuthenticationHandlerHolder.java
(original)
+++ sling/trunk/bundles/commons/auth/src/main/java/org/apache/sling/commons/auth/impl/engine/EngineAuthenticationHandlerHolder.java
Fri May 21 18:12:35 2010
@@ -71,7 +71,6 @@ public final class EngineAuthenticationH
         AuthenticationInfo info = new AuthenticationInfo(
             engineAuthInfo.getAuthType());
         info.put(AuthenticationInfo.CREDENTIALS, engineAuthInfo.getCredentials());
-        info.put(AuthenticationInfo.WORKSPACE, engineAuthInfo.getWorkspaceName());
 
         return info;
     }

Modified: sling/trunk/bundles/commons/auth/src/main/java/org/apache/sling/commons/auth/spi/AuthenticationInfo.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/auth/src/main/java/org/apache/sling/commons/auth/spi/AuthenticationInfo.java?rev=947108&r1=947107&r2=947108&view=diff
==============================================================================
--- sling/trunk/bundles/commons/auth/src/main/java/org/apache/sling/commons/auth/spi/AuthenticationInfo.java
(original)
+++ sling/trunk/bundles/commons/auth/src/main/java/org/apache/sling/commons/auth/spi/AuthenticationInfo.java
Fri May 21 18:12:35 2010
@@ -78,7 +78,7 @@ public class AuthenticationInfo extends 
     /**
      * The name of the property providing the name of the user on whose behalf
      * the request is being handled. This property is set by the
-     * {@link #AuthenticationInfo(String, String, char[], String)} constructor
+     * {@link #AuthenticationInfo(String, String, char[])} constructor
      * and may be <code>null</code> if this instance is created by either the
      * {@link #AuthenticationInfo(String, String)} or
      * {@link #AuthenticationInfo(String, String, char[])} constructors.
@@ -90,7 +90,7 @@ public class AuthenticationInfo extends 
     /**
      * The name of the property providing the password of the user on whose
      * behalf the request is being handled. This property is set by the
-     * {@link #AuthenticationInfo(String, String, char[], String)} constructor
+     * {@link #AuthenticationInfo(String, String, char[])} constructor
      * and may be <code>null</code> if this instance is created by either the
      * {@link #AuthenticationInfo(String, String)} or
      * {@link #AuthenticationInfo(String, String, char[])} constructors.
@@ -103,8 +103,7 @@ public class AuthenticationInfo extends 
      * The name of the property providing the JCR credentials. These credentials
      * are preset to the credentials given to the
      * {@link #AuthenticationInfo(String, String)} or
-     * {@link #AuthenticationInfo(String, String, char[])} constructors. the
-     * {@link #AuthenticationInfo(String, String, char[], String)} constructor
+     * {@link #AuthenticationInfo(String, String, char[])} constructors.
      * is used the credentials property is set to a JCR
      * <code>SimpleCredentials</code> instance containing the user id and
      * password passed to the constructor.
@@ -112,17 +111,6 @@ public class AuthenticationInfo extends 
     public static final String CREDENTIALS = "user.jcr.credentials";
 
     /**
-     * The name of the property providing the name of the JCR workspace to which
-     * the request should be connected. This property may be set by any of the
-     * constructors. If this property is not set, the user will be connected to
-     * a default workspace as defined by the JCR repository to which the request
-     * is connected.
-     * <p>
-     * The type of this property, if present, is <code>String</code>.
-     */
-    public static final String WORKSPACE = "user.jcr.workspace";
-
-    /**
      * Creates an instance of this class with just the authentication type. To
      * effectively use this instance the user Id with optional password and/or
      * the credentials should be set.
@@ -130,7 +118,7 @@ public class AuthenticationInfo extends 
      * @param authType The authentication type, must not be <code>null</code>.
      */
     public AuthenticationInfo(final String authType) {
-        this(authType, null, null, null);
+        this(authType, null, null);
     }
 
     /**
@@ -144,14 +132,12 @@ public class AuthenticationInfo extends 
      *             <code>null</code>.
      */
     public AuthenticationInfo(final String authType, final String userId) {
-        this(authType, userId, null, null);
+        this(authType, userId, null);
     }
 
     /**
      * Creates an instance of this class authenticating with the given type and
-     * userid/password connecting to the default workspace as if the
-     * {@link #AuthenticationInfo(String, String, char[], String)} method would
-     * be called with a <code>null</code> workspace name.
+     * userid/password connecting.
      *
      * @param authType The authentication type, must not be <code>null</code>.
      * @param userId The name of the user to authenticate as. This may be
@@ -163,33 +149,9 @@ public class AuthenticationInfo extends 
      */
     public AuthenticationInfo(final String authType, final String userId,
             final char[] password) {
-        this(authType, userId, password, null);
-    }
-
-    /**
-     * Creates an instance of this class authenticating with the given type and
-     * userid/password.
-     *
-     * @param authType The authentication type, must not be <code>null</code>.
-     * @param userId The name of the user to authenticate as. This may be
-     *            <code>null</code> for the constructor and later be set.
-     * @param password The password to authenticate with or <code>null</code>
if
-     *            no password can be supplied.
-     * @param workspaceName The name of the workspace to connect to, may be
-     *            <code>null</code> to connect to the default workspace.
-     * @throws NullPointerException if <code>authType</code> is
-     *             <code>null</code>
-     */
-    public AuthenticationInfo(final String authType, final String userId,
-            final char[] password, final String workspaceName) {
-        if (authType == null) {
-            throw new NullPointerException("authType");
-        }
-
         super.put(AUTH_TYPE, authType);
         putIfNotNull(USER, userId);
         putIfNotNull(PASSWORD, password);
-        putIfNotNull(WORKSPACE, workspaceName);
     }
 
     /**
@@ -267,10 +229,6 @@ public class AuthenticationInfo extends 
      * <td>{@link #CREDENTIALS}</td>
      * <td><code>javax.jcr.Credentials</code></td>
      * </tr>
-     * <tr>
-     * <td>{@link #WORKSPACE}</td>
-     * <td><code>String</code></td>
-     * </tr>
      * </table>
      * <p>
      * If the value for the special key does not match the required type an
@@ -308,11 +266,6 @@ public class AuthenticationInfo extends 
                 + " property must be a javax.jcr.Credentials instance");
         }
 
-        if (WORKSPACE.equals(key) && !(value instanceof String)) {
-            throw new IllegalArgumentException(WORKSPACE
-                + " property must be a String");
-        }
-
         return super.put(key, value);
     }
 

Modified: sling/trunk/bundles/commons/auth/src/test/java/org/apache/sling/commons/auth/spi/AuthenticationInfoTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/auth/src/test/java/org/apache/sling/commons/auth/spi/AuthenticationInfoTest.java?rev=947108&r1=947107&r2=947108&view=diff
==============================================================================
--- sling/trunk/bundles/commons/auth/src/test/java/org/apache/sling/commons/auth/spi/AuthenticationInfoTest.java
(original)
+++ sling/trunk/bundles/commons/auth/src/test/java/org/apache/sling/commons/auth/spi/AuthenticationInfoTest.java
Fri May 21 18:12:35 2010
@@ -75,7 +75,6 @@ public class AuthenticationInfoTest {
         Assert.assertEquals("test", info.getAuthType());
         assertNull(info.getUser());
         assertNull(info.getPassword());
-        assertNull(info.get(AuthenticationInfo.WORKSPACE));
     }
 
     @Test
@@ -84,7 +83,6 @@ public class AuthenticationInfoTest {
         Assert.assertEquals("test", info.getAuthType());
         Assert.assertEquals("name", info.getUser());
         assertNull(info.getPassword());
-        assertNull(info.get(AuthenticationInfo.WORKSPACE));
     }
 
     @Test
@@ -95,18 +93,16 @@ public class AuthenticationInfoTest {
         Assert.assertEquals("test", info.getAuthType());
         Assert.assertEquals("name", info.getUser());
         assertSame(pwd, info.getPassword());
-        assertNull(info.get(AuthenticationInfo.WORKSPACE));
     }
 
     @Test
     public void testAuthenticationInfoStringStringCharArrayString() {
         final char[] pwd = new char[6];
         final AuthenticationInfo info = new AuthenticationInfo("test", "name",
-            pwd, "wsp");
+            pwd);
         Assert.assertEquals("test", info.getAuthType());
         Assert.assertEquals("name", info.getUser());
         assertSame(pwd, info.getPassword());
-        Assert.assertEquals("wsp", info.get(AuthenticationInfo.WORKSPACE));
     }
 
     @Test
@@ -185,42 +181,12 @@ public class AuthenticationInfoTest {
     }
 
     @Test
-    public void testSetWorkspaceName() {
-        final AuthenticationInfo info = new AuthenticationInfo("test", "user",
-            new char[0], "wsp");
-        Assert.assertEquals("wsp", info.get(AuthenticationInfo.WORKSPACE));
-
-        info.remove(AuthenticationInfo.WORKSPACE);
-        Assert.assertEquals(null, info.get(AuthenticationInfo.WORKSPACE));
-
-        info.put(AuthenticationInfo.WORKSPACE, "dummy");
-        Assert.assertEquals("dummy", info.get(AuthenticationInfo.WORKSPACE));
-
-        info.put(AuthenticationInfo.WORKSPACE, "");
-        Assert.assertEquals("", info.get(AuthenticationInfo.WORKSPACE));
-    }
-
-    @Test
-    public void testGetWorkspaceName() {
-        final AuthenticationInfo info = new AuthenticationInfo("test");
-        info.put(AuthenticationInfo.WORKSPACE, "wsp");
-
-        Assert.assertEquals("wsp", info.get(AuthenticationInfo.WORKSPACE));
-        Assert.assertEquals("wsp", info.get(AuthenticationInfo.WORKSPACE));
-        Assert.assertEquals(info.get(AuthenticationInfo.WORKSPACE),
-                info.get(AuthenticationInfo.WORKSPACE));
-    }
-
-    @Test
     public void testSetCredentials() {
         final Credentials creds = new SimpleCredentials("user", new char[0]);
         final AuthenticationInfo info = new AuthenticationInfo("test");
 
         info.put(AuthenticationInfo.CREDENTIALS, creds);
         Assert.assertSame(creds, info.get(AuthenticationInfo.CREDENTIALS));
-
-        info.remove(AuthenticationInfo.WORKSPACE);
-        Assert.assertSame(creds, info.get(AuthenticationInfo.CREDENTIALS));
     }
 
     @Test
@@ -265,27 +231,24 @@ public class AuthenticationInfoTest {
     @Test
     public void testPutStringObject() {
         final AuthenticationInfo info = new AuthenticationInfo("test", "user",
-            new char[2], "wsp");
+            new char[2]);
         info.put(AuthenticationInfo.CREDENTIALS,
                 new SimpleCredentials("user", new char[2]));
 
         test_put_fail(info, AuthenticationInfo.AUTH_TYPE, null);
         test_put_fail(info, AuthenticationInfo.USER, null);
         test_put_fail(info, AuthenticationInfo.PASSWORD, null);
-        test_put_fail(info, AuthenticationInfo.WORKSPACE, null);
         test_put_fail(info, AuthenticationInfo.CREDENTIALS, null);
 
         test_put_fail(info, AuthenticationInfo.AUTH_TYPE, 42);
         test_put_fail(info, AuthenticationInfo.USER, 42);
         test_put_fail(info, AuthenticationInfo.PASSWORD, "string");
-        test_put_fail(info, AuthenticationInfo.WORKSPACE, 42);
         test_put_fail(info, AuthenticationInfo.CREDENTIALS, "string");
 
         test_put_success(info, AuthenticationInfo.AUTH_TYPE, "new_type");
         test_put_success(info, AuthenticationInfo.USER, "new_user");
         test_put_success(info, AuthenticationInfo.PASSWORD,
             "new_pwd".toCharArray());
-        test_put_success(info, AuthenticationInfo.WORKSPACE, "new_wsp");
         test_put_success(info, AuthenticationInfo.CREDENTIALS,
             new SimpleCredentials("new_user", new char[0]));
     }



Mime
View raw message