jackrabbit-oak-commits mailing list archives

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

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

Added:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/AccessControlManagerDelegator.java
  (with props)
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/JackrabbitAccessControlManagerDelegator.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=1513526&r1=1513525&r2=1513526&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:36 2013
@@ -34,10 +34,13 @@ import javax.jcr.Workspace;
 import javax.jcr.observation.ObservationManager;
 import javax.jcr.security.AccessControlManager;
 
+import org.apache.jackrabbit.api.security.JackrabbitAccessControlManager;
 import org.apache.jackrabbit.api.security.authorization.PrivilegeManager;
 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.AccessControlManagerDelegator;
+import org.apache.jackrabbit.oak.jcr.delegate.JackrabbitAccessControlManagerDelegator;
 import org.apache.jackrabbit.oak.jcr.delegate.PrincipalManagerDelegator;
 import org.apache.jackrabbit.oak.jcr.delegate.PrivilegeManagerDelegator;
 import org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate;
@@ -173,7 +176,14 @@ public class SessionContext implements N
     @Nonnull
     public AccessControlManager getAccessControlManager() throws RepositoryException {
         if (accessControlManager == null) {
-            accessControlManager = getConfig(AuthorizationConfiguration.class).getAccessControlManager(delegate.getRoot(),
namePathMapper);
+            AccessControlManager acm = getConfig(AuthorizationConfiguration.class)
+                    .getAccessControlManager(delegate.getRoot(), namePathMapper);
+            if (acm instanceof JackrabbitAccessControlManager) {
+                accessControlManager = new JackrabbitAccessControlManagerDelegator(
+                        delegate, (JackrabbitAccessControlManager) acm);
+            } else {
+                accessControlManager = new AccessControlManagerDelegator(delegate, acm);
+            }
         }
         return accessControlManager;
     }

Added: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/AccessControlManagerDelegator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/AccessControlManagerDelegator.java?rev=1513526&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/AccessControlManagerDelegator.java
(added)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/AccessControlManagerDelegator.java
Tue Aug 13 14:54:36 2013
@@ -0,0 +1,141 @@
+/*
+ * 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.RepositoryException;
+import javax.jcr.security.AccessControlManager;
+import javax.jcr.security.AccessControlPolicy;
+import javax.jcr.security.AccessControlPolicyIterator;
+import javax.jcr.security.Privilege;
+
+import org.apache.jackrabbit.oak.jcr.operation.SessionOperation;
+
+/**
+ * This implementation of {@code AccessControlManager} delegates back to a
+ * delegatee wrapping each call into a {@link SessionOperation} closure.
+ * 
+ * @see SessionDelegate#perform(SessionOperation)
+ */
+public class AccessControlManagerDelegator implements AccessControlManager {
+    private final SessionDelegate delegate;
+    private final AccessControlManager acManager;
+
+    public AccessControlManagerDelegator(SessionDelegate delegate, AccessControlManager acManager)
{
+        this.acManager = acManager;
+        this.delegate = delegate;
+    }
+
+    @Override
+    public Privilege[] getSupportedPrivileges(final String absPath) throws RepositoryException
{
+        return delegate.perform(new SessionOperation<Privilege[]>() {
+            @Override
+            public Privilege[] perform() throws RepositoryException {
+                return acManager.getSupportedPrivileges(absPath);
+            }
+        });
+    }
+
+    @Override
+    public Privilege privilegeFromName(final String privilegeName) throws RepositoryException
{
+        return delegate.perform(new SessionOperation<Privilege>() {
+            @Override
+            public Privilege perform() throws RepositoryException {
+                return acManager.privilegeFromName(privilegeName);
+            }
+        });
+    }
+
+    @Override
+    public boolean hasPrivileges(final String absPath, final Privilege[] privileges)
+            throws RepositoryException {
+        return delegate.perform(new SessionOperation<Boolean>() {
+            @Override
+            public Boolean perform() throws RepositoryException {
+                return acManager.hasPrivileges(absPath, privileges);
+            }
+        });
+    }
+
+    @Override
+    public Privilege[] getPrivileges(final String absPath) throws RepositoryException {
+        return delegate.perform(new SessionOperation<Privilege[]>() {
+            @Override
+            public Privilege[] perform() throws RepositoryException {
+                return acManager.getPrivileges(absPath);
+            }
+        });
+    }
+
+    @Override
+    public AccessControlPolicy[] getPolicies(final String absPath) throws RepositoryException
{
+        return delegate.perform(new SessionOperation<AccessControlPolicy[]>() {
+            @Override
+            public AccessControlPolicy[] perform() throws RepositoryException {
+                return acManager.getPolicies(absPath);
+            }
+        });
+    }
+
+    @Override
+    public AccessControlPolicy[] getEffectivePolicies(final String absPath)
+            throws RepositoryException {
+        return delegate.perform(new SessionOperation<AccessControlPolicy[]>() {
+            @Override
+            public AccessControlPolicy[] perform() throws RepositoryException {
+                return acManager.getEffectivePolicies(absPath);
+            }
+        });
+    }
+
+    @Override
+    public AccessControlPolicyIterator getApplicablePolicies(final String absPath)
+            throws RepositoryException {
+        return delegate.perform(new SessionOperation<AccessControlPolicyIterator>()
{
+            @Override
+            public AccessControlPolicyIterator perform() throws RepositoryException {
+                return acManager.getApplicablePolicies(absPath);
+            }
+        });
+    }
+
+    @Override
+    public void setPolicy(final String absPath, final AccessControlPolicy policy)
+            throws RepositoryException {
+        delegate.perform(new SessionOperation<Void>() {
+            @Override
+            public Void perform() throws RepositoryException {
+                acManager.setPolicy(absPath, policy);
+                return null;
+            }
+        });
+    }
+
+    @Override
+    public void removePolicy(final String absPath, final AccessControlPolicy policy)
+            throws RepositoryException {
+        delegate.perform(new SessionOperation<Void>() {
+            @Override
+            public Void perform() throws RepositoryException {
+                acManager.removePolicy(absPath, policy);
+                return null;
+            }
+        });
+    }
+}

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

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

