2 package eu
.etaxonomy
.cdm
.database
;
4 import java
.util
.EnumSet
;
6 import org
.apache
.log4j
.Logger
;
7 import org
.hibernate
.HibernateException
;
8 import org
.springframework
.security
.core
.Authentication
;
10 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
11 import eu
.etaxonomy
.cdm
.persistence
.hibernate
.permission
.CRUD
;
12 import eu
.etaxonomy
.cdm
.persistence
.hibernate
.permission
.Operation
;
13 import eu
.etaxonomy
.cdm
.persistence
.hibernate
.permission
.Role
;
22 public class PermissionDeniedException
extends HibernateException
{
24 private static final long serialVersionUID
= 1L;
26 private static final Logger logger
= Logger
27 .getLogger(PermissionDeniedException
.class);
32 public PermissionDeniedException(String message
) {
36 public PermissionDeniedException(Authentication authentication
, CdmBase entity
, Operation requiredOperation
) {
37 super(requiredOperation
+ " not permitted for '" + authentication
.getName()
38 + "' on " + entity
.getClass().getSimpleName() + "[uuid:" + entity
.getUuid() + "', toString:'" + entity
.toString() + "']");
41 public PermissionDeniedException(Authentication authentication
, CdmBase entity
, EnumSet
<CRUD
> requiredOperation
) {
42 super(requiredOperation
+ " not permitted for '" + authentication
.getName()
43 + "' on " + entity
.getClass().getSimpleName() + "[uuid:" + entity
.getUuid() + "', toString:'" + entity
.toString() + "']");
46 public PermissionDeniedException(Authentication authentication
, CdmBase entity
, String requiredOperation
) {
47 super(requiredOperation
+ " not permitted for '" + authentication
.getName()
48 + "' on " + entity
.getClass().getSimpleName() + "[uuid:" + entity
.getUuid() + "', toString:'" + entity
.toString() + "']");
52 * @param authentication
55 public PermissionDeniedException(Authentication authentication
, Role
[] roles
) {
57 super("Permission denied for '" + authentication
.getName()
58 + "' none of the roles '" + roles
+ "' found in authentication.");
64 public PermissionDeniedException(Throwable cause
) {
72 public PermissionDeniedException(String message
, Throwable cause
) {
73 super(message
, cause
);