diff options
author | Eike Stepper | 2012-08-08 06:57:56 +0000 |
---|---|---|
committer | Eike Stepper | 2012-08-08 06:57:56 +0000 |
commit | 9cd047c1c9fefe8030ca753afbf4824c028a7902 (patch) | |
tree | 9a175c802e7b6be759282b7672868c22cb733a21 | |
parent | 9ff04e5105cd3e098c0087dfabe646fefcb1d163 (diff) | |
download | cdo-9cd047c1c9fefe8030ca753afbf4824c028a7902.tar.gz cdo-9cd047c1c9fefe8030ca753afbf4824c028a7902.tar.xz cdo-9cd047c1c9fefe8030ca753afbf4824c028a7902.zip |
[384535] Develop Lucene-based IStore
https://bugs.eclipse.org/bugs/show_bug.cgi?id=384535
31 files changed, 1255 insertions, 155 deletions
diff --git a/plugins/org.eclipse.emf.cdo.security.edit/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.security.edit/META-INF/MANIFEST.MF index aae2f28701..67f74cd290 100644 --- a/plugins/org.eclipse.emf.cdo.security.edit/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.cdo.security.edit/META-INF/MANIFEST.MF @@ -2,13 +2,13 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.emf.cdo.security.edit;singleton:=true -Bundle-Version: 4.1.0.qualifier +Bundle-Version: 4.2.0.qualifier Bundle-ClassPath: . Bundle-Activator: org.eclipse.emf.cdo.security.provider.SecurityEditPlugin$Implementation Bundle-Vendor: %providerName Bundle-Localization: plugin Bundle-RequiredExecutionEnvironment: J2SE-1.5 -Export-Package: org.eclipse.emf.cdo.security.provider;version="4.1.0" +Export-Package: org.eclipse.emf.cdo.security.provider;version="4.2.0" Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)", org.eclipse.emf.cdo.security;bundle-version="[4.1.0,5.0.0)";visibility:=reexport, org.eclipse.emf.cdo.edit;bundle-version="[4.1.0,5.0.0)";visibility:=reexport diff --git a/plugins/org.eclipse.emf.cdo.security.edit/plugin.properties b/plugins/org.eclipse.emf.cdo.security.edit/plugin.properties index d1af9e7a5d..e93e757184 100644 --- a/plugins/org.eclipse.emf.cdo.security.edit/plugin.properties +++ b/plugins/org.eclipse.emf.cdo.security.edit/plugin.properties @@ -86,3 +86,7 @@ _UI_Permission_access_feature = Access _UI_ClassPermission_applicableClass_feature = Applicable Class _UI_PackagePermission_applicablePackage_feature = Applicable Package _UI_ResourcePermission_pattern_feature = Pattern +_UI_SecurityItemProvider_type = Item Provider +_UI_Realm_defaultUserDirectory_feature = Default User Directory +_UI_Realm_defaultGroupDirectory_feature = Default Group Directory +_UI_Realm_defaultRoleDirectory_feature = Default Role Directory diff --git a/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/RealmItemProvider.java b/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/RealmItemProvider.java index c13be5943c..4116f11c9a 100644 --- a/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/RealmItemProvider.java +++ b/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/RealmItemProvider.java @@ -72,6 +72,9 @@ public class RealmItemProvider extends SecurityElementItemProvider implements IE addAllPermissionsPropertyDescriptor(object); addNamePropertyDescriptor(object); addDefaultAccessPropertyDescriptor(object); + addDefaultUserDirectoryPropertyDescriptor(object); + addDefaultGroupDirectoryPropertyDescriptor(object); + addDefaultRoleDirectoryPropertyDescriptor(object); } return itemPropertyDescriptors; } @@ -126,6 +129,54 @@ public class RealmItemProvider extends SecurityElementItemProvider implements IE } /** + * This adds a property descriptor for the Default User Directory feature. + * <!-- begin-user-doc --> + * @since 4.2 + * <!-- end-user-doc --> + * @generated + */ + protected void addDefaultUserDirectoryPropertyDescriptor(Object object) + { + itemPropertyDescriptors.add(createItemPropertyDescriptor( + ((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(), + getString("_UI_Realm_defaultUserDirectory_feature"), //$NON-NLS-1$ + getString("_UI_PropertyDescriptor_description", "_UI_Realm_defaultUserDirectory_feature", "_UI_Realm_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + SecurityPackage.Literals.REALM__DEFAULT_USER_DIRECTORY, true, false, true, null, null, null)); + } + + /** + * This adds a property descriptor for the Default Group Directory feature. + * <!-- begin-user-doc --> + * @since 4.2 + * <!-- end-user-doc --> + * @generated + */ + protected void addDefaultGroupDirectoryPropertyDescriptor(Object object) + { + itemPropertyDescriptors.add(createItemPropertyDescriptor( + ((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(), + getString("_UI_Realm_defaultGroupDirectory_feature"), //$NON-NLS-1$ + getString("_UI_PropertyDescriptor_description", "_UI_Realm_defaultGroupDirectory_feature", "_UI_Realm_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + SecurityPackage.Literals.REALM__DEFAULT_GROUP_DIRECTORY, true, false, true, null, null, null)); + } + + /** + * This adds a property descriptor for the Default Role Directory feature. + * <!-- begin-user-doc --> + * @since 4.2 + * <!-- end-user-doc --> + * @generated + */ + protected void addDefaultRoleDirectoryPropertyDescriptor(Object object) + { + itemPropertyDescriptors.add(createItemPropertyDescriptor( + ((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(), + getString("_UI_Realm_defaultRoleDirectory_feature"), //$NON-NLS-1$ + getString("_UI_PropertyDescriptor_description", "_UI_Realm_defaultRoleDirectory_feature", "_UI_Realm_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + SecurityPackage.Literals.REALM__DEFAULT_ROLE_DIRECTORY, true, false, true, null, null, null)); + } + + /** * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. diff --git a/plugins/org.eclipse.emf.cdo.security/.settings/.api_filters b/plugins/org.eclipse.emf.cdo.security/.settings/.api_filters new file mode 100644 index 0000000000..2ffed666bf --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.security/.settings/.api_filters @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<component id="org.eclipse.emf.cdo.security" version="2"> + <resource path="src/org/eclipse/emf/cdo/security/impl/SecurityFactoryImpl.java" type="org.eclipse.emf.cdo.security.impl.SecurityFactoryImpl"> + <filter id="1143996420"> + <message_arguments> + <message_argument value="createClassPermission(EClass, Access)"/> + </message_arguments> + </filter> + <filter id="1143996420"> + <message_arguments> + <message_argument value="createDirectory(String)"/> + </message_arguments> + </filter> + <filter id="1143996420"> + <message_arguments> + <message_argument value="createGroup(String)"/> + </message_arguments> + </filter> + <filter id="1143996420"> + <message_arguments> + <message_argument value="createPackagePermission(EPackage, Access)"/> + </message_arguments> + </filter> + <filter id="1143996420"> + <message_arguments> + <message_argument value="createRealm(String)"/> + </message_arguments> + </filter> + <filter id="1143996420"> + <message_arguments> + <message_argument value="createRealm(String, Access)"/> + </message_arguments> + </filter> + <filter id="1143996420"> + <message_arguments> + <message_argument value="createResourcePermission(String, Access)"/> + </message_arguments> + </filter> + <filter id="1143996420"> + <message_arguments> + <message_argument value="createRole(String)"/> + </message_arguments> + </filter> + <filter id="1143996420"> + <message_arguments> + <message_argument value="createUser(String)"/> + </message_arguments> + </filter> + <filter id="1143996420"> + <message_arguments> + <message_argument value="createUser(String, String)"/> + </message_arguments> + </filter> + </resource> +</component> diff --git a/plugins/org.eclipse.emf.cdo.security/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.security/META-INF/MANIFEST.MF index a0024849f6..e8592dd52d 100644 --- a/plugins/org.eclipse.emf.cdo.security/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.cdo.security/META-INF/MANIFEST.MF @@ -2,14 +2,14 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.emf.cdo.security;singleton:=true -Bundle-Version: 4.1.0.qualifier +Bundle-Version: 4.2.0.qualifier Bundle-ClassPath: . Bundle-Vendor: %providerName Bundle-Localization: plugin Bundle-RequiredExecutionEnvironment: J2SE-1.5 -Export-Package: org.eclipse.emf.cdo.security;version="4.1.0", - org.eclipse.emf.cdo.security.impl;version="4.1.0", - org.eclipse.emf.cdo.security.util;version="4.1.0" +Export-Package: org.eclipse.emf.cdo.security;version="4.2.0", + org.eclipse.emf.cdo.security.impl;version="4.2.0", + org.eclipse.emf.cdo.security.util;version="4.2.0" Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)", org.eclipse.emf.cdo;bundle-version="[4.1.0,5.0.0)";visibility:=reexport Bundle-ActivationPolicy: lazy diff --git a/plugins/org.eclipse.emf.cdo.security/model/security.ecore b/plugins/org.eclipse.emf.cdo.security/model/security.ecore index a733028ff1..5ac20dc9dd 100644 --- a/plugins/org.eclipse.emf.cdo.security/model/security.ecore +++ b/plugins/org.eclipse.emf.cdo.security/model/security.ecore @@ -20,6 +20,10 @@ derived="true"/> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/> <eStructuralFeatures xsi:type="ecore:EAttribute" name="defaultAccess" eType="#//AccessObject"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="defaultUserDirectory" eType="#//Directory"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="defaultGroupDirectory" + eType="#//Directory"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="defaultRoleDirectory" eType="#//Directory"/> </eClassifiers> <eClassifiers xsi:type="ecore:EClass" name="Directory" eSuperTypes="#//SecurityItem"> <eStructuralFeatures xsi:type="ecore:EReference" name="items" upperBound="-1" diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/Assignee.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/Assignee.java index 8b63da2de1..bbe93250f5 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/Assignee.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/Assignee.java @@ -15,6 +15,8 @@ import org.eclipse.emf.common.util.EList; /** * <!-- begin-user-doc --> * A representation of the model object '<em><b>Assignee</b></em>'. + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. * <!-- end-user-doc --> * * <p> diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/Directory.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/Directory.java index cad5a7dbf5..1c668e4def 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/Directory.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/Directory.java @@ -15,6 +15,9 @@ import org.eclipse.emf.common.util.EList; /** * <!-- begin-user-doc --> * A representation of the model object '<em><b>Container</b></em>'. + * @extends SecurityItemContainer + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. * <!-- end-user-doc --> * * <p> @@ -29,7 +32,7 @@ import org.eclipse.emf.common.util.EList; * @model * @generated */ -public interface Directory extends SecurityItem +public interface Directory extends SecurityItem, SecurityItemContainer { /** * Returns the value of the '<em><b>Items</b></em>' containment reference list. 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 10edc7abcd..73e07e6f02 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 @@ -15,6 +15,8 @@ import org.eclipse.emf.common.util.EList; /** * <!-- begin-user-doc --> * A representation of the model object '<em><b>Group</b></em>'. + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. * <!-- end-user-doc --> * * <p> diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/Realm.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/Realm.java index 944ed878e6..27e6e452c8 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/Realm.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/Realm.java @@ -15,6 +15,9 @@ import org.eclipse.emf.common.util.EList; /** * <!-- begin-user-doc --> * A representation of the model object '<em><b>Realm</b></em>'. + * @extends SecurityItemContainer + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. * <!-- end-user-doc --> * * <p> @@ -27,6 +30,9 @@ import org.eclipse.emf.common.util.EList; * <li>{@link org.eclipse.emf.cdo.security.Realm#getAllPermissions <em>All Permissions</em>}</li> * <li>{@link org.eclipse.emf.cdo.security.Realm#getName <em>Name</em>}</li> * <li>{@link org.eclipse.emf.cdo.security.Realm#getDefaultAccess <em>Default Access</em>}</li> + * <li>{@link org.eclipse.emf.cdo.security.Realm#getDefaultUserDirectory <em>Default User Directory</em>}</li> + * <li>{@link org.eclipse.emf.cdo.security.Realm#getDefaultGroupDirectory <em>Default Group Directory</em>}</li> + * <li>{@link org.eclipse.emf.cdo.security.Realm#getDefaultRoleDirectory <em>Default Role Directory</em>}</li> * </ul> * </p> * @@ -34,7 +40,7 @@ import org.eclipse.emf.common.util.EList; * @model * @generated */ -public interface Realm extends SecurityElement +public interface Realm extends SecurityElement, SecurityItemContainer { /** * Returns the value of the '<em><b>Items</b></em>' containment reference list. @@ -168,4 +174,88 @@ public interface Realm extends SecurityElement */ void setDefaultAccess(Access value); + /** + * Returns the value of the '<em><b>Default User Directory</b></em>' reference. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Default User Directory</em>' reference isn't clear, + * there really should be more of a description here... + * </p> + * @since 4.2 + * <!-- end-user-doc --> + * @return the value of the '<em>Default User Directory</em>' reference. + * @see #setDefaultUserDirectory(Directory) + * @see org.eclipse.emf.cdo.security.SecurityPackage#getRealm_DefaultUserDirectory() + * @model + * @generated + */ + Directory getDefaultUserDirectory(); + + /** + * Sets the value of the '{@link org.eclipse.emf.cdo.security.Realm#getDefaultUserDirectory <em>Default User Directory</em>}' reference. + * <!-- begin-user-doc --> + * @since 4.2 + * <!-- end-user-doc --> + * @param value the new value of the '<em>Default User Directory</em>' reference. + * @see #getDefaultUserDirectory() + * @generated + */ + void setDefaultUserDirectory(Directory value); + + /** + * Returns the value of the '<em><b>Default Group Directory</b></em>' reference. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Default Group Directory</em>' reference isn't clear, + * there really should be more of a description here... + * </p> + * @since 4.2 + * <!-- end-user-doc --> + * @return the value of the '<em>Default Group Directory</em>' reference. + * @see #setDefaultGroupDirectory(Directory) + * @see org.eclipse.emf.cdo.security.SecurityPackage#getRealm_DefaultGroupDirectory() + * @model + * @generated + */ + Directory getDefaultGroupDirectory(); + + /** + * Sets the value of the '{@link org.eclipse.emf.cdo.security.Realm#getDefaultGroupDirectory <em>Default Group Directory</em>}' reference. + * <!-- begin-user-doc --> + * @since 4.2 + * <!-- end-user-doc --> + * @param value the new value of the '<em>Default Group Directory</em>' reference. + * @see #getDefaultGroupDirectory() + * @generated + */ + void setDefaultGroupDirectory(Directory value); + + /** + * Returns the value of the '<em><b>Default Role Directory</b></em>' reference. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Default Role Directory</em>' reference isn't clear, + * there really should be more of a description here... + * </p> + * @since 4.2 + * <!-- end-user-doc --> + * @return the value of the '<em>Default Role Directory</em>' reference. + * @see #setDefaultRoleDirectory(Directory) + * @see org.eclipse.emf.cdo.security.SecurityPackage#getRealm_DefaultRoleDirectory() + * @model + * @generated + */ + Directory getDefaultRoleDirectory(); + + /** + * Sets the value of the '{@link org.eclipse.emf.cdo.security.Realm#getDefaultRoleDirectory <em>Default Role Directory</em>}' reference. + * <!-- begin-user-doc --> + * @since 4.2 + * <!-- end-user-doc --> + * @param value the new value of the '<em>Default Role Directory</em>' reference. + * @see #getDefaultRoleDirectory() + * @generated + */ + void setDefaultRoleDirectory(Directory value); + } // SecurityRealm diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/RealmUtil.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/RealmUtil.java index 5acea1e63e..53cf067811 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/RealmUtil.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/RealmUtil.java @@ -15,6 +15,8 @@ import org.eclipse.net4j.util.ObjectUtil; import org.eclipse.emf.common.util.BasicEList; import org.eclipse.emf.common.util.EList; +import java.util.Iterator; + /** * Various static helper methods for dealing with {@link Realm realms}. * @@ -104,6 +106,99 @@ public final class RealmUtil return null; } + /** + * @since 4.2 + */ + public static User removeUser(EList<SecurityItem> items, String userID) + { + for (Iterator<SecurityItem> it = items.iterator(); it.hasNext();) + { + SecurityItem item = it.next(); + if (item instanceof User) + { + User user = (User)item; + if (ObjectUtil.equals(user.getId(), userID)) + { + it.remove(); + return user; + } + } + else if (item instanceof Directory) + { + Directory directory = (Directory)item; + User user = removeUser(directory.getItems(), userID); + if (user != null) + { + return user; + } + } + } + + return null; + } + + /** + * @since 4.2 + */ + public static Group removeGroup(EList<SecurityItem> items, String groupID) + { + for (Iterator<SecurityItem> it = items.iterator(); it.hasNext();) + { + SecurityItem item = it.next(); + if (item instanceof Group) + { + Group group = (Group)item; + if (ObjectUtil.equals(group.getId(), groupID)) + { + it.remove(); + return group; + } + } + else if (item instanceof Directory) + { + Directory directory = (Directory)item; + Group group = removeGroup(directory.getItems(), groupID); + if (group != null) + { + return group; + } + } + } + + return null; + } + + /** + * @since 4.2 + */ + public static Role removeRole(EList<SecurityItem> items, String roleID) + { + for (Iterator<SecurityItem> it = items.iterator(); it.hasNext();) + { + SecurityItem item = it.next(); + if (item instanceof Role) + { + Role role = (Role)item; + if (ObjectUtil.equals(role.getId(), roleID)) + { + it.remove(); + return role; + } + } + else if (item instanceof Directory) + { + Directory directory = (Directory)item; + Role role = removeRole(directory.getItems(), roleID); + if (role != null) + { + return role; + } + } + } + + return null; + } + public static BasicEList<User> allUsers(EList<SecurityItem> items) { BasicEList<User> result = new BasicEList<User>(); diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/Role.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/Role.java index 80ac1a4edd..07fd6e0d9f 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/Role.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/Role.java @@ -15,6 +15,8 @@ import org.eclipse.emf.common.util.EList; /** * <!-- begin-user-doc --> * A representation of the model object '<em><b>Role</b></em>'. + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. * <!-- end-user-doc --> * * <p> diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityElement.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityElement.java index 770a05179d..eea24edbdc 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityElement.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityElement.java @@ -15,6 +15,8 @@ import org.eclipse.emf.cdo.etypes.ModelElement; /** * <!-- begin-user-doc --> * A representation of the model object '<em><b>Element</b></em>'. + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. * <!-- end-user-doc --> * * diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityFactory.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityFactory.java index 7f7670cc58..2118d15119 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityFactory.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityFactory.java @@ -10,12 +10,16 @@ */ package org.eclipse.emf.cdo.security; +import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EFactory; +import org.eclipse.emf.ecore.EPackage; /** * <!-- begin-user-doc --> * The <b>Factory</b> for the model. * It provides a create method for each non-abstract class of the model. + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. * <!-- end-user-doc --> * @see org.eclipse.emf.cdo.security.SecurityPackage * @generated @@ -40,6 +44,16 @@ public interface SecurityFactory extends EFactory Realm createRealm(); /** + * @since 4.2 + */ + Realm createRealm(String name); + + /** + * @since 4.2 + */ + Realm createRealm(String name, Access defaultAccess); + + /** * Returns a new object of class '<em>Directory</em>'. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -49,6 +63,11 @@ public interface SecurityFactory extends EFactory Directory createDirectory(); /** + * @since 4.2 + */ + Directory createDirectory(String name); + + /** * Returns a new object of class '<em>Role</em>'. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -58,6 +77,11 @@ public interface SecurityFactory extends EFactory Role createRole(); /** + * @since 4.2 + */ + Role createRole(String id); + + /** * Returns a new object of class '<em>Group</em>'. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -67,6 +91,11 @@ public interface SecurityFactory extends EFactory Group createGroup(); /** + * @since 4.2 + */ + Group createGroup(String id); + + /** * Returns a new object of class '<em>User</em>'. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -76,6 +105,16 @@ public interface SecurityFactory extends EFactory User createUser(); /** + * @since 4.2 + */ + User createUser(String id); + + /** + * @since 4.2 + */ + User createUser(String id, String password); + + /** * Returns a new object of class '<em>User Password</em>'. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -94,6 +133,11 @@ public interface SecurityFactory extends EFactory ClassPermission createClassPermission(); /** + * @since 4.2 + */ + ClassPermission createClassPermission(EClass eClass, Access access); + + /** * Returns a new object of class '<em>Package Permission</em>'. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -103,6 +147,11 @@ public interface SecurityFactory extends EFactory PackagePermission createPackagePermission(); /** + * @since 4.2 + */ + PackagePermission createPackagePermission(EPackage ePackage, Access access); + + /** * Returns a new object of class '<em>Resource Permission</em>'. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -112,6 +161,11 @@ public interface SecurityFactory extends EFactory ResourcePermission createResourcePermission(); /** + * @since 4.2 + */ + ResourcePermission createResourcePermission(String pattern, Access access); + + /** * Returns the package supported by this factory. * <!-- begin-user-doc --> * <!-- end-user-doc --> diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityItem.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityItem.java index 9be64271d9..468207a159 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityItem.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityItem.java @@ -13,6 +13,8 @@ package org.eclipse.emf.cdo.security; /** * <!-- begin-user-doc --> * A representation of the model object '<em><b>Item</b></em>'. + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. * <!-- end-user-doc --> * * diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityItemContainer.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityItemContainer.java new file mode 100644 index 0000000000..73fb046369 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityItemContainer.java @@ -0,0 +1,32 @@ +/* + * 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; + +/** + * @author Eike Stepper + * @since 4.2 + */ +public interface SecurityItemContainer extends SecurityItemProvider +{ + public Role addRole(String id); + + public Group addGroup(String id); + + public User addUser(String id); + + public User addUser(String id, String password); + + public Role removeRole(String id); + + public Group removeGroup(String id); + + public User removeUser(String id); +} diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityItemProvider.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityItemProvider.java new file mode 100644 index 0000000000..35e8ea7393 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/SecurityItemProvider.java @@ -0,0 +1,24 @@ +/* + * 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; + +/** + * @author Eike Stepper + * @since 4.2 + */ +public interface SecurityItemProvider +{ + public Role getRole(String id); + + public Group getGroup(String id); + + public User getUser(String id); +} 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 25ec4e59ab..4a9338506e 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 @@ -29,6 +29,8 @@ import org.eclipse.emf.ecore.EReference; * <li>each enum,</li> * <li>and each data type</li> * </ul> + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. * <!-- end-user-doc --> * @see org.eclipse.emf.cdo.security.SecurityFactory * @model kind="package" @@ -217,13 +219,44 @@ public interface SecurityPackage extends EPackage int REALM__DEFAULT_ACCESS = SECURITY_ELEMENT_FEATURE_COUNT + 6; /** + * The feature id for the '<em><b>Default User Directory</b></em>' reference. + * <!-- begin-user-doc --> + * @since 4.2 + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int REALM__DEFAULT_USER_DIRECTORY = SECURITY_ELEMENT_FEATURE_COUNT + 7; + + /** + * The feature id for the '<em><b>Default Group Directory</b></em>' reference. + * <!-- begin-user-doc --> + * @since 4.2 + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int REALM__DEFAULT_GROUP_DIRECTORY = SECURITY_ELEMENT_FEATURE_COUNT + 8; + + /** + * The feature id for the '<em><b>Default Role Directory</b></em>' reference. + * <!-- begin-user-doc --> + * @since 4.2 + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int REALM__DEFAULT_ROLE_DIRECTORY = SECURITY_ELEMENT_FEATURE_COUNT + 9; + + /** * The number of structural features of the '<em>Realm</em>' class. * <!-- begin-user-doc --> + * @noreference This field is not intended to be referenced by clients. * <!-- end-user-doc --> * @generated * @ordered */ - int REALM_FEATURE_COUNT = SECURITY_ELEMENT_FEATURE_COUNT + 7; + int REALM_FEATURE_COUNT = SECURITY_ELEMENT_FEATURE_COUNT + 10; /** * The feature id for the '<em><b>Annotations</b></em>' containment reference list. @@ -831,6 +864,7 @@ public interface SecurityPackage extends EPackage /** * The meta object id for the '{@link org.eclipse.emf.cdo.security.Access <em>Access</em>}' enum. * <!-- begin-user-doc --> + * @noreference This field is not intended to be referenced by clients. * <!-- end-user-doc --> * @see org.eclipse.emf.cdo.security.Access * @see org.eclipse.emf.cdo.security.impl.SecurityPackageImpl#getAccess() @@ -841,6 +875,7 @@ public interface SecurityPackage extends EPackage /** * The meta object id for the '<em>Access Object</em>' data type. * <!-- begin-user-doc --> + * @noreference This field is not intended to be referenced by clients. * <!-- end-user-doc --> * @see org.eclipse.emf.cdo.security.Access * @see org.eclipse.emf.cdo.security.impl.SecurityPackageImpl#getAccessObject() @@ -946,6 +981,42 @@ public interface SecurityPackage extends EPackage EAttribute getRealm_DefaultAccess(); /** + * Returns the meta object for the reference '{@link org.eclipse.emf.cdo.security.Realm#getDefaultUserDirectory <em>Default User Directory</em>}'. + * <!-- begin-user-doc --> + * @since 4.2 + * <!-- end-user-doc --> + * @return the meta object for the reference '<em>Default User Directory</em>'. + * @see org.eclipse.emf.cdo.security.Realm#getDefaultUserDirectory() + * @see #getRealm() + * @generated + */ + EReference getRealm_DefaultUserDirectory(); + + /** + * Returns the meta object for the reference '{@link org.eclipse.emf.cdo.security.Realm#getDefaultGroupDirectory <em>Default Group Directory</em>}'. + * <!-- begin-user-doc --> + * @since 4.2 + * <!-- end-user-doc --> + * @return the meta object for the reference '<em>Default Group Directory</em>'. + * @see org.eclipse.emf.cdo.security.Realm#getDefaultGroupDirectory() + * @see #getRealm() + * @generated + */ + EReference getRealm_DefaultGroupDirectory(); + + /** + * Returns the meta object for the reference '{@link org.eclipse.emf.cdo.security.Realm#getDefaultRoleDirectory <em>Default Role Directory</em>}'. + * <!-- begin-user-doc --> + * @since 4.2 + * <!-- end-user-doc --> + * @return the meta object for the reference '<em>Default Role Directory</em>'. + * @see org.eclipse.emf.cdo.security.Realm#getDefaultRoleDirectory() + * @see #getRealm() + * @generated + */ + EReference getRealm_DefaultRoleDirectory(); + + /** * Returns the meta object for class '{@link org.eclipse.emf.cdo.security.Directory <em>Directory</em>}'. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -1447,6 +1518,8 @@ public interface SecurityPackage extends EPackage * <li>each enum,</li> * <li>and each data type</li> * </ul> + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. * <!-- end-user-doc --> * @generated */ @@ -1529,6 +1602,33 @@ public interface SecurityPackage extends EPackage EAttribute REALM__DEFAULT_ACCESS = eINSTANCE.getRealm_DefaultAccess(); /** + * The meta object literal for the '<em><b>Default User Directory</b></em>' reference feature. + * <!-- begin-user-doc --> + * @since 4.2 + * <!-- end-user-doc --> + * @generated + */ + EReference REALM__DEFAULT_USER_DIRECTORY = eINSTANCE.getRealm_DefaultUserDirectory(); + + /** + * The meta object literal for the '<em><b>Default Group Directory</b></em>' reference feature. + * <!-- begin-user-doc --> + * @since 4.2 + * <!-- end-user-doc --> + * @generated + */ + EReference REALM__DEFAULT_GROUP_DIRECTORY = eINSTANCE.getRealm_DefaultGroupDirectory(); + + /** + * The meta object literal for the '<em><b>Default Role Directory</b></em>' reference feature. + * <!-- begin-user-doc --> + * @since 4.2 + * <!-- end-user-doc --> + * @generated + */ + EReference REALM__DEFAULT_ROLE_DIRECTORY = eINSTANCE.getRealm_DefaultRoleDirectory(); + + /** * The meta object literal for the '{@link org.eclipse.emf.cdo.security.impl.DirectoryImpl <em>Directory</em>}' class. * <!-- begin-user-doc --> * <!-- end-user-doc --> 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 86762b41f6..5d1975eb97 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 @@ -15,6 +15,8 @@ import org.eclipse.emf.common.util.EList; /** * <!-- begin-user-doc --> * A representation of the model object '<em><b>User</b></em>'. + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. * <!-- end-user-doc --> * * <p> diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/UserPassword.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/UserPassword.java index 6ee2cc958f..0547f485fd 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/UserPassword.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/UserPassword.java @@ -15,6 +15,8 @@ import org.eclipse.emf.cdo.CDOObject; /** * <!-- begin-user-doc --> * A representation of the model object '<em><b>User Password</b></em>'. + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. * <!-- end-user-doc --> * * <p> diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/DirectoryImpl.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/DirectoryImpl.java index 0f3e9538cf..9642520991 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/DirectoryImpl.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/DirectoryImpl.java @@ -11,8 +11,13 @@ package org.eclipse.emf.cdo.security.impl; import org.eclipse.emf.cdo.security.Directory; +import org.eclipse.emf.cdo.security.Group; +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.SecurityPackage; +import org.eclipse.emf.cdo.security.User; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EClass; @@ -85,4 +90,92 @@ public class DirectoryImpl extends SecurityItemImpl implements Directory eSet(SecurityPackage.Literals.DIRECTORY__NAME, newName); } + /** + * @since 4.2 + */ + public Role getRole(String id) + { + return RealmUtil.findRole(getItems(), id); + } + + /** + * @since 4.2 + */ + public Group getGroup(String id) + { + return RealmUtil.findGroup(getItems(), id); + } + + /** + * @since 4.2 + */ + public User getUser(String id) + { + return RealmUtil.findUser(getItems(), id); + } + + /** + * @since 4.2 + */ + public Role addRole(String id) + { + Role role = SecurityFactory.eINSTANCE.createRole(id); + getItems().add(role); + return role; + } + + /** + * @since 4.2 + */ + public Group addGroup(String id) + { + Group group = SecurityFactory.eINSTANCE.createGroup(id); + getItems().add(group); + return group; + } + + /** + * @since 4.2 + */ + public User addUser(String id) + { + User user = SecurityFactory.eINSTANCE.createUser(id); + getItems().add(user); + return user; + } + + /** + * @since 4.2 + */ + public User addUser(String id, String password) + { + User user = SecurityFactory.eINSTANCE.createUser(id, password); + getItems().add(user); + return user; + } + + /** + * @since 4.2 + */ + public Role removeRole(String id) + { + return RealmUtil.removeRole(getItems(), id); + } + + /** + * @since 4.2 + */ + public Group removeGroup(String id) + { + return RealmUtil.removeGroup(getItems(), id); + } + + /** + * @since 4.2 + */ + public User removeUser(String id) + { + return RealmUtil.removeUser(getItems(), id); + } + } // ContainerImpl diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/PermissionImpl.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/PermissionImpl.java index 9e4e3c5124..a18dced868 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/PermissionImpl.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/PermissionImpl.java @@ -10,8 +10,8 @@ */ package org.eclipse.emf.cdo.security.impl; -import org.eclipse.emf.cdo.security.Permission; import org.eclipse.emf.cdo.security.Access; +import org.eclipse.emf.cdo.security.Permission; import org.eclipse.emf.cdo.security.Role; import org.eclipse.emf.cdo.security.SecurityPackage; diff --git a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/RealmImpl.java b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/RealmImpl.java index 4cc483d451..4aebd8608d 100644 --- a/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/RealmImpl.java +++ b/plugins/org.eclipse.emf.cdo.security/src/org/eclipse/emf/cdo/security/impl/RealmImpl.java @@ -11,11 +11,13 @@ package org.eclipse.emf.cdo.security.impl; import org.eclipse.emf.cdo.security.Access; +import org.eclipse.emf.cdo.security.Directory; import org.eclipse.emf.cdo.security.Group; import org.eclipse.emf.cdo.security.Permission; 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.SecurityPackage; import org.eclipse.emf.cdo.security.User; @@ -39,6 +41,9 @@ import org.eclipse.emf.ecore.InternalEObject; * <li>{@link org.eclipse.emf.cdo.security.impl.RealmImpl#getAllPermissions <em>All Permissions</em>}</li> * <li>{@link org.eclipse.emf.cdo.security.impl.RealmImpl#getName <em>Name</em>}</li> * <li>{@link org.eclipse.emf.cdo.security.impl.RealmImpl#getDefaultAccess <em>Default Access</em>}</li> + * <li>{@link org.eclipse.emf.cdo.security.impl.RealmImpl#getDefaultUserDirectory <em>Default User Directory</em>}</li> + * <li>{@link org.eclipse.emf.cdo.security.impl.RealmImpl#getDefaultGroupDirectory <em>Default Group Directory</em>}</li> + * <li>{@link org.eclipse.emf.cdo.security.impl.RealmImpl#getDefaultRoleDirectory <em>Default Role Directory</em>}</li> * </ul> * </p> * @@ -246,6 +251,232 @@ public class RealmImpl extends SecurityElementImpl implements Realm eSet(SecurityPackage.Literals.REALM__DEFAULT_ACCESS, newDefaultAccess); } + /** + * <!-- begin-user-doc --> + * @since 4.2 + * <!-- end-user-doc --> + * @generated + */ + public Directory getDefaultUserDirectory() + { + return (Directory)eGet(SecurityPackage.Literals.REALM__DEFAULT_USER_DIRECTORY, true); + } + + /** + * <!-- begin-user-doc --> + * @since 4.2 + * <!-- end-user-doc --> + * @generated + */ + public void setDefaultUserDirectory(Directory newDefaultUserDirectory) + { + eSet(SecurityPackage.Literals.REALM__DEFAULT_USER_DIRECTORY, newDefaultUserDirectory); + } + + /** + * <!-- begin-user-doc --> + * @since 4.2 + * <!-- end-user-doc --> + * @generated + */ + public Directory getDefaultGroupDirectory() + { + return (Directory)eGet(SecurityPackage.Literals.REALM__DEFAULT_GROUP_DIRECTORY, true); + } + + /** + * <!-- begin-user-doc --> + * @since 4.2 + * <!-- end-user-doc --> + * @generated + */ + public void setDefaultGroupDirectory(Directory newDefaultGroupDirectory) + { + eSet(SecurityPackage.Literals.REALM__DEFAULT_GROUP_DIRECTORY, newDefaultGroupDirectory); + } + + /** + * <!-- begin-user-doc --> + * @since 4.2 + * <!-- end-user-doc --> + * @generated + */ + public Directory getDefaultRoleDirectory() + { + return (Directory)eGet(SecurityPackage.Literals.REALM__DEFAULT_ROLE_DIRECTORY, true); + } + + /** + * <!-- begin-user-doc --> + * @since 4.2 + * <!-- end-user-doc --> + * @generated + */ + public void setDefaultRoleDirectory(Directory newDefaultRoleDirectory) + { + eSet(SecurityPackage.Literals.REALM__DEFAULT_ROLE_DIRECTORY, newDefaultRoleDirectory); + } + + /** + * @since 4.2 + */ + public Role getRole(String id) + { + return RealmUtil.findRole(getItems(), id); + } + + /** + * @since 4.2 + */ + public Group getGroup(String id) + { + return RealmUtil.findGroup(getItems(), id); + } + + /** + * @since 4.2 + */ + public User getUser(String id) + { + return RealmUtil.findUser(getItems(), id); + } + + /** + * @since 4.2 + */ + protected EList<SecurityItem> getRoleItems() + { + Directory directory = getDefaultRoleDirectory(); + return directory != null ? directory.getItems() : getItems(); + } + + /** + * @since 4.2 + */ + protected EList<SecurityItem> getGroupItems() + { + Directory directory = getDefaultGroupDirectory(); + return directory != null ? directory.getItems() : getItems(); + } + + /** + * @since 4.2 + */ + protected EList<SecurityItem> getUserItems() + { + Directory directory = getDefaultUserDirectory(); + return directory != null ? directory.getItems() : getItems(); + } + + /** + * @since 4.2 + */ + public Role addRole(String id) + { + Role role = SecurityFactory.eINSTANCE.createRole(id); + + EList<SecurityItem> items = getRoleItems(); + items.add(role); + return role; + } + + /** + * @since 4.2 + */ + public Group addGroup(String id) + { + Group group = SecurityFactory.eINSTANCE.createGroup(id); + + EList<SecurityItem> items = getGroupItems(); + items.add(group); + return group; + } + + /** + * @since 4.2 + */ + public User addUser(String id) + { + User user = SecurityFactory.eINSTANCE.createUser(id); + return addUser(user); + } + + /** + * @since 4.2 + */ + public User addUser(String id, String password) + { + User user = SecurityFactory.eINSTANCE.createUser(id, password); + return addUser(user); + } + + /** + * @since 4.2 + */ + protected User addUser(User user) + { + EList<SecurityItem> items = getUserItems(); + items.add(user); + return user; + } + + /** + * @since 4.2 + */ + public Role removeRole(String id) + { + EList<SecurityItem> items = getRoleItems(); + Role role = RealmUtil.removeRole(items, id); + if (role == null) + { + EList<SecurityItem> realmItems = getItems(); + if (items != realmItems) + { + role = RealmUtil.removeRole(realmItems, id); + } + } + + return role; + } + + /** + * @since 4.2 + */ + public Group removeGroup(String id) + { + EList<SecurityItem> items = getGroupItems(); + Group group = RealmUtil.removeGroup(items, id); + if (group == null) + { + EList<SecurityItem> realmItems = getItems(); + if (items != realmItems) + { + group = RealmUtil.removeGroup(realmItems, id); + } + } + + return group; + } + + /** + * @since 4.2 + */ + public User removeUser(String id) + { + EList<SecurityItem> items = getUserItems(); + User user = RealmUtil.removeUser(items, id); + if (user == null) + { + EList<SecurityItem> realmItems = getItems(); + if (items != realmItems) + { + user = RealmUtil.removeUser(realmItems, id); + } + } + + return user; + } + @Override public Realm getRealm() { 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 bbd8ce69c7..a53f1d1cb1 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 @@ -11,11 +11,11 @@ package org.eclipse.emf.cdo.security.impl; //import org.eclipse.emf.cdo.security.*; +import org.eclipse.emf.cdo.security.Access; import org.eclipse.emf.cdo.security.ClassPermission; import org.eclipse.emf.cdo.security.Directory; import org.eclipse.emf.cdo.security.Group; import org.eclipse.emf.cdo.security.PackagePermission; -import org.eclipse.emf.cdo.security.Access; import org.eclipse.emf.cdo.security.Realm; import org.eclipse.emf.cdo.security.ResourcePermission; import org.eclipse.emf.cdo.security.Role; @@ -156,6 +156,82 @@ public class SecurityFactoryImpl extends EFactoryImpl implements SecurityFactory return realm; } + public Realm createRealm(String name) + { + Realm realm = createRealm(); + realm.setName(name); + return realm; + } + + public Realm createRealm(String name, Access defaultAccess) + { + Realm realm = createRealm(name); + realm.setDefaultAccess(defaultAccess); + return realm; + } + + public Directory createDirectory(String name) + { + Directory directory = createDirectory(); + directory.setName(name); + return directory; + } + + public Role createRole(String id) + { + Role role = createRole(); + role.setId(id); + return role; + } + + public Group createGroup(String id) + { + Group group = createGroup(); + group.setId(id); + return group; + } + + public User createUser(String id) + { + User user = createUser(); + user.setId(id); + return user; + } + + public User createUser(String id, String password) + { + UserPassword userPassword = createUserPassword(); + userPassword.setEncrypted(password); + + User user = createUser(id); + user.setPassword(userPassword); + return user; + } + + public ClassPermission createClassPermission(EClass eClass, Access access) + { + ClassPermission permission = createClassPermission(); + permission.setApplicableClass(eClass); + permission.setAccess(access); + return permission; + } + + public PackagePermission createPackagePermission(EPackage ePackage, Access access) + { + PackagePermission permission = createPackagePermission(); + permission.setApplicablePackage(ePackage); + permission.setAccess(access); + return permission; + } + + public ResourcePermission createResourcePermission(String pattern, Access access) + { + ResourcePermission permission = createResourcePermission(); + permission.setPattern(pattern); + permission.setAccess(access); + return permission; + } + /** * <!-- begin-user-doc --> * <!-- end-user-doc --> 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 05069f4a69..0d87da97e2 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 @@ -11,13 +11,13 @@ package org.eclipse.emf.cdo.security.impl; import org.eclipse.emf.cdo.etypes.EtypesPackage; +import org.eclipse.emf.cdo.security.Access; import org.eclipse.emf.cdo.security.Assignee; -import org.eclipse.emf.cdo.security.Permission; import org.eclipse.emf.cdo.security.ClassPermission; import org.eclipse.emf.cdo.security.Directory; import org.eclipse.emf.cdo.security.Group; import org.eclipse.emf.cdo.security.PackagePermission; -import org.eclipse.emf.cdo.security.Access; +import org.eclipse.emf.cdo.security.Permission; import org.eclipse.emf.cdo.security.Realm; import org.eclipse.emf.cdo.security.ResourcePermission; import org.eclipse.emf.cdo.security.Role; @@ -179,7 +179,7 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage /** * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends. - * + * * <p>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. * <!-- begin-user-doc --> @@ -192,7 +192,9 @@ 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 @@ -309,6 +311,39 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage /** * <!-- begin-user-doc --> + * @since 4.2 + * <!-- end-user-doc --> + * @generated + */ + public EReference getRealm_DefaultUserDirectory() + { + return (EReference)realmEClass.getEStructuralFeatures().get(7); + } + + /** + * <!-- begin-user-doc --> + * @since 4.2 + * <!-- end-user-doc --> + * @generated + */ + public EReference getRealm_DefaultGroupDirectory() + { + return (EReference)realmEClass.getEStructuralFeatures().get(8); + } + + /** + * <!-- begin-user-doc --> + * @since 4.2 + * <!-- end-user-doc --> + * @generated + */ + public EReference getRealm_DefaultRoleDirectory() + { + return (EReference)realmEClass.getEStructuralFeatures().get(9); + } + + /** + * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @@ -784,7 +819,9 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage public void createPackageContents() { if (isCreated) + { return; + } isCreated = true; // Create classes and their features @@ -800,6 +837,9 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage createEReference(realmEClass, REALM__ALL_PERMISSIONS); createEAttribute(realmEClass, REALM__NAME); createEAttribute(realmEClass, REALM__DEFAULT_ACCESS); + createEReference(realmEClass, REALM__DEFAULT_USER_DIRECTORY); + createEReference(realmEClass, REALM__DEFAULT_GROUP_DIRECTORY); + createEReference(realmEClass, REALM__DEFAULT_ROLE_DIRECTORY); directoryEClass = createEClass(DIRECTORY); createEReference(directoryEClass, DIRECTORY__ITEMS); @@ -877,7 +917,9 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage public void initializePackageContents() { if (isInitialized) + { return; + } isInitialized = true; // Initialize package @@ -895,22 +937,22 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage // Add supertypes to classes securityElementEClass.getESuperTypes().add(theEtypesPackage.getModelElement()); - 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()); - classPermissionEClass.getESuperTypes().add(this.getPermission()); - packagePermissionEClass.getESuperTypes().add(this.getPermission()); - resourcePermissionEClass.getESuperTypes().add(this.getPermission()); + 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()); + classPermissionEClass.getESuperTypes().add(getPermission()); + packagePermissionEClass.getESuperTypes().add(getPermission()); + resourcePermissionEClass.getESuperTypes().add(getPermission()); // 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, this.getRealm(), "getRealm", 1, 1, IS_UNIQUE, IS_ORDERED); //$NON-NLS-1$ + addEOperation(securityElementEClass, 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$ @@ -918,27 +960,27 @@ 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(), - this.getSecurityItem(), + 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$ initEReference( getRealm_AllUsers(), - this.getUser(), + getUser(), null, "allUsers", 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$ initEReference( getRealm_AllGroups(), - this.getGroup(), + getGroup(), null, "allGroups", 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$ initEReference( getRealm_AllRoles(), - this.getRole(), + getRole(), null, "allRoles", 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$ initEReference( getRealm_AllPermissions(), - this.getPermission(), + getPermission(), null, "allPermissions", 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( @@ -947,13 +989,28 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage "name", null, 0, 1, Realm.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEAttribute( getRealm_DefaultAccess(), - this.getAccessObject(), + getAccessObject(), "defaultAccess", null, 0, 1, Realm.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ + initEReference( + getRealm_DefaultUserDirectory(), + getDirectory(), + null, + "defaultUserDirectory", 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$ + initEReference( + getRealm_DefaultGroupDirectory(), + getDirectory(), + null, + "defaultGroupDirectory", 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$ + initEReference( + getRealm_DefaultRoleDirectory(), + getDirectory(), + null, + "defaultRoleDirectory", 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$ initEClass(directoryEClass, Directory.class, "Directory", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ initEReference( getDirectory_Items(), - this.getSecurityItem(), + 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( @@ -968,13 +1025,13 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage "id", null, 0, 1, Role.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEReference( getRole_Permissions(), - this.getPermission(), - this.getPermission_Role(), + getPermission(), + getPermission_Role(), "permissions", 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$ initEReference( getRole_Assignees(), - this.getAssignee(), - this.getAssignee_Roles(), + getAssignee(), + 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$ initEClass(assigneeEClass, Assignee.class, "Assignee", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ @@ -984,47 +1041,47 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage "id", null, 0, 1, Assignee.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEReference( getAssignee_Roles(), - this.getRole(), - this.getRole_Assignees(), + getRole(), + 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$ initEClass(groupEClass, Group.class, "Group", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ initEReference( getGroup_Users(), - this.getUser(), - this.getUser_Groups(), + getUser(), + 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$ initEReference( getGroup_InheritedGroups(), - this.getGroup(), - this.getGroup_InheritingGroups(), + getGroup(), + 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_InheritingGroups(), - this.getGroup(), - this.getGroup_InheritedGroups(), + getGroup(), + 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_AllInheritedGroups(), - this.getGroup(), + 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_AllInheritingGroups(), - this.getGroup(), + 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(), + 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$ initEClass(userEClass, User.class, "User", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ initEReference( getUser_Groups(), - this.getGroup(), - this.getGroup_Users(), + getGroup(), + 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$ initEAttribute( getUser_Label(), @@ -1044,11 +1101,11 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage "email", 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_DefaultAccessOverride(), - this.getAccessObject(), + getAccessObject(), "defaultAccessOverride", 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_DefaultAccess(), - this.getAccessObject(), + getAccessObject(), "defaultAccess", 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_Locked(), @@ -1056,27 +1113,27 @@ 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(), - this.getUserPassword(), + 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$ initEReference( getUser_AllGroups(), - this.getGroup(), + 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(), + 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$ initEReference( getUser_AllPermissions(), - this.getPermission(), + getPermission(), null, "allPermissions", 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_UnassignedRoles(), - this.getRole(), + getRole(), null, "unassignedRoles", 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$ @@ -1091,12 +1148,12 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage "Permission", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); //$NON-NLS-1$ initEReference( getPermission_Role(), - this.getRole(), - this.getRole_Permissions(), + getRole(), + getRole_Permissions(), "role", null, 1, 1, Permission.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ initEAttribute( getPermission_Access(), - this.getAccess(), + getAccess(), "access", "WRITE", 1, 1, Permission.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); //$NON-NLS-1$ //$NON-NLS-2$ initEClass(classPermissionEClass, ClassPermission.class, @@ -1146,7 +1203,7 @@ public class SecurityPackageImpl extends EPackageImpl implements SecurityPackage */ protected void createExtendedMetaDataAnnotations() { - String source = "http:///org/eclipse/emf/ecore/util/ExtendedMetaData"; //$NON-NLS-1$ + String source = "http:///org/eclipse/emf/ecore/util/ExtendedMetaData"; //$NON-NLS-1$ addAnnotation(accessObjectEDataType, source, new String[] { "name", "Access:Object", //$NON-NLS-1$ //$NON-NLS-2$ "baseType", "Access" //$NON-NLS-1$ //$NON-NLS-2$ }); 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 616a8818d0..cc40afb786 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 @@ -12,11 +12,11 @@ package org.eclipse.emf.cdo.security.util; import org.eclipse.emf.cdo.etypes.ModelElement; import org.eclipse.emf.cdo.security.Assignee; -import org.eclipse.emf.cdo.security.Permission; import org.eclipse.emf.cdo.security.ClassPermission; import org.eclipse.emf.cdo.security.Directory; import org.eclipse.emf.cdo.security.Group; import org.eclipse.emf.cdo.security.PackagePermission; +import org.eclipse.emf.cdo.security.Permission; import org.eclipse.emf.cdo.security.Realm; import org.eclipse.emf.cdo.security.ResourcePermission; import org.eclipse.emf.cdo.security.Role; 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 a71cbbd811..bb490c8f7f 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 @@ -12,11 +12,11 @@ package org.eclipse.emf.cdo.security.util; import org.eclipse.emf.cdo.etypes.ModelElement; import org.eclipse.emf.cdo.security.Assignee; -import org.eclipse.emf.cdo.security.Permission; import org.eclipse.emf.cdo.security.ClassPermission; import org.eclipse.emf.cdo.security.Directory; import org.eclipse.emf.cdo.security.Group; import org.eclipse.emf.cdo.security.PackagePermission; +import org.eclipse.emf.cdo.security.Permission; import org.eclipse.emf.cdo.security.Realm; import org.eclipse.emf.cdo.security.ResourcePermission; import org.eclipse.emf.cdo.security.Role; 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 59faa5a9b9..4f15b1b5df 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.1.0.qualifier +Bundle-Version: 4.1.100.qualifier Bundle-ClassPath: . Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -12,15 +12,15 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.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.1.0"; +Export-Package: org.eclipse.emf.cdo.server.internal.security;version="4.1.100"; 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.1.0";x-internal:=true, - org.eclipse.emf.cdo.server.security;version="4.1.0", - org.eclipse.emf.cdo.server.spi.security;version="4.1.0" + org.eclipse.emf.cdo.server.internal.security.bundle;version="4.1.100";x-internal:=true, + org.eclipse.emf.cdo.server.security;version="4.1.100", + org.eclipse.emf.cdo.server.spi.security;version="4.1.100" 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 78d14a6582..8dd57ce4b8 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 @@ -11,6 +11,7 @@ package org.eclipse.emf.cdo.server.internal.security; import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.model.EMFUtil; import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.common.revision.CDORevisionProvider; import org.eclipse.emf.cdo.common.security.CDOPermission; @@ -23,13 +24,10 @@ import org.eclipse.emf.cdo.security.Access; import org.eclipse.emf.cdo.security.ClassPermission; import org.eclipse.emf.cdo.security.Directory; import org.eclipse.emf.cdo.security.Group; -import org.eclipse.emf.cdo.security.PackagePermission; import org.eclipse.emf.cdo.security.Permission; 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.SecurityPackage; import org.eclipse.emf.cdo.security.User; import org.eclipse.emf.cdo.security.UserPassword; @@ -61,9 +59,7 @@ import org.eclipse.net4j.util.om.monitor.OMMonitor; import org.eclipse.net4j.util.security.IUserManager; import org.eclipse.net4j.util.security.SecurityUtil; -import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EClassifier; import org.eclipse.emf.ecore.util.EcoreUtil; import java.util.ArrayList; @@ -81,7 +77,10 @@ public class SecurityManager extends Lifecycle implements InternalSecurityManage @Override protected void onActivated(ILifecycle lifecycle) { - init(); + if (isActive()) + { + init(); + } } @Override @@ -111,16 +110,12 @@ public class SecurityManager extends Lifecycle implements InternalSecurityManage private IConnector connector; + private CDONet4jSession session; + private CDOTransaction transaction; private Realm realm; - private EList<SecurityItem> newUsers; - - private EList<SecurityItem> newGroups; - - private EList<SecurityItem> newRoles; - public SecurityManager(String realmPath, IManagedContainer container) { this.realmPath = realmPath; @@ -145,7 +140,10 @@ public class SecurityManager extends Lifecycle implements InternalSecurityManage public void setRepository(InternalRepository repository) { this.repository = repository; - init(); + if (isActive()) + { + init(); + } } public Realm getRealm() @@ -153,41 +151,164 @@ public class SecurityManager extends Lifecycle implements InternalSecurityManage return realm; } - public User getUser(String userID) + public Role getRole(String id) + { + Role item = realm.getRole(id); + if (item == null) + { + throw new SecurityException("Role " + id + " not found"); + } + + return item; + } + + public Group getGroup(String id) + { + Group item = realm.getGroup(id); + if (item == null) + { + throw new SecurityException("Group " + id + " not found"); + } + + return item; + } + + public User getUser(String id) { synchronized (users) { - User user = users.get(userID); - if (user == null) + User item = users.get(id); + if (item == null) { - EList<SecurityItem> items = realm.getItems(); - user = RealmUtil.findUser(items, userID); - if (user == null) + item = realm.getUser(id); + if (item == null) { - throw new SecurityException("User " + userID + " not found"); + throw new SecurityException("User " + id + " not found"); } - users.put(userID, user); + users.put(id, item); } - return user; + return item; } } - public void modify(RealmOperation operation) + public Role addRole(final String id) { - synchronized (transaction) + final Role[] result = { null }; + modify(new RealmOperation() { - operation.execute(realm); + public void execute(Realm realm) + { + result[0] = realm.addRole(id); + } + }); - try + return result[0]; + } + + public Group addGroup(final String id) + { + final Group[] result = { null }; + modify(new RealmOperation() + { + public void execute(Realm realm) + { + result[0] = realm.addGroup(id); + } + }); + + return result[0]; + } + + public User addUser(final String id) + { + final User[] result = { null }; + modify(new RealmOperation() + { + public void execute(Realm realm) + { + result[0] = realm.addUser(id); + } + }); + + return result[0]; + } + + public User addUser(final String id, final String password) + { + final User[] result = { null }; + modify(new RealmOperation() + { + public void execute(Realm realm) + { + result[0] = realm.addUser(id); + } + }); + + return result[0]; + } + + public Role removeRole(final String id) + { + final Role[] result = { null }; + modify(new RealmOperation() + { + public void execute(Realm realm) + { + result[0] = realm.removeRole(id); + } + }); + + return result[0]; + } + + public Group removeGroup(final String id) + { + final Group[] result = { null }; + modify(new RealmOperation() + { + public void execute(Realm realm) { - transaction.commit(); + result[0] = realm.removeGroup(id); } - catch (CommitException ex) + }); + + return result[0]; + } + + public User removeUser(final String id) + { + final User[] result = { null }; + modify(new RealmOperation() + { + public void execute(Realm realm) { - throw WrappedException.wrap(ex); + result[0] = realm.removeUser(id); } + }); + + return result[0]; + } + + public void modify(RealmOperation operation) + { + checkActive(); + CDOTransaction transaction = session.openTransaction(); + + try + { + Realm transactionRealm = transaction.getObject(realm); + operation.execute(transactionRealm); + transaction.commit(); + } + catch (CommitException ex) + { + throw WrappedException.wrap(ex); + } + finally + { + transaction.close(); } } @@ -252,7 +373,7 @@ public class SecurityManager extends Lifecycle implements InternalSecurityManage protected void init() { - if (!isActive() || repository == null) + if (repository == null) { return; } @@ -273,7 +394,7 @@ public class SecurityManager extends Lifecycle implements InternalSecurityManage config.setConnector(connector); config.setRepositoryName(repositoryName); - CDONet4jSession session = config.openNet4jSession(); + session = config.openNet4jSession(); transaction = session.openTransaction(); boolean firstTime = !transaction.hasResource(realmPath); @@ -308,73 +429,61 @@ public class SecurityManager extends Lifecycle implements InternalSecurityManage protected Realm createRealm() { - Realm realm = SecurityFactory.eINSTANCE.createRealm(); - realm.setName("Security Realm"); + Realm realm = SecurityFactory.eINSTANCE.createRealm("Security Realm"); + realm.setDefaultRoleDirectory(addDirectory(realm, "Roles")); + realm.setDefaultGroupDirectory(addDirectory(realm, "Groups")); + realm.setDefaultUserDirectory(addDirectory(realm, "Users")); - // Create directories + // Create roles - Directory users = SecurityFactory.eINSTANCE.createDirectory(); - users.setName("Users"); - realm.getItems().add(users); - newUsers = users.getItems(); + Role allReaderRole = realm.addRole("All Objects Reader"); + allReaderRole.getPermissions().add(SecurityFactory.eINSTANCE.createResourcePermission(".*", Access.READ)); - Directory groups = SecurityFactory.eINSTANCE.createDirectory(); - groups.setName("Groups"); - realm.getItems().add(groups); - newGroups = groups.getItems(); + Role allWriterRole = realm.addRole("All Objects Writer"); + allWriterRole.getPermissions().add(SecurityFactory.eINSTANCE.createResourcePermission(".*", Access.WRITE)); - Directory roles = SecurityFactory.eINSTANCE.createDirectory(); - roles.setName("Roles"); - realm.getItems().add(roles); - newRoles = roles.getItems(); + Role treeReaderRole = realm.addRole("Resource Tree Reader"); + treeReaderRole.getPermissions().add( + SecurityFactory.eINSTANCE.createPackagePermission(EresourcePackage.eINSTANCE, Access.READ)); - // Create items + Role treeWriterRole = realm.addRole("Resource Tree Writer"); + treeWriterRole.getPermissions().add( + SecurityFactory.eINSTANCE.createPackagePermission(EresourcePackage.eINSTANCE, Access.WRITE)); - User admin = SecurityFactory.eINSTANCE.createUser(); - admin.setId("Administrator"); - newUsers.add(admin); - - UserPassword adminPassword = SecurityFactory.eINSTANCE.createUserPassword(); - adminPassword.setEncrypted("0000"); - admin.setPassword(adminPassword); - - Group admins = SecurityFactory.eINSTANCE.createGroup(); - admins.setId("Administrators"); - admins.getUsers().add(admin); - newGroups.add(admins); + Role adminRole = realm.addRole("Administration"); + for (EClass eClass : EMFUtil.getConcreteClasses(SecurityPackage.eINSTANCE)) + { + if (eClass != SecurityPackage.Literals.USER_PASSWORD) + { + ClassPermission permission = SecurityFactory.eINSTANCE.createClassPermission(eClass, Access.WRITE); + adminRole.getPermissions().add(permission); + } + } - // Create administration role + // Create groups - Role administration = SecurityFactory.eINSTANCE.createRole(); - administration.setId("Administration"); - administration.getAssignees().add(admins); - newRoles.add(administration); + Group adminsGroup = realm.addGroup("Administrators"); + adminsGroup.getRoles().add(treeReaderRole); + adminsGroup.getRoles().add(adminRole); - PackagePermission allResources = SecurityFactory.eINSTANCE.createPackagePermission(); - allResources.setAccess(Access.READ); - administration.getPermissions().add(allResources); - allResources.setApplicablePackage(EresourcePackage.eINSTANCE); + Group usersGroup = realm.addGroup("Users"); + usersGroup.getRoles().add(treeReaderRole); - for (EClassifier eClassifier : SecurityPackage.eINSTANCE.getEClassifiers()) - { - if (eClassifier instanceof EClass) - { - EClass eClass = (EClass)eClassifier; - if (eClass.isInterface() || eClass.isAbstract() || eClass == SecurityPackage.Literals.USER_PASSWORD) - { - continue; - } + // Create users - ClassPermission permission = SecurityFactory.eINSTANCE.createClassPermission(); - permission.setAccess(Access.WRITE); - administration.getPermissions().add(permission); - permission.setApplicableClass(eClass); - } - } + User adminUser = realm.addUser("Administrator", "0000"); + adminUser.getGroups().add(adminsGroup); return realm; } + protected Directory addDirectory(Realm realm, String name) + { + Directory directory = SecurityFactory.eINSTANCE.createDirectory(name); + realm.getItems().add(directory); + return directory; + } + protected CDOPermission convertPermission(Access permission) { if (permission != null) @@ -436,7 +545,8 @@ public class SecurityManager extends Lifecycle implements InternalSecurityManage users.clear(); realm = null; - transaction.getSession().close(); + session.close(); + session = null; transaction = null; connector.close(); @@ -534,6 +644,11 @@ public class SecurityManager extends Lifecycle implements InternalSecurityManage public void handleTransactionBeforeCommitting(ITransaction transaction, CommitContext commitContext, OMMonitor monitor) throws RuntimeException { + if (transaction.getSessionID() == session.getSessionID()) + { + return; // Access through ISecurityManager.modify(RealmOperation) + } + CDOBranchPoint securityContext = commitContext.getBranchPoint(); String userID = commitContext.getUserID(); User user = getUser(userID); 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 c449157171..53118d3c31 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 @@ -11,23 +11,23 @@ package org.eclipse.emf.cdo.server.security; import org.eclipse.emf.cdo.security.Realm; -import org.eclipse.emf.cdo.security.User; +import org.eclipse.emf.cdo.security.SecurityItemContainer; import org.eclipse.emf.cdo.server.IRepository; /** * Protects a given {@link IRepository repository}. * + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. * @see SecurityManagerUtil#createSecurityManager(String) * @author Eike Stepper */ -public interface ISecurityManager +public interface ISecurityManager extends SecurityItemContainer { public IRepository getRepository(); public Realm getRealm(); - public User getUser(String userID); - public void modify(RealmOperation operation); /** diff --git a/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/spi/security/InternalSecurityManager.java b/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/spi/security/InternalSecurityManager.java index b80ff5d8f0..05e8a0e582 100644 --- a/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/spi/security/InternalSecurityManager.java +++ b/plugins/org.eclipse.emf.cdo.server.security/src/org/eclipse/emf/cdo/server/spi/security/InternalSecurityManager.java @@ -19,6 +19,8 @@ import org.eclipse.net4j.util.container.IManagedContainer; /** * @author Eike Stepper + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. */ public interface InternalSecurityManager extends ISecurityManager { |