jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r818473 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/security/user/ main/resources/org/apache/jackrabbit/core/nodetype/ test/java/org/apache/jackrabbit/core/security/user/
Date Thu, 24 Sep 2009 13:21:00 GMT
Author: angela
Date: Thu Sep 24 13:21:00 2009
New Revision: 818473

URL: http://svn.apache.org/viewvc?rev=818473&view=rev
Log:
JCR-2313: Improvements to user management (2)  [NOTE: work in progress]

- rep:userId now is redundant and contained in jcr:uuid (access user by id) and node name
(display user id)
-> removed from node type definition and adjusted impl accordingly

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/AuthorizableImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/GroupImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserConstants.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/AuthorizableImplTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/NodeResolverTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserManagerImplTest.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/AuthorizableImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/AuthorizableImpl.java?rev=818473&r1=818472&r2=818473&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/AuthorizableImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/AuthorizableImpl.java
Thu Sep 24 13:21:00 2009
@@ -26,6 +26,7 @@
 import org.apache.jackrabbit.core.nodetype.NodeTypeImpl;
 import org.apache.jackrabbit.core.security.principal.PrincipalImpl;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.util.Text;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -70,6 +71,16 @@
 
     //-------------------------------------------------------< Authorizable >---
     /**
+     * Returns the unescaped name of the node that defines this <code>Authorizable</code>.
+     *
+     * @return the unescaped name of the node that defines this <code>Authorizable</code>.
+     * @see Authorizable#getID()
+     */
+    public String getID() throws RepositoryException {
+        return Text.unescapeIllegalJcrChars(getNode().getName());
+    }
+
+    /**
      * @see Authorizable#declaredMemberOf()
      */
     public Iterator<Group> declaredMemberOf() throws RepositoryException {
@@ -351,7 +362,7 @@
      */
     private boolean isProtectedProperty(String propertyName) throws RepositoryException {
         Name pName = getSession().getQName(propertyName);
-        return P_PRINCIPAL_NAME.equals(pName) || P_USERID.equals(pName)
+        return P_PRINCIPAL_NAME.equals(pName)
                 || P_GROUPS.equals(pName)
                 || P_IMPERSONATORS.equals(pName) || P_PASSWORD.equals(pName);
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/GroupImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/GroupImpl.java?rev=818473&r1=818472&r2=818473&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/GroupImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/GroupImpl.java
Thu Sep 24 13:21:00 2009
@@ -63,19 +63,6 @@
 
     //-------------------------------------------------------< Authorizable >---
     /**
-     * Returns the name of the node that defines this <code>Group</code>, that
-     * has been used taking the principal name as hint, unescaping any chars
-     * that have been escaped to circumvent incompatitibilities with JCR name
-     * limitations.
-     *
-     * @return name of the node that defines this <code>Group</code>.
-     * @see Authorizable#getID()
-     */
-    public String getID() throws RepositoryException {
-        return Text.unescapeIllegalJcrChars(getNode().getName());
-    }
-
-    /**
      * @see Authorizable#isGroup()
      */
     public boolean isGroup() {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserConstants.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserConstants.java?rev=818473&r1=818472&r2=818473&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserConstants.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserConstants.java
Thu Sep 24 13:21:00 2009
@@ -47,6 +47,11 @@
     String GROUP_ADMIN_GROUP_NAME = "GroupAdmin";
 
     Name P_PRINCIPAL_NAME = NF.create(Name.NS_REP_URI, "principalName");
+    /**
+     * @deprecated As of 2.0 the id-hash is stored with the jcr:uuid making the
+     * rep:userId property redundant. It has been removed from the node type
+     * definition.
+     */
     Name P_USERID = NF.create(Name.NS_REP_URI, "userId");
     Name P_PASSWORD = NF.create(Name.NS_REP_URI, "password");
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserImpl.java?rev=818473&r1=818472&r2=818473&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserImpl.java
Thu Sep 24 13:21:00 2009
@@ -35,19 +35,14 @@
  */
 public class UserImpl extends AuthorizableImpl implements User {
 
-    private final String id;
-
     private Principal principal;
     private Impersonation impersonation;
 
     protected UserImpl(NodeImpl node, UserManagerImpl userManager) throws RepositoryException
{
         super(node, userManager);
-
-        id = node.getProperty(P_USERID).getString();
     }
 
     //--------------------------------------------------------------------------
-
     /**
      *
      * @param password
@@ -65,20 +60,18 @@
         }
     }
 
-    //-------------------------------------------------------< Authorizable >---
-    /**
-     * @see org.apache.jackrabbit.api.security.user.Authorizable#getID()
-     */
-    public String getID() throws RepositoryException {
-        return id;
-    }
-
     //------------------------------------------------< User >------------------
     /**
      * @see User#isAdmin()
      */
     public boolean isAdmin() {
-        return userManager.isAdminId(id);
+        try {
+            return userManager.isAdminId(getID());
+        } catch (RepositoryException e) {
+            // should never get here
+            log.error("Internal error while retrieving UserID.", e);
+            return false;
+        }
     }
 
     /**
@@ -87,7 +80,7 @@
     public Credentials getCredentials() throws RepositoryException {
         try {
             String password = getNode().getProperty(P_PASSWORD).getString();
-            return new CryptedSimpleCredentials(id, password);
+            return new CryptedSimpleCredentials(getID(), password);
         } catch (NoSuchAlgorithmException e) {
             throw new RepositoryException(e);
         } catch (UnsupportedEncodingException e) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java?rev=818473&r1=818472&r2=818473&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java
Thu Sep 24 13:21:00 2009
@@ -487,7 +487,6 @@
         try {
             NodeImpl userNode = (NodeImpl) nodeCreator.createUserNode(userID, intermediatePath);
 
-            setProperty(userNode, P_USERID, getValue(userID), true);
             setProperty(userNode, P_PASSWORD, getValue(UserImpl.buildPasswordValue(password)),
true);
             setProperty(userNode, P_PRINCIPAL_NAME, getValue(principal.getName()), true);
             if (!batchModus) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd?rev=818473&r1=818472&r2=818473&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/resources/org/apache/jackrabbit/core/nodetype/builtin_nodetypes.cnd
Thu Sep 24 13:21:00 2009
@@ -600,7 +600,6 @@
   - rep:impersonators (STRING) protected multiple
 
 [rep:User] > rep:Authorizable, rep:Impersonatable
-  - rep:userId (STRING) protected mandatory
   - rep:password (STRING) protected mandatory
 
 [rep:Group] > rep:Authorizable

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/AuthorizableImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/AuthorizableImplTest.java?rev=818473&r1=818472&r2=818473&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/AuthorizableImplTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/AuthorizableImplTest.java
Thu Sep 24 13:21:00 2009
@@ -54,7 +54,6 @@
 
         if (superuser instanceof SessionImpl) {
             NameResolver resolver = (SessionImpl) superuser;
-            protectedUserProps.add(resolver.getJCRName(UserConstants.P_USERID));
             protectedUserProps.add(resolver.getJCRName(UserConstants.P_PASSWORD));
             protectedUserProps.add(resolver.getJCRName(UserConstants.P_GROUPS));
             protectedUserProps.add(resolver.getJCRName(UserConstants.P_IMPERSONATORS));
@@ -135,7 +134,7 @@
         UserImpl user = (UserImpl) getTestUser(superuser);
         NodeImpl n = user.getNode();
 
-        checkProtected(n.getProperty(UserConstants.P_USERID));
+        checkProtected(n.getProperty(UserConstants.P_PASSWORD));
         checkProtected(n.getProperty(UserConstants.P_PRINCIPAL_NAME));
         if (n.hasProperty(UserConstants.P_GROUPS)) {
             checkProtected(n.getProperty(UserConstants.P_GROUPS));

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/NodeResolverTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/NodeResolverTest.java?rev=818473&r1=818472&r2=818473&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/NodeResolverTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/NodeResolverTest.java
Thu Sep 24 13:21:00 2009
@@ -125,16 +125,6 @@
         }
     }
 
-    public void testFindNodeByUserID() throws NotExecutableException, RepositoryException
{
-        UserImpl currentUser = getCurrentUser(superuser);
-
-        NodeResolver nr = createNodeResolver(currentUser.getNode().getSession());
-
-        Node result = nr.findNode(UserConstants.P_USERID, currentUser.getID(), UserConstants.NT_REP_USER);
-        assertNotNull(result);
-        assertTrue(currentUser.getNode().isSame(result));
-    }
-
     public void testFindNodeByMultiValueProp() throws NotExecutableException, RepositoryException
{
         UserImpl currentUser = getCurrentUser(superuser);
 

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserManagerImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserManagerImplTest.java?rev=818473&r1=818472&r2=818473&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserManagerImplTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserManagerImplTest.java
Thu Sep 24 13:21:00 2009
@@ -43,7 +43,6 @@
 public class UserManagerImplTest extends AbstractUserTest {
 
     private String pPrincipalName;
-    private String pUserID;
 
     protected void setUp() throws Exception {
         super.setUp();
@@ -52,7 +51,6 @@
         }
         NameResolver resolver = (SessionImpl) superuser;
         pPrincipalName = resolver.getJCRName(UserConstants.P_PRINCIPAL_NAME);
-        pUserID = resolver.getJCRName(UserConstants.P_USERID);
     }
 
     private String getTestUserId(Principal p) throws RepositoryException {
@@ -262,14 +260,6 @@
             }
             assertTrue("Searching for principal-name must find the created user.", found);
 
-            it = userMgr.findAuthorizables(pUserID, uid, UserManager.SEARCH_TYPE_USER);
-            found = false;
-            while (it.hasNext() && !found) {
-                User nu = (User) it.next();
-                found = nu.getID().equals(uid);
-            }
-            assertTrue("Searching for user id must find the created user.", found);
-
             // but search groups should not find anything
             it = userMgr.findAuthorizables(pPrincipalName, p.getName(), UserManager.SEARCH_TYPE_GROUP);
             assertFalse(it.hasNext());



Mime
View raw message