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 | |
public class AuthorizationException extends KualiException { |
29 | |
private static final long serialVersionUID = -3874239711783179351L; |
30 | |
protected final String userId; |
31 | |
protected final String action; |
32 | |
protected final String targetType; |
33 | |
protected final Map<String, Object> additionalDetails; |
34 | |
|
35 | |
public AuthorizationException(String userId, String action, String targetType) { |
36 | 0 | this(userId, action, targetType, Collections.<String, Object>emptyMap()); |
37 | 0 | } |
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
public AuthorizationException(String userId, String action, String targetType, Map<String, Object> additionalDetails) { |
48 | 0 | this(userId, action, targetType, |
49 | |
"user '" + userId + "' is not authorized to take action '" + action + "' on targets of type '" + targetType + "'" + (additionalDetails != null && !additionalDetails.isEmpty() ? " Additional Details : " + additionalDetails : ""), |
50 | |
additionalDetails); |
51 | 0 | } |
52 | |
|
53 | |
|
54 | |
public AuthorizationException(String userId, String action, String targetType, String message, Map<String, Object> additionalDetails) { |
55 | 0 | super(message); |
56 | |
|
57 | 0 | this.userId = userId; |
58 | 0 | this.action = action; |
59 | 0 | this.targetType = targetType; |
60 | 0 | this.additionalDetails = additionalDetails; |
61 | 0 | } |
62 | |
|
63 | |
public Map<String, Object> getAdditionalDetails() { |
64 | 0 | return additionalDetails; |
65 | |
} |
66 | |
|
67 | |
public String getUserId() { |
68 | 0 | return userId; |
69 | |
} |
70 | |
|
71 | |
public String getAction() { |
72 | 0 | return action; |
73 | |
} |
74 | |
|
75 | |
public String getTargetType() { |
76 | 0 | return targetType; |
77 | |
} |
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
public String getErrorMessageKey() { |
83 | 0 | return RiceKeyConstants.AUTHORIZATION_ERROR_GENERAL; |
84 | |
} |
85 | |
} |