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