Project

General

Profile

Download (5.15 KB) Statistics
| Branch: | Tag: | Revision:
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.ICdmEntityUuidCacher;
18
import eu.etaxonomy.cdm.model.common.CdmBase;
19
import eu.etaxonomy.cdm.model.common.User;
20
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
21
import eu.etaxonomy.cdm.persistence.hibernate.permission.CdmAuthority;
22

    
23
/**
24
 * UserHelper interface.
25
 *
26
 * @author a.kohlbecker
27
 * @since May 23, 2017
28
 *
29
 */
30
public interface UserHelper {
31

    
32
    @Deprecated
33
    boolean userHasPermission(Class<? extends CdmBase> cdmType, Integer entitiyId, Object ... args);
34

    
35
    boolean userHasPermission(Class<? extends CdmBase> cdmType, UUID entitiyUUID, Object ... args);
36

    
37
    boolean userHasPermission(Class<? extends CdmBase> cdmType, Object ... args);
38

    
39
    boolean userHasPermission(CdmBase entity, Object ... args);
40

    
41
    User user();
42

    
43
    String userName();
44

    
45
    boolean userIsAnnonymous();
46

    
47
    boolean userIsAutheticated();
48

    
49
    boolean userIsAdmin();
50

    
51
    boolean userIs(RoleProbe roleProbe);
52

    
53
    /**
54
     *
55
     * @param username
56
     * @param cdmEntity
57
     * @param crud
58
     * @param property
59
     * @return the newly created CdmAuthority only if a new CdmAuthority has been added to the user otherwise
60
     * <code>null</code> in case the operation failed of if the user was already granted with this authority.
61
     */
62
    public CdmAuthority createAuthorityFor(String username, CdmBase cdmEntity, EnumSet<CRUD> crud, String property);
63

    
64
    /**
65
     *
66
     * @param username
67
     * @param cdmType
68
     * @param entitiyId
69
     * @param crud
70
     * @param property
71
     * @return the newly created CdmAuthority only if a new CdmAuthority has been added to the user otherwise
72
     * <code>null</code> in case the operation failed of if the user was already granted with this authority.
73
     */
74
    public CdmAuthority createAuthorityFor(String username, Class<? extends CdmBase> cdmType, Integer entitiyId, EnumSet<CRUD> crud, String property);
75

    
76

    
77
    /**
78
    *
79
    * @param username
80
    * @param cdmType
81
    * @param entitiyUuid
82
    * @param crud
83
    * @param property
84
    * @return the newly created CdmAuthority only if a new CdmAuthority has been added to the user otherwise
85
    * <code>null</code> in case the operation failed of if the user was already granted with this authority.
86
    */
87
   public CdmAuthority createAuthorityFor(String username, Class<? extends CdmBase> cdmType, UUID entitiyUuid, EnumSet<CRUD> crud, String property);
88

    
89

    
90
    /**
91
     * @param cdmType
92
     * @param entitiyId
93
     * @param crud
94
     * @return the newly created CdmAuthority only if a new CdmAuthority has been added to the user otherwise
95
     * <code>null</code> in case the operation failed of if the user was already granted with this authority.
96
     */
97
    public CdmAuthority createAuthorityForCurrentUser(Class<? extends CdmBase> cdmType, Integer entitiyId, EnumSet<CRUD> crud, String property);
98

    
99
    /**
100
     * @param cdmType
101
     * @param entitiyUuid
102
     * @param crud
103
     * @return the newly created CdmAuthority only if a new CdmAuthority has been added to the user otherwise
104
     * <code>null</code> in case the operation failed of if the user was already granted with this authority.
105
     */
106
    public CdmAuthority createAuthorityForCurrentUser(Class<? extends CdmBase> cdmType, UUID entitiyUuid, EnumSet<CRUD> crud, String property);
107

    
108
    /**
109
     * @param cdmType
110
     * @param entitiyId
111
     * @param crud
112
     * @return the newly created CdmAuthority only if a new CdmAuthority has been added to the user otherwise
113
     * <code>null</code> in case the operation failed of if the user was already granted with this authority.
114
     */
115
    public CdmAuthority createAuthorityForCurrentUser(CdmBase cdmEntity, EnumSet<CRUD> crud, String property);
116

    
117
    /**
118
     * Scans the currently authenticated user for CdmAuthorities which match the given parameters
119
     *
120
     * @param cdmEntity
121
     * @param crud
122
     * @return
123
     */
124
    public Collection<CdmAuthority> findUserPermissions(CdmBase cdmEntity, EnumSet<CRUD> crud);
125

    
126
    /**
127
     * Scans the currently authenticated user for CdmAuthorities which match the given parameters
128
     *
129
     * @param cdmType
130
     * @param crud
131
     * @return
132
     */
133
    public <T extends CdmBase> Collection<CdmAuthority> findUserPermissions(Class<T> cdmType, EnumSet<CRUD> crud);
134

    
135
    /**
136
     * @param newAuthority
137
     */
138
    public void removeAuthorityForCurrentUser(CdmAuthority newAuthority);
139

    
140
    /**
141
     * @param username
142
     * @param newAuthority
143
     */
144
    public void removeAuthorityForCurrentUser(String username, CdmAuthority newAuthority);
145

    
146
    /**
147
     *
148
     */
149
    public void logout();
150

    
151
    void setSecurityContextAccess(SecurityContextAccess securityContextAccess);
152

    
153
    /**
154
     * @return
155
     */
156
    public Authentication getAuthentication();
157

    
158
    public CdmUserHelper withCache(ICdmEntityUuidCacher iCdmCacher);
159

    
160

    
161
}
(12-12/12)