You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by an...@apache.org on 2014/01/08 15:01:09 UTC

svn commit: r1556535 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate: AuthorizableDelegator.java GroupDelegator.java ImpersonationDelegator.java UserDelegator.java UserManagerDelegator.java

Author: angela
Date: Wed Jan  8 14:01:09 2014
New Revision: 1556535

URL: http://svn.apache.org/r1556535
Log:
OAK-1124 : OAK-938 incomplete: session refresh must also be reflected on derived interfaces

Added:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/AuthorizableDelegator.java   (with props)
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/GroupDelegator.java   (with props)
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/ImpersonationDelegator.java   (with props)
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/UserDelegator.java   (with props)
Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/UserManagerDelegator.java

Added: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/AuthorizableDelegator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/AuthorizableDelegator.java?rev=1556535&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/AuthorizableDelegator.java (added)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/AuthorizableDelegator.java Wed Jan  8 14:01:09 2014
@@ -0,0 +1,255 @@
+/*
+ * 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.Iterator;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.Value;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterators;
+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.session.operation.SessionOperation;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+/**
+ * Base class for {@link GroupDelegator} and {@link UserDelegator}.
+ */
+abstract class AuthorizableDelegator implements Authorizable {
+
+    final SessionDelegate sessionDelegate;
+    final Authorizable delegate;
+
+    AuthorizableDelegator(@Nonnull SessionDelegate sessionDelegate, @Nonnull Authorizable delegate) {
+        checkArgument(!(delegate instanceof AuthorizableDelegator));
+        this.sessionDelegate = sessionDelegate;
+        this.delegate = delegate;
+    }
+
+    static Authorizable wrap(@Nonnull SessionDelegate sessionDelegate, @Nullable Authorizable authorizable) {
+        if (authorizable == null) {
+            return null;
+        }
+        if (authorizable.isGroup()) {
+            return GroupDelegator.wrap(sessionDelegate, (Group) authorizable);
+        } else {
+            return UserDelegator.wrap(sessionDelegate, (User) authorizable);
+        }
+    }
+
+    static Authorizable unwrap(@Nonnull Authorizable authorizable) {
+        if (authorizable.isGroup()) {
+            return GroupDelegator.unwrap((Group) authorizable);
+        } else {
+            return UserDelegator.unwrap((User) authorizable);
+        }
+    }
+
+    //-------------------------------------------------------< Authorizable >---
+    @Override
+    public boolean isGroup() {
+        return sessionDelegate.safePerform(new SessionOperation<Boolean>() {
+            @Override
+            public Boolean perform() {
+                return delegate.isGroup();
+            }
+        });
+    }
+
+    @Override
+    public String getID() throws RepositoryException {
+        return sessionDelegate.perform(new SessionOperation<String>() {
+            @Override
+            public String perform() throws RepositoryException {
+                return delegate.getID();
+            }
+        });
+    }
+
+
+
+    @Override
+    public Principal getPrincipal() throws RepositoryException {
+        return sessionDelegate.perform(new SessionOperation<Principal>() {
+            @Override
+            public Principal perform() throws RepositoryException {
+                return delegate.getPrincipal();
+            }
+        });
+    }
+
+    @Override
+    public Iterator<Group> declaredMemberOf() throws RepositoryException {
+        return sessionDelegate.perform(new SessionOperation<Iterator<Group>>() {
+            @Override
+            public Iterator<Group> perform() throws RepositoryException {
+                Iterator<Group> groups = delegate.declaredMemberOf();
+                return Iterators.transform(groups, new Function<Group, Group>() {
+                    @Nullable
+                    @Override
+                    public Group apply(@Nullable Group group) {
+                        return GroupDelegator.wrap(sessionDelegate, group);
+                    }
+                });
+            }
+        });
+    }
+
+    @Override
+    public Iterator<Group> memberOf() throws RepositoryException {
+        return sessionDelegate.perform(new SessionOperation<Iterator<Group>>() {
+            @Override
+            public Iterator<Group> perform() throws RepositoryException {
+                Iterator<Group> groups = delegate.memberOf();
+                return Iterators.transform(groups, new Function<Group, Group>() {
+                    @Nullable
+                    @Override
+                    public Group apply(@Nullable Group group) {
+                        return GroupDelegator.wrap(sessionDelegate, group);
+                    }
+                });
+            }
+        });
+    }
+
+    @Override
+    public void remove() throws RepositoryException {
+        sessionDelegate.perform(new SessionOperation<Void>() {
+            @Override
+            public Void perform() throws RepositoryException {
+                delegate.remove();
+                return null;
+            }
+        });
+    }
+
+    @Override
+    public Iterator<String> getPropertyNames() throws RepositoryException {
+        return sessionDelegate.perform(new SessionOperation<Iterator<String>>() {
+            @Override
+            public Iterator<String> perform() throws RepositoryException {
+                return delegate.getPropertyNames();
+            }
+        });
+    }
+
+    @Override
+    public Iterator<String> getPropertyNames(final String relPath) throws RepositoryException {
+        return sessionDelegate.perform(new SessionOperation<Iterator<String>>() {
+            @Override
+            public Iterator<String> perform() throws RepositoryException {
+                return delegate.getPropertyNames(relPath);
+            }
+        });
+    }
+
+    @Override
+    public boolean hasProperty(final String relPath) throws RepositoryException {
+        return sessionDelegate.perform(new SessionOperation<Boolean>() {
+            @Override
+            public Boolean perform() throws RepositoryException {
+                return delegate.hasProperty(relPath);
+            }
+        });
+    }
+
+    @Override
+    public void setProperty(final String relPath, final Value value) throws RepositoryException {
+        sessionDelegate.perform(new SessionOperation<Void>() {
+            @Override
+            public Void perform() throws RepositoryException {
+                delegate.setProperty(relPath, value);
+                return null;
+            }
+        });
+    }
+
+    @Override
+    public void setProperty(final String relPath, final Value[] value) throws RepositoryException {
+        sessionDelegate.perform(new SessionOperation<Void>() {
+            @Override
+            public Void perform() throws RepositoryException {
+                delegate.setProperty(relPath, value);
+                return null;
+            }
+        });
+    }
+
+    @Override
+    public Value[] getProperty(final String relPath) throws RepositoryException {
+        return sessionDelegate.perform(new SessionOperation<Value[]>() {
+            @Override
+            public Value[] perform() throws RepositoryException {
+                return delegate.getProperty(relPath);
+            }
+        });
+    }
+
+    @Override
+    public boolean removeProperty(final String relPath) throws RepositoryException {
+        return sessionDelegate.perform(new SessionOperation<Boolean>() {
+            @Override
+            public Boolean perform() throws RepositoryException {
+                return delegate.removeProperty(relPath);
+            }
+        });
+    }
+
+    @Override
+    public String getPath() throws UnsupportedRepositoryOperationException, RepositoryException {
+        return sessionDelegate.perform(new SessionOperation<String>() {
+            @Override
+            public String perform() throws RepositoryException {
+                return delegate.getPath();
+            }
+        });
+    }
+
+    //-------------------------------------------------------------< Object >---
+    @Override
+    public boolean equals(Object other) {
+        if (other == this) {
+            return true;
+        }
+        if (other instanceof AuthorizableDelegator) {
+            AuthorizableDelegator ad = (AuthorizableDelegator) other;
+            return delegate.equals(ad.delegate);
+        }
+        return false;
+    }
+
+    @Override
+    public int hashCode() {
+        return delegate.hashCode();
+    }
+
+
+    @Override
+    public String toString() {
+        return delegate.toString();
+    }
+}

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

