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
.api
.utility
;
11 import java
.util
.Collection
;
12 import java
.util
.EnumSet
;
13 import java
.util
.UUID
;
15 import org
.springframework
.security
.core
.Authentication
;
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
;
23 * UserHelper interface.
25 * @author a.kohlbecker
29 public interface UserHelper
{
31 boolean userHasPermission(Class
<?
extends CdmBase
> cdmType
, Integer entitiyId
, Object
... args
);
33 boolean userHasPermission(Class
<?
extends CdmBase
> cdmType
, UUID entitiyUUID
, Object
... args
);
35 boolean userHasPermission(Class
<?
extends CdmBase
> cdmType
, Object
... args
);
37 boolean userHasPermission(CdmBase entity
, Object
... args
);
43 boolean userIsAnnonymous();
45 boolean userIsAutheticated();
47 boolean userIsAdmin();
49 boolean userIs(RoleProbe roleProbe
);
57 * @return the newly created CdmAuthority only if a new CdmAuthority has been added to the user otherwise
58 * <code>null</code> in case the operation failed of if the user was already granted with this authority.
60 public CdmAuthority
createAuthorityFor(String username
, CdmBase cdmEntity
, EnumSet
<CRUD
> crud
, String property
);
69 * @return the newly created CdmAuthority only if a new CdmAuthority has been added to the user otherwise
70 * <code>null</code> in case the operation failed of if the user was already granted with this authority.
72 public CdmAuthority
createAuthorityFor(String username
, Class
<?
extends CdmBase
> cdmType
, Integer entitiyId
, EnumSet
<CRUD
> crud
, String 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.
85 public CdmAuthority
createAuthorityFor(String username
, Class
<?
extends CdmBase
> cdmType
, UUID entitiyUuid
, EnumSet
<CRUD
> crud
, String property
);
92 * @return the newly created CdmAuthority only if a new CdmAuthority has been added to the user otherwise
93 * <code>null</code> in case the operation failed of if the user was already granted with this authority.
95 public CdmAuthority
createAuthorityForCurrentUser(Class
<?
extends CdmBase
> cdmType
, Integer entitiyId
, EnumSet
<CRUD
> crud
, String property
);
101 * @return the newly created CdmAuthority only if a new CdmAuthority has been added to the user otherwise
102 * <code>null</code> in case the operation failed of if the user was already granted with this authority.
104 public CdmAuthority
createAuthorityForCurrentUser(Class
<?
extends CdmBase
> cdmType
, UUID entitiyUuid
, EnumSet
<CRUD
> crud
, String property
);
110 * @return the newly created CdmAuthority only if a new CdmAuthority has been added to the user otherwise
111 * <code>null</code> in case the operation failed of if the user was already granted with this authority.
113 public CdmAuthority
createAuthorityForCurrentUser(CdmBase cdmEntity
, EnumSet
<CRUD
> crud
, String property
);
116 * Scans the currently authenticated user for CdmAuthorities which match the given parameters
122 public Collection
<CdmAuthority
> findUserPermissions(CdmBase cdmEntity
, EnumSet
<CRUD
> crud
);
125 * @param newAuthority
127 public void removeAuthorityForCurrentUser(CdmAuthority newAuthority
);
131 * @param newAuthority
133 public void removeAuthorityForCurrentUser(String username
, CdmAuthority newAuthority
);
138 public void logout();
140 void setSecurityContextAccess(SecurityContextAccess securityContextAccess
);
145 public Authentication
getAuthentication();