From ddc6120a7f9db25f5991e5f0bf2db600482b4cad Mon Sep 17 00:00:00 2001
From: Eike Stepper
Date: Mon, 28 May 2012 10:32:03 +0200
Subject: [380629] Design a default Security model
https://bugs.eclipse.org/bugs/show_bug.cgi?id=380629
---
.../plugin.properties | 6 +
.../cdo/security/provider/GroupItemProvider.java | 48 +++
.../SecurityItemProviderAdapterFactory.java | 16 +-
.../cdo/security/provider/UserItemProvider.java | 51 +++
.../cdo/security/presentation/SecurityEditor.java | 4 +-
.../model/security.ecore | 12 +
.../model/security.ecorediag | 56 ++--
.../src/org/eclipse/emf/cdo/security/Group.java | 51 +++
.../eclipse/emf/cdo/security/SecurityPackage.java | 186 ++++++++++-
.../src/org/eclipse/emf/cdo/security/User.java | 50 +++
.../eclipse/emf/cdo/security/impl/CachedList.java | 345 +++++++++++++++++++++
.../eclipse/emf/cdo/security/impl/GroupImpl.java | 126 ++++++++
.../emf/cdo/security/impl/SecurityFactoryImpl.java | 15 +-
.../emf/cdo/security/impl/SecurityPackageImpl.java | 161 +++++++---
.../eclipse/emf/cdo/security/impl/UserImpl.java | 97 ++++++
.../cdo/security/util/SecurityAdapterFactory.java | 2 +
.../emf/cdo/security/util/SecuritySwitch.java | 64 +---
.../server/internal/security/SecurityManager.java | 26 ++
.../emf/cdo/server/security/ISecurityManager.java | 8 +-
19 files changed, 1175 insertions(+), 149 deletions(-)
create mode 100644 plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/CachedList.java
diff --git a/plugins/org.eclipse.emf.cdo.security.edit/plugin.properties b/plugins/org.eclipse.emf.cdo.security.edit/plugin.properties
index beaad9d7aa..ffc4ef785c 100644
--- a/plugins/org.eclipse.emf.cdo.security.edit/plugin.properties
+++ b/plugins/org.eclipse.emf.cdo.security.edit/plugin.properties
@@ -59,3 +59,9 @@ _UI_Group_inheritingGroups_feature = Inheriting Groups
_UI_Directory_type = Directory
_UI_Directory_items_feature = Items
_UI_Directory_name_feature = Name
+_UI_Group_allInheritedGroups_feature = All Inherited Groups
+_UI_Group_allRoles_feature = All Roles
+_UI_User_allGroups_feature = All Groups
+_UI_User_allRoles_feature = All Roles
+_UI_User_label_feature = Label
+_UI_Group_allInheritingGroups_feature = All Inheriting Groups
diff --git a/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/GroupItemProvider.java b/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/GroupItemProvider.java
index aee28b3b49..236bb331a7 100644
--- a/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/GroupItemProvider.java
+++ b/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/GroupItemProvider.java
@@ -66,7 +66,10 @@ public class GroupItemProvider extends AssigneeItemProvider implements IEditingD
super.getPropertyDescriptors(object);
addInheritedGroupsPropertyDescriptor(object);
+ addAllInheritedGroupsPropertyDescriptor(object);
addInheritingGroupsPropertyDescriptor(object);
+ addAllInheritingGroupsPropertyDescriptor(object);
+ addAllRolesPropertyDescriptor(object);
addUsersPropertyDescriptor(object);
}
return itemPropertyDescriptors;
@@ -117,6 +120,51 @@ public class GroupItemProvider extends AssigneeItemProvider implements IEditingD
SecurityPackage.Literals.GROUP__INHERITING_GROUPS, true, false, true, null, null, null));
}
+ /**
+ * This adds a property descriptor for the All Inheriting Groups feature.
+ *
+ *
+ * @generated
+ */
+ protected void addAllInheritingGroupsPropertyDescriptor(Object object)
+ {
+ itemPropertyDescriptors.add(createItemPropertyDescriptor(
+ ((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(),
+ getString("_UI_Group_allInheritingGroups_feature"), //$NON-NLS-1$
+ getString("_UI_PropertyDescriptor_description", "_UI_Group_allInheritingGroups_feature", "_UI_Group_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ SecurityPackage.Literals.GROUP__ALL_INHERITING_GROUPS, false, false, false, null, null, null));
+ }
+
+ /**
+ * This adds a property descriptor for the All Inherited Groups feature.
+ *
+ *
+ * @generated
+ */
+ protected void addAllInheritedGroupsPropertyDescriptor(Object object)
+ {
+ itemPropertyDescriptors.add(createItemPropertyDescriptor(
+ ((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(),
+ getString("_UI_Group_allInheritedGroups_feature"), //$NON-NLS-1$
+ getString("_UI_PropertyDescriptor_description", "_UI_Group_allInheritedGroups_feature", "_UI_Group_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ SecurityPackage.Literals.GROUP__ALL_INHERITED_GROUPS, false, false, false, null, null, null));
+ }
+
+ /**
+ * This adds a property descriptor for the All Roles feature.
+ *
+ *
+ * @generated
+ */
+ protected void addAllRolesPropertyDescriptor(Object object)
+ {
+ itemPropertyDescriptors.add(createItemPropertyDescriptor(
+ ((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(),
+ getString("_UI_Group_allRoles_feature"), //$NON-NLS-1$
+ getString("_UI_PropertyDescriptor_description", "_UI_Group_allRoles_feature", "_UI_Group_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ SecurityPackage.Literals.GROUP__ALL_ROLES, false, false, false, null, null, null));
+ }
+
/**
* This returns Group.gif.
*
diff --git a/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/SecurityItemProviderAdapterFactory.java b/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/SecurityItemProviderAdapterFactory.java
index 36f9559850..26b612adbb 100644
--- a/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/SecurityItemProviderAdapterFactory.java
+++ b/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/SecurityItemProviderAdapterFactory.java
@@ -312,7 +312,7 @@ public class SecurityItemProviderAdapterFactory extends SecurityAdapterFactory i
if (isFactoryForType(type))
{
Object adapter = super.adapt(object, type);
- if (!(type instanceof Class>) || ((Class>)type).isInstance(adapter))
+ if (!(type instanceof Class>) || (((Class>)type).isInstance(adapter)))
{
return adapter;
}
@@ -390,7 +390,7 @@ public class SecurityItemProviderAdapterFactory extends SecurityAdapterFactory i
}
/**
- * This disposes all of the item providers created by this factory.
+ * This disposes all of the item providers created by this factory.
*
*
* @generated
@@ -398,29 +398,17 @@ public class SecurityItemProviderAdapterFactory extends SecurityAdapterFactory i
public void dispose()
{
if (realmItemProvider != null)
- {
realmItemProvider.dispose();
- }
if (directoryItemProvider != null)
- {
directoryItemProvider.dispose();
- }
if (roleItemProvider != null)
- {
roleItemProvider.dispose();
- }
if (groupItemProvider != null)
- {
groupItemProvider.dispose();
- }
if (userItemProvider != null)
- {
userItemProvider.dispose();
- }
if (userPasswordItemProvider != null)
- {
userPasswordItemProvider.dispose();
- }
}
}
diff --git a/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/UserItemProvider.java b/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/UserItemProvider.java
index 9dd8e137b9..68b2b2c70a 100644
--- a/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/UserItemProvider.java
+++ b/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/UserItemProvider.java
@@ -70,6 +70,9 @@ public class UserItemProvider extends AssigneeItemProvider implements IEditingDo
super.getPropertyDescriptors(object);
addGroupsPropertyDescriptor(object);
+ addAllGroupsPropertyDescriptor(object);
+ addAllRolesPropertyDescriptor(object);
+ addLabelPropertyDescriptor(object);
addFirstNamePropertyDescriptor(object);
addLastNamePropertyDescriptor(object);
addEmailPropertyDescriptor(object);
@@ -93,6 +96,53 @@ public class UserItemProvider extends AssigneeItemProvider implements IEditingDo
SecurityPackage.Literals.USER__GROUPS, true, false, true, null, null, null));
}
+ /**
+ * This adds a property descriptor for the All Groups feature.
+ *
+ *
+ * @generated
+ */
+ protected void addAllGroupsPropertyDescriptor(Object object)
+ {
+ itemPropertyDescriptors.add(createItemPropertyDescriptor(
+ ((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(),
+ getString("_UI_User_allGroups_feature"), //$NON-NLS-1$
+ getString("_UI_PropertyDescriptor_description", "_UI_User_allGroups_feature", "_UI_User_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ SecurityPackage.Literals.USER__ALL_GROUPS, false, false, false, null, null, null));
+ }
+
+ /**
+ * This adds a property descriptor for the All Roles feature.
+ *
+ *
+ * @generated
+ */
+ protected void addAllRolesPropertyDescriptor(Object object)
+ {
+ itemPropertyDescriptors.add(createItemPropertyDescriptor(
+ ((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(),
+ getString("_UI_User_allRoles_feature"), //$NON-NLS-1$
+ getString("_UI_PropertyDescriptor_description", "_UI_User_allRoles_feature", "_UI_User_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ SecurityPackage.Literals.USER__ALL_ROLES, false, false, false, null, null, null));
+ }
+
+ /**
+ * This adds a property descriptor for the Label feature.
+ *
+ *
+ * @generated
+ */
+ protected void addLabelPropertyDescriptor(Object object)
+ {
+ itemPropertyDescriptors.add(createItemPropertyDescriptor(
+ ((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(),
+ getResourceLocator(),
+ getString("_UI_User_label_feature"), //$NON-NLS-1$
+ getString("_UI_PropertyDescriptor_description", "_UI_User_label_feature", "_UI_User_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ SecurityPackage.Literals.USER__LABEL, false, false, false, ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, null,
+ null));
+ }
+
/**
* This adds a property descriptor for the First Name feature.
*
@@ -245,6 +295,7 @@ public class UserItemProvider extends AssigneeItemProvider implements IEditingDo
switch (notification.getFeatureID(User.class))
{
+ case SecurityPackage.USER__LABEL:
case SecurityPackage.USER__FIRST_NAME:
case SecurityPackage.USER__LAST_NAME:
case SecurityPackage.USER__EMAIL:
diff --git a/plugins/org.eclipse.emf.cdo.security.editor/src/org/eclipse/emf/cdo/security/presentation/SecurityEditor.java b/plugins/org.eclipse.emf.cdo.security.editor/src/org/eclipse/emf/cdo/security/presentation/SecurityEditor.java
index efba1b23f7..ddab24cf48 100644
--- a/plugins/org.eclipse.emf.cdo.security.editor/src/org/eclipse/emf/cdo/security/presentation/SecurityEditor.java
+++ b/plugins/org.eclipse.emf.cdo.security.editor/src/org/eclipse/emf/cdo/security/presentation/SecurityEditor.java
@@ -1361,7 +1361,7 @@ public class SecurityEditor extends MultiPageEditorPart implements IEditingDomai
/**
* This returns whether something has been persisted to the URI of the specified resource.
- * The implementation uses the URI converter from the editor's resource set to try to open an input stream.
+ * The implementation uses the URI converter from the editor's resource set to try to open an input stream.
*
*
* @generated
@@ -1426,7 +1426,7 @@ public class SecurityEditor extends MultiPageEditorPart implements IEditingDomai
*/
protected void doSaveAs(URI uri, IEditorInput editorInput)
{
- editingDomain.getResourceSet().getResources().get(0).setURI(uri);
+ (editingDomain.getResourceSet().getResources().get(0)).setURI(uri);
setInputWithNotify(editorInput);
setPartName(editorInput.getName());
IProgressMonitor progressMonitor = getActionBars().getStatusLineManager() != null ? getActionBars()
diff --git a/plugins/org.eclipse.emf.cdo.security/model/security.ecore b/plugins/org.eclipse.emf.cdo.security/model/security.ecore
index ac6b3d4d68..2fb7329c14 100644
--- a/plugins/org.eclipse.emf.cdo.security/model/security.ecore
+++ b/plugins/org.eclipse.emf.cdo.security/model/security.ecore
@@ -30,14 +30,26 @@
*
*
+ * If the meaning of the 'All Inheriting Groups' reference list isn't clear, + * there really should be more of a description here... + *
+ * + * @return the value of the 'All Inheriting Groups' reference list. + * @see org.eclipse.emf.cdo.security.SecurityPackage#getGroup_AllInheritingGroups() + * @model transient="true" changeable="false" volatile="true" derived="true" + * @generated + */ + EList+ * If the meaning of the 'All Inherited Groups' reference list isn't clear, + * there really should be more of a description here... + *
+ * + * @return the value of the 'All Inherited Groups' reference list. + * @see org.eclipse.emf.cdo.security.SecurityPackage#getGroup_AllInheritedGroups() + * @model transient="true" changeable="false" volatile="true" derived="true" + * @generated + */ + EList+ * If the meaning of the 'All Roles' reference list isn't clear, + * there really should be more of a description here... + *
+ * + * @return the value of the 'All Roles' reference list. + * @see org.eclipse.emf.cdo.security.SecurityPackage#getGroup_AllRoles() + * @model transient="true" changeable="false" volatile="true" derived="true" + * @generated + */ + EList+ * If the meaning of the 'All Groups' reference list isn't clear, + * there really should be more of a description here... + *
+ * + * @return the value of the 'All Groups' reference list. + * @see org.eclipse.emf.cdo.security.SecurityPackage#getUser_AllGroups() + * @model transient="true" changeable="false" volatile="true" derived="true" + * @generated + */ + EList+ * If the meaning of the 'All Roles' reference list isn't clear, + * there really should be more of a description here... + *
+ * + * @return the value of the 'All Roles' reference list. + * @see org.eclipse.emf.cdo.security.SecurityPackage#getUser_AllRoles() + * @model transient="true" changeable="false" volatile="true" derived="true" + * @generated + */ + EList+ * If the meaning of the 'Label' attribute isn't clear, + * there really should be more of a description here... + *
+ * + * @return the value of the 'Label' attribute. + * @see org.eclipse.emf.cdo.security.SecurityPackage#getUser_Label() + * @model transient="true" changeable="false" volatile="true" derived="true" + * @generated + */ + String getLabel(); + /** * Returns the value of the 'First Name' attribute. * diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/CachedList.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/CachedList.java new file mode 100644 index 0000000000..8d52f21f45 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/CachedList.java @@ -0,0 +1,345 @@ +/* + * 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.security.impl; + +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.util.EcoreEList; +import org.eclipse.emf.ecore.util.InternalEList; + +import java.lang.ref.SoftReference; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.Set; + +/** + * @author Eike Stepper + */ +abstract class CachedList