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 @@ + + + + + + diff --git a/plugins/org.eclipse.emf.cdo.security/model/security.ecorediag b/plugins/org.eclipse.emf.cdo.security/model/security.ecorediag index 9fdfc768a2..48394ff517 100644 --- a/plugins/org.eclipse.emf.cdo.security/model/security.ecorediag +++ b/plugins/org.eclipse.emf.cdo.security/model/security.ecorediag @@ -18,7 +18,7 @@ - + @@ -39,6 +39,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -66,7 +86,7 @@ - + @@ -154,7 +174,7 @@ - + @@ -162,26 +182,26 @@ - + - + - + - + @@ -193,13 +213,13 @@ - + - + @@ -236,9 +256,9 @@ - - - + + + @@ -250,7 +270,7 @@ - + @@ -264,9 +284,9 @@ - - - + + + @@ -278,7 +298,7 @@ - + @@ -292,7 +312,7 @@ - + diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/Group.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/Group.java index 32f7e31e93..12f7a9acb9 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/Group.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/Group.java @@ -21,7 +21,10 @@ import org.eclipse.emf.common.util.EList; * The following features are supported: *
    *
  • {@link org.eclipse.emf.cdo.security.Group#getInheritedGroups Inherited Groups}
  • + *
  • {@link org.eclipse.emf.cdo.security.Group#getAllInheritedGroups All Inherited Groups}
  • *
  • {@link org.eclipse.emf.cdo.security.Group#getInheritingGroups Inheriting Groups}
  • + *
  • {@link org.eclipse.emf.cdo.security.Group#getAllInheritingGroups All Inheriting Groups}
  • + *
  • {@link org.eclipse.emf.cdo.security.Group#getAllRoles All Roles}
  • *
  • {@link org.eclipse.emf.cdo.security.Group#getUsers Users}
  • *
*

@@ -86,4 +89,52 @@ public interface Group extends Assignee */ EList getInheritingGroups(); + /** + * Returns the value of the 'All Inheriting Groups' reference list. + * The list contents are of type {@link org.eclipse.emf.cdo.security.Group}. + * + *

+ * 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 getAllInheritingGroups(); + + /** + * Returns the value of the 'All Inherited Groups' reference list. + * The list contents are of type {@link org.eclipse.emf.cdo.security.Group}. + * + *

+ * 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 getAllInheritedGroups(); + + /** + * Returns the value of the 'All Roles' reference list. + * The list contents are of type {@link org.eclipse.emf.cdo.security.Role}. + * + *

+ * 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 getAllRoles(); + } // Group diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityPackage.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityPackage.java index b4390870fb..2acaed64c6 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityPackage.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityPackage.java @@ -361,6 +361,15 @@ public interface SecurityPackage extends EPackage */ int GROUP__INHERITED_GROUPS = ASSIGNEE_FEATURE_COUNT + 0; + /** + * The feature id for the 'All Inherited Groups' reference list. + * + * + * @generated + * @ordered + */ + int GROUP__ALL_INHERITED_GROUPS = ASSIGNEE_FEATURE_COUNT + 1; + /** * The feature id for the 'Inheriting Groups' reference list. * @@ -368,7 +377,25 @@ public interface SecurityPackage extends EPackage * @generated * @ordered */ - int GROUP__INHERITING_GROUPS = ASSIGNEE_FEATURE_COUNT + 1; + int GROUP__INHERITING_GROUPS = ASSIGNEE_FEATURE_COUNT + 2; + + /** + * The feature id for the 'All Inheriting Groups' reference list. + * + * + * @generated + * @ordered + */ + int GROUP__ALL_INHERITING_GROUPS = ASSIGNEE_FEATURE_COUNT + 3; + + /** + * The feature id for the 'All Roles' reference list. + * + * + * @generated + * @ordered + */ + int GROUP__ALL_ROLES = ASSIGNEE_FEATURE_COUNT + 4; /** * The feature id for the 'Users' reference list. @@ -377,7 +404,7 @@ public interface SecurityPackage extends EPackage * @generated * @ordered */ - int GROUP__USERS = ASSIGNEE_FEATURE_COUNT + 2; + int GROUP__USERS = ASSIGNEE_FEATURE_COUNT + 5; /** * The number of structural features of the 'Group' class. @@ -386,7 +413,7 @@ public interface SecurityPackage extends EPackage * @generated * @ordered */ - int GROUP_FEATURE_COUNT = ASSIGNEE_FEATURE_COUNT + 3; + int GROUP_FEATURE_COUNT = ASSIGNEE_FEATURE_COUNT + 6; /** * The meta object id for the '{@link org.eclipse.emf.cdo.security.impl.UserImpl User}' class. @@ -434,6 +461,33 @@ public interface SecurityPackage extends EPackage */ int USER__GROUPS = ASSIGNEE_FEATURE_COUNT + 0; + /** + * The feature id for the 'All Groups' reference list. + * + * + * @generated + * @ordered + */ + int USER__ALL_GROUPS = ASSIGNEE_FEATURE_COUNT + 1; + + /** + * The feature id for the 'All Roles' reference list. + * + * + * @generated + * @ordered + */ + int USER__ALL_ROLES = ASSIGNEE_FEATURE_COUNT + 2; + + /** + * The feature id for the 'Label' attribute. + * + * + * @generated + * @ordered + */ + int USER__LABEL = ASSIGNEE_FEATURE_COUNT + 3; + /** * The feature id for the 'First Name' attribute. * @@ -441,7 +495,7 @@ public interface SecurityPackage extends EPackage * @generated * @ordered */ - int USER__FIRST_NAME = ASSIGNEE_FEATURE_COUNT + 1; + int USER__FIRST_NAME = ASSIGNEE_FEATURE_COUNT + 4; /** * The feature id for the 'Last Name' attribute. @@ -450,7 +504,7 @@ public interface SecurityPackage extends EPackage * @generated * @ordered */ - int USER__LAST_NAME = ASSIGNEE_FEATURE_COUNT + 2; + int USER__LAST_NAME = ASSIGNEE_FEATURE_COUNT + 5; /** * The feature id for the 'Email' attribute. @@ -459,7 +513,7 @@ public interface SecurityPackage extends EPackage * @generated * @ordered */ - int USER__EMAIL = ASSIGNEE_FEATURE_COUNT + 3; + int USER__EMAIL = ASSIGNEE_FEATURE_COUNT + 6; /** * The feature id for the 'Locked' attribute. @@ -468,7 +522,7 @@ public interface SecurityPackage extends EPackage * @generated * @ordered */ - int USER__LOCKED = ASSIGNEE_FEATURE_COUNT + 4; + int USER__LOCKED = ASSIGNEE_FEATURE_COUNT + 7; /** * The feature id for the 'Password' containment reference. @@ -477,7 +531,7 @@ public interface SecurityPackage extends EPackage * @generated * @ordered */ - int USER__PASSWORD = ASSIGNEE_FEATURE_COUNT + 5; + int USER__PASSWORD = ASSIGNEE_FEATURE_COUNT + 8; /** * The number of structural features of the 'User' class. @@ -486,7 +540,7 @@ public interface SecurityPackage extends EPackage * @generated * @ordered */ - int USER_FEATURE_COUNT = ASSIGNEE_FEATURE_COUNT + 6; + int USER_FEATURE_COUNT = ASSIGNEE_FEATURE_COUNT + 9; /** * The meta object id for the '{@link org.eclipse.emf.cdo.security.impl.UserPasswordImpl User Password}' class. @@ -718,6 +772,39 @@ public interface SecurityPackage extends EPackage */ EReference getGroup_InheritingGroups(); + /** + * Returns the meta object for the reference list '{@link org.eclipse.emf.cdo.security.Group#getAllInheritingGroups All Inheriting Groups}'. + * + * + * @return the meta object for the reference list 'All Inheriting Groups'. + * @see org.eclipse.emf.cdo.security.Group#getAllInheritingGroups() + * @see #getGroup() + * @generated + */ + EReference getGroup_AllInheritingGroups(); + + /** + * Returns the meta object for the reference list '{@link org.eclipse.emf.cdo.security.Group#getAllInheritedGroups All Inherited Groups}'. + * + * + * @return the meta object for the reference list 'All Inherited Groups'. + * @see org.eclipse.emf.cdo.security.Group#getAllInheritedGroups() + * @see #getGroup() + * @generated + */ + EReference getGroup_AllInheritedGroups(); + + /** + * Returns the meta object for the reference list '{@link org.eclipse.emf.cdo.security.Group#getAllRoles All Roles}'. + * + * + * @return the meta object for the reference list 'All Roles'. + * @see org.eclipse.emf.cdo.security.Group#getAllRoles() + * @see #getGroup() + * @generated + */ + EReference getGroup_AllRoles(); + /** * Returns the meta object for class '{@link org.eclipse.emf.cdo.security.User User}'. * @@ -739,6 +826,39 @@ public interface SecurityPackage extends EPackage */ EReference getUser_Groups(); + /** + * Returns the meta object for the reference list '{@link org.eclipse.emf.cdo.security.User#getAllGroups All Groups}'. + * + * + * @return the meta object for the reference list 'All Groups'. + * @see org.eclipse.emf.cdo.security.User#getAllGroups() + * @see #getUser() + * @generated + */ + EReference getUser_AllGroups(); + + /** + * Returns the meta object for the reference list '{@link org.eclipse.emf.cdo.security.User#getAllRoles All Roles}'. + * + * + * @return the meta object for the reference list 'All Roles'. + * @see org.eclipse.emf.cdo.security.User#getAllRoles() + * @see #getUser() + * @generated + */ + EReference getUser_AllRoles(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.cdo.security.User#getLabel Label}'. + * + * + * @return the meta object for the attribute 'Label'. + * @see org.eclipse.emf.cdo.security.User#getLabel() + * @see #getUser() + * @generated + */ + EAttribute getUser_Label(); + /** * Returns the meta object for the attribute '{@link org.eclipse.emf.cdo.security.User#getFirstName First Name}'. * @@ -1004,6 +1124,30 @@ public interface SecurityPackage extends EPackage */ EReference GROUP__INHERITING_GROUPS = eINSTANCE.getGroup_InheritingGroups(); + /** + * The meta object literal for the 'All Inheriting Groups' reference list feature. + * + * + * @generated + */ + EReference GROUP__ALL_INHERITING_GROUPS = eINSTANCE.getGroup_AllInheritingGroups(); + + /** + * The meta object literal for the 'All Inherited Groups' reference list feature. + * + * + * @generated + */ + EReference GROUP__ALL_INHERITED_GROUPS = eINSTANCE.getGroup_AllInheritedGroups(); + + /** + * The meta object literal for the 'All Roles' reference list feature. + * + * + * @generated + */ + EReference GROUP__ALL_ROLES = eINSTANCE.getGroup_AllRoles(); + /** * The meta object literal for the '{@link org.eclipse.emf.cdo.security.impl.UserImpl User}' class. * @@ -1022,6 +1166,30 @@ public interface SecurityPackage extends EPackage */ EReference USER__GROUPS = eINSTANCE.getUser_Groups(); + /** + * The meta object literal for the 'All Groups' reference list feature. + * + * + * @generated + */ + EReference USER__ALL_GROUPS = eINSTANCE.getUser_AllGroups(); + + /** + * The meta object literal for the 'All Roles' reference list feature. + * + * + * @generated + */ + EReference USER__ALL_ROLES = eINSTANCE.getUser_AllRoles(); + + /** + * The meta object literal for the 'Label' attribute feature. + * + * + * @generated + */ + EAttribute USER__LABEL = eINSTANCE.getUser_Label(); + /** * The meta object literal for the 'First Name' attribute feature. * diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/User.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/User.java index 5090f476d6..08e9a95182 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/User.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/User.java @@ -21,6 +21,9 @@ import org.eclipse.emf.common.util.EList; * The following features are supported: *
    *
  • {@link org.eclipse.emf.cdo.security.User#getGroups Groups}
  • + *
  • {@link org.eclipse.emf.cdo.security.User#getAllGroups All Groups}
  • + *
  • {@link org.eclipse.emf.cdo.security.User#getAllRoles All Roles}
  • + *
  • {@link org.eclipse.emf.cdo.security.User#getLabel Label}
  • *
  • {@link org.eclipse.emf.cdo.security.User#getFirstName First Name}
  • *
  • {@link org.eclipse.emf.cdo.security.User#getLastName Last Name}
  • *
  • {@link org.eclipse.emf.cdo.security.User#getEmail Email}
  • @@ -53,6 +56,53 @@ public interface User extends Assignee */ EList getGroups(); + /** + * Returns the value of the 'All Groups' reference list. + * The list contents are of type {@link org.eclipse.emf.cdo.security.Group}. + * + *

    + * 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 getAllGroups(); + + /** + * Returns the value of the 'All Roles' reference list. + * The list contents are of type {@link org.eclipse.emf.cdo.security.Role}. + * + *

    + * 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 getAllRoles(); + + /** + * Returns the value of the 'Label' attribute. + * + *

    + * 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 implements InternalEList, EStructuralFeature.Setting +{ + private SoftReference cache; + + protected CachedList() + { + } + + private InternalEList getList() + { + Object[] data = null; + if (cache != null) + { + data = cache.get(); + } + + if (data == null) + { + data = getData(); + cache = new SoftReference(data); + } + + InternalEObject owner = getOwner(); + EStructuralFeature feature = getFeature(); + return new EcoreEList.UnmodifiableEList.FastCompare(owner, feature, data.length, data); + } + + protected abstract InternalEObject getOwner(); + + protected abstract EStructuralFeature getFeature(); + + protected abstract Object[] getData(); + + public void move(int newPosition, E object) + { + getList().move(newPosition, object); + } + + public E move(int newPosition, int oldPosition) + { + return getList().move(newPosition, oldPosition); + } + + public E basicGet(int index) + { + return getList().basicGet(index); + } + + public List basicList() + { + return getList().basicList(); + } + + public Iterator basicIterator() + { + return getList().basicIterator(); + } + + public ListIterator basicListIterator() + { + return getList().basicListIterator(); + } + + public ListIterator basicListIterator(int index) + { + return getList().basicListIterator(index); + } + + public Object[] basicToArray() + { + return getList().basicToArray(); + } + + public T[] basicToArray(T[] array) + { + return getList().basicToArray(array); + } + + public int basicIndexOf(Object object) + { + return getList().basicIndexOf(object); + } + + public int basicLastIndexOf(Object object) + { + return getList().basicLastIndexOf(object); + } + + public boolean basicContains(Object object) + { + return getList().basicContains(object); + } + + public boolean basicContainsAll(Collection collection) + { + return getList().basicContainsAll(collection); + } + + public NotificationChain basicRemove(Object object, NotificationChain notifications) + { + return getList().basicRemove(object, notifications); + } + + public NotificationChain basicAdd(E object, NotificationChain notifications) + { + return getList().basicAdd(object, notifications); + } + + public void addUnique(E object) + { + getList().addUnique(object); + } + + public void addUnique(int index, E object) + { + getList().addUnique(index, object); + } + + public boolean addAllUnique(Collection collection) + { + return getList().addAllUnique(collection); + } + + public boolean addAllUnique(int index, Collection collection) + { + return getList().addAllUnique(index, collection); + } + + public E setUnique(int index, E object) + { + return getList().setUnique(index, object); + } + + public int size() + { + return getList().size(); + } + + public boolean isEmpty() + { + return getList().isEmpty(); + } + + public boolean contains(Object o) + { + return getList().contains(o); + } + + public Iterator iterator() + { + return getList().iterator(); + } + + public Object[] toArray() + { + return getList().toArray(); + } + + public T[] toArray(T[] a) + { + return getList().toArray(a); + } + + public boolean add(E e) + { + return getList().add(e); + } + + public boolean remove(Object o) + { + return getList().remove(o); + } + + public boolean containsAll(Collection c) + { + return getList().containsAll(c); + } + + public boolean addAll(Collection c) + { + return getList().addAll(c); + } + + public boolean addAll(int index, Collection c) + { + return getList().addAll(index, c); + } + + public boolean removeAll(Collection c) + { + return getList().removeAll(c); + } + + public boolean retainAll(Collection c) + { + return getList().retainAll(c); + } + + public void clear() + { + getList().clear(); + } + + @Override + public boolean equals(Object o) + { + return getList().equals(o); + } + + @Override + public int hashCode() + { + return getList().hashCode(); + } + + public E get(int index) + { + return getList().get(index); + } + + public E set(int index, E element) + { + return getList().set(index, element); + } + + public void add(int index, E element) + { + getList().add(index, element); + } + + public E remove(int index) + { + return getList().remove(index); + } + + public int indexOf(Object o) + { + return getList().indexOf(o); + } + + public int lastIndexOf(Object o) + { + return getList().lastIndexOf(o); + } + + public ListIterator listIterator() + { + return getList().listIterator(); + } + + public ListIterator listIterator(int index) + { + return getList().listIterator(index); + } + + public List subList(int fromIndex, int toIndex) + { + return getList().subList(fromIndex, toIndex); + } + + public EObject getEObject() + { + return getOwner(); + } + + public EStructuralFeature getEStructuralFeature() + { + return getFeature(); + } + + public Object get(boolean resolve) + { + return getList(); + } + + public void set(Object newValue) + { + throw new UnsupportedOperationException(); + } + + public boolean isSet() + { + return !getList().isEmpty(); + } + + public void unset() + { + throw new UnsupportedOperationException(); + } + + /** + * @author Eike Stepper + */ + static abstract class RecursionSafe extends CachedList + { + protected RecursionSafe() + { + } + + @Override + protected Object[] getData() + { + @SuppressWarnings("unchecked") + O start = (O)getOwner(); + + Set visited = new HashSet(); + Set result = new HashSet(); + + getData(start, visited, result); + return result.toArray(); + } + + protected abstract void getData(O object, Set visited, Set result); + } +} diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/GroupImpl.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/GroupImpl.java index ca4a5b30ca..76c9259a40 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/GroupImpl.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/GroupImpl.java @@ -11,11 +11,16 @@ package org.eclipse.emf.cdo.security.impl; import org.eclipse.emf.cdo.security.Group; +import org.eclipse.emf.cdo.security.Role; import org.eclipse.emf.cdo.security.SecurityPackage; import org.eclipse.emf.cdo.security.User; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.InternalEObject; + +import java.util.Set; /** * @@ -25,7 +30,10 @@ import org.eclipse.emf.ecore.EClass; * The following features are implemented: *
      *
    • {@link org.eclipse.emf.cdo.security.impl.GroupImpl#getInheritedGroups Inherited Groups}
    • + *
    • {@link org.eclipse.emf.cdo.security.impl.GroupImpl#getAllInheritedGroups All Inherited Groups}
    • *
    • {@link org.eclipse.emf.cdo.security.impl.GroupImpl#getInheritingGroups Inheriting Groups}
    • + *
    • {@link org.eclipse.emf.cdo.security.impl.GroupImpl#getAllInheritingGroups All Inheriting Groups}
    • + *
    • {@link org.eclipse.emf.cdo.security.impl.GroupImpl#getAllRoles All Roles}
    • *
    • {@link org.eclipse.emf.cdo.security.impl.GroupImpl#getUsers Users}
    • *
    *

    @@ -34,6 +42,94 @@ import org.eclipse.emf.ecore.EClass; */ public class GroupImpl extends AssigneeImpl implements Group { + private EList allInheritedGroups = new CachedList.RecursionSafe() + { + @Override + protected InternalEObject getOwner() + { + return GroupImpl.this; + } + + @Override + protected EStructuralFeature getFeature() + { + return SecurityPackage.Literals.GROUP__ALL_INHERITED_GROUPS; + } + + @Override + protected void getData(Group group, Set visited, Set result) + { + if (visited.add(group)) + { + result.add(group); + + for (Group inheritedGroup : group.getInheritedGroups()) + { + getData(inheritedGroup, visited, result); + } + } + } + }; + + private EList allInheritingGroups = new CachedList.RecursionSafe() + { + @Override + protected InternalEObject getOwner() + { + return GroupImpl.this; + } + + @Override + protected EStructuralFeature getFeature() + { + return SecurityPackage.Literals.GROUP__ALL_INHERITING_GROUPS; + } + + @Override + protected void getData(Group group, Set visited, Set result) + { + if (visited.add(group)) + { + result.add(group); + + for (Group inheritingGroup : group.getInheritingGroups()) + { + getData(inheritingGroup, visited, result); + } + } + } + }; + + private EList allRoles = new CachedList.RecursionSafe() + { + @Override + protected InternalEObject getOwner() + { + return GroupImpl.this; + } + + @Override + protected EStructuralFeature getFeature() + { + return SecurityPackage.Literals.GROUP__ALL_ROLES; + } + + @Override + protected void getData(Group group, Set visited, Set result) + { + if (visited.add(group)) + { + EList roles = group.getRoles(); + result.addAll(roles); + + for (Group inheritedGroup : group.getInheritedGroups()) + { + getData(inheritedGroup, visited, result); + } + } + } + }; + /** * * @@ -88,4 +184,34 @@ public class GroupImpl extends AssigneeImpl implements Group return (EList)eGet(SecurityPackage.Literals.GROUP__INHERITING_GROUPS, true); } + /** + * + * + * @generated NOT + */ + public EList getAllInheritingGroups() + { + return allInheritingGroups; + } + + /** + * + * + * @generated NOT + */ + public EList getAllInheritedGroups() + { + return allInheritedGroups; + } + + /** + * + * + * @generated NOT + */ + public EList getAllRoles() + { + return allRoles; + } + } // GroupImpl diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/SecurityFactoryImpl.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/SecurityFactoryImpl.java index 3b0f840b83..e2eb2a9ad2 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/SecurityFactoryImpl.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/SecurityFactoryImpl.java @@ -10,6 +10,7 @@ */ package org.eclipse.emf.cdo.security.impl; +//import org.eclipse.emf.cdo.security.*; import org.eclipse.emf.cdo.security.Directory; import org.eclipse.emf.cdo.security.Group; import org.eclipse.emf.cdo.security.Realm; @@ -44,7 +45,7 @@ public class SecurityFactoryImpl extends EFactoryImpl implements SecurityFactory try { SecurityFactory theSecurityFactory = (SecurityFactory)EPackage.Registry.INSTANCE - .getEFactory("http://www.eclipse.org/emf/CDO/security/4.1.0"); //$NON-NLS-1$ + .getEFactory("http://www.eclipse.org/emf/CDO/security/4.1.0"); //$NON-NLS-1$ if (theSecurityFactory != null) { return theSecurityFactory; @@ -79,17 +80,17 @@ public class SecurityFactoryImpl extends EFactoryImpl implements SecurityFactory switch (eClass.getClassifierID()) { case SecurityPackage.REALM: - return createRealm(); + return (EObject)createRealm(); case SecurityPackage.DIRECTORY: - return createDirectory(); + return (EObject)createDirectory(); case SecurityPackage.ROLE: - return createRole(); + return (EObject)createRole(); case SecurityPackage.GROUP: - return createGroup(); + return (EObject)createGroup(); case SecurityPackage.USER: - return createUser(); + return (EObject)createUser(); case SecurityPackage.USER_PASSWORD: - return createUserPassword(); + return (EObject)createUserPassword(); default: throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$ } diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/SecurityPackageImpl.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/SecurityPackageImpl.java index f6c2e83ec0..e230d2da94 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/SecurityPackageImpl.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/SecurityPackageImpl.java @@ -130,7 +130,7 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage /** * Creates, registers, and initializes the Package for this model, and for any others upon which it depends. - * + * *

    This method is used to initialize {@link SecurityPackage#eINSTANCE} when that field is accessed. * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. * @@ -143,9 +143,7 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage public static SecurityPackage init() { if (isInited) - { return (SecurityPackage)EPackage.Registry.INSTANCE.getEPackage(SecurityPackage.eNS_URI); - } // Obtain or create and register package SecurityPackageImpl theSecurityPackage = (SecurityPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof SecurityPackageImpl ? EPackage.Registry.INSTANCE @@ -337,7 +335,7 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage */ public EReference getGroup_Users() { - return (EReference)groupEClass.getEStructuralFeatures().get(2); + return (EReference)groupEClass.getEStructuralFeatures().get(5); } /** @@ -356,10 +354,40 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage * @generated */ public EReference getGroup_InheritingGroups() + { + return (EReference)groupEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + public EReference getGroup_AllInheritingGroups() + { + return (EReference)groupEClass.getEStructuralFeatures().get(3); + } + + /** + * + * + * @generated + */ + public EReference getGroup_AllInheritedGroups() { return (EReference)groupEClass.getEStructuralFeatures().get(1); } + /** + * + * + * @generated + */ + public EReference getGroup_AllRoles() + { + return (EReference)groupEClass.getEStructuralFeatures().get(4); + } + /** * * @@ -380,6 +408,36 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage return (EReference)userEClass.getEStructuralFeatures().get(0); } + /** + * + * + * @generated + */ + public EReference getUser_AllGroups() + { + return (EReference)userEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EReference getUser_AllRoles() + { + return (EReference)userEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + public EAttribute getUser_Label() + { + return (EAttribute)userEClass.getEStructuralFeatures().get(3); + } + /** * * @@ -387,7 +445,7 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage */ public EAttribute getUser_FirstName() { - return (EAttribute)userEClass.getEStructuralFeatures().get(1); + return (EAttribute)userEClass.getEStructuralFeatures().get(4); } /** @@ -397,7 +455,7 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage */ public EAttribute getUser_LastName() { - return (EAttribute)userEClass.getEStructuralFeatures().get(2); + return (EAttribute)userEClass.getEStructuralFeatures().get(5); } /** @@ -407,7 +465,7 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage */ public EAttribute getUser_Email() { - return (EAttribute)userEClass.getEStructuralFeatures().get(3); + return (EAttribute)userEClass.getEStructuralFeatures().get(6); } /** @@ -417,7 +475,7 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage */ public EAttribute getUser_Locked() { - return (EAttribute)userEClass.getEStructuralFeatures().get(4); + return (EAttribute)userEClass.getEStructuralFeatures().get(7); } /** @@ -427,7 +485,7 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage */ public EReference getUser_Password() { - return (EReference)userEClass.getEStructuralFeatures().get(5); + return (EReference)userEClass.getEStructuralFeatures().get(8); } /** @@ -477,9 +535,7 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage public void createPackageContents() { if (isCreated) - { return; - } isCreated = true; // Create classes and their features @@ -506,11 +562,17 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage groupEClass = createEClass(GROUP); createEReference(groupEClass, GROUP__INHERITED_GROUPS); + createEReference(groupEClass, GROUP__ALL_INHERITED_GROUPS); createEReference(groupEClass, GROUP__INHERITING_GROUPS); + createEReference(groupEClass, GROUP__ALL_INHERITING_GROUPS); + createEReference(groupEClass, GROUP__ALL_ROLES); createEReference(groupEClass, GROUP__USERS); userEClass = createEClass(USER); createEReference(userEClass, USER__GROUPS); + createEReference(userEClass, USER__ALL_GROUPS); + createEReference(userEClass, USER__ALL_ROLES); + createEAttribute(userEClass, USER__LABEL); createEAttribute(userEClass, USER__FIRST_NAME); createEAttribute(userEClass, USER__LAST_NAME); createEAttribute(userEClass, USER__EMAIL); @@ -538,9 +600,7 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage public void initializePackageContents() { if (isInitialized) - { return; - } isInitialized = true; // Initialize package @@ -558,19 +618,19 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage // Add supertypes to classes securityElementEClass.getESuperTypes().add(theEtypesPackage.getModelElement()); - securityItemEClass.getESuperTypes().add(getSecurityElement()); - realmEClass.getESuperTypes().add(getSecurityElement()); - directoryEClass.getESuperTypes().add(getSecurityItem()); - roleEClass.getESuperTypes().add(getSecurityItem()); - assigneeEClass.getESuperTypes().add(getSecurityItem()); - groupEClass.getESuperTypes().add(getAssignee()); - userEClass.getESuperTypes().add(getAssignee()); + securityItemEClass.getESuperTypes().add(this.getSecurityElement()); + realmEClass.getESuperTypes().add(this.getSecurityElement()); + directoryEClass.getESuperTypes().add(this.getSecurityItem()); + roleEClass.getESuperTypes().add(this.getSecurityItem()); + assigneeEClass.getESuperTypes().add(this.getSecurityItem()); + groupEClass.getESuperTypes().add(this.getAssignee()); + userEClass.getESuperTypes().add(this.getAssignee()); // Initialize classes and features; add operations and parameters initEClass(securityElementEClass, SecurityElement.class, "SecurityElement", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ - addEOperation(securityElementEClass, getRealm(), "getRealm", 1, 1, IS_UNIQUE, IS_ORDERED); //$NON-NLS-1$ + addEOperation(securityElementEClass, this.getRealm(), "getRealm", 1, 1, IS_UNIQUE, IS_ORDERED); //$NON-NLS-1$ initEClass(securityItemEClass, SecurityItem.class, "SecurityItem", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ @@ -578,7 +638,7 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage initEClass(realmEClass, Realm.class, "Realm", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ initEReference( getRealm_Items(), - getSecurityItem(), + this.getSecurityItem(), null, "items", null, 0, -1, Realm.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEAttribute( @@ -589,7 +649,7 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage initEClass(directoryEClass, Directory.class, "Directory", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ initEReference( getDirectory_Items(), - getSecurityItem(), + this.getSecurityItem(), null, "items", null, 0, -1, Directory.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEAttribute( @@ -600,8 +660,8 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage initEClass(roleEClass, Role.class, "Role", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ initEReference( getRole_Assignees(), - getAssignee(), - getAssignee_Roles(), + this.getAssignee(), + this.getAssignee_Roles(), "assignees", null, 0, -1, Role.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEAttribute( getRole_Id(), @@ -615,8 +675,8 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage initEClass(assigneeEClass, Assignee.class, "Assignee", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ initEReference( getAssignee_Roles(), - getRole(), - getRole_Assignees(), + this.getRole(), + this.getRole_Assignees(), "roles", null, 0, -1, Assignee.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEAttribute( getAssignee_Id(), @@ -626,26 +686,55 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage initEClass(groupEClass, Group.class, "Group", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ initEReference( getGroup_InheritedGroups(), - getGroup(), - getGroup_InheritingGroups(), + this.getGroup(), + this.getGroup_InheritingGroups(), "inheritedGroups", null, 0, -1, Group.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ + initEReference( + getGroup_AllInheritedGroups(), + this.getGroup(), + null, + "allInheritedGroups", null, 0, -1, Group.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEReference( getGroup_InheritingGroups(), - getGroup(), - getGroup_InheritedGroups(), + this.getGroup(), + this.getGroup_InheritedGroups(), "inheritingGroups", null, 0, -1, Group.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ + initEReference( + getGroup_AllInheritingGroups(), + this.getGroup(), + null, + "allInheritingGroups", null, 0, -1, Group.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ + initEReference( + getGroup_AllRoles(), + this.getRole(), + null, + "allRoles", null, 0, -1, Group.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEReference( getGroup_Users(), - getUser(), - getUser_Groups(), + this.getUser(), + this.getUser_Groups(), "users", null, 0, -1, Group.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEClass(userEClass, User.class, "User", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ initEReference( getUser_Groups(), - getGroup(), - getGroup_Users(), + this.getGroup(), + this.getGroup_Users(), "groups", null, 0, -1, User.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ + initEReference( + getUser_AllGroups(), + this.getGroup(), + null, + "allGroups", null, 0, -1, User.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ + initEReference( + getUser_AllRoles(), + this.getRole(), + null, + "allRoles", null, 0, -1, User.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ + initEAttribute( + getUser_Label(), + theEcorePackage.getEString(), + "label", null, 0, 1, User.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEAttribute( getUser_FirstName(), theEcorePackage.getEString(), @@ -664,7 +753,7 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage "locked", null, 0, 1, User.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEReference( getUser_Password(), - getUserPassword(), + this.getUserPassword(), null, "password", null, 0, 1, User.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/UserImpl.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/UserImpl.java index bca8da5863..b89ea6527d 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/UserImpl.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/UserImpl.java @@ -11,12 +11,18 @@ package org.eclipse.emf.cdo.security.impl; import org.eclipse.emf.cdo.security.Group; +import org.eclipse.emf.cdo.security.Role; import org.eclipse.emf.cdo.security.SecurityPackage; import org.eclipse.emf.cdo.security.User; import org.eclipse.emf.cdo.security.UserPassword; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.InternalEObject; + +import java.util.HashSet; +import java.util.Set; /** * @@ -26,6 +32,9 @@ import org.eclipse.emf.ecore.EClass; * The following features are implemented: *

      *
    • {@link org.eclipse.emf.cdo.security.impl.UserImpl#getGroups Groups}
    • + *
    • {@link org.eclipse.emf.cdo.security.impl.UserImpl#getAllGroups All Groups}
    • + *
    • {@link org.eclipse.emf.cdo.security.impl.UserImpl#getAllRoles All Roles}
    • + *
    • {@link org.eclipse.emf.cdo.security.impl.UserImpl#getLabel Label}
    • *
    • {@link org.eclipse.emf.cdo.security.impl.UserImpl#getFirstName First Name}
    • *
    • {@link org.eclipse.emf.cdo.security.impl.UserImpl#getLastName Last Name}
    • *
    • {@link org.eclipse.emf.cdo.security.impl.UserImpl#getEmail Email}
    • @@ -38,6 +47,64 @@ import org.eclipse.emf.ecore.EClass; */ public class UserImpl extends AssigneeImpl implements User { + private EList allGroups = new CachedList() + { + @Override + protected InternalEObject getOwner() + { + return UserImpl.this; + } + + @Override + protected EStructuralFeature getFeature() + { + return SecurityPackage.Literals.USER__ALL_GROUPS; + } + + @Override + protected Object[] getData() + { + Set result = new HashSet(); + + for (Group group : getGroups()) + { + result.add(group); + result.addAll(group.getAllInheritedGroups()); + } + + return result.toArray(); + } + }; + + private EList allRoles = new CachedList() + { + @Override + protected InternalEObject getOwner() + { + return UserImpl.this; + } + + @Override + protected EStructuralFeature getFeature() + { + return SecurityPackage.Literals.USER__ALL_ROLES; + } + + @Override + protected Object[] getData() + { + Set result = new HashSet(); + result.addAll(getRoles()); + + for (Group group : getAllGroups()) + { + result.addAll(group.getAllRoles()); + } + + return result.toArray(); + } + }; + /** * * @@ -70,6 +137,36 @@ public class UserImpl extends AssigneeImpl implements User return (EList)eGet(SecurityPackage.Literals.USER__GROUPS, true); } + /** + * + * + * @generated NOT + */ + public EList getAllGroups() + { + return allGroups; + } + + /** + * + * + * @generated NOT + */ + public EList getAllRoles() + { + return allRoles; + } + + /** + * + * + * @generated + */ + public String getLabel() + { + return (String)eGet(SecurityPackage.Literals.USER__LABEL, true); + } + /** * * diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/util/SecurityAdapterFactory.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/util/SecurityAdapterFactory.java index 33737ed051..35cfea28c1 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/util/SecurityAdapterFactory.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/util/SecurityAdapterFactory.java @@ -27,6 +27,8 @@ import org.eclipse.emf.common.notify.Notifier; import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; import org.eclipse.emf.ecore.EObject; +//import org.eclipse.emf.cdo.security.*; + /** * * The Adapter Factory for the model. diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/util/SecuritySwitch.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/util/SecuritySwitch.java index 0ffc6fb0d9..02ca779e9e 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/util/SecuritySwitch.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/util/SecuritySwitch.java @@ -27,6 +27,8 @@ import org.eclipse.emf.ecore.EObject; import java.util.List; +//import org.eclipse.emf.cdo.security.*; + /** * * The Switch for the model's inheritance hierarchy. @@ -112,13 +114,9 @@ public class SecuritySwitch SecurityElement securityElement = (SecurityElement)theEObject; T result = caseSecurityElement(securityElement); if (result == null) - { result = caseModelElement(securityElement); - } if (result == null) - { result = defaultCase(theEObject); - } return result; } case SecurityPackage.SECURITY_ITEM: @@ -126,17 +124,11 @@ public class SecuritySwitch SecurityItem securityItem = (SecurityItem)theEObject; T result = caseSecurityItem(securityItem); if (result == null) - { result = caseSecurityElement(securityItem); - } if (result == null) - { result = caseModelElement(securityItem); - } if (result == null) - { result = defaultCase(theEObject); - } return result; } case SecurityPackage.REALM: @@ -144,17 +136,11 @@ public class SecuritySwitch Realm realm = (Realm)theEObject; T result = caseRealm(realm); if (result == null) - { result = caseSecurityElement(realm); - } if (result == null) - { result = caseModelElement(realm); - } if (result == null) - { result = defaultCase(theEObject); - } return result; } case SecurityPackage.DIRECTORY: @@ -162,21 +148,13 @@ public class SecuritySwitch Directory directory = (Directory)theEObject; T result = caseDirectory(directory); if (result == null) - { result = caseSecurityItem(directory); - } if (result == null) - { result = caseSecurityElement(directory); - } if (result == null) - { result = caseModelElement(directory); - } if (result == null) - { result = defaultCase(theEObject); - } return result; } case SecurityPackage.ROLE: @@ -184,21 +162,13 @@ public class SecuritySwitch Role role = (Role)theEObject; T result = caseRole(role); if (result == null) - { result = caseSecurityItem(role); - } if (result == null) - { result = caseSecurityElement(role); - } if (result == null) - { result = caseModelElement(role); - } if (result == null) - { result = defaultCase(theEObject); - } return result; } case SecurityPackage.ASSIGNEE: @@ -206,21 +176,13 @@ public class SecuritySwitch Assignee assignee = (Assignee)theEObject; T result = caseAssignee(assignee); if (result == null) - { result = caseSecurityItem(assignee); - } if (result == null) - { result = caseSecurityElement(assignee); - } if (result == null) - { result = caseModelElement(assignee); - } if (result == null) - { result = defaultCase(theEObject); - } return result; } case SecurityPackage.GROUP: @@ -228,25 +190,15 @@ public class SecuritySwitch Group group = (Group)theEObject; T result = caseGroup(group); if (result == null) - { result = caseAssignee(group); - } if (result == null) - { result = caseSecurityItem(group); - } if (result == null) - { result = caseSecurityElement(group); - } if (result == null) - { result = caseModelElement(group); - } if (result == null) - { result = defaultCase(theEObject); - } return result; } case SecurityPackage.USER: @@ -254,25 +206,15 @@ public class SecuritySwitch User user = (User)theEObject; T result = caseUser(user); if (result == null) - { result = caseAssignee(user); - } if (result == null) - { result = caseSecurityItem(user); - } if (result == null) - { result = caseSecurityElement(user); - } if (result == null) - { result = caseModelElement(user); - } if (result == null) - { result = defaultCase(theEObject); - } return result; } case SecurityPackage.USER_PASSWORD: @@ -280,9 +222,7 @@ public class SecuritySwitch UserPassword userPassword = (UserPassword)theEObject; T result = caseUserPassword(userPassword); if (result == null) - { result = defaultCase(theEObject); - } return result; } default: 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 16e04e8119..9794a28f9c 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 @@ -18,8 +18,10 @@ import org.eclipse.emf.cdo.eresource.CDOResource; import org.eclipse.emf.cdo.net4j.CDONet4jSession; import org.eclipse.emf.cdo.net4j.CDONet4jSessionConfiguration; import org.eclipse.emf.cdo.net4j.CDONet4jUtil; +import org.eclipse.emf.cdo.security.Group; import org.eclipse.emf.cdo.security.Realm; import org.eclipse.emf.cdo.security.RealmUtil; +import org.eclipse.emf.cdo.security.Role; import org.eclipse.emf.cdo.security.SecurityFactory; import org.eclipse.emf.cdo.security.SecurityItem; import org.eclipse.emf.cdo.security.User; @@ -151,6 +153,30 @@ public class SecurityManager implements ISecurityManager, IUserManager, IPermiss return realm; } + public Group getGroup(String groupID) + { + EList items = realm.getItems(); + Group group = RealmUtil.findGroup(items, groupID); + if (group == null) + { + throw new SecurityException("Group " + groupID + " not found"); + } + + return group; + } + + public Role getRole(String roleID) + { + EList items = realm.getItems(); + Role role = RealmUtil.findRole(items, roleID); + if (role == null) + { + throw new SecurityException("Role " + roleID + " not found"); + } + + return role; + } + public User getUser(String userID) { synchronized (users) diff --git a/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/security/ISecurityManager.java b/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/security/ISecurityManager.java index 250c8b0e69..afba2a5686 100644 --- a/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/security/ISecurityManager.java +++ b/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/security/ISecurityManager.java @@ -10,7 +10,9 @@ */ package org.eclipse.emf.cdo.server.security; +import org.eclipse.emf.cdo.security.Group; import org.eclipse.emf.cdo.security.Realm; +import org.eclipse.emf.cdo.security.Role; import org.eclipse.emf.cdo.security.User; import org.eclipse.emf.cdo.server.IRepository; @@ -24,7 +26,11 @@ public interface ISecurityManager { public Realm getRealm(); - public User getUser(String userID); + public User getUser(String userID) throws SecurityException; + + public Group getGroup(String groupID) throws SecurityException; + + public Role getRole(String roleID) throws SecurityException; public void modify(RealmOperation operation); -- cgit v1.2.3