Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-05-28 11:39:03 +0000
committerEike Stepper2012-05-28 11:39:03 +0000
commitadf13a7aa548a3507b48eb9a5d1188322f92b22a (patch)
tree5afdf2cc35a51baf6b7cdfa4bbeb5290b29729f7 /plugins
parent193c117d042f886a45a4724cc3f16fffef638382 (diff)
downloadcdo-adf13a7aa548a3507b48eb9a5d1188322f92b22a.tar.gz
cdo-adf13a7aa548a3507b48eb9a5d1188322f92b22a.tar.xz
cdo-adf13a7aa548a3507b48eb9a5d1188322f92b22a.zip
[380629] Design a default Security model
https://bugs.eclipse.org/bugs/show_bug.cgi?id=380629
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/internal/security/ResourceRoleProvider.java76
-rw-r--r--plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/internal/security/SecurityManager.java10
2 files changed, 85 insertions, 1 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/internal/security/ResourceRoleProvider.java b/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/internal/security/ResourceRoleProvider.java
new file mode 100644
index 0000000000..d96c2c30de
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/internal/security/ResourceRoleProvider.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.security;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionProvider;
+import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
+import org.eclipse.emf.cdo.common.security.CDOPermission;
+import org.eclipse.emf.cdo.security.Role;
+import org.eclipse.emf.cdo.server.IStoreAccessor.CommitContext;
+import org.eclipse.emf.cdo.server.security.ISecurityManager;
+import org.eclipse.emf.cdo.server.spi.security.IRoleProvider;
+
+import org.eclipse.net4j.util.factory.ProductCreationException;
+
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public class ResourceRoleProvider implements IRoleProvider
+{
+ public ResourceRoleProvider()
+ {
+ }
+
+ public void handleCommit(ISecurityManager securityManager, CommitContext commitContext)
+ {
+ // Do nothing
+ }
+
+ public Set<Role> getRoles(ISecurityManager securityManager, CDOBranchPoint securityContext,
+ CDORevisionProvider revisionProvider, CDORevision revision, CDOPermission permission)
+ {
+ if (revisionProvider == null)
+ {
+ return null;
+ }
+
+ String path = CDORevisionUtil.getResourceNodePath(revision, revisionProvider);
+ return getRoles(securityManager, path, permission);
+ }
+
+ private Set<Role> getRoles(ISecurityManager securityManager, String path, CDOPermission permission)
+ {
+ return null;
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static class Factory extends IRoleProvider.Factory
+ {
+ public static final String TYPE = "resource";
+
+ public Factory()
+ {
+ super(TYPE);
+ }
+
+ @Override
+ public ResourceRoleProvider create(String description) throws ProductCreationException
+ {
+ return new ResourceRoleProvider();
+ }
+ }
+}
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 3448a862cd..6fdc5ecdf6 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
@@ -58,8 +58,10 @@ import org.eclipse.net4j.util.security.SecurityUtil;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.util.EcoreUtil;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -316,7 +318,13 @@ public class SecurityManager implements ISecurityManager
{
if (roleProviders == null)
{
- roleProviders = (IRoleProvider[])container.getElements(IRoleProvider.Factory.PRODUCT_GROUP);
+ List<IRoleProvider> result = new ArrayList<IRoleProvider>();
+ for (String factoryType : container.getFactoryTypes(IRoleProvider.Factory.PRODUCT_GROUP))
+ {
+ result.add((IRoleProvider)container.getElement(IRoleProvider.Factory.PRODUCT_GROUP, factoryType, null));
+ }
+
+ roleProviders = result.toArray(new IRoleProvider[result.size()]);
}
}

Back to the top