jackrabbit-oak-commits mailing list archives

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

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

Added:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/PrincipalManagerDelegator.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=1513525&r1=1513524&r2=1513525&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:22 2013
@@ -38,6 +38,7 @@ 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.PrincipalManagerDelegator;
 import org.apache.jackrabbit.oak.jcr.delegate.PrivilegeManagerDelegator;
 import org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate;
 import org.apache.jackrabbit.oak.jcr.delegate.UserManagerDelegator;
@@ -180,8 +181,9 @@ public class SessionContext implements N
     @Nonnull
     public PrincipalManager getPrincipalManager() {
         if (principalManager == null) {
-            principalManager = getConfig(PrincipalConfiguration.class)
-                    .getPrincipalManager(delegate.getRoot(), namePathMapper);
+            principalManager = new PrincipalManagerDelegator(delegate,
+                    getConfig(PrincipalConfiguration.class)
+                            .getPrincipalManager(delegate.getRoot(), namePathMapper));
         }
         return principalManager;
     }

Added: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/PrincipalManagerDelegator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/PrincipalManagerDelegator.java?rev=1513525&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/PrincipalManagerDelegator.java
(added)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/PrincipalManagerDelegator.java
Tue Aug 13 14:54:22 2013
@@ -0,0 +1,113 @@
+/*
+ * 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 org.apache.jackrabbit.api.security.principal.PrincipalIterator;
+import org.apache.jackrabbit.api.security.principal.PrincipalManager;
+import org.apache.jackrabbit.oak.jcr.operation.SessionOperation;
+
+/**
+ * This implementation of {@code PrincipalManager} delegates back to a
+ * delegatee wrapping each call into a {@link SessionOperation} closure.
+ *
+ * @see SessionDelegate#perform(SessionOperation)
+ */
+public class PrincipalManagerDelegator implements PrincipalManager {
+    private final SessionDelegate delegate;
+    private final PrincipalManager principalManager;
+
+    public PrincipalManagerDelegator(SessionDelegate delegate,
+            PrincipalManager principalManager) {
+        this.principalManager = principalManager;
+        this.delegate = delegate;
+    }
+
+    @Override
+    public boolean hasPrincipal(final String principalName) {
+        return delegate.safePerform(new SessionOperation<Boolean>() {
+            @Override
+            public Boolean perform() {
+                return principalManager.hasPrincipal(principalName);
+            }
+        });
+    }
+
+    @Override
+    public Principal getPrincipal(final String principalName) {
+        return delegate.safePerform(new SessionOperation<Principal>() {
+            @Override
+            public Principal perform() {
+                return principalManager.getPrincipal(principalName);
+            }
+        });
+    }
+
+    @Override
+    public PrincipalIterator findPrincipals(final String simpleFilter) {
+        return delegate.safePerform(new SessionOperation<PrincipalIterator>() {
+            @Override
+            public PrincipalIterator perform() {
+                return principalManager.findPrincipals(simpleFilter);
+            }
+        });
+    }
+
+    @Override
+    public PrincipalIterator findPrincipals(final String simpleFilter, final int searchType)
{
+        return delegate.safePerform(new SessionOperation<PrincipalIterator>() {
+            @Override
+            public PrincipalIterator perform() {
+                return principalManager.findPrincipals(simpleFilter, searchType);
+            }
+        });
+    }
+
+    @Override
+    public PrincipalIterator getPrincipals(final int searchType) {
+        return delegate.safePerform(new SessionOperation<PrincipalIterator>() {
+            @Override
+            public PrincipalIterator perform() {
+                return principalManager.getPrincipals(searchType);
+            }
+        });
+    }
+
+    @Override
+    public PrincipalIterator getGroupMembership(final Principal principal) {
+        return delegate.safePerform(new SessionOperation<PrincipalIterator>() {
+            @Override
+            public PrincipalIterator perform() {
+                return principalManager.getGroupMembership(principal);
+            }
+        });
+    }
+
+    @Override
+    public Principal getEveryone() {
+        return delegate.safePerform(new SessionOperation<Principal>() {
+            @Override
+            public Principal perform() {
+                return principalManager.getEveryone();
+            }
+        });
+    }
+}

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

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



Mime
View raw message