Project

General

Profile

Download (4.65 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.vaadin.permission;
10

    
11
import java.util.EnumSet;
12
import java.util.UUID;
13

    
14
import com.vaadin.server.VaadinSession;
15

    
16
import eu.etaxonomy.cdm.model.common.CdmBase;
17
import eu.etaxonomy.cdm.model.common.User;
18
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
19
import eu.etaxonomy.cdm.persistence.hibernate.permission.CdmAuthority;
20

    
21
/**
22
 * UserHelper interface. Implementations should use the {@link #VADDIN_SESSION_KEY} to auto registers
23
 * in the VaadinSession.
24
 *
25
 * @author a.kohlbecker
26
 * @since May 23, 2017
27
 *
28
 */
29
public interface UserHelper {
30

    
31
    public static final String VADDIN_SESSION_KEY = "USER_HELPER";
32

    
33
    /**
34
     * Static accessor method to obtain the auto-registered UserHelper-Bean from the
35
     * VaadinSession.
36
     *
37
     * @return
38
     */
39
    public static UserHelper fromSession() {
40
       return (UserHelper)VaadinSession.getCurrent().getAttribute(VADDIN_SESSION_KEY);
41
    }
42

    
43
    boolean userHasPermission(Class<? extends CdmBase> cdmType, Integer entitiyId, Object ... args);
44

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

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

    
49
    boolean userHasPermission(CdmBase entity, Object ... args);
50

    
51
    boolean userIsRegistrationCurator();
52

    
53
    boolean userIsAdmin();
54

    
55
    User user();
56

    
57
    String userName();
58

    
59
    boolean userIsAnnonymous();
60

    
61
    boolean userIsAutheticated();
62

    
63
    /**
64
     *
65
     * @param username
66
     * @param cdmEntity
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, CdmBase cdmEntity, EnumSet<CRUD> crud, String property);
73

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

    
86

    
87
    /**
88
    *
89
    * @param username
90
    * @param cdmType
91
    * @param entitiyUuid
92
    * @param crud
93
    * @param property
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 createAuthorityFor(String username, Class<? extends CdmBase> cdmType, UUID entitiyUuid, EnumSet<CRUD> crud, String property);
98

    
99

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

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

    
118
    /**
119
     * @param cdmType
120
     * @param entitiyId
121
     * @param crud
122
     * @return the newly created CdmAuthority only if a new CdmAuthority has been added to the user otherwise
123
     * <code>null</code> in case the operation failed of if the user was already granted with this authority.
124
     */
125
    public CdmAuthority createAuthorityForCurrentUser(CdmBase cdmEntity, EnumSet<CRUD> crud, String property);
126

    
127
    /**
128
     * @param newAuthority
129
     */
130
    public void removeAuthorityForCurrentUser(CdmAuthority newAuthority);
131

    
132
    /**
133
     * @param username
134
     * @param newAuthority
135
     */
136
    public void removeAuthorityForCurrentUser(String username, CdmAuthority newAuthority);
137

    
138

    
139
}
(8-8/9)