Added: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/JackrabbitAccessControlManagerDelegator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/JackrabbitAccessControlManagerDelegator.java?rev=1513526&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/JackrabbitAccessControlManagerDelegator.java
(added)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/JackrabbitAccessControlManagerDelegator.java
Tue Aug 13 14:54:36 2013
@@ -0,0 +1,154 @@
+/*
+ * 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 java.security.Principal;
+import java.util.Set;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.security.AccessControlPolicy;
+import javax.jcr.security.AccessControlPolicyIterator;
+import javax.jcr.security.Privilege;
+
+import org.apache.jackrabbit.api.security.JackrabbitAccessControlManager;
+import org.apache.jackrabbit.api.security.JackrabbitAccessControlPolicy;
+import org.apache.jackrabbit.oak.jcr.operation.SessionOperation;
+
+/**
+ * This implementation of {@code JackrabbitAccessControlManager} delegates back to a
+ * delegatee wrapping each call into a {@link SessionOperation} closure.
+ *
+ * @see SessionDelegate#perform(SessionOperation)
+ */
+public class JackrabbitAccessControlManagerDelegator implements JackrabbitAccessControlManager
{
+    private final JackrabbitAccessControlManager jackrabbitACManager;
+    private final SessionDelegate delegate;
+    private final AccessControlManagerDelegator jcrACManager;
+
+    public JackrabbitAccessControlManagerDelegator(SessionDelegate delegate,
+            JackrabbitAccessControlManager acManager) {
+        this.jackrabbitACManager = acManager;
+        this.delegate = delegate;
+        this.jcrACManager = new AccessControlManagerDelegator(delegate, acManager);
+    }
+
+    @Override
+    public JackrabbitAccessControlPolicy[] getApplicablePolicies(final Principal principal)
+            throws RepositoryException {
+        return delegate.perform(new SessionOperation<JackrabbitAccessControlPolicy[]>()
{
+            @Override
+            public JackrabbitAccessControlPolicy[] perform() throws RepositoryException {
+                return jackrabbitACManager.getApplicablePolicies(principal);
+            }
+        });
+    }
+
+    @Override
+    public JackrabbitAccessControlPolicy[] getPolicies(final Principal principal)
+            throws RepositoryException {
+        return delegate.perform(new SessionOperation<JackrabbitAccessControlPolicy[]>()
{
+            @Override
+            public JackrabbitAccessControlPolicy[] perform() throws RepositoryException {
+                return jackrabbitACManager.getPolicies(principal);
+            }
+        });
+    }
+
+    @Override
+    public AccessControlPolicy[] getEffectivePolicies(final Set<Principal> principals)
+            throws RepositoryException {
+        return delegate.perform(new SessionOperation<AccessControlPolicy[]>() {
+            @Override
+            public AccessControlPolicy[] perform() throws RepositoryException {
+                return jackrabbitACManager.getEffectivePolicies(principals);
+            }
+        });
+    }
+
+    @Override
+    public boolean hasPrivileges(final String absPath, final Set<Principal> principals,
+            final Privilege[] privileges) throws RepositoryException {
+        return delegate.perform(new SessionOperation<Boolean>() {
+            @Override
+            public Boolean perform() throws RepositoryException {
+                return jackrabbitACManager.hasPrivileges(absPath, principals, privileges);
+            }
+        });
+    }
+
+    @Override
+    public Privilege[] getPrivileges(final String absPath, final Set<Principal> principals)
+            throws RepositoryException {
+        return delegate.perform(new SessionOperation<Privilege[]>() {
+            @Override
+            public Privilege[] perform() throws RepositoryException {
+                return jackrabbitACManager.getPrivileges(absPath, principals);
+            }
+        });
+    }
+
+    @Override
+    public Privilege[] getSupportedPrivileges(String absPath) throws RepositoryException
{
+        return jcrACManager.getSupportedPrivileges(absPath);
+    }
+
+    @Override
+    public Privilege privilegeFromName(String privilegeName) throws RepositoryException {
+        return jcrACManager.privilegeFromName(privilegeName);
+    }
+
+    @Override
+    public boolean hasPrivileges(String absPath, Privilege[] privileges)
+            throws RepositoryException {
+        return jcrACManager.hasPrivileges(absPath, privileges);
+    }
+
+    @Override
+    public Privilege[] getPrivileges(String absPath) throws RepositoryException {
+        return jcrACManager.getPrivileges(absPath);
+    }
+
+    @Override
+    public AccessControlPolicy[] getPolicies(String absPath) throws RepositoryException {
+        return jcrACManager.getPolicies(absPath);
+    }
+
+    @Override
+    public AccessControlPolicy[] getEffectivePolicies(String absPath) throws RepositoryException
{
+        return jcrACManager.getEffectivePolicies(absPath);
+    }
+
+    @Override
+    public AccessControlPolicyIterator getApplicablePolicies(String absPath)
+            throws RepositoryException {
+        return jcrACManager.getApplicablePolicies(absPath);
+    }
+
+    @Override
+    public void setPolicy(String absPath, AccessControlPolicy policy) throws RepositoryException
{
+        jcrACManager.setPolicy(absPath, policy);
+    }
+
+    @Override
+    public void removePolicy(String absPath, AccessControlPolicy policy)
+            throws RepositoryException {
+        jcrACManager.removePolicy(absPath, policy);
+    }
+}

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

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



Mime
View raw message