jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1333800 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security: principal/ user/
Date Fri, 04 May 2012 07:59:00 GMT
Author: angela
Date: Fri May  4 07:59:00 2012
New Revision: 1333800

URL: http://svn.apache.org/viewvc?rev=1333800&view=rev
Log:
OAK-50 : User management (WIP)

Added:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/EveryonePrincipal.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/MembershipManager.java
Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizableImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/GroupImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/UserImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/UserManagerImpl.java

Added: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/EveryonePrincipal.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/EveryonePrincipal.java?rev=1333800&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/EveryonePrincipal.java
(added)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/EveryonePrincipal.java
Fri May  4 07:59:00 2012
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.jcr.security.principal;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * EveryonePrincipal...
+ */
+public class EveryonePrincipal {
+
+    /**
+     * logger instance
+     */
+    private static final Logger log = LoggerFactory.getLogger(EveryonePrincipal.class);
+
+    public static final String NAME = "everyone";
+}
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizableImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizableImpl.java?rev=1333800&r1=1333799&r2=1333800&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizableImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizableImpl.java
Fri May  4 07:59:00 2012
@@ -19,7 +19,7 @@ package org.apache.jackrabbit.oak.jcr.se
 import org.apache.jackrabbit.api.security.user.Authorizable;
 import org.apache.jackrabbit.api.security.user.Group;
 import org.apache.jackrabbit.api.security.user.User;
-import org.apache.jackrabbit.oak.jcr.NodeImpl;
+import org.apache.jackrabbit.oak.jcr.security.principal.EveryonePrincipal;
 import org.apache.jackrabbit.util.Text;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -55,33 +55,46 @@ abstract class AuthorizableImpl implemen
     static final String REP_MEMBERS = "rep:members";
     static final String REP_IMPERSONATORS = "rep:impersonators";
 
-    private final NodeImpl node;  // FIXME use NodeDelegate instead of NodeImpl
+    private final Node node;
     private final UserManagerImpl userManager;
 
     private int hashCode;
 
