jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1511302 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserManagerImpl.java oak-jcr/pom.xml oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
Date Wed, 07 Aug 2013 13:32:01 GMT
Author: mduerig
Date: Wed Aug  7 13:32:01 2013
New Revision: 1511302

URL: http://svn.apache.org/r1511302
Log:
OAK-938 UserManager does not honour session refresh settings
Tentative fix by wrapping the core user manager into a SessionOperation closure

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserManagerImpl.java
    jackrabbit/oak/trunk/oak-jcr/pom.xml
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserManagerImpl.java?rev=1511302&r1=1511301&r2=1511302&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserManagerImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserManagerImpl.java
Wed Aug  7 13:32:01 2013
@@ -16,11 +16,14 @@
  */
 package org.apache.jackrabbit.oak.security.user;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+
 import java.io.UnsupportedEncodingException;
 import java.security.NoSuchAlgorithmException;
 import java.security.Principal;
 import java.util.Iterator;
 import java.util.List;
+
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
@@ -53,8 +56,6 @@ import org.apache.jackrabbit.oak.spi.sec
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-
 /**
  * UserManagerImpl...
  */

Modified: jackrabbit/oak/trunk/oak-jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/pom.xml?rev=1511302&r1=1511301&r2=1511302&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-jcr/pom.xml Wed Aug  7 13:32:01 2013
@@ -263,7 +263,6 @@
       org.apache.jackrabbit.oak.jcr.security.authorization.CopyTest#testCopyInvisibleAcContent
      <!-- OAK-920 -->
 
       org.apache.jackrabbit.oak.jcr.security.user.MemberNodeImportTest                  
            <!-- OAK-414, OAK-482 -->
-      org.apache.jackrabbit.oak.jcr.security.user.UserManagerTest#testAutoRefreshSession
            <!-- OAK-938 -->
 
       org.apache.jackrabbit.core.query.ExcerptTest#testMoreTextDotsAtEnd                
            <!-- OAK-318 -->
       org.apache.jackrabbit.core.query.ExcerptTest#testMoreTextDotsAtStart              
            <!-- OAK-318 -->

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java?rev=1511302&r1=1511301&r2=1511302&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java
Wed Aug  7 13:32:01 2013
@@ -18,7 +18,9 @@ package org.apache.jackrabbit.oak.jcr;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
+import java.security.Principal;
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -40,6 +42,11 @@ import javax.jcr.version.VersionManager;
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.api.security.authorization.PrivilegeManager;
 import org.apache.jackrabbit.api.security.principal.PrincipalManager;
+import org.apache.jackrabbit.api.security.user.Authorizable;
+import org.apache.jackrabbit.api.security.user.AuthorizableExistsException;
+import org.apache.jackrabbit.api.security.user.Group;
+import org.apache.jackrabbit.api.security.user.Query;
+import org.apache.jackrabbit.api.security.user.User;
 import org.apache.jackrabbit.api.security.user.UserManager;
 import org.apache.jackrabbit.oak.api.ContentSession;
 import org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate;
@@ -47,6 +54,7 @@ import org.apache.jackrabbit.oak.jcr.del
 import org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate;
 import org.apache.jackrabbit.oak.jcr.delegate.VersionManagerDelegate;
 import org.apache.jackrabbit.oak.jcr.observation.ObservationManagerImpl;
+import org.apache.jackrabbit.oak.jcr.operation.SessionOperation;
 import org.apache.jackrabbit.oak.jcr.security.AccessManager;
 import org.apache.jackrabbit.oak.jcr.version.VersionHistoryImpl;
 import org.apache.jackrabbit.oak.jcr.version.VersionImpl;
