jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1513524 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr: SessionContext.java delegate/PrivilegeManagerDelegator.java
Date Tue, 13 Aug 2013 14:54:10 GMT
Author: mduerig
Date: Tue Aug 13 14:54:10 2013
New Revision: 1513524

URL: http://svn.apache.org/r1513524
Log:
OAK-958: Session related entities do not honour session refresh settings
Wrap PrivilegeManager

Added:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/PrivilegeManagerDelegator.java
  (with props)
Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/SessionContext.java

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=1513524&r1=1513523&r2=1513524&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
Tue Aug 13 14:54:10 2013
@@ -38,10 +38,11 @@ import org.apache.jackrabbit.api.securit
 import org.apache.jackrabbit.api.security.principal.PrincipalManager;
 import org.apache.jackrabbit.api.security.user.UserManager;
 import org.apache.jackrabbit.oak.api.ContentSession;
+import org.apache.jackrabbit.oak.jcr.delegate.PrivilegeManagerDelegator;
 import org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate;
+import org.apache.jackrabbit.oak.jcr.delegate.UserManagerDelegator;
 import org.apache.jackrabbit.oak.jcr.observation.ObservationManagerImpl;
 import org.apache.jackrabbit.oak.jcr.security.AccessManager;
-import org.apache.jackrabbit.oak.jcr.delegate.UserManagerDelegator;
 import org.apache.jackrabbit.oak.namepath.LocalNameMapper;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
 import org.apache.jackrabbit.oak.namepath.NamePathMapperImpl;
@@ -197,7 +198,9 @@ public class SessionContext implements N
     @Nonnull
     public PrivilegeManager getPrivilegeManager() {
         if (privilegeManager == null) {
-            privilegeManager = getConfig(PrivilegeConfiguration.class).getPrivilegeManager(delegate.getRoot(),
namePathMapper);
+            privilegeManager = new PrivilegeManagerDelegator(delegate,
+                    getConfig(PrivilegeConfiguration.class)
+                            .getPrivilegeManager(delegate.getRoot(), namePathMapper));
         }
         return privilegeManager;
     }

Added: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/PrivilegeManagerDelegator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/PrivilegeManagerDelegator.java?rev=1513524&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/PrivilegeManagerDelegator.java
(added)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/PrivilegeManagerDelegator.java
Tue Aug 13 14:54:10 2013
@@ -0,0 +1,75 @@
+/*
+ * 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.delegate;
+
+import javax.jcr.AccessDeniedException;
+import javax.jcr.NamespaceException;
+import javax.jcr.RepositoryException;
+import javax.jcr.security.AccessControlException;
+import javax.jcr.security.Privilege;
+
+import org.apache.jackrabbit.api.security.authorization.PrivilegeManager;
+import org.apache.jackrabbit.oak.jcr.operation.SessionOperation;
+
+/**
+ * This implementation of {@code PrivilegeManager} delegates back to a
+ * delegatee wrapping each call into a {@link SessionOperation} closure.
+ *
+ * @see SessionDelegate#perform(SessionOperation)
+ */
+public class PrivilegeManagerDelegator implements PrivilegeManager {
+    private final PrivilegeManager pm;
+    private final SessionDelegate delegate;
+
+    public PrivilegeManagerDelegator(SessionDelegate delegate, PrivilegeManager pm) {
+        this.pm = pm;
+        this.delegate = delegate;
+    }
+
+    @Override
+    public Privilege[] getRegisteredPrivileges() throws RepositoryException {
+        return delegate.perform(new SessionOperation<Privilege[]>() {
+            @Override
+            public Privilege[] perform() throws RepositoryException {
+                return pm.getRegisteredPrivileges();
+            }
+        });
+    }
+
+    @Override
+    public Privilege getPrivilege(final String privilegeName) throws AccessControlException,
RepositoryException {
+        return delegate.perform(new SessionOperation<Privilege>() {
+            @Override
+            public Privilege perform() throws RepositoryException {
+                return pm.getPrivilege(privilegeName);
+            }
+        });
+    }
+
+    @Override
+    public Privilege registerPrivilege(final String privilegeName, final boolean isAbstract,
final String[] declaredAggregateNames) throws AccessDeniedException, NamespaceException, RepositoryException
{
+        return delegate.perform(new SessionOperation<Privilege>() {
+            @Override
+            public Privilege perform() throws RepositoryException {
+                return pm.registerPrivilege(privilegeName, isAbstract, declaredAggregateNames);
+            }
+        });
+    }
+}

Propchange: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/PrivilegeManagerDelegator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/PrivilegeManagerDelegator.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL



Mime
View raw message