Author: mduerig
Date: Tue Aug 13 14:53:16 2013
New Revision: 1513520
URL: http://svn.apache.org/r1513520
Log:
OAK-938 UserManager does not honour session refresh settings
Promote (anonymous) inner classes to top level classes
Added:
jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/UserManagerDelegator.java
(with props)
jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/operation/UserManagerOperation.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=1513520&r1=1513519&r2=1513520&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:53:16 2013
@@ -18,9 +18,7 @@ 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;
@@ -38,17 +36,12 @@ import javax.jcr.security.AccessControlM
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.SessionDelegate;
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.delegate.UserManagerDelegator;
import org.apache.jackrabbit.oak.namepath.LocalNameMapper;
import org.apache.jackrabbit.oak.namepath.NamePathMapper;
import org.apache.jackrabbit.oak.namepath.NamePathMapperImpl;
@@ -194,166 +187,11 @@ public class SessionContext implements N
return principalManager;
}
- private abstract class UserManagerOperation<T> extends SessionOperation<T>
{
- @Override
- public void checkPreconditions() throws RepositoryException {
- delegate.checkAlive();
- }
- }
-
@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) {
- 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
UserManagerOperation<Authorizable>() {
- @Override
- public Authorizable perform() throws
RepositoryException {
- return uMgr.getAuthorizable(id);
- }
- });
- }
-
- @Override
- public Authorizable getAuthorizable(final Principal principal)
throws RepositoryException {
- return delegate.perform(new
UserManagerOperation<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
UserManagerOperation<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
UserManagerOperation<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
UserManagerOperation<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
UserManagerOperation<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 UserManagerOperation<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 UserManagerOperation<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 UserManagerOperation<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 UserManagerOperation<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 UserManagerOperation<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 UserManagerOperation<Group>() {
- @Override
- public Group perform() throws RepositoryException {
- return uMgr.createGroup(groupID, principal,
intermediatePath);
- }
- });
- }
-
- @Override
- public boolean isAutoSave() {
- try {
- return delegate.perform(new
UserManagerOperation<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 UserManagerOperation<Void>() {
- @Override
- public Void perform() throws RepositoryException {
- uMgr.autoSave(enable);
- return null;
- }
- });
- }
- };
-
+ userManager = new UserManagerDelegator(delegate,
getConfig(UserConfiguration.class)
+ .getUserManager(delegate.getRoot(), namePathMapper));
}
return userManager;
}
@@ -512,4 +350,5 @@ public class SessionContext implements N
private <T> T getConfig(Class<T> clss) {
return repository.getSecurityProvider().getConfiguration(clss);
}
+
}
Added:
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=1513520&view=auto
==============================================================================
---
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/UserManagerDelegator.java
Tue Aug 13 14:53:16 2013
@@ -0,0 +1,196 @@
+/*
+ * 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.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+
+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.jcr.operation.UserManagerOperation;
+
+/**
+ * This implementation of {@code UserManager} delegates back to a
+ * delegatee wrapping each call into a {@link UserManager} closure.
+ *
+ * @see
SessionDelegate#perform(org.apache.jackrabbit.oak.jcr.operation.SessionOperation)
+ */
+public class UserManagerDelegator implements UserManager {
+ private final UserManager userManagerDelegate;
+ private final SessionDelegate sessionDelegate;
+
+ public UserManagerDelegator(final SessionDelegate sessionDelegate,
UserManager userManagerDelegate) {
+ this.userManagerDelegate = userManagerDelegate;
+ this.sessionDelegate = sessionDelegate;
+ }
+
+ @Override
+ public Authorizable getAuthorizable(final String id) throws
RepositoryException {
+ return sessionDelegate.perform(new
UserManagerOperation<Authorizable>(sessionDelegate) {
+ @Override
+ public Authorizable perform() throws RepositoryException {
+ return userManagerDelegate.getAuthorizable(id);
+ }
+ });
+ }
+
+ @Override
+ public Authorizable getAuthorizable(final Principal principal) throws
RepositoryException {
+ return sessionDelegate.perform(new
UserManagerOperation<Authorizable>(sessionDelegate) {
+ @Override
+ public Authorizable perform() throws RepositoryException {
+ return userManagerDelegate.getAuthorizable(principal);
+ }
+ });
+ }
+
+ @Override
+ public Authorizable getAuthorizableByPath(final String path) throws
UnsupportedRepositoryOperationException, RepositoryException {
+ return sessionDelegate.perform(new
UserManagerOperation<Authorizable>(sessionDelegate) {
+ @Override
+ public Authorizable perform() throws RepositoryException {
+ return userManagerDelegate.getAuthorizableByPath(path);
+ }
+ });
+ }
+
+ @Override
+ public Iterator<Authorizable> findAuthorizables(final String relPath,
final String value) throws RepositoryException {
+ return sessionDelegate.perform(new
UserManagerOperation<Iterator<Authorizable>>(sessionDelegate) {
+ @Override
+ public Iterator<Authorizable> perform() throws RepositoryException
{
+ return userManagerDelegate.findAuthorizables(relPath, value);
+ }
+ });
+ }
+
+ @Override
+ public Iterator<Authorizable> findAuthorizables(final String relPath,
final String value, final int searchType) throws RepositoryException {
+ return sessionDelegate.perform(new
UserManagerOperation<Iterator<Authorizable>>(sessionDelegate) {
+ @Override
+ public Iterator<Authorizable> perform() throws RepositoryException
{
+ return userManagerDelegate.findAuthorizables(relPath, value,
searchType);
+ }
+ });
+ }
+
+ @Override
+ public Iterator<Authorizable> findAuthorizables(final Query query) throws
RepositoryException {
+ return sessionDelegate.perform(new
UserManagerOperation<Iterator<Authorizable>>(sessionDelegate) {
+ @Override
+ public Iterator<Authorizable> perform() throws RepositoryException
{
+ return userManagerDelegate.findAuthorizables(query);
+ }
+ });
+ }
+
+ @Override
+ public User createUser(final String userID, final String password) throws
AuthorizableExistsException, RepositoryException {
+ return sessionDelegate.perform(new
UserManagerOperation<User>(sessionDelegate) {
+ @Override
+ public User perform() throws RepositoryException {
+ return userManagerDelegate.createUser(userID, password);
+ }
+ });
+ }
+
+ @Override
+ public User createUser(final String userID, final String password, final
Principal principal, final String intermediatePath) throws
AuthorizableExistsException, RepositoryException {
+ return sessionDelegate.perform(new
UserManagerOperation<User>(sessionDelegate) {
+ @Override
+ public User perform() throws RepositoryException {
+ return userManagerDelegate.createUser(userID, password,
principal, intermediatePath);
+ }
+ });
+ }
+
+ @Override
+ public Group createGroup(final String groupID) throws
AuthorizableExistsException, RepositoryException {
+ return sessionDelegate.perform(new
UserManagerOperation<Group>(sessionDelegate) {
+ @Override
+ public Group perform() throws RepositoryException {
+ return userManagerDelegate.createGroup(groupID);
+ }
+ });
+ }
+
+ @Override
+ public Group createGroup(final Principal principal) throws
AuthorizableExistsException, RepositoryException {
+ return sessionDelegate.perform(new
UserManagerOperation<Group>(sessionDelegate) {
+ @Override
+ public Group perform() throws RepositoryException {
+ return userManagerDelegate.createGroup(principal);
+ }
+ });
+ }
+
+ @Override
+ public Group createGroup(final Principal principal, final String
intermediatePath) throws AuthorizableExistsException, RepositoryException {
+ return sessionDelegate.perform(new
UserManagerOperation<Group>(sessionDelegate) {
+ @Override
+ public Group perform() throws RepositoryException {
+ return userManagerDelegate.createGroup(principal,
intermediatePath);
+ }
+ });
+ }
+
+ @Override
+ public Group createGroup(final String groupID, final Principal principal,
final String intermediatePath) throws AuthorizableExistsException,
RepositoryException {
+ return sessionDelegate.perform(new
UserManagerOperation<Group>(sessionDelegate) {
+ @Override
+ public Group perform() throws RepositoryException {
+ return userManagerDelegate.createGroup(groupID, principal,
intermediatePath);
+ }
+ });
+ }
+
+ @Override
+ public boolean isAutoSave() {
+ try {
+ return sessionDelegate.perform(new
UserManagerOperation<Boolean>(sessionDelegate) {
+ @Override
+ public Boolean perform() {
+ return userManagerDelegate.isAutoSave();
+ }
+ });
+ } catch (RepositoryException e) {
+ assert false : "Unexpected exception: " + e;
+ return false;
+ }
+ }
+
+ @Override
+ public void autoSave(final boolean enable) throws
UnsupportedRepositoryOperationException, RepositoryException {
+ sessionDelegate.perform(new
UserManagerOperation<Void>(sessionDelegate) {
+ @Override
+ public Void perform() throws RepositoryException {
+ userManagerDelegate.autoSave(enable);
+ return null;
+ }
+ });
+ }
+}
Propchange:
jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/UserManagerDelegator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/UserManagerDelegator.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev URL
Added:
jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/operation/UserManagerOperation.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/operation/UserManagerOperation.java?rev=1513520&view=auto
==============================================================================
---
jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/operation/UserManagerOperation.java
(added)
+++
jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/operation/UserManagerOperation.java
Tue Aug 13 14:53:16 2013
@@ -0,0 +1,37 @@
+/*
+ * 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.operation;
+
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate;
+
+public abstract class UserManagerOperation<T> extends SessionOperation<T> {
+ private final SessionDelegate delegate;
+
+ protected UserManagerOperation(SessionDelegate delegate) {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public void checkPreconditions() throws RepositoryException {
+ delegate.checkAlive();
+ }
+}
Propchange:
jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/operation/UserManagerOperation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/operation/UserManagerOperation.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev URL