@@ -199,8 +207,157 @@ public class SessionContext implements N
 
     @Nonnull
     public UserManager getUserManager() {
+        // TODO Move to top level class (OAK-938), make UserManager from core the delegate
and pass root through argument of perform
         if (userManager == null) {
-            userManager = getConfig(UserConfiguration.class).getUserManager(delegate.getRoot(),
namePathMapper);
+            final UserManager uMgr = getConfig(UserConfiguration.class).getUserManager(delegate.getRoot(),
namePathMapper);
+            userManager = new UserManager() {
+                @Override
+                public Authorizable getAuthorizable(final String id) throws RepositoryException
{
+                    return delegate.perform(new SessionOperation<Authorizable>() {
+                        @Override
+                        public Authorizable perform() throws RepositoryException {
+                            return uMgr.getAuthorizable(id);
+                        }
+                    });
+                }
+
+                @Override
+                public Authorizable getAuthorizable(final Principal principal) throws RepositoryException
{
+                    return delegate.perform(new SessionOperation<Authorizable>() {
+                        @Override
+                        public Authorizable perform() throws RepositoryException {
+                            return uMgr.getAuthorizable(principal);
+                        }
+                    });
+                }
+
+                @Override
+                public Authorizable getAuthorizableByPath(final String path) throws UnsupportedRepositoryOperationException,
RepositoryException {
+                    return delegate.perform(new SessionOperation<Authorizable>() {
+                        @Override
+                        public Authorizable perform() throws RepositoryException {
+                            return uMgr.getAuthorizableByPath(path);
+                        }
+                    });
+                }
+
+                @Override
+                public Iterator<Authorizable> findAuthorizables(final String relPath,
final String value) throws RepositoryException {
+                    return delegate.perform(new SessionOperation<Iterator<Authorizable>>()
{
+                        @Override
+                        public Iterator<Authorizable> perform() throws RepositoryException
{
+                            return uMgr.findAuthorizables(relPath, value);
+                        }
+                    });
+                }
+
+                @Override
+                public Iterator<Authorizable> findAuthorizables(final String relPath,
final String value, final int searchType) throws RepositoryException {
+                    return delegate.perform(new SessionOperation<Iterator<Authorizable>>()
{
+                        @Override
+                        public Iterator<Authorizable> perform() throws RepositoryException
{
+                            return uMgr.findAuthorizables(relPath, value, searchType);
+                        }
+                    });
+                }
+
+                @Override
+                public Iterator<Authorizable> findAuthorizables(final Query query)
throws RepositoryException {
+                    return delegate.perform(new SessionOperation<Iterator<Authorizable>>()
{
+                        @Override
+                        public Iterator<Authorizable> perform() throws RepositoryException
{
+                            return uMgr.findAuthorizables(query);
+                        }
+                    });
+                }
+
+                @Override
+                public User createUser(final String userID, final String password) throws
AuthorizableExistsException, RepositoryException {
+                    return delegate.perform(new SessionOperation<User>() {
+                        @Override
+                        public User perform() throws RepositoryException {
+                            return uMgr.createUser(userID, password);
+                        }
+                    });
+                }
+
+                @Override
+                public User createUser(final String userID, final String password, final
Principal principal, final String intermediatePath) throws AuthorizableExistsException, RepositoryException
{
+                    return delegate.perform(new SessionOperation<User>() {
+                        @Override
+                        public User perform() throws RepositoryException {
+                            return uMgr.createUser(userID, password, principal, intermediatePath);
+                        }
+                    });
+                }
+
+                @Override
+                public Group createGroup(final String groupID) throws AuthorizableExistsException,
RepositoryException {
+                    return delegate.perform(new SessionOperation<Group>() {
+                        @Override
+                        public Group perform() throws RepositoryException {
+                            return uMgr.createGroup(groupID);
+                        }
+                    });
+                }
+
+                @Override
+                public Group createGroup(final Principal principal) throws AuthorizableExistsException,
RepositoryException {
+                    return delegate.perform(new SessionOperation<Group>() {
+                        @Override
+                        public Group perform() throws RepositoryException {
+                            return uMgr.createGroup(principal);
+                        }
+                    });
+                }
+
+                @Override
+                public Group createGroup(final Principal principal, final String intermediatePath)
throws AuthorizableExistsException, RepositoryException {
+                    return delegate.perform(new SessionOperation<Group>() {
+                        @Override
+                        public Group perform() throws RepositoryException {
+                            return uMgr.createGroup(principal, intermediatePath);
+                        }
+                    });
+                }
+
+                @Override
+                public Group createGroup(final String groupID, final Principal principal,
final String intermediatePath) throws AuthorizableExistsException, RepositoryException {
+                    return delegate.perform(new SessionOperation<Group>() {
+                        @Override
+                        public Group perform() throws RepositoryException {
+                            return uMgr.createGroup(groupID, principal, intermediatePath);
+                        }
+                    });
+                }
+
+                @Override
+                public boolean isAutoSave() {
+                    try {
+                        return delegate.perform(new SessionOperation<Boolean>() {
+                            @Override
+                            public Boolean perform() throws RepositoryException {
+                                return uMgr.isAutoSave();
+                            }
+                        });
+                    } catch (RepositoryException e) {
+                        assert false : "Unexpected exception: " + e;
+                        return false;
+                    }
+                }
+
+                @Override
+                public void autoSave(final boolean enable) throws UnsupportedRepositoryOperationException,
RepositoryException {
+                    delegate.perform(new SessionOperation<Void>() {
+                        @Override
+                        public Void perform() throws RepositoryException {
+                            uMgr.autoSave(enable);
+                            return null;
+                        }
+                    });
+                }
+            };
+
         }
         return userManager;
     }



Mime
View raw message