2 * Copyright (C) 2017 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.cdm
.vaadin
.security
;
11 import java
.util
.EnumSet
;
13 import com
.vaadin
.server
.VaadinSession
;
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
;
21 * UserHelper interface. Implementations should use the {@link #VADDIN_SESSION_KEY} to auto registers
22 * in the VaadinSession.
24 * @author a.kohlbecker
28 public interface UserHelper
{
30 public static final String VADDIN_SESSION_KEY
= "USER_HELPER";
33 * Static accessor method to obtain the auto-registered UserHelper-Bean from the
38 public static UserHelper
fromSession() {
39 return (UserHelper
)VaadinSession
.getCurrent().getAttribute(VADDIN_SESSION_KEY
);
42 boolean userHasPermission(Class
<?
extends CdmBase
> cdmType
, Integer entitiyId
, Object
... args
);
44 boolean userHasPermission(Class
<?
extends CdmBase
> cdmType
, Object
... args
);
46 boolean userHasPermission(CdmBase entity
, Object
... args
);
48 boolean userIsRegistrationCurator();
50 boolean userIsAdmin();
56 boolean userIsAnnonymous();
58 boolean userIsAutheticated();
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.
69 public CdmAuthority
createAuthorityFor(String username
, CdmBase cdmEntity
, EnumSet
<CRUD
> crud
, String 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.
81 public CdmAuthority
createAuthorityFor(String username
, Class
<?
extends CdmBase
> cdmType
, Integer entitiyId
, EnumSet
<CRUD
> crud
, String property
);
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.
90 public CdmAuthority
createAuthorityForCurrentUser(Class
<?
extends CdmBase
> cdmType
, Integer entitiyId
, EnumSet
<CRUD
> crud
, String property
);
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.
99 public CdmAuthority
createAuthorityForCurrentUser(CdmBase cdmEntity
, EnumSet
<CRUD
> crud
, String property
);
102 * @param newAuthority
104 public void removeAuthorityForCurrentUser(CdmAuthority newAuthority
);
108 * @param newAuthority
110 public void removeAuthorityForCurrentUser(String username
, CdmAuthority newAuthority
);