Project

General

Profile

Download (3.61 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.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.model.common.User;
17
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
18
import eu.etaxonomy.cdm.persistence.hibernate.permission.CdmAuthority;
19

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

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

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

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

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

    
46
    boolean userHasPermission(CdmBase entity, Object ... args);
47

    
48
    boolean userIsRegistrationCurator();
49

    
50
    boolean userIsAdmin();
51

    
52
    User user();
53

    
54
    String userName();
55

    
56
    boolean userIsAnnonymous();
57

    
58
    boolean userIsAutheticated();
59

    
60
    /**
61
     *
62
     * @param username
63
     * @param cdmEntity
64
     * @param crud
65
     * @param property
66
     * @return the newly created CdmAuthority only if a new CdmAuthority has been added to the user otherwise
67
     * <code>null</code> in case the operation failed of if the user was already granted with this authority.
68
     */
69
    public CdmAuthority createAuthorityFor(String username, CdmBase cdmEntity, EnumSet<CRUD> crud, String property);
70

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

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

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

    
101
    /**
102
     * @param newAuthority
103
     */
104
    public void removeAuthorityForCurrentUser(CdmAuthority newAuthority);
105

    
106
    /**
107
     * @param username
108
     * @param newAuthority
109
     */
110
    public void removeAuthorityForCurrentUser(String username, CdmAuthority newAuthority);
111

    
112

    
113
}
(7-7/8)