diff options
author | Eike Stepper | 2013-10-01 10:41:01 +0000 |
---|---|---|
committer | Eike Stepper | 2013-10-01 18:21:43 +0000 |
commit | 596ce42d6fe3d648f771b7a27b3af5f828f25a2a (patch) | |
tree | 7fb5d428878fec3efdf177de24df1bcd7d64e2e1 | |
parent | 04c53c1cb3132f7d3e674dfae3b7dbddafce6e03 (diff) | |
download | cdo-596ce42d6fe3d648f771b7a27b3af5f828f25a2a.tar.gz cdo-596ce42d6fe3d648f771b7a27b3af5f828f25a2a.tar.xz cdo-596ce42d6fe3d648f771b7a27b3af5f828f25a2a.zip |
[418267] [Security] Cached permissions are not always properly updated
after commits
https://bugs.eclipse.org/bugs/show_bug.cgi?id=418267
5 files changed, 84 insertions, 40 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitTransactionIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitTransactionIndication.java index 6177acfddf..73157b8824 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitTransactionIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitTransactionIndication.java @@ -419,9 +419,13 @@ public class CommitTransactionIndication extends CDOServerIndicationWithMonitori IPermissionManager permissionManager = session.getManager().getPermissionManager(); if (permissionManager != null) { - out.writeBoolean(true); - respondingNewPermissions(out, permissionManager, session, commitContext.getNewObjects()); - respondingNewPermissions(out, permissionManager, session, commitContext.getDirtyObjects()); + InternalCDORevision[] newObjects = commitContext.getNewObjects(); + InternalCDORevision[] dirtyObjects = commitContext.getDirtyObjects(); + + out.writeInt(newObjects.length + dirtyObjects.length); + + respondingNewPermissions(out, permissionManager, session, newObjects); + respondingNewPermissions(out, permissionManager, session, dirtyObjects); } else { @@ -436,8 +440,6 @@ public class CommitTransactionIndication extends CDOServerIndicationWithMonitori if (size != 0) { CDOBranchPoint securityContext = commitContext.getBranchPoint(); - - out.writeInt(size); for (int i = 0; i < size; i++) { InternalCDORevision revision = revisions[i]; diff --git a/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/internal/security/SecurityManager.java b/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/internal/security/SecurityManager.java index 08ba264124..a30f362278 100644 --- a/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/internal/security/SecurityManager.java +++ b/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/internal/security/SecurityManager.java @@ -456,6 +456,7 @@ public class SecurityManager extends Lifecycle implements InternalSecurityManage try { handler.init(this, firstTime); + OM.LOG.info("Security realm handled by " + handler); } catch (Exception ex) { diff --git a/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/spi/security/AnnotationHandler.java b/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/spi/security/AnnotationHandler.java index a6d7d0e86f..14e4176cc3 100644 --- a/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/spi/security/AnnotationHandler.java +++ b/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/spi/security/AnnotationHandler.java @@ -158,6 +158,12 @@ public class AnnotationHandler implements InternalSecurityManager.CommitHandler } } + @Override + public String toString() + { + return getClass().getSimpleName(); + } + /** * @author Eike Stepper * @since 4.3 diff --git a/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/spi/security/HomeFolderHandler.java b/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/spi/security/HomeFolderHandler.java index bc25ea01c6..ad9fd74e3a 100644 --- a/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/spi/security/HomeFolderHandler.java +++ b/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/spi/security/HomeFolderHandler.java @@ -25,6 +25,9 @@ import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; import org.eclipse.emf.cdo.transaction.CDOTransaction; import org.eclipse.emf.cdo.view.CDOView; +import org.eclipse.net4j.util.concurrent.ExecutorServiceFactory; +import org.eclipse.net4j.util.container.IManagedContainer; +import org.eclipse.net4j.util.container.IManagedContainer.ContainerAware; import org.eclipse.net4j.util.factory.ProductCreationException; import org.eclipse.emf.common.util.BasicEList; @@ -32,6 +35,7 @@ import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EClass; import java.util.List; +import java.util.concurrent.ExecutorService; /** * If the meaning of this type isn't clear, there really should be more of a description here... @@ -47,6 +51,8 @@ public class HomeFolderHandler implements InternalSecurityManager.CommitHandler2 private final String homeFolder; + private ExecutorService executorService; + public HomeFolderHandler(String homeFolder) { this.homeFolder = homeFolder == null || homeFolder.length() == 0 ? DEFAULT_HOME_FOLDER : homeFolder; @@ -62,6 +68,16 @@ public class HomeFolderHandler implements InternalSecurityManager.CommitHandler2 return homeFolder; } + public ExecutorService getExecutorService() + { + return executorService; + } + + public void setExecutorService(ExecutorService executorService) + { + this.executorService = executorService; + } + public void init(InternalSecurityManager securityManager, boolean firstTime) { if (firstTime) @@ -134,51 +150,58 @@ public class HomeFolderHandler implements InternalSecurityManager.CommitHandler2 } } - protected void handleUsers(InternalSecurityManager securityManager, final List<String> userIDs, final boolean init) + protected void handleUsers(final InternalSecurityManager securityManager, final List<String> userIDs, + final boolean init) { - securityManager.modify(new RealmOperation() + executorService.submit(new Runnable() { - public void execute(Realm realm) + public void run() { - String roleID = "Home Folder " + homeFolder; - Role role; - - if (init) - { - role = realm.addRole(roleID); - initRole(role); - } - else + securityManager.modify(new RealmOperation() { - role = realm.getRole(roleID); - if (role == null) + public void execute(Realm realm) { - OM.LOG.warn("Role '" + roleID + "' not found in " + HomeFolderHandler.this); - return; - } - } - - CDOTransaction transaction = (CDOTransaction)realm.cdoView(); + String roleID = "Home Folder " + homeFolder; + Role role; - for (String userID : userIDs) - { - try - { - User user = realm.getUser(userID); - if (user == null) + if (init) { - OM.LOG.warn("User '" + userID + "' not found in " + HomeFolderHandler.this); + role = realm.addRole(roleID); + initRole(role); } else { - handleUser(transaction, realm, role, user); + role = realm.getRole(roleID); + if (role == null) + { + OM.LOG.warn("Role '" + roleID + "' not found in " + HomeFolderHandler.this); + return; + } + } + + CDOTransaction transaction = (CDOTransaction)realm.cdoView(); + + for (String userID : userIDs) + { + try + { + User user = realm.getUser(userID); + if (user == null) + { + OM.LOG.warn("User '" + userID + "' not found in " + HomeFolderHandler.this); + } + else + { + handleUser(transaction, realm, role, user); + } + } + catch (Exception ex) + { + OM.LOG.error(ex); + } } } - catch (Exception ex) - { - OM.LOG.error(ex); - } - } + }); } }); } @@ -198,17 +221,28 @@ public class HomeFolderHandler implements InternalSecurityManager.CommitHandler2 /** * @author Eike Stepper */ - public static class Factory extends InternalSecurityManager.CommitHandler.Factory + public static class Factory extends InternalSecurityManager.CommitHandler.Factory implements ContainerAware { + private IManagedContainer container; + public Factory() { super("home"); } + public void setManagedContainer(IManagedContainer container) + { + this.container = container; + } + @Override public CommitHandler create(String homeFolder) throws ProductCreationException { - return new HomeFolderHandler(homeFolder); + ExecutorService executorService = ExecutorServiceFactory.get(container); + + HomeFolderHandler handler = new HomeFolderHandler(homeFolder); + handler.setExecutorService(executorService); + return handler; } } } diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java index 53447d4658..e38d04a193 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java @@ -55,6 +55,7 @@ public class OpenSessionDialog extends TitleAreaDialog { super.configureShell(newShell); newShell.setText(TITLE); + newShell.setSize(380, 240); } @Override |