Added: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/GroupDelegator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/GroupDelegator.java?rev=1556535&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/GroupDelegator.java (added)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/GroupDelegator.java Wed Jan  8 14:01:09 2014
@@ -0,0 +1,145 @@
+/*
+ * 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.Iterator;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.Value;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterators;
+import org.apache.jackrabbit.api.security.user.Authorizable;
+import org.apache.jackrabbit.api.security.user.Group;
+import org.apache.jackrabbit.oak.jcr.session.operation.SessionOperation;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+/**
+ * This implementation of {@code Group} delegates back to a
+ * delegatee wrapping each call into a {@link SessionOperation} closure.
+ *
+ * @see SessionDelegate#perform(SessionOperation)
+ */
+final class GroupDelegator extends AuthorizableDelegator implements Group {
+
+    private GroupDelegator(SessionDelegate sessionDelegate, Group groupDelegate) {
+        super(sessionDelegate, groupDelegate);
+    }
+
+    static Group wrap(@Nonnull SessionDelegate sessionDelegate, Group group) {
+        if (group == null) {
+            return null;
+        } else {
+            return new GroupDelegator(sessionDelegate, group);
+        }
+    }
+
+    @Nonnull
+    static Group unwrap(@Nonnull Group group) {
+        if (group instanceof GroupDelegator) {
+            return ((GroupDelegator) group).getDelegate();
+        } else {
+            return group;
+        }
+    }
+
+    private Group getDelegate() {
+        return (Group) delegate;
+    }
+
+    //--------------------------------------------------------------< Group >---
+    @Override
+    public Iterator<Authorizable> getDeclaredMembers() throws RepositoryException {
+        return sessionDelegate.perform(new SessionOperation<Iterator<Authorizable>>() {
+            @Override
+            public Iterator<Authorizable> perform() throws RepositoryException {
+                Iterator<Authorizable> authorizables = getDelegate().getDeclaredMembers();
+                return Iterators.transform(authorizables, new Function<Authorizable, Authorizable>() {
+                    @Nullable
+                    @Override
+                    public Authorizable apply(@Nullable Authorizable authorizable) {
+                        return wrap(sessionDelegate, authorizable);
+                    }
+                });
+            }
+        });
+    }
+
+    @Override
+    public Iterator<Authorizable> getMembers() throws RepositoryException {
+        return sessionDelegate.perform(new SessionOperation<Iterator<Authorizable>>() {
+            @Override
+            public Iterator<Authorizable> perform() throws RepositoryException {
+                Iterator<Authorizable> authorizables = getDelegate().getMembers();
+                return Iterators.transform(authorizables, new Function<Authorizable, Authorizable>() {
+                    @Nullable
+                    @Override
+                    public Authorizable apply(@Nullable Authorizable authorizable) {
+                        return wrap(sessionDelegate, authorizable);
+                    }
+                });
+            }
+        });
+    }
+
+    @Override
+    public boolean isDeclaredMember(final Authorizable authorizable) throws RepositoryException {
+        return sessionDelegate.perform(new SessionOperation<Boolean>() {
+            @Override
+            public Boolean perform() throws RepositoryException {
+                return getDelegate().isDeclaredMember(unwrap(authorizable));
+            }
+        });
+    }
+
+    @Override
+    public boolean isMember(final Authorizable authorizable) throws RepositoryException {
+        return sessionDelegate.perform(new SessionOperation<Boolean>() {
+            @Override
+            public Boolean perform() throws RepositoryException {
+                return getDelegate().isMember(unwrap(authorizable));
+            }
+        });
+    }
+
+    @Override
+    public boolean addMember(final Authorizable authorizable) throws RepositoryException {
+        return sessionDelegate.perform(new SessionOperation<Boolean>() {
+            @Override
+            public Boolean perform() throws RepositoryException {
+                return getDelegate().addMember(unwrap(authorizable));
+            }
+        });
+    }
+
+    @Override
+    public boolean removeMember(final Authorizable authorizable) throws RepositoryException {
+        return sessionDelegate.perform(new SessionOperation<Boolean>() {
+            @Override
+            public Boolean perform() throws RepositoryException {
+                return getDelegate().removeMember(unwrap(authorizable));
+            }
+        });
+    }
+}

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

