Revision 63e1618b
fixing #3096 (visual response if a user is not granted to edit a specific part of the classification tree)
.gitattributes | ||
---|---|---|
1205 | 1205 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/menu/TaxonRelationshipTypeMenuPreferences.java -text |
1206 | 1206 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/VocabularyTermWizard.java -text |
1207 | 1207 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/wizard/VocabularyTermWizardPage.java -text |
1208 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/security/RequiredPermissions.java -text |
|
1208 | 1209 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java -text |
1209 | 1210 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStoreConnector.java -text |
1210 | 1211 |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/ContextManager.java -text |
.gitignore | ||
---|---|---|
3 | 3 |
eu.etaxonomy.taxeditor.application/target |
4 | 4 |
eu.etaxonomy.taxeditor.bulkeditor/.settings |
5 | 5 |
eu.etaxonomy.taxeditor.bulkeditor/target |
6 |
eu.etaxonomy.taxeditor.cdmlib/.directory |
|
6 | 7 |
eu.etaxonomy.taxeditor.cdmlib/.settings |
7 | 8 |
eu.etaxonomy.taxeditor.cdmlib/cdmlib-*.jar |
8 | 9 |
eu.etaxonomy.taxeditor.cdmlib/cdmlib-*.zip |
eu.etaxonomy.taxeditor.cdmlib/.classpath | ||
---|---|---|
93 | 93 |
<classpathentry exported="true" kind="lib" path="lib/spring-modules-cache-0.7.jar" sourcepath="lib/spring-modules-cache-0.7src.zip"/> |
94 | 94 |
<classpathentry exported="true" kind="lib" path="lib/spring-modules-lucene-0.8a.jar" sourcepath="lib/spring-modules-lucene-0.8asrc.zip"/> |
95 | 95 |
<classpathentry exported="true" kind="lib" path="lib/spring-security-config-3.0.5.RELEASE.jar"/> |
96 |
<classpathentry exported="true" kind="lib" path="lib/spring-security-core-3.0.5.RELEASE.jar"/> |
|
96 |
<classpathentry exported="true" kind="lib" path="lib/spring-security-core-3.0.5.RELEASE.jar" sourcepath="/home/andreas/.m2/repository/org/springframework/security/spring-security-core/3.0.5.RELEASE/spring-security-core-3.0.5.RELEASE-sources.jar"/>
|
|
97 | 97 |
<classpathentry exported="true" kind="lib" path="lib/wsdl4j-1.6.1.jar" sourcepath="lib/wsdl4j-1.6.1src.zip"/> |
98 | 98 |
<classpathentry exported="true" kind="lib" path="lib/xalan-2.7.0.jar"/> |
99 | 99 |
<classpathentry exported="true" kind="lib" path="lib/xercesImpl-2.7.1.jar"/> |
... | ... | |
117 | 117 |
<classpathentry exported="true" kind="lib" path="lib/cdmlib-model-3.0.13-SNAPSHOT-sources.jar"/> |
118 | 118 |
<classpathentry exported="true" kind="lib" path="lib/cdmlib-model-3.0.13-SNAPSHOT.jar"/> |
119 | 119 |
<classpathentry exported="true" kind="lib" path="lib/cdmlib-persistence-3.0.13-SNAPSHOT-sources.jar"/> |
120 |
<classpathentry exported="true" kind="lib" path="lib/cdmlib-persistence-3.0.13-SNAPSHOT.jar"/> |
|
120 |
<classpathentry exported="true" kind="lib" path="lib/cdmlib-persistence-3.0.13-SNAPSHOT.jar" sourcepath="lib/cdmlib-persistence-3.0.13-SNAPSHOT-sources.jar"/>
|
|
121 | 121 |
<classpathentry exported="true" kind="lib" path="lib/cdmlib-print-3.0.13-SNAPSHOT-sources.jar"/> |
122 | 122 |
<classpathentry exported="true" kind="lib" path="lib/cdmlib-print-3.0.13-SNAPSHOT.jar"/> |
123 | 123 |
<classpathentry exported="true" kind="lib" path="lib/cdmlib-remote-3.0.13-SNAPSHOT-sources.jar"/> |
124 | 124 |
<classpathentry exported="true" kind="lib" path="lib/cdmlib-remote-3.0.13-SNAPSHOT.jar"/> |
125 | 125 |
<classpathentry exported="true" kind="lib" path="lib/cdmlib-services-3.0.13-SNAPSHOT-sources.jar"/> |
126 |
<classpathentry exported="true" kind="lib" path="lib/cdmlib-services-3.0.13-SNAPSHOT.jar"/> |
|
126 |
<classpathentry exported="true" kind="lib" path="lib/cdmlib-services-3.0.13-SNAPSHOT.jar" sourcepath="lib/cdmlib-services-3.0.13-SNAPSHOT-sources.jar"/>
|
|
127 | 127 |
<classpathentry kind="output" path="bin"/> |
128 | 128 |
</classpath> |
eu.etaxonomy.taxeditor.cdmlib/META-INF/MANIFEST.MF | ||
---|---|---|
383 | 383 |
org.hibernate.type, |
384 | 384 |
org.hibernate.event, |
385 | 385 |
eu.etaxonomy.cdm.model.common", |
386 |
eu.etaxonomy.cdm.persistence.hibernate.permission, |
|
386 | 387 |
eu.etaxonomy.cdm.persistence.query;uses:="org.hibernate,org.hibernate.envers.query,org.hibernate.criterion", |
387 | 388 |
eu.etaxonomy.cdm.print, |
388 | 389 |
eu.etaxonomy.cdm.print.out, |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNodeLabelProvider.java | ||
---|---|---|
15 | 15 |
import org.eclipse.jface.viewers.ILabelProvider; |
16 | 16 |
import org.eclipse.jface.viewers.StyledString; |
17 | 17 |
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider; |
18 |
import org.eclipse.jface.viewers.StyledString.Styler; |
|
19 |
import org.eclipse.swt.SWT; |
|
18 | 20 |
import org.eclipse.swt.graphics.Image; |
21 |
import org.eclipse.swt.graphics.TextStyle; |
|
19 | 22 |
import org.eclipse.ui.navigator.IDescriptionProvider; |
20 | 23 |
import org.hibernate.LazyInitializationException; |
21 | 24 |
|
22 | 25 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
26 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
23 | 27 |
import eu.etaxonomy.cdm.model.common.IIdentifiableEntity; |
24 | 28 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
25 | 29 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
30 |
import eu.etaxonomy.cdm.persistence.hibernate.permission.Operation; |
|
26 | 31 |
import eu.etaxonomy.taxeditor.navigation.NavigationUtil; |
32 |
import eu.etaxonomy.taxeditor.preference.Resources; |
|
33 |
import eu.etaxonomy.taxeditor.security.RequiredPermissions; |
|
34 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
35 |
import eu.etaxonomy.taxeditor.store.StoreUtil; |
|
27 | 36 |
|
28 | 37 |
/** |
29 | 38 |
* <p>TaxonNodeLabelProvider class.</p> |
... | ... | |
35 | 44 |
public class TaxonNodeLabelProvider extends ColumnLabelProvider |
36 | 45 |
implements ILabelProvider, IDescriptionProvider, IStyledLabelProvider { |
37 | 46 |
|
47 |
|
|
48 |
private Styler notGrantedStyler = null; |
|
49 |
|
|
38 | 50 |
/** {@inheritDoc} */ |
39 | 51 |
@Override |
40 | 52 |
public Image getImage(Object element) { |
... | ... | |
84 | 96 |
*/ |
85 | 97 |
/** {@inheritDoc} */ |
86 | 98 |
public StyledString getStyledText(Object element) { |
87 |
return new StyledString(getText(element)); |
|
99 |
// determine style base on user grants |
|
100 |
Styler styler = null; |
|
101 |
if(!CdmStore.currentAuthentiationHasPermission((CdmBase)element, RequiredPermissions.TAXONNODE_EDIT)){ |
|
102 |
styler = getNotGrantedStyler(); |
|
103 |
} |
|
104 |
return new StyledString(getText(element), styler); |
|
105 |
|
|
106 |
} |
|
107 |
|
|
108 |
/** |
|
109 |
* @return |
|
110 |
*/ |
|
111 |
private Styler getNotGrantedStyler() { |
|
112 |
if (notGrantedStyler == null) { |
|
113 |
notGrantedStyler = new Styler() { |
|
114 |
@Override |
|
115 |
public void applyStyles(TextStyle textStyle) { |
|
116 |
textStyle.underline = false; |
|
117 |
textStyle.foreground = StoreUtil.getColor(Resources.COLOR_TEXT_DISABLED); |
|
118 |
} |
|
119 |
}; |
|
120 |
} |
|
121 |
return notGrantedStyler; |
|
88 | 122 |
} |
89 | 123 |
} |
eu.etaxonomy.taxeditor.store/META-INF/MANIFEST.MF | ||
---|---|---|
24 | 24 |
eu.etaxonomy.taxeditor.preference.matching, |
25 | 25 |
eu.etaxonomy.taxeditor.preference.menu, |
26 | 26 |
eu.etaxonomy.taxeditor.preference.wizard, |
27 |
eu.etaxonomy.taxeditor.security, |
|
27 | 28 |
eu.etaxonomy.taxeditor.store, |
28 | 29 |
eu.etaxonomy.taxeditor.store.internal, |
29 | 30 |
eu.etaxonomy.taxeditor.store.operations, |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/security/RequiredPermissions.java | ||
---|---|---|
1 |
/** |
|
2 |
* |
|
3 |
*/ |
|
4 |
package eu.etaxonomy.taxeditor.security; |
|
5 |
|
|
6 |
import java.util.EnumSet; |
|
7 |
|
|
8 |
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD; |
|
9 |
import eu.etaxonomy.cdm.persistence.hibernate.permission.Operation; |
|
10 |
|
|
11 |
/** |
|
12 |
* Provides the required permissions a user would need in order to view or edit a |
|
13 |
* specific cdm type. |
|
14 |
* |
|
15 |
* @author andreas kohlbecker |
|
16 |
* |
|
17 |
*/ |
|
18 |
public class RequiredPermissions { |
|
19 |
|
|
20 |
public static final EnumSet<CRUD> TAXONNODE_EDIT = Operation.UPDATE; |
|
21 |
|
|
22 |
|
|
23 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java | ||
---|---|---|
12 | 12 |
import java.lang.reflect.InvocationTargetException; |
13 | 13 |
import java.lang.reflect.Method; |
14 | 14 |
import java.lang.reflect.Type; |
15 |
import java.util.EnumSet; |
|
15 | 16 |
|
16 | 17 |
import org.eclipse.core.runtime.IProgressMonitor; |
17 | 18 |
import org.eclipse.core.runtime.jobs.Job; |
18 | 19 |
import org.eclipse.swt.widgets.Display; |
19 | 20 |
import org.springframework.core.io.ClassPathResource; |
20 | 21 |
import org.springframework.core.io.Resource; |
22 |
import org.springframework.security.access.PermissionEvaluator; |
|
21 | 23 |
import org.springframework.security.authentication.ProviderManager; |
24 |
import org.springframework.security.core.context.SecurityContext; |
|
25 |
import org.springframework.security.core.context.SecurityContextHolder; |
|
22 | 26 |
|
23 | 27 |
import eu.etaxonomy.cdm.api.application.CdmApplicationController; |
24 | 28 |
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration; |
... | ... | |
27 | 31 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
28 | 32 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
29 | 33 |
import eu.etaxonomy.cdm.ext.geo.IEditGeoService; |
34 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
30 | 35 |
import eu.etaxonomy.cdm.model.common.Language; |
36 |
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD; |
|
37 |
import eu.etaxonomy.cdm.persistence.hibernate.permission.Operation; |
|
31 | 38 |
import eu.etaxonomy.taxeditor.datasource.CdmDataSourceRepository; |
32 | 39 |
import eu.etaxonomy.taxeditor.io.ExportManager; |
33 | 40 |
import eu.etaxonomy.taxeditor.io.ImportManager; |
... | ... | |
289 | 296 |
public static ProviderManager getAuthenticationManager() { |
290 | 297 |
return getCurrentApplicationConfiguration().getAuthenticationManager(); |
291 | 298 |
} |
299 |
|
|
300 |
/** |
|
301 |
* <p> |
|
302 |
* getAuthenticationManager |
|
303 |
* </p> |
|
304 |
* |
|
305 |
* @return a |
|
306 |
* {@link PermissionEvaluator} object. |
|
307 |
*/ |
|
308 |
public static PermissionEvaluator getPermissionEvaluator() { |
|
309 |
return getCurrentApplicationConfiguration().getPermissionEvaluator(); |
|
310 |
} |
|
292 | 311 |
|
293 | 312 |
/** |
294 | 313 |
* <p> |
... | ... | |
301 | 320 |
return (IEditGeoService) getCurrentApplicationConfiguration().getBean( |
302 | 321 |
"editGeoService"); |
303 | 322 |
} |
323 |
|
|
324 |
/* |
|
325 |
* SECURITY RELATED CONVENIENCE METHODS |
|
326 |
*/ |
|
327 |
|
|
328 |
/** |
|
329 |
* @see org.springframework.security.access.PermissionEvaluator#hasPermission(org.springframework.security.core.Authentication, java.lang.Object, java.lang.Object) |
|
330 |
* |
|
331 |
* @param targetDomainObject |
|
332 |
* @param permission |
|
333 |
* @return |
|
334 |
*/ |
|
335 |
public static boolean currentAuthentiationHasPermission(CdmBase targetDomainObject, EnumSet<CRUD> permission){ |
|
336 |
//TODO use getCurrentApplicationConfiguration().currentAuthentiationHasPermission(CdmBase targetDomainObject, Operation permission) instead |
|
337 |
SecurityContext context = SecurityContextHolder.getContext(); |
|
338 |
return getPermissionEvaluator().hasPermission(context.getAuthentication(), targetDomainObject, permission); |
|
339 |
} |
|
304 | 340 |
|
305 | 341 |
/* |
306 | 342 |
* LANGUAGE |
Also available in: Unified diff