-    AuthorizableImpl(NodeImpl node, UserManagerImpl userManager) {
+    AuthorizableImpl(Node node, UserManagerImpl userManager) throws RepositoryException {
+        checkValidNode(node);
         this.node = node;
         this.userManager = userManager;
     }
 
+    abstract void checkValidNode(Node node) throws RepositoryException;
+
+    static boolean isValidAuthorizableImpl(Authorizable authorizable) {
+        return authorizable instanceof AuthorizableImpl;
+    }
+
     //-------------------------------------------------------< Authorizable >---
+    /**
+     * @see org.apache.jackrabbit.api.security.user.Authorizable#getID()
+     */
     @Override
     public String getID() throws RepositoryException {
-        // TODO
-        return null;
+        return Text.unescapeIllegalJcrChars(getNode().getName());
     }
 
+    /**
+     * @see Authorizable#declaredMemberOf()
+     */
     @Override
     public Iterator<Group> declaredMemberOf() throws RepositoryException {
-        // TODO
-        return null;
+        return collectMembership(false);
     }
 
+    /**
+     * @see Authorizable#memberOf()
+     */
     @Override
     public Iterator<Group> memberOf() throws RepositoryException {
-        // TODO
-        return null;
+        return collectMembership(true);
     }
 
     /**
@@ -265,7 +278,7 @@ abstract class AuthorizableImpl implemen
     public String toString() {
         try {
             String typeStr = (isGroup()) ? "Group '" : "User '";
-            return typeStr + getID() + '\'';
+            return new StringBuilder().append(typeStr).append(getID()).append('\'').toString();
         } catch (RepositoryException e) {
             return super.toString();
         }
@@ -275,7 +288,7 @@ abstract class AuthorizableImpl implemen
     /**
      * @return The node associated with this authorizable instance.
      */
-    NodeImpl getNode() {
+    Node getNode() {
         return node;
     }
 
@@ -302,6 +315,15 @@ abstract class AuthorizableImpl implemen
     }
 
     /**
+     *
+     * @return
+     * @throws RepositoryException
+     */
+    boolean isEveryone() throws RepositoryException {
+        return isGroup() && EveryonePrincipal.NAME.equals(getPrincipalName());
+    }
+
+    /**
      * Returns true if the given property of the authorizable node is one of the
      * non-protected properties defined by the rep:Authorizable node type or a
      * some other descendant of the authorizable node.
@@ -372,4 +394,13 @@ abstract class AuthorizableImpl implemen
         }
         return n;
     }
+
+    private Iterator<Group> collectMembership(boolean includeIndirect) throws RepositoryException
{
+        MembershipManager membershipManager = userManager.getMembershipManager();
+        if (includeIndirect) {
+            return membershipManager.getMembership(this);
+        } else {
+            return membershipManager.getDeclaredMembership(this);
+        }
+    }
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/GroupImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/GroupImpl.java?rev=1333800&r1=1333799&r2=1333800&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/GroupImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/GroupImpl.java
Fri May  4 07:59:00 2012
@@ -18,10 +18,11 @@ package org.apache.jackrabbit.oak.jcr.se
 
 import org.apache.jackrabbit.api.security.user.Authorizable;
 import org.apache.jackrabbit.api.security.user.Group;
-import org.apache.jackrabbit.oak.jcr.NodeImpl;
+import org.apache.jackrabbit.api.security.user.UserManager;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 import java.security.Principal;
 import java.util.Enumeration;
@@ -37,10 +38,17 @@ class GroupImpl extends AuthorizableImpl
      */
     private static final Logger log = LoggerFactory.getLogger(GroupImpl.class);
 
-    public GroupImpl(NodeImpl node, UserManagerImpl userManager) {
+    GroupImpl(Node node, UserManagerImpl userManager) throws RepositoryException {
         super(node, userManager);
     }
 
+    @Override
+    void checkValidNode(Node node) throws RepositoryException {
+        if (node == null || !node.isNodeType(AuthorizableImpl.NT_REP_GROUP)) {
+            throw new IllegalArgumentException("Invalid group node: node type rep:Group expected.");
+        }
+    }
+
     //-------------------------------------------------------< Authorizable >---
     /**
      * @see org.apache.jackrabbit.api.security.user.Authorizable#isGroup()
@@ -59,46 +67,123 @@ class GroupImpl extends AuthorizableImpl
     }
 
     //--------------------------------------------------------------< Group >---
-
+    /**
+     * @see org.apache.jackrabbit.api.security.user.Group#getDeclaredMembers()
+     */
     @Override
     public Iterator<Authorizable> getDeclaredMembers() throws RepositoryException {
-        // TODO
-        return null;
+        return getMembers(false);
     }
 
+    /**
+     * @see org.apache.jackrabbit.api.security.user.Group#getMembers()
+     */
     @Override
     public Iterator<Authorizable> getMembers() throws RepositoryException {
-        // TODO
-        return null;
+        return getMembers(true);
     }
 
+    /**
+     * @see org.apache.jackrabbit.api.security.user.Group#isDeclaredMember(org.apache.jackrabbit.api.security.user.Authorizable)
+     */
     @Override
     public boolean isDeclaredMember(Authorizable authorizable) throws RepositoryException
{
-        // TODO
-        return false;
+        return isMember(authorizable, false);
     }
 
+    /**
+     * @see org.apache.jackrabbit.api.security.user.Group#isMember(org.apache.jackrabbit.api.security.user.Authorizable)
+     */
     @Override
     public boolean isMember(Authorizable authorizable) throws RepositoryException {
-        // TODO
-        return false;
+        return isMember(authorizable, true);
     }
 
+    /**
+     * @see org.apache.jackrabbit.api.security.user.Group#addMember(org.apache.jackrabbit.api.security.user.Authorizable)
+     */
     @Override
     public boolean addMember(Authorizable authorizable) throws RepositoryException {
-        // TODO
-        return false;
+        if (!isValidAuthorizableImpl(authorizable)) {
+            log.warn("Invalid Authorizable: {}", authorizable);
+            return false;
+        }
+        if (isEveryone() || ((AuthorizableImpl) authorizable).isEveryone()) {
+            return false;
+        }
+
+        AuthorizableImpl authImpl = ((AuthorizableImpl) authorizable);
+        Node memberNode = authImpl.getNode();
+        if (memberNode.isSame(getNode())) {
+            String msg = "Attempt to add a group as member of itself (" + getID() + ").";
+            log.warn(msg);
+            return false;
+        }
+
+        if (authImpl.isGroup() && ((GroupImpl) authImpl).isMember(this)) {
+            log.warn("Attempt to create circular group membership.");
+            return false;
+        }
+
+        return getUserManager().getMembershipManager().addMember(this, authImpl);
     }
 
+    /**
+     * @see org.apache.jackrabbit.api.security.user.Group#removeMember(org.apache.jackrabbit.api.security.user.Authorizable)
+     */
     @Override
     public boolean removeMember(Authorizable authorizable) throws RepositoryException {
-        // TODO
-        return false;
+        if (!isValidAuthorizableImpl(authorizable)) {
+            log.warn("Invalid Authorizable: {}", authorizable);
+            return false;
+        }
+        if (isEveryone()) {
+            return false;
+        }
+
+        return getUserManager().getMembershipManager().removeMember(this, (AuthorizableImpl)
authorizable);
     }
 
     //--------------------------------------------------------------------------
     /**
      *
+     * @param includeInherited
+     * @return
+     * @throws RepositoryException
+     */
+    private Iterator<Authorizable> getMembers(boolean includeInherited) throws RepositoryException
{
+        if (isEveryone()) {
+            return getUserManager().findAuthorizables(AuthorizableImpl.REP_PRINCIPAL_NAME,
null, UserManager.SEARCH_TYPE_AUTHORIZABLE);
+        } else if (includeInherited) {
+            return getUserManager().getMembershipManager().getMembers(this);
+        } else {
+            return getUserManager().getMembershipManager().getDeclaredMembers(this);
+        }
+    }
+
+    /**
+     *
+     * @param authorizable
+     * @param includeInherited
+     * @return
+     * @throws RepositoryException
+     */
+    private boolean isMember(Authorizable authorizable, boolean includeInherited) throws
RepositoryException {
+        if (!isValidAuthorizableImpl(authorizable)) {
+            return false;
+        } else if (getNode().isSame(((AuthorizableImpl) authorizable).getNode())) {
+            return false;
+        } else if (isEveryone()) {
+            return true;
+        } else if (includeInherited) {
+            return getUserManager().getMembershipManager().hasMember(this, (AuthorizableImpl)
authorizable);
+        } else {
+            return getUserManager().getMembershipManager().hasDeclaredMember(this, (AuthorizableImpl)
authorizable);
+        }
+    }
+
+    /**
+     *
      */
     private class GroupPrincipal extends ItemBasedPrincipalImpl implements java.security.acl.Group
{
 

Added: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/MembershipManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/MembershipManager.java?rev=1333800&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/MembershipManager.java
(added)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/MembershipManager.java
Fri May  4 07:59:00 2012
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.jcr.security.user;
+
+import org.apache.jackrabbit.api.security.user.Authorizable;
+import org.apache.jackrabbit.api.security.user.Group;
+import org.apache.jackrabbit.oak.jcr.SessionDelegate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.RepositoryException;
+import java.util.Iterator;
+
+/**
+ * MembershipManager...
+ */
+class MembershipManager {
+
+    private static final Logger log = LoggerFactory.getLogger(MembershipManager.class);
+
+    private final UserManagerImpl userManager;
+    private final SessionDelegate sessionDelegate;
+
+    MembershipManager(UserManagerImpl userManager, SessionDelegate sessionDelegate) {
+        this.userManager = userManager;
+        this.sessionDelegate = sessionDelegate;
+    }
+
+    Iterator<Group> getDeclaredMembership(AuthorizableImpl authorizable) throws RepositoryException
{
+        // TODO
+        return null;
+    }
+
+    Iterator<Group> getMembership(AuthorizableImpl authorizable) throws RepositoryException
{
+        // TODO
+        return null;
+    }
+
+    boolean hasDeclaredMember(GroupImpl group, AuthorizableImpl authorizable) throws RepositoryException
{
+        // TODO
+        return false;
+    }
+
+    boolean hasMember(GroupImpl group, AuthorizableImpl authorizable) throws RepositoryException
{
+        // TODO
+        return false;
+    }
+
+    Iterator<Authorizable> getDeclaredMembers(GroupImpl group) throws RepositoryException
{
+        // TODO
+        return null;
+    }
+
+    Iterator<Authorizable> getMembers(GroupImpl group) throws RepositoryException {
+        // TODO
+        return null;
+    }
+
+    boolean addMember(GroupImpl group, AuthorizableImpl authorizable) throws RepositoryException
{
+       // todo
+        return false;
+    }
+
+    boolean removeMember(GroupImpl group, AuthorizableImpl authorizable) throws RepositoryException
{
+        // todo
+        return false;
+    }
+}
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/UserImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/UserImpl.java?rev=1333800&r1=1333799&r2=1333800&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/UserImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/UserImpl.java
Fri May  4 07:59:00 2012
@@ -18,11 +18,11 @@ package org.apache.jackrabbit.oak.jcr.se
 
 import org.apache.jackrabbit.api.security.user.Impersonation;
 import org.apache.jackrabbit.api.security.user.User;
-import org.apache.jackrabbit.oak.jcr.NodeImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.jcr.Credentials;
+import javax.jcr.Node;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.UnsupportedRepositoryOperationException;
@@ -38,10 +38,16 @@ class UserImpl extends AuthorizableImpl 
      */
     private static final Logger log = LoggerFactory.getLogger(UserImpl.class);
 
-    UserImpl(NodeImpl node, UserManagerImpl userManager) {
+    UserImpl(Node node, UserManagerImpl userManager) throws RepositoryException {
         super(node, userManager);
     }
 
+    void checkValidNode(Node node) throws RepositoryException {
+        if (node == null || !node.isNodeType(AuthorizableImpl.NT_REP_USER)) {
+            throw new IllegalArgumentException("Invalid group node: node type rep:Group expected.");
+        }
+    }
+
     //-------------------------------------------------------< Authorizable >---
     /**
      * @see org.apache.jackrabbit.api.security.user.Authorizable#isGroup()

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/UserManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/UserManagerImpl.java?rev=1333800&r1=1333799&r2=1333800&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/UserManagerImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/UserManagerImpl.java
Fri May  4 07:59:00 2012
@@ -31,6 +31,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.jcr.ItemNotFoundException;
+import javax.jcr.Node;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
@@ -46,15 +47,14 @@ import java.util.List;
  */
 public class UserManagerImpl implements UserManager {
 
-    /**
-     * logger instance
-     */
     private static final Logger log = LoggerFactory.getLogger(UserManagerImpl.class);
 
     private final SessionDelegate sessionDelegate;
     private final UserManagerConfig config;
     private final AuthorizableNodeCreator nodeCreator;
 
+    private MembershipManager membershipManager;
+    
     public UserManagerImpl(SessionDelegate sessionDelegate, UserManagerConfig config) {
         this.sessionDelegate = sessionDelegate;
         this.config = config;
@@ -69,8 +69,7 @@ public class UserManagerImpl implements 
     public Authorizable getAuthorizable(String id) throws RepositoryException {
         Authorizable authorizable = null;
         try {
-            // FIXME use NodeDelegate instead od NodeImpl
-            NodeImpl node = (NodeImpl) sessionDelegate.getSession().getNodeByIdentifier(buildIdentifier(id));
+            Node node = getSession().getNodeByIdentifier(buildIdentifier(id));
             authorizable = getAuthorizable(node);
         } catch (ItemNotFoundException e) {
             log.debug("No authorizable with ID " + id);
@@ -83,7 +82,7 @@ public class UserManagerImpl implements 
      */
     @Override
     public Authorizable getAuthorizable(Principal principal) throws RepositoryException {
-        Session session = sessionDelegate.getSession();
+        Session session = getSession();
         Authorizable authorizable = null;
         if (principal instanceof ItemBasedPrincipal) {
             String authPath = ((ItemBasedPrincipal) principal).getPath();
@@ -108,10 +107,17 @@ public class UserManagerImpl implements 
         return authorizable;
     }
 
+    /**
+     * @see UserManager#getAuthorizableByPath(String)
+     */
     @Override
     public Authorizable getAuthorizableByPath(String path) throws RepositoryException {
-        // TODO
-        return null;
+        Session session = getSession();
+        if (session.nodeExists(path)) {
+            return getAuthorizable(session.getNode(path));
+        } else {
+            return null;
+        }
     }
 
     @Override
@@ -229,7 +235,7 @@ public class UserManagerImpl implements 
      */
     void onCreate(User user, String password) throws RepositoryException {
         for (AuthorizableAction action : config.getAuthorizableActions()) {
-            action.onCreate(user, password, sessionDelegate.getSession());
+            action.onCreate(user, password, getSession());
         }
     }
 
@@ -243,7 +249,7 @@ public class UserManagerImpl implements 
      */
     void onCreate(Group group) throws RepositoryException {
         for (AuthorizableAction action : config.getAuthorizableActions()) {
-            action.onCreate(group, sessionDelegate.getSession());
+            action.onCreate(group, getSession());
         }
     }
 
@@ -257,7 +263,7 @@ public class UserManagerImpl implements 
      */
     void onRemove(Authorizable authorizable) throws RepositoryException {
         for (AuthorizableAction action : config.getAuthorizableActions()) {
-            action.onRemove(authorizable, sessionDelegate.getSession());
+            action.onRemove(authorizable, getSession());
         }
     }
 
@@ -272,7 +278,7 @@ public class UserManagerImpl implements 
      */
     void onPasswordChange(User user, String password) throws RepositoryException {
         for (AuthorizableAction action : config.getAuthorizableActions()) {
-            action.onPasswordChange(user, password, sessionDelegate.getSession());
+            action.onPasswordChange(user, password, getSession());
         }
     }
 
@@ -293,7 +299,7 @@ public class UserManagerImpl implements 
      * @param forceHash If true the specified password will always be hashed.
      * @throws javax.jcr.RepositoryException If an error occurs
      */
-    void setPassword(NodeImpl userNode, String password, boolean forceHash) throws RepositoryException
{
+    void setPassword(Node userNode, String password, boolean forceHash) throws RepositoryException
{
         if (password != null) {
             log.debug("Password is null.");
             return;
@@ -326,21 +332,32 @@ public class UserManagerImpl implements 
         setInternalProperty(userNode, AuthorizableImpl.REP_PRINCIPAL_NAME, principal.getName(),
PropertyType.STRING);
     }
 
-    void setInternalProperty(NodeImpl userNode, String name, String value, int type) throws
RepositoryException {
+    void setInternalProperty(Node userNode, String name, String value, int type) throws RepositoryException
{
         CoreValue cv = ValueConverter.toCoreValue(value, type, sessionDelegate);
-        sessionDelegate.getTree(userNode.getOakPath()).setProperty(name, cv);
+        sessionDelegate.getTree(getInternalPath(userNode)).setProperty(name, cv);
     }
 
-    void setInternalProperty(NodeImpl userNode, String name, String[] values, int type) throws
RepositoryException {
+    void setInternalProperty(Node userNode, String name, String[] values, int type) throws
RepositoryException {
         List<CoreValue> cvs = ValueConverter.toCoreValues(values, type, sessionDelegate);
-        sessionDelegate.getTree(userNode.getOakPath()).setProperty(name, cvs);
+        sessionDelegate.getTree(getInternalPath(userNode)).setProperty(name, cvs);
     }
 
-    void removeInternalProperty(NodeImpl userNode, String name) {
-        sessionDelegate.getTree(userNode.getOakPath()).removeProperty(name);
+    void removeInternalProperty(Node userNode, String name) throws RepositoryException {
+        sessionDelegate.getTree(getInternalPath(userNode)).removeProperty(name);
     }
 
-    private Authorizable getAuthorizable(NodeImpl node) throws RepositoryException {
+    Session getSession() {
+        return sessionDelegate.getSession();
+    }
+
+    MembershipManager getMembershipManager() {
+        if (membershipManager == null) {
+            membershipManager = new MembershipManager(this, sessionDelegate);
+        }
+        return membershipManager;
+    }
+
+    private Authorizable getAuthorizable(Node node) throws RepositoryException {
         if (node.isNodeType(AuthorizableImpl.NT_REP_USER)) {
             return new UserImpl(node, this);
         } else if (node.isNodeType(AuthorizableImpl.NT_REP_GROUP)) {
@@ -358,4 +375,8 @@ public class UserManagerImpl implements 
     private void checkValidID(String authorizableID) {
         // TODO
     }
+
+    private String getInternalPath(Node node) throws RepositoryException {
+        return sessionDelegate.getNamePathMapper().toOakPath(node.getPath());
+    }
 }
\ No newline at end of file



Mime
View raw message