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
|
import eu.etaxonomy.cdm.persistence.hibernate.permission.CdmAuthority;
|
18
|
|
19
|
/**
|
20
|
* UserHelper interface. Implementations should use the {@link #VADDIN_SESSION_KEY} to auto registers
|
21
|
* in the VaadinSession.
|
22
|
*
|
23
|
* @author a.kohlbecker
|
24
|
* @since May 23, 2017
|
25
|
*
|
26
|
*/
|
27
|
public interface UserHelper {
|
28
|
|
29
|
public static final String VADDIN_SESSION_KEY = "USER_HELPER";
|
30
|
|
31
|
/**
|
32
|
* Static accessor method to obtain the auto-registered UserHelper-Bean from the
|
33
|
* VaadinSession.
|
34
|
*
|
35
|
* @return
|
36
|
*/
|
37
|
public static UserHelper fromSession() {
|
38
|
return (UserHelper)VaadinSession.getCurrent().getAttribute(VADDIN_SESSION_KEY);
|
39
|
}
|
40
|
|
41
|
boolean userHasPermission(Class<? extends CdmBase> cdmType, Integer entitiyId, Object ... args);
|
42
|
|
43
|
boolean userHasPermission(Class<? extends CdmBase> cdmType, Object ... args);
|
44
|
|
45
|
boolean userHasPermission(CdmBase entity, Object ... args);
|
46
|
|
47
|
boolean userIsRegistrationCurator();
|
48
|
|
49
|
boolean userIsAdmin();
|
50
|
|
51
|
String userName();
|
52
|
|
53
|
boolean userIsAnnonymous();
|
54
|
|
55
|
boolean userIsAutheticated();
|
56
|
|
57
|
/**
|
58
|
*
|
59
|
* @param username
|
60
|
* @param cdmEntity
|
61
|
* @param crud
|
62
|
* @param property
|
63
|
* @return the newly created CdmAuthority only if a new CdmAuthority has been added to the user otherwise
|
64
|
* <code>null</code> in case the operation failed of if the user was already granted with this authority.
|
65
|
*/
|
66
|
public CdmAuthority createAuthorityFor(String username, CdmBase cdmEntity, EnumSet<CRUD> crud, String property);
|
67
|
|
68
|
/**
|
69
|
*
|
70
|
* @param username
|
71
|
* @param cdmType
|
72
|
* @param entitiyId
|
73
|
* @param crud
|
74
|
* @param property
|
75
|
* @return the newly created CdmAuthority only if a new CdmAuthority has been added to the user otherwise
|
76
|
* <code>null</code> in case the operation failed of if the user was already granted with this authority.
|
77
|
*/
|
78
|
public CdmAuthority createAuthorityFor(String username, Class<? extends CdmBase> cdmType, Integer entitiyId, EnumSet<CRUD> crud, String property);
|
79
|
|
80
|
/**
|
81
|
* @param cdmType
|
82
|
* @param entitiyId
|
83
|
* @param crud
|
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 createAuthorityForCurrentUser(Class<? extends CdmBase> cdmType, Integer entitiyId, EnumSet<CRUD> crud, String property);
|
88
|
|
89
|
/**
|
90
|
* @param cdmType
|
91
|
* @param entitiyId
|
92
|
* @param crud
|
93
|
* @return the newly created CdmAuthority only if a new CdmAuthority has been added to the user otherwise
|
94
|
* <code>null</code> in case the operation failed of if the user was already granted with this authority.
|
95
|
*/
|
96
|
public CdmAuthority createAuthorityForCurrentUser(CdmBase cdmEntity, EnumSet<CRUD> crud, String property);
|
97
|
|
98
|
/**
|
99
|
* @param newAuthority
|
100
|
*/
|
101
|
public void removeAuthorityForCurrentUser(CdmAuthority newAuthority);
|
102
|
|
103
|
/**
|
104
|
* @param username
|
105
|
* @param newAuthority
|
106
|
*/
|
107
|
public void removeAuthorityForCurrentUser(String username, CdmAuthority newAuthority);
|
108
|
|
109
|
|
110
|
}
|