Revision 3692b5bf
Added by Andreas Kohlbecker about 10 years ago
.gitattributes | ||
---|---|---|
1266 | 1266 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/menu/TaxonRelationshipTypeMenuPreferences.java -text |
1267 | 1267 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/VocabularyTermWizard.java -text |
1268 | 1268 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/VocabularyTermWizardPage.java -text |
1269 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/security/PermissionPropertyTester.java -text |
|
1269 | 1270 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/security/RequiredPermissions.java -text |
1270 | 1271 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java -text |
1271 | 1272 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStoreConnector.java -text |
eu.etaxonomy.taxeditor.navigation/plugin.xml | ||
---|---|---|
84 | 84 |
id="eu.etaxonomy.navigation.menu.new" |
85 | 85 |
label="New"> |
86 | 86 |
<command |
87 |
commandId="eu.etaxonomy.taxeditor.navigation.newTaxonNode"
|
|
87 |
commandId="eu.etaxonomy.taxeditor.navigation.command.create.taxonNode"
|
|
88 | 88 |
label="Taxon" |
89 | 89 |
style="push"> |
90 | 90 |
</command> |
... | ... | |
93 | 93 |
visible="true"> |
94 | 94 |
</separator> |
95 | 95 |
<command |
96 |
commandId="eu.etaxonomy.taxeditor.navigation.newClassification"
|
|
97 |
id="eu.etaxonomy.taxeditor.navigation.newClassificationHandler"
|
|
96 |
commandId="eu.etaxonomy.taxeditor.navigation.create.classification"
|
|
97 |
id="eu.etaxonomy.taxeditor.navigation.create.classificationHandler"
|
|
98 | 98 |
label="Classification" |
99 | 99 |
style="push"> |
100 | 100 |
</command> |
... | ... | |
104 | 104 |
visible="true"> |
105 | 105 |
</separator> |
106 | 106 |
<command |
107 |
commandId="eu.etaxonomy.taxeditor.navigation.command.editSelection" |
|
107 |
commandId="eu.etaxonomy.taxeditor.navigation.command.update.editSelection"
|
|
108 | 108 |
label="Edit" |
109 | 109 |
style="push"> |
110 | 110 |
<visibleWhen |
... | ... | |
120 | 120 |
</visibleWhen> |
121 | 121 |
</command> |
122 | 122 |
<command |
123 |
commandId="eu.etaxonomy.taxeditor.navigator.command.changeAcceptedToSynonym" |
|
123 |
commandId="eu.etaxonomy.taxeditor.navigator.command.update.changeAcceptedToSynonym"
|
|
124 | 124 |
label="Change Accepted Taxon to Synonym" |
125 | 125 |
style="push"> |
126 | 126 |
<visibleWhen |
... | ... | |
131 | 131 |
</visibleWhen> |
132 | 132 |
</command> |
133 | 133 |
<command |
134 |
commandId="eu.etaxonomy.taxeditor.navigation.command.moveTaxon" |
|
134 |
commandId="eu.etaxonomy.taxeditor.navigation.command.update.moveTaxon"
|
|
135 | 135 |
label="Move Taxon (with child taxa)" |
136 | 136 |
style="push"> |
137 | 137 |
<visibleWhen |
138 | 138 |
checkEnabled="true"> |
139 |
<reference |
|
140 |
definitionId="isTaxonNode"> |
|
141 |
</reference> |
|
139 |
<reference
|
|
140 |
definitionId="isTaxonNode">
|
|
141 |
</reference>
|
|
142 | 142 |
</visibleWhen> |
143 | 143 |
</command> |
144 | 144 |
<separator |
... | ... | |
208 | 208 |
<menuContribution |
209 | 209 |
locationURI="menu:eu.etaxonomy.navigation.menu.new"> |
210 | 210 |
<command |
211 |
commandId="eu.etaxonomy.taxeditor.navigation.newTaxonNode"
|
|
211 |
commandId="eu.etaxonomy.taxeditor.navigation.command.create.taxonNode"
|
|
212 | 212 |
label="Taxon" |
213 | 213 |
style="push"> |
214 | 214 |
</command> |
... | ... | |
217 | 217 |
visible="true"> |
218 | 218 |
</separator> |
219 | 219 |
<command |
220 |
commandId="eu.etaxonomy.taxeditor.navigation.newClassification"
|
|
221 |
id="eu.etaxonomy.taxeditor.navigation.newClassificationHandler"
|
|
220 |
commandId="eu.etaxonomy.taxeditor.navigation.create.classification"
|
|
221 |
id="eu.etaxonomy.taxeditor.navigation.create.classificationHandler"
|
|
222 | 222 |
label="Classification" |
223 | 223 |
style="push"> |
224 | 224 |
</command> |
... | ... | |
264 | 264 |
point="org.eclipse.ui.commands"> |
265 | 265 |
<command |
266 | 266 |
defaultHandler="eu.etaxonomy.taxeditor.navigation.navigator.handler.NewTaxonNodeHandler" |
267 |
id="eu.etaxonomy.taxeditor.navigation.newTaxonNode"
|
|
267 |
id="eu.etaxonomy.taxeditor.navigation.command.create.taxonNode"
|
|
268 | 268 |
name="New Taxon Node"> |
269 | 269 |
</command> |
270 | 270 |
<command |
271 | 271 |
defaultHandler="eu.etaxonomy.taxeditor.navigation.navigator.handler.NewClassificationHandler" |
272 |
id="eu.etaxonomy.taxeditor.navigation.newClassification"
|
|
272 |
id="eu.etaxonomy.taxeditor.navigation.create.classification"
|
|
273 | 273 |
name="New Classification"> |
274 | 274 |
</command> |
275 | 275 |
</extension> |
... | ... | |
277 | 277 |
point="org.eclipse.ui.commands"> |
278 | 278 |
<command |
279 | 279 |
defaultHandler="eu.etaxonomy.taxeditor.navigation.navigator.handler.EditHandler" |
280 |
id="eu.etaxonomy.taxeditor.navigation.command.editSelection" |
|
280 |
id="eu.etaxonomy.taxeditor.navigation.command.update.editSelection"
|
|
281 | 281 |
name="Edit"> |
282 | 282 |
</command> |
283 | 283 |
<command |
284 | 284 |
defaultHandler="eu.etaxonomy.taxeditor.navigation.navigator.handler.MoveTaxonHandler" |
285 |
id="eu.etaxonomy.taxeditor.navigation.command.moveTaxon" |
|
285 |
id="eu.etaxonomy.taxeditor.navigation.command.update.moveTaxon"
|
|
286 | 286 |
name="Move Taxon"> |
287 | 287 |
</command> |
288 | 288 |
<command |
... | ... | |
297 | 297 |
</command> |
298 | 298 |
<command |
299 | 299 |
defaultHandler="eu.etaxonomy.taxeditor.navigation.navigator.handler.ChangeAcceptedTaxonToSynonymHandler" |
300 |
id="eu.etaxonomy.taxeditor.navigator.command.changeAcceptedToSynonym" |
|
300 |
id="eu.etaxonomy.taxeditor.navigator.command.update.changeAcceptedToSynonym"
|
|
301 | 301 |
name="Change Accepted Taxon to Synonym"> |
302 | 302 |
</command> |
303 | 303 |
</extension> |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/NavigationUtil.java | ||
---|---|---|
58 | 58 |
*/ |
59 | 59 |
public static void executeEditHandler(){ |
60 | 60 |
|
61 |
String commandId = "eu.etaxonomy.taxeditor.navigation.command.editSelection"; |
|
61 |
String commandId = "eu.etaxonomy.taxeditor.navigation.command.update.editSelection";
|
|
62 | 62 |
|
63 | 63 |
IHandlerService handlerService = (IHandlerService) AbstractUtility.getService(IHandlerService.class); |
64 | 64 |
try { |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/MoveTaxonHandler.java | ||
---|---|---|
104 | 104 |
public boolean onComplete() { |
105 | 105 |
return false; |
106 | 106 |
} |
107 |
|
|
107 | 108 |
} |
eu.etaxonomy.taxeditor.store/plugin.xml | ||
---|---|---|
894 | 894 |
properties="isModifiable" |
895 | 895 |
type="org.eclipse.jface.viewers.IStructuredSelection"> |
896 | 896 |
</propertyTester> |
897 |
<propertyTester |
|
898 |
class="eu.etaxonomy.taxeditor.security.PermissionPropertyTester" |
|
899 |
id="eu.etaxonomy.taxeditor.security.permissionTester" |
|
900 |
namespace="eu.etaxonomy.taxeditor.security.permissionTester" |
|
901 |
properties="hasPermissions, hasRoles" |
|
902 |
type="org.eclipse.jface.viewers.IStructuredSelection"> |
|
903 |
</propertyTester> |
|
897 | 904 |
</extension> |
898 | 905 |
<extension |
899 | 906 |
point="org.eclipse.core.expressions.definitions"> |
... | ... | |
924 | 931 |
</test> |
925 | 932 |
</with> |
926 | 933 |
</definition> |
934 |
<definition |
|
935 |
id="canUPDATE"> |
|
936 |
<with |
|
937 |
variable="selection"> |
|
938 |
<test |
|
939 |
args="UPDATE" |
|
940 |
property="eu.etaxonomy.taxeditor.security.permissionTester.hasPermissions"> |
|
941 |
</test> |
|
942 |
</with> |
|
943 |
</definition> |
|
944 |
<definition |
|
945 |
id="canDELETE"> |
|
946 |
<with |
|
947 |
variable="selection"> |
|
948 |
<test |
|
949 |
args="DELETE" |
|
950 |
property="eu.etaxonomy.taxeditor.security.permissionTester.hasPermissions"> |
|
951 |
</test> |
|
952 |
</with> |
|
953 |
</definition> |
|
954 |
<definition |
|
955 |
id="canCREATE"> |
|
956 |
<with |
|
957 |
variable="selection"> |
|
958 |
<test |
|
959 |
args="CREATE" |
|
960 |
property="eu.etaxonomy.taxeditor.security.permissionTester.hasPermissions"> |
|
961 |
</test> |
|
962 |
</with> |
|
963 |
</definition> |
|
964 |
<definition |
|
965 |
id="hasROLE_USER_MANAGER"> |
|
966 |
<test |
|
967 |
args="ROLE_USER_MANAGER" |
|
968 |
property="eu.etaxonomy.taxeditor.security.permissionTester.hasRole"> |
|
969 |
</test> |
|
970 |
</definition> |
|
971 |
</extension> |
|
972 |
<extension |
|
973 |
point="org.eclipse.ui.activities"> |
|
974 |
<activity |
|
975 |
description="DELETE permission dependent ui contributions" |
|
976 |
id="eu.etaxonomy.taxeditor.store.activityDelete" |
|
977 |
name="Delete"> |
|
978 |
<enabledWhen> |
|
979 |
<reference |
|
980 |
definitionId="canDELETE"> |
|
981 |
</reference> |
|
982 |
</enabledWhen> |
|
983 |
</activity> |
|
984 |
<activityPatternBinding |
|
985 |
activityId="eu.etaxonomy.taxeditor.store.activityDelete" |
|
986 |
pattern="eu\.etaxonomy\.taxeditor\..*/.*.delete"> |
|
987 |
</activityPatternBinding> |
|
988 |
<activity |
|
989 |
description="UPDATE permission dependent ui contributions" |
|
990 |
id="eu.etaxonomy.taxeditor.store.activityUpdate" |
|
991 |
name="Update"> |
|
992 |
<enabledWhen> |
|
993 |
<reference |
|
994 |
definitionId="canUPDATE"> |
|
995 |
</reference> |
|
996 |
</enabledWhen> |
|
997 |
</activity> |
|
998 |
<activityPatternBinding |
|
999 |
activityId="eu.etaxonomy.taxeditor.store.activityUpdate" |
|
1000 |
pattern="eu\.etaxonomy\.taxeditor\..*/.*.command\.update\..*"> |
|
1001 |
</activityPatternBinding> |
|
1002 |
<activity |
|
1003 |
description="CREATE permission dependent ui contributions" |
|
1004 |
id="eu.etaxonomy.taxeditor.store.activityCreate" |
|
1005 |
name="Delete"> |
|
1006 |
<enabledWhen> |
|
1007 |
<reference |
|
1008 |
definitionId="canDELETE"> |
|
1009 |
</reference> |
|
1010 |
</enabledWhen> |
|
1011 |
</activity> |
|
1012 |
<activityPatternBinding |
|
1013 |
activityId="eu.etaxonomy.taxeditor.store.activityCreate" |
|
1014 |
pattern="eu\.etaxonomy\.taxeditor\..*/.*.command\.create\..*"> |
|
1015 |
</activityPatternBinding> |
|
1016 |
<activity |
|
1017 |
description="ROLE_USER_MANAGER dependent ui contributions" |
|
1018 |
id="eu.etaxonomy.taxeditor.store.activityUserManagement" |
|
1019 |
name="UserManagement"> |
|
1020 |
<enabledWhen> |
|
1021 |
<reference |
|
1022 |
definitionId="hasROLE_USER_MANAGER"> |
|
1023 |
</reference> |
|
1024 |
</enabledWhen> |
|
1025 |
</activity> |
|
1026 |
<activityPatternBinding |
|
1027 |
activityId="eu.etaxonomy.taxeditor.store.activityUserManagement" |
|
1028 |
pattern="eu\.etaxonomy\.taxeditor\..*/.*.UserManagement"> |
|
1029 |
</activityPatternBinding> |
|
927 | 1030 |
</extension> |
928 | 1031 |
|
929 | 1032 |
</plugin> |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/security/PermissionPropertyTester.java | ||
---|---|---|
1 |
package eu.etaxonomy.taxeditor.security; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.EnumSet; |
|
5 |
import java.util.Iterator; |
|
6 |
import java.util.List; |
|
7 |
|
|
8 |
import javax.management.relation.Role; |
|
9 |
|
|
10 |
import org.apache.commons.lang.StringUtils; |
|
11 |
import org.eclipse.core.expressions.PropertyTester; |
|
12 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
13 |
|
|
14 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
15 |
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD; |
|
16 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
17 |
|
|
18 |
public class PermissionPropertyTester extends PropertyTester { |
|
19 |
|
|
20 |
private static final String HAS_ROLES = "hasRoles"; |
|
21 |
private static final String HAS_PERMISSIONS = "hasPermissions"; |
|
22 |
|
|
23 |
private static final String CREATE = CRUD.CREATE.toString(); |
|
24 |
private static final String READ = CRUD.READ.toString(); |
|
25 |
private static final String UPDATE = CRUD.UPDATE.toString(); |
|
26 |
private static final String DELETE = CRUD.DELETE.toString(); |
|
27 |
|
|
28 |
@Override |
|
29 |
public boolean test(Object receiver, String property, Object[] args, |
|
30 |
Object expectedValue) { |
|
31 |
|
|
32 |
|
|
33 |
if(property.equals(HAS_PERMISSIONS)){ |
|
34 |
|
|
35 |
return checkHasPermission(receiver, args); |
|
36 |
} |
|
37 |
|
|
38 |
if(property.equals(HAS_ROLES)){ |
|
39 |
return checkHasRoles(property, args); |
|
40 |
} |
|
41 |
|
|
42 |
return false; |
|
43 |
} |
|
44 |
|
|
45 |
private boolean checkHasRoles(String property, Object[] args) { |
|
46 |
List<Role> roles = new ArrayList<Role>(); |
|
47 |
for(int i = 0; i < args.length; i++){ |
|
48 |
roles.add((Role)args[i]); |
|
49 |
} |
|
50 |
// return CdmStore.currentAuthentiationHasOneOfRoles(roles.get(0)); // FIXME |
|
51 |
return false; |
|
52 |
|
|
53 |
} |
|
54 |
|
|
55 |
private boolean checkHasPermission(Object receiver, Object[] args) { |
|
56 |
EnumSet<CRUD> crudSet = crudSetFromArgs(args); |
|
57 |
|
|
58 |
|
|
59 |
List<Object> selectedElements = ((IStructuredSelection) receiver).toList(); |
|
60 |
for(Object selectedElement : selectedElements){ |
|
61 |
if(selectedElement instanceof CdmBase && ! CdmStore.currentAuthentiationHasPermission((CdmBase) selectedElement, crudSet)){ |
|
62 |
return false; |
|
63 |
} |
|
64 |
} |
|
65 |
|
|
66 |
return true; |
|
67 |
} |
|
68 |
|
|
69 |
private EnumSet<CRUD> crudSetFromArgs(Object[] args) { |
|
70 |
EnumSet<CRUD> crudSet = EnumSet.noneOf(CRUD.class); |
|
71 |
for(int i = 0; i < args.length; i++){ |
|
72 |
try { |
|
73 |
crudSet.add(CRUD.valueOf(args[i].toString())); |
|
74 |
} catch (Exception e){ |
|
75 |
System.err.println("could not add " + args[i]); |
|
76 |
} |
|
77 |
} |
|
78 |
return crudSet; |
|
79 |
} |
|
80 |
|
|
81 |
} |
Also available in: Unified diff
base implementation and configuration for securing the editor - #4055 (action enablement adapts to the users granted authorities)