Added: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/ImpersonationDelegator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/ImpersonationDelegator.java?rev=1556535&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/ImpersonationDelegator.java (added)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/ImpersonationDelegator.java Wed Jan  8 14:01:09 2014
@@ -0,0 +1,96 @@
+/*
+ * 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 static com.google.common.base.Preconditions.checkArgument;
+
+import java.security.Principal;
+
+import javax.jcr.RepositoryException;
+import javax.security.auth.Subject;
+
+import org.apache.jackrabbit.api.security.principal.PrincipalIterator;
+import org.apache.jackrabbit.api.security.user.Impersonation;
+import org.apache.jackrabbit.oak.jcr.session.operation.SessionOperation;
+
+/**
+ * This implementation of {@code Impersonation} delegates back to a
+ * delegatee wrapping each call into a {@link SessionOperation} closure.
+ *
+ * @see SessionDelegate#perform(SessionOperation)
+ */
+class ImpersonationDelegator implements Impersonation {
+    private final SessionDelegate sessionDelegate;
+    private final Impersonation impersonationDelegate;
+
+    private ImpersonationDelegator(SessionDelegate sessionDelegate, Impersonation impersonationDelegate) {
+        checkArgument(!(impersonationDelegate instanceof ImpersonationDelegator));
+        this.sessionDelegate = sessionDelegate;
+        this.impersonationDelegate = impersonationDelegate;
+    }
+
+    static Impersonation wrap(SessionDelegate sessionDelegate, Impersonation impersonation) {
+        if (impersonation == null) {
+            return null;
+        } else {
+            return new ImpersonationDelegator(sessionDelegate, impersonation);
+        }
+    }
+
+    @Override
+    public PrincipalIterator getImpersonators() throws RepositoryException {
+        return sessionDelegate.perform(new SessionOperation<PrincipalIterator>() {
+            @Override
+            public PrincipalIterator perform() throws RepositoryException {
+                return impersonationDelegate.getImpersonators();
+            }
+        });
+    }
+
+    @Override
+    public boolean grantImpersonation(final Principal principal) throws RepositoryException {
+        return sessionDelegate.perform(new SessionOperation<Boolean>() {
+            @Override
+            public Boolean perform() throws RepositoryException {
+                return impersonationDelegate.grantImpersonation(principal);
+            }
+        });
+    }
+
+    @Override
+    public boolean revokeImpersonation(final Principal principal) throws RepositoryException {
+        return sessionDelegate.perform(new SessionOperation<Boolean>() {
+            @Override
+            public Boolean perform() throws RepositoryException {
+                return impersonationDelegate.revokeImpersonation(principal);
+            }
+        });
+    }
+
+    @Override
+    public boolean allows(final Subject subject) throws RepositoryException {
+        return sessionDelegate.perform(new SessionOperation<Boolean>() {
+            @Override
+            public Boolean perform() throws RepositoryException {
+                return impersonationDelegate.allows(subject);
+            }
+        });
+    }
+}

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

