Revision 68b2628a
Added by Andreas Kohlbecker over 6 years ago
- ID 68b2628aa8d5a04a8ce343e1298b0ca7f462e722
- Parent 5613f613
src/main/java/eu/etaxonomy/cdm/service/CdmUserHelper.java | ||
---|---|---|
11 | 11 |
import java.util.EnumSet; |
12 | 12 |
|
13 | 13 |
import org.springframework.beans.factory.annotation.Autowired; |
14 |
import org.springframework.beans.factory.annotation.Qualifier; |
|
14 | 15 |
import org.springframework.security.authentication.AnonymousAuthenticationToken; |
15 | 16 |
import org.springframework.security.core.Authentication; |
16 | 17 |
import org.springframework.security.core.context.SecurityContext; |
... | ... | |
19 | 20 |
import com.vaadin.spring.annotation.SpringComponent; |
20 | 21 |
import com.vaadin.spring.annotation.UIScope; |
21 | 22 |
|
23 |
import eu.etaxonomy.cdm.api.application.CdmRepository; |
|
22 | 24 |
import eu.etaxonomy.cdm.database.PermissionDeniedException; |
23 | 25 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
24 | 26 |
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD; |
... | ... | |
39 | 41 |
@Autowired |
40 | 42 |
private ICdmPermissionEvaluator permissionEvaluator; |
41 | 43 |
|
44 |
@Autowired |
|
45 |
@Qualifier("cdmRepository") |
|
46 |
private CdmRepository repo; |
|
47 |
|
|
42 | 48 |
public CdmUserHelper(){ |
43 | 49 |
super(); |
44 | 50 |
} |
... | ... | |
98 | 104 |
public boolean userHasPermission(CdmBase entity, Object ... args){ |
99 | 105 |
EnumSet<CRUD> crudSet = crudSetFromArgs(args); |
100 | 106 |
try { |
101 |
return permissionEvaluator.hasPermission(getAuthentication(), entity, crudSet); |
|
107 |
return permissionEvaluator.hasPermission(getAuthentication(), entity, crudSet);
|
|
102 | 108 |
} catch (PermissionDeniedException e){ |
103 | 109 |
//IGNORE |
104 | 110 |
} |
... | ... | |
109 | 115 |
public boolean userHasPermission(Class<? extends CdmBase> cdmType, Integer entitiyId, Object ... args){ |
110 | 116 |
EnumSet<CRUD> crudSet = crudSetFromArgs(args); |
111 | 117 |
try { |
112 |
return permissionEvaluator.hasPermission(getAuthentication(), cdmType, entitiyId.toString(), crudSet); |
|
118 |
CdmBase entity = repo.getCommonService().find(cdmType, entitiyId); |
|
119 |
return permissionEvaluator.hasPermission(getAuthentication(), entity, crudSet); |
|
113 | 120 |
} catch (PermissionDeniedException e){ |
114 | 121 |
//IGNORE |
115 | 122 |
} |
Also available in: Unified diff
ref #6999 fixing permission evaluation and adding debug button to gain per entitiy permissions