ref #7597 Use LongRunningTaskService for taxon aggregation
[cdmlib.git] / cdmlib-services / src / main / java / eu / etaxonomy / cdm / api / utility / UserHelper.java
1 /**
2 * Copyright (C) 2017 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9 package eu.etaxonomy.cdm.api.utility;
10
11 import java.util.Collection;
12 import java.util.EnumSet;
13 import java.util.UUID;
14
15 import org.springframework.security.core.Authentication;
16
17 import eu.etaxonomy.cdm.model.common.CdmBase;
18 import eu.etaxonomy.cdm.model.common.User;
19 import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
20 import eu.etaxonomy.cdm.persistence.hibernate.permission.CdmAuthority;
21
22 /**
23 * UserHelper interface.
24 *
25 * @author a.kohlbecker
26 * @since May 23, 2017
27 *
28 */
29 public interface UserHelper {
30
31 boolean userHasPermission(Class<? extends CdmBase> cdmType, Integer entitiyId, Object ... args);
32
33 boolean userHasPermission(Class<? extends CdmBase> cdmType, UUID entitiyUUID, Object ... args);
34
35 boolean userHasPermission(Class<? extends CdmBase> cdmType, Object ... args);
36
37 boolean userHasPermission(CdmBase entity, Object ... args);
38
39 User user();
40
41 String userName();
42
43 boolean userIsAnnonymous();
44
45 boolean userIsAutheticated();
46
47 boolean userIsAdmin();
48
49 boolean userIs(RoleProbe roleProbe);
50
51 /**
52 *
53 * @param username
54 * @param cdmEntity
55 * @param crud
56 * @param property
57 * @return the newly created CdmAuthority only if a new CdmAuthority has been added to the user otherwise
58 * <code>null</code> in case the operation failed of if the user was already granted with this authority.
59 */
60 public CdmAuthority createAuthorityFor(String username, CdmBase cdmEntity, EnumSet<CRUD> crud, String property);
61
62 /**
63 *
64 * @param username
65 * @param cdmType
66 * @param entitiyId
67 * @param crud
68 * @param property
69 * @return the newly created CdmAuthority only if a new CdmAuthority has been added to the user otherwise
70 * <code>null</code> in case the operation failed of if the user was already granted with this authority.
71 */
72 public CdmAuthority createAuthorityFor(String username, Class<? extends CdmBase> cdmType, Integer entitiyId, EnumSet<CRUD> crud, String property);
73
74
75 /**
76 *
77 * @param username
78 * @param cdmType
79 * @param entitiyUuid
80 * @param crud
81 * @param property
82 * @return the newly created CdmAuthority only if a new CdmAuthority has been added to the user otherwise
83 * <code>null</code> in case the operation failed of if the user was already granted with this authority.
84 */
85 public CdmAuthority createAuthorityFor(String username, Class<? extends CdmBase> cdmType, UUID entitiyUuid, EnumSet<CRUD> crud, String property);
86
87
88 /**
89 * @param cdmType
90 * @param entitiyId
91 * @param crud
92 * @return the newly created CdmAuthority only if a new CdmAuthority has been added to the user otherwise
93 * <code>null</code> in case the operation failed of if the user was already granted with this authority.
94 */
95 public CdmAuthority createAuthorityForCurrentUser(Class<? extends CdmBase> cdmType, Integer entitiyId, EnumSet<CRUD> crud, String property);
96
97 /**
98 * @param cdmType
99 * @param entitiyUuid
100 * @param crud
101 * @return the newly created CdmAuthority only if a new CdmAuthority has been added to the user otherwise
102 * <code>null</code> in case the operation failed of if the user was already granted with this authority.
103 */
104 public CdmAuthority createAuthorityForCurrentUser(Class<? extends CdmBase> cdmType, UUID entitiyUuid, EnumSet<CRUD> crud, String property);
105
106 /**
107 * @param cdmType
108 * @param entitiyId
109 * @param crud
110 * @return the newly created CdmAuthority only if a new CdmAuthority has been added to the user otherwise
111 * <code>null</code> in case the operation failed of if the user was already granted with this authority.
112 */
113 public CdmAuthority createAuthorityForCurrentUser(CdmBase cdmEntity, EnumSet<CRUD> crud, String property);
114
115 /**
116 * Scans the currently authenticated user for CdmAuthorities which match the given parameters
117 *
118 * @param cdmEntity
119 * @param crud
120 * @return
121 */
122 public Collection<CdmAuthority> findUserPermissions(CdmBase cdmEntity, EnumSet<CRUD> crud);
123
124 /**
125 * @param newAuthority
126 */
127 public void removeAuthorityForCurrentUser(CdmAuthority newAuthority);
128
129 /**
130 * @param username
131 * @param newAuthority
132 */
133 public void removeAuthorityForCurrentUser(String username, CdmAuthority newAuthority);
134
135 /**
136 *
137 */
138 public void logout();
139
140 void setSecurityContextAccess(SecurityContextAccess securityContextAccess);
141
142 /**
143 * @return
144 */
145 public Authentication getAuthentication();
146
147
148 }