Added: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/UserDelegator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/UserDelegator.java?rev=1556535&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/UserDelegator.java (added)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/UserDelegator.java Wed Jan  8 14:01:09 2014
@@ -0,0 +1,147 @@
+/*
+ * 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.annotation.Nonnull;
+import javax.jcr.Credentials;
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.api.security.user.Impersonation;
+import org.apache.jackrabbit.api.security.user.User;
+import org.apache.jackrabbit.oak.jcr.session.operation.SessionOperation;
+
+/**
+ * This implementation of {@code User} delegates back to a
+ * delegatee wrapping each call into a {@link SessionOperation} closure.
+ *
+ * @see SessionDelegate#perform(SessionOperation)
+ */
+final class UserDelegator extends AuthorizableDelegator implements User {
+
+    private UserDelegator(SessionDelegate sessionDelegate, User userDelegate) {
+        super(sessionDelegate, userDelegate);
+    }
+
+    static User wrap(SessionDelegate sessionDelegate, User user) {
+        if (user == null) {
+            return null;
+        } else {
+            return new UserDelegator(sessionDelegate, user);
+        }
+    }
+
+    @Nonnull
+    static User unwrap(@Nonnull User user) {
+        if (user instanceof UserDelegator) {
+            return ((UserDelegator) user).getDelegate();
+        } else {
+            return user;
+        }
+    }
+
+    private User getDelegate() {
+        return (User) delegate;
+    }
+
+    //---------------------------------------------------------------< User >---
+    @Override
+    public boolean isAdmin() {
+        return sessionDelegate.safePerform(new SessionOperation<Boolean>() {
+            @Override
+            public Boolean perform() {
+                return getDelegate().isAdmin();
+            }
+        });
+    }
+
+    @Override
+    public Credentials getCredentials() {
+        return sessionDelegate.safePerform(new SessionOperation<Credentials>() {
+            @Override
+            public Credentials perform() throws RepositoryException {
+                return getDelegate().getCredentials();
+            }
+        });
+    }
+
+    @Override
+    public Impersonation getImpersonation() {
+        return sessionDelegate.safePerform(new SessionOperation<Impersonation>() {
+            @Override
+            public Impersonation perform() throws RepositoryException {
+                Impersonation impersonation = getDelegate().getImpersonation();
+                return ImpersonationDelegator.wrap(sessionDelegate, impersonation);
+            }
+        });
+    }
+
+    @Override
+    public void changePassword(final String password) throws RepositoryException {
+        sessionDelegate.perform(new SessionOperation<Void>() {
+            @Override
+            public Void perform() throws RepositoryException {
+                getDelegate().changePassword(password);
+                return null;
+            }
+        });
+    }
+
+    @Override
+    public void changePassword(final String password, final String oldPassword) throws RepositoryException {
+        sessionDelegate.perform(new SessionOperation<Void>() {
+            @Override
+            public Void perform() throws RepositoryException {
+                getDelegate().changePassword(password, oldPassword);
+                return null;
+            }
+        });
+    }
+
+    @Override
+    public void disable(final String reason) throws RepositoryException {
+        sessionDelegate.perform(new SessionOperation<Void>() {
+            @Override
+            public Void perform() throws RepositoryException {
+                getDelegate().disable(reason);
+                return null;
+            }
+        });
+    }
+
+    @Override
+    public boolean isDisabled() throws RepositoryException {
+        return sessionDelegate.perform(new SessionOperation<Boolean>() {
+            @Override
+            public Boolean perform() throws RepositoryException {
+                return getDelegate().isDisabled();
+            }
+        });
+    }
+
+    @Override
+    public String getDisabledReason() throws RepositoryException {
+        return sessionDelegate.perform(new SessionOperation<String>() {
+            @Override
+            public String perform() throws RepositoryException {
+                return getDelegate().getDisabledReason();
+            }
+        });
+    }
+}

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

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/UserManagerDelegator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/UserManagerDelegator.java?rev=1556535&r1=1556534&r2=1556535&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/UserManagerDelegator.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/UserManagerDelegator.java Wed Jan  8 14:01:09 2014
@@ -21,10 +21,12 @@ package org.apache.jackrabbit.oak.jcr.de
 
 import java.security.Principal;
 import java.util.Iterator;
