Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Redor2016-09-16 15:32:47 +0000
committerEike Stepper2016-09-24 08:37:12 +0000
commitb8be6e007b76707e409c3693d43585b6a41effa5 (patch)
tree1a7c3a4ebaf163490bfe3ca05dcd989de5f0692b /plugins
parent24e214f39f88ef039701b06c85828ba75f4ff3d5 (diff)
downloadcdo-b8be6e007b76707e409c3693d43585b6a41effa5.tar.gz
cdo-b8be6e007b76707e409c3693d43585b6a41effa5.tar.xz
cdo-b8be6e007b76707e409c3693d43585b6a41effa5.zip
[501607] Fix circularly error when Realm is modified first.
If Realm is modified first and then other objects are modified, the commit was not possible. https://bugs.eclipse.org/bugs/show_bug.cgi?id=501607 Change-Id: I9854acf079b05a10e3ef4b5b860199b8715d8bae Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.server.security/META-INF/MANIFEST.MF10
-rw-r--r--plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/internal/security/SecurityManager.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_501607_Test.java104
3 files changed, 111 insertions, 6 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.security/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.server.security/META-INF/MANIFEST.MF
index b4daf94f68..c556526e22 100644
--- a/plugins/org.eclipse.emf.cdo.server.security/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.server.security/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.emf.cdo.server.security;singleton:=true
Bundle-Name: %pluginName
-Bundle-Version: 4.3.200.qualifier
+Bundle-Version: 4.3.300.qualifier
Bundle-ClassPath: .
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -12,15 +12,15 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
org.eclipse.emf.cdo.security;bundle-version="[4.1.0,5.0.0)",
org.eclipse.emf.cdo.net4j;bundle-version="[4.1.0,5.0.0)",
org.eclipse.net4j.jvm;bundle-version="[4.1.0,5.0.0)"
-Export-Package: org.eclipse.emf.cdo.server.internal.security;version="4.3.200";
+Export-Package: org.eclipse.emf.cdo.server.internal.security;version="4.3.300";
x-friends:="org.eclipse.emf.cdo.tests,
org.eclipse.emf.cdo.tests.db,
org.eclipse.emf.cdo.tests.db4o,
org.eclipse.emf.cdo.tests.hibernate,
org.eclipse.emf.cdo.tests.mongodb,
org.eclipse.emf.cdo.tests.objectivity",
- org.eclipse.emf.cdo.server.internal.security.bundle;version="4.3.200";x-internal:=true,
- org.eclipse.emf.cdo.server.security;version="4.3.200",
- org.eclipse.emf.cdo.server.spi.security;version="4.3.200"
+ org.eclipse.emf.cdo.server.internal.security.bundle;version="4.3.300";x-internal:=true,
+ org.eclipse.emf.cdo.server.security;version="4.3.300",
+ org.eclipse.emf.cdo.server.spi.security;version="4.3.300"
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.eclipse.emf.cdo.server.internal.security.bundle.OM$Activator
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 c04af800ae..380987f1a0 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
@@ -10,6 +10,7 @@
* Christian W. Damus (CEA LIST) - bug 399306
* Christian W. Damus (CEA LIST) - bug 418454
* Christian W. Damus (CEA LIST) - bug 399487
+ * Laurent Redor (Obeo) - bug 501607
*/
package org.eclipse.emf.cdo.server.internal.security;
@@ -1211,7 +1212,7 @@ public class SecurityManager extends Lifecycle implements InternalSecurityManage
if (object.eClass().getEPackage() == SecurityPackage.eINSTANCE)
{
validate(object, diagnostic, context);
- realmChecked = object instanceof Realm;
+ realmChecked |= object instanceof Realm;
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_501607_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_501607_Test.java
new file mode 100644
index 0000000000..d440dbb101
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_501607_Test.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2016 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:
+ * Laurent Redor (Obeo) - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.security.Realm;
+import org.eclipse.emf.cdo.security.SecurityFactory;
+import org.eclipse.emf.cdo.security.User;
+import org.eclipse.emf.cdo.server.security.ISecurityManager;
+import org.eclipse.emf.cdo.server.security.SecurityManagerUtil;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesAfter;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.SessionConfig;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.security.IPasswordCredentials;
+import org.eclipse.net4j.util.security.IPasswordCredentialsProvider;
+import org.eclipse.net4j.util.security.PasswordCredentials;
+
+/**
+ * Bug 501607: [Security] "Security realm integrity violation: An object may not circularly
+ * contain itself" thrown when modifying several elements and Realm in first position
+ *
+ * @author Laurent Redor (Obeo)
+ */
+@CleanRepositoriesBefore(reason = "Security manager installed on repository")
+@CleanRepositoriesAfter(reason = "Security manager installed on repository")
+public class Bugzilla_501607_Test extends AbstractCDOTest
+{
+ /**
+ * Ensure that there is no CommitException thrown during the modification.
+ *
+ * @throws Exception
+ * In case of problem
+ */
+ public void testCommitChangesWhenModifyingRealmFirst() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ // Firstly, modify the Realm
+ Realm realm = getRealm(transaction);
+ User createdUser = SecurityFactory.eINSTANCE.createUser();
+ createdUser.setId("lredor");
+ realm.getItems().add(createdUser);
+ // Then make another modification on element contained in Realm
+ realm.getGroup("Users").getUsers().add(realm.addUser("cdamus", "12345678"));
+
+ try
+ {
+ transaction.commit();
+ }
+ catch (CommitException ex)
+ {
+ fail("Commit rolled back: " + ex.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public void setUp() throws Exception
+ {
+ getTestProperties().put(SessionConfig.PROP_TEST_CREDENTIALS_PROVIDER, new IPasswordCredentialsProvider()
+ {
+
+ public boolean isInteractive()
+ {
+ return false;
+ }
+
+ public IPasswordCredentials getCredentials()
+ {
+ return new PasswordCredentials(User.ADMINISTRATOR, "0000");
+ }
+ });
+
+ super.doSetUp();
+
+ // Create the security manager and attach it to the repository
+ ISecurityManager securityManager = SecurityManagerUtil.createSecurityManager("/security", getServerContainer());
+ getTestProperties().put(RepositoryConfig.PROP_TEST_SECURITY_MANAGER, securityManager);
+ getRepository();
+ LifecycleUtil.waitForActive(securityManager, 10000L);
+ }
+
+ Realm getRealm(CDOView view)
+ {
+ CDOResource resource = view.getResource("/security");
+ return (Realm)resource.getContents().get(0);
+ }
+}

Back to the top