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.Collection;
|
12
|
import java.util.EnumSet;
|
13
|
import java.util.UUID;
|
14
|
|
15
|
import com.vaadin.server.VaadinSession;
|
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. Implementations should use the {@link #VADDIN_SESSION_KEY} to auto registers
|
24
|
* in the VaadinSession.
|
25
|
*
|
26
|
* @author a.kohlbecker
|
27
|
* @since May 23, 2017
|
28
|
*
|
29
|
*/
|
30
|
public interface UserHelper {
|
31
|
|
32
|
public static final String VADDIN_SESSION_KEY = "USER_HELPER";
|
33
|
|
34
|
/**
|
35
|
* Static accessor method to obtain the auto-registered UserHelper-Bean from the
|
36
|
* VaadinSession.
|
37
|
*
|
38
|
* @return
|
39
|
*/
|
40
|
public static UserHelper fromSession() {
|
41
|
return (UserHelper)VaadinSession.getCurrent().getAttribute(VADDIN_SESSION_KEY);
|
42
|
}
|
43
|
|
44
|
boolean userHasPermission(Class<? extends CdmBase> cdmType, Integer entitiyId, Object ... args);
|
45
|
|
46
|
boolean userHasPermission(Class<? extends CdmBase> cdmType, UUID entitiyUUID, Object ... args);
|
47
|
|
48
|
boolean userHasPermission(Class<? extends CdmBase> cdmType, Object ... args);
|
49
|
|
50
|
boolean userHasPermission(CdmBase entity, Object ... args);
|
51
|
|
52
|
boolean userIsRegistrationCurator();
|
53
|
|
54
|
boolean userIsAdmin();
|
55
|
|
56
|
User user();
|
57
|
|
58
|
String userName();
|
59
|
|
60
|
boolean userIsAnnonymous();
|
61
|
|
62
|
boolean userIsAutheticated();
|
63
|
|
64
|
/**
|
65
|
*
|
66
|
* @param username
|
67
|
* @param cdmEntity
|
68
|
* @param crud
|
69
|
* @param property
|
70
|
* @return the newly created CdmAuthority only if a new CdmAuthority has been added to the user otherwise
|
71
|
* <code>null</code> in case the operation failed of if the user was already granted with this authority.
|
72
|
*/
|
73
|
public CdmAuthority createAuthorityFor(String username, CdmBase cdmEntity, EnumSet<CRUD> crud, String property);
|
74
|
|
75
|
/**
|
76
|
*
|
77
|
* @param username
|
78
|
* @param cdmType
|
79
|
* @param entitiyId
|
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, Integer entitiyId, EnumSet<CRUD> crud, String property);
|
86
|
|
87
|
|
88
|
/**
|
89
|
*
|
90
|
* @param username
|
91
|
* @param cdmType
|
92
|
* @param entitiyUuid
|
93
|
* @param crud
|
94
|
* @param property
|
95
|
* @return the newly created CdmAuthority only if a new CdmAuthority has been added to the user otherwise
|
96
|
* <code>null</code> in case the operation failed of if the user was already granted with this authority.
|
97
|
*/
|
98
|
public CdmAuthority createAuthorityFor(String username, Class<? extends CdmBase> cdmType, UUID entitiyUuid, EnumSet<CRUD> crud, String property);
|
99
|
|
100
|
|
101
|
/**
|
102
|
* @param cdmType
|
103
|
* @param entitiyId
|
104
|
* @param crud
|
105
|
* @return the newly created CdmAuthority only if a new CdmAuthority has been added to the user otherwise
|
106
|
* <code>null</code> in case the operation failed of if the user was already granted with this authority.
|
107
|
*/
|
108
|
public CdmAuthority createAuthorityForCurrentUser(Class<? extends CdmBase> cdmType, Integer entitiyId, EnumSet<CRUD> crud, String property);
|
109
|
|
110
|
/**
|
111
|
* @param cdmType
|
112
|
* @param entitiyUuid
|
113
|
* @param crud
|
114
|
* @return the newly created CdmAuthority only if a new CdmAuthority has been added to the user otherwise
|
115
|
* <code>null</code> in case the operation failed of if the user was already granted with this authority.
|
116
|
*/
|
117
|
public CdmAuthority createAuthorityForCurrentUser(Class<? extends CdmBase> cdmType, UUID entitiyUuid, EnumSet<CRUD> crud, String property);
|
118
|
|
119
|
/**
|
120
|
* @param cdmType
|
121
|
* @param entitiyId
|
122
|
* @param crud
|
123
|
* @return the newly created CdmAuthority only if a new CdmAuthority has been added to the user otherwise
|
124
|
* <code>null</code> in case the operation failed of if the user was already granted with this authority.
|
125
|
*/
|
126
|
public CdmAuthority createAuthorityForCurrentUser(CdmBase cdmEntity, EnumSet<CRUD> crud, String property);
|
127
|
|
128
|
/**
|
129
|
* Scans the currently authenticated user for CdmAuthorities which match the given parameters
|
130
|
*
|
131
|
* @param cdmEntity
|
132
|
* @param crud
|
133
|
* @return
|
134
|
*/
|
135
|
public Collection<CdmAuthority> findUserPermissions(CdmBase cdmEntity, EnumSet<CRUD> crud);
|
136
|
|
137
|
/**
|
138
|
* @param newAuthority
|
139
|
*/
|
140
|
public void removeAuthorityForCurrentUser(CdmAuthority newAuthority);
|
141
|
|
142
|
/**
|
143
|
* @param username
|
144
|
* @param newAuthority
|
145
|
*/
|
146
|
public void removeAuthorityForCurrentUser(String username, CdmAuthority newAuthority);
|
147
|
|
148
|
|
149
|
}
|