-
+import javax.annotation.Nullable;
 import javax.jcr.RepositoryException;
 import javax.jcr.UnsupportedRepositoryOperationException;
 
+import com.google.common.base.Function;
+import com.google.common.collect.Iterators;
 import org.apache.jackrabbit.api.security.user.Authorizable;
 import org.apache.jackrabbit.api.security.user.AuthorizableExistsException;
 import org.apache.jackrabbit.api.security.user.Group;
@@ -33,6 +35,8 @@ import org.apache.jackrabbit.api.securit
 import org.apache.jackrabbit.api.security.user.UserManager;
 import org.apache.jackrabbit.oak.jcr.session.operation.UserManagerOperation;
 
+import static com.google.common.base.Preconditions.checkState;
+
 /**
  * This implementation of {@code UserManager} delegates back to a
  * delegatee wrapping each call into a {@link UserManager} closure.
@@ -40,12 +44,14 @@ import org.apache.jackrabbit.oak.jcr.ses
  * @see SessionDelegate#perform(org.apache.jackrabbit.oak.jcr.session.operation.SessionOperation)
  */
 public class UserManagerDelegator implements UserManager {
-    private final UserManager userManagerDelegate;
+
     private final SessionDelegate sessionDelegate;
+    private final UserManager userManagerDelegate;
 
     public UserManagerDelegator(final SessionDelegate sessionDelegate, UserManager userManagerDelegate) {
-        this.userManagerDelegate = userManagerDelegate;
+        checkState(!(userManagerDelegate instanceof UserManagerDelegator));
         this.sessionDelegate = sessionDelegate;
+        this.userManagerDelegate = userManagerDelegate;
     }
 
     @Override
@@ -53,7 +59,8 @@ public class UserManagerDelegator implem
         return sessionDelegate.perform(new UserManagerOperation<Authorizable>(sessionDelegate) {
             @Override
             public Authorizable perform() throws RepositoryException {
-                return userManagerDelegate.getAuthorizable(id);
+                Authorizable authorizable = userManagerDelegate.getAuthorizable(id);
+                return AuthorizableDelegator.wrap(sessionDelegate, authorizable);
             }
         });
     }
