1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.exception;
17
18 import org.kuali.rice.core.api.exception.KualiException;
19 import org.kuali.rice.core.api.util.RiceKeyConstants;
20
21 import java.util.Collections;
22 import java.util.Map;
23
24
25
26
27
28
29
30 public class AuthorizationException extends KualiException {
31 private static final long serialVersionUID = -3874239711783179351L;
32
33 protected final String userId;
34 protected final String action;
35 protected final String targetType;
36 protected final Map<String, Object> additionalDetails;
37
38 public AuthorizationException(String userId, String action, String targetType) {
39 this(userId, action, targetType, Collections.<String, Object>emptyMap());
40 }
41
42
43
44
45
46
47
48
49
50
51 public AuthorizationException(String userId, String action, String targetType,
52 Map<String, Object> additionalDetails) {
53 this(userId, action, targetType, "user '" + userId + "' is not authorized to take action '" + action
54 + "' on targets of type '" + targetType + "'"
55 + (additionalDetails != null && !additionalDetails.isEmpty() ?
56 " Additional Details : " + additionalDetails : ""), additionalDetails);
57 }
58
59
60
61
62 public AuthorizationException(String userId, String action, String targetType, String message,
63 Map<String, Object> additionalDetails) {
64 super(message);
65
66 this.userId = userId;
67 this.action = action;
68 this.targetType = targetType;
69 this.additionalDetails = additionalDetails;
70 }
71
72 public String getUserId() {
73 return userId;
74 }
75
76 public String getAction() {
77 return action;
78 }
79
80 public String getTargetType() {
81 return targetType;
82 }
83
84 public Map<String, Object> getAdditionalDetails() {
85 return additionalDetails;
86 }
87
88
89
90
91
92 @Deprecated
93 public String getErrorMessageKey() {
94 return RiceKeyConstants.AUTHORIZATION_ERROR_GENERAL;
95 }
96 }