Project

General

Profile

Download (4.81 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.permission.CRUD;
20
import eu.etaxonomy.cdm.model.permission.User;
21
import eu.etaxonomy.cdm.persistence.permission.CdmAuthority;
22

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

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

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

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

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

    
40
    User user();
41

    
42
    String userName();
43

    
44
    boolean userIsAnnonymous();
45

    
46
    boolean userIsAutheticated();
47

    
48
    boolean userIsAdmin();
49

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

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

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

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

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

    
111
    /**
112
     * Scans the currently authenticated user for CdmAuthorities which match the given parameters
113
     */
114
    public Collection<CdmAuthority> findUserPermissions(CdmBase cdmEntity, EnumSet<CRUD> crud);
115

    
116
    /**
117
     * Scans the currently authenticated user for CdmAuthorities which match the given parameters
118
     */
119
    public <T extends CdmBase> Collection<CdmAuthority> findUserPermissions(Class<T> cdmType, EnumSet<CRUD> crud);
120

    
121
    public void removeAuthorityForCurrentUser(CdmAuthority newAuthority);
122

    
123
    public void removeAuthorityForCurrentUser(String username, CdmAuthority newAuthority);
124

    
125
    public void logout();
126

    
127
    void setSecurityContextAccess(SecurityContextAccess securityContextAccess);
128

    
129
    public Authentication getAuthentication();
130

    
131
    public CdmUserHelper withCache(ICdmEntityUuidCacher iCdmCacher);
132
}
(12-12/12)