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.security;
|
10
|
|
11
|
import java.util.EnumSet;
|
12
|
|
13
|
import com.vaadin.server.VaadinSession;
|
14
|
|
15
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
16
|
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
|
17
|
|
18
|
/**
|
19
|
* UserHelper interface. Implementations should use the {@link #VADDIN_SESSION_KEY} to auto registers
|
20
|
* in the VaadinSession.
|
21
|
*
|
22
|
* @author a.kohlbecker
|
23
|
* @since May 23, 2017
|
24
|
*
|
25
|
*/
|
26
|
public interface UserHelper {
|
27
|
|
28
|
public static final String VADDIN_SESSION_KEY = "USER_HELPER";
|
29
|
|
30
|
/**
|
31
|
* Static accessor method to obtain the auto-registered UserHelper-Bean from the
|
32
|
* VaadinSession.
|
33
|
*
|
34
|
* @return
|
35
|
*/
|
36
|
public static UserHelper fromSession() {
|
37
|
return (UserHelper)VaadinSession.getCurrent().getAttribute(VADDIN_SESSION_KEY);
|
38
|
}
|
39
|
|
40
|
boolean userHasPermission(Class<? extends CdmBase> cdmType, Integer entitiyId, Object ... args);
|
41
|
|
42
|
boolean userHasPermission(Class<? extends CdmBase> cdmType, Object ... args);
|
43
|
|
44
|
boolean userHasPermission(CdmBase entity, Object ... args);
|
45
|
|
46
|
boolean userIsRegistrationCurator();
|
47
|
|
48
|
boolean userIsAdmin();
|
49
|
|
50
|
String userName();
|
51
|
|
52
|
boolean userIsAnnonymous();
|
53
|
|
54
|
boolean userIsAutheticated();
|
55
|
|
56
|
public void createAuthorityFor(String username, Class<? extends CdmBase> cdmType, Integer entitiyId, EnumSet<CRUD> crud, String property);
|
57
|
|
58
|
/**
|
59
|
* @param cdmType
|
60
|
* @param entitiyId
|
61
|
* @param crud
|
62
|
*/
|
63
|
void createAuthorityForCurrentUser(Class<? extends CdmBase> cdmType, Integer entitiyId, EnumSet<CRUD> crud, String property);
|
64
|
|
65
|
|
66
|
}
|