@@ -63,7 +70,8 @@ public class UserManagerDelegator implem
         return sessionDelegate.perform(new UserManagerOperation<Authorizable>(sessionDelegate) {
             @Override
             public Authorizable perform() throws RepositoryException {
-                return userManagerDelegate.getAuthorizable(principal);
+                Authorizable authorizable = userManagerDelegate.getAuthorizable(principal);
+                return AuthorizableDelegator.wrap(sessionDelegate, authorizable);
             }
         });
     }
@@ -73,7 +81,8 @@ public class UserManagerDelegator implem
         return sessionDelegate.perform(new UserManagerOperation<Authorizable>(sessionDelegate) {
             @Override
             public Authorizable perform() throws RepositoryException {
-                return userManagerDelegate.getAuthorizableByPath(path);
+                Authorizable authorizable = userManagerDelegate.getAuthorizableByPath(path);
+                return AuthorizableDelegator.wrap(sessionDelegate, authorizable);
             }
         });
     }
@@ -83,7 +92,14 @@ public class UserManagerDelegator implem
         return sessionDelegate.perform(new UserManagerOperation<Iterator<Authorizable>>(sessionDelegate) {
             @Override
             public Iterator<Authorizable> perform() throws RepositoryException {
-                return userManagerDelegate.findAuthorizables(relPath, value);
+                Iterator<Authorizable> authorizables = userManagerDelegate.findAuthorizables(relPath, value);
+                return Iterators.transform(authorizables, new Function<Authorizable, Authorizable>() {
+                    @Nullable
+                    @Override
+                    public Authorizable apply(Authorizable authorizable) {
+                        return AuthorizableDelegator.wrap(sessionDelegate, authorizable);
+                    }
+                });
             }
         });
     }
