1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package eu.ehri.project.exceptions;
21
22
23
24
25
26 public class PermissionDenied extends Exception {
27
28 private static final long serialVersionUID = -3948097018322416889L;
29
30 private String accessor;
31 private String entity;
32 private String scope;
33 private String permission;
34
35 public PermissionDenied(String accessor, String message) {
36 super(String.format("Permission denied accessing resource as '%s': %s",
37 accessor, message));
38 this.accessor = accessor;
39 }
40
41 public PermissionDenied(String message) {
42 super(message);
43 }
44
45 public PermissionDenied(String accessor, String entity, String message) {
46 super(String.format(
47 "Permission denied accessing resource '%s' as '%s': %s",
48 entity, accessor, message));
49 this.accessor = accessor;
50 this.entity = entity;
51 }
52
53 public PermissionDenied(String accessor, String entity,
54 String permission, String scope) {
55 super(
56 String.format(
57 "Permission '%s' denied for resource '%s' as '%s' with scope '%s'",
58 permission, entity,
59 accessor, scope));
60 this.accessor = accessor;
61 this.entity = entity;
62 this.scope = scope;
63 this.permission = permission;
64 }
65
66 public String getAccessor() {
67 return accessor;
68 }
69
70 public String getEntity() {
71 return entity;
72 }
73
74 public String getScope() {
75 return scope;
76 }
77
78 public String getPermission() {
79 return permission;
80 }
81 }