@@ -93,7 +109,14 @@ public class UserManagerDelegator implem
         return sessionDelegate.perform(new UserManagerOperation<Iterator<Authorizable>>(sessionDelegate) {
             @Override
             public Iterator<Authorizable> perform() throws RepositoryException {
-                return userManagerDelegate.findAuthorizables(relPath, value, searchType);
+                Iterator<Authorizable> authorizables = userManagerDelegate.findAuthorizables(relPath, value, searchType);
+                return Iterators.transform(authorizables, new Function<Authorizable, Authorizable>() {
+                    @Nullable
+                    @Override
+                    public Authorizable apply(Authorizable authorizable) {
+                        return AuthorizableDelegator.wrap(sessionDelegate, authorizable);
+                    }
+                });
             }
         });
     }
@@ -103,7 +126,14 @@ public class UserManagerDelegator implem
         return sessionDelegate.perform(new UserManagerOperation<Iterator<Authorizable>>(sessionDelegate) {
             @Override
             public Iterator<Authorizable> perform() throws RepositoryException {
-                return userManagerDelegate.findAuthorizables(query);
+                Iterator<Authorizable> authorizables = userManagerDelegate.findAuthorizables(query);
+                return Iterators.transform(authorizables, new Function<Authorizable, Authorizable>() {
+                    @Nullable
+                    @Override
+                    public Authorizable apply(Authorizable authorizable) {
+                        return AuthorizableDelegator.wrap(sessionDelegate, authorizable);
+                    }
+                });
             }
         });
     }
@@ -113,7 +143,8 @@ public class UserManagerDelegator implem
         return sessionDelegate.perform(new UserManagerOperation<User>(sessionDelegate) {
             @Override
             public User perform() throws RepositoryException {
-                return userManagerDelegate.createUser(userID, password);
+                User user = userManagerDelegate.createUser(userID, password);
+                return UserDelegator.wrap(sessionDelegate, user);
             }
         });
     }
@@ -123,7 +154,8 @@ public class UserManagerDelegator implem
         return sessionDelegate.perform(new UserManagerOperation<User>(sessionDelegate) {
             @Override
             public User perform() throws RepositoryException {
-                return userManagerDelegate.createUser(userID, password, principal, intermediatePath);
+                User user = userManagerDelegate.createUser(userID, password, principal, intermediatePath);
+                return UserDelegator.wrap(sessionDelegate, user);
             }
         });
     }
@@ -133,7 +165,8 @@ public class UserManagerDelegator implem
         return sessionDelegate.perform(new UserManagerOperation<Group>(sessionDelegate) {
             @Override
             public Group perform() throws RepositoryException {
-                return userManagerDelegate.createGroup(groupID);
+                Group group = userManagerDelegate.createGroup(groupID);
+                return GroupDelegator.wrap(sessionDelegate, group);
             }
         });
     }
@@ -143,7 +176,8 @@ public class UserManagerDelegator implem
         return sessionDelegate.perform(new UserManagerOperation<Group>(sessionDelegate) {
             @Override
             public Group perform() throws RepositoryException {
-                return userManagerDelegate.createGroup(principal);
+                Group group = userManagerDelegate.createGroup(principal);
+                return GroupDelegator.wrap(sessionDelegate, group);
             }
         });
     }
@@ -153,7 +187,8 @@ public class UserManagerDelegator implem
         return sessionDelegate.perform(new UserManagerOperation<Group>(sessionDelegate) {
             @Override
             public Group perform() throws RepositoryException {
-                return userManagerDelegate.createGroup(principal, intermediatePath);
+                Group group = userManagerDelegate.createGroup(principal, intermediatePath);
+                return GroupDelegator.wrap(sessionDelegate, group);
             }
         });
     }
@@ -163,7 +198,8 @@ public class UserManagerDelegator implem
         return sessionDelegate.perform(new UserManagerOperation<Group>(sessionDelegate) {
             @Override
             public Group perform() throws RepositoryException {
-                return userManagerDelegate.createGroup(groupID, principal, intermediatePath);
+                Group group = userManagerDelegate.createGroup(groupID, principal, intermediatePath);
+                return GroupDelegator.wrap(sessionDelegate, group);
             }
         });
     }