01: /*
02: * Copyright 2005-2006 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.core.exceptions;
17:
18: import org.kuali.RiceKeyConstants;
19:
20: /**
21: * This class represents an exception that is thrown when a given user is not authorized to take the given action on the given
22: * target type.
23: */
24: public class AuthorizationException extends RuntimeException {
25: private static final long serialVersionUID = -3874239711783179351L;
26: protected final String userId;
27: protected final String action;
28: protected final String targetType;
29:
30: public AuthorizationException(String userId, String action,
31: String targetType) {
32: this (userId, action, targetType, "user '" + userId
33: + "' is not authorized to take action '" + action
34: + "' on targets of type '" + targetType + "'");
35: }
36:
37: protected AuthorizationException(String userId, String action,
38: String targetType, String message) {
39: super (message);
40:
41: this .userId = userId;
42: this .action = action;
43: this .targetType = targetType;
44: }
45:
46: public String getUserId() {
47: return userId;
48: }
49:
50: public String getAction() {
51: return action;
52: }
53:
54: public String getTargetType() {
55: return targetType;
56: }
57:
58: /**
59: * @return message key used by Struts to select the error message to be displayed
60: */
61: public String getErrorMessageKey() {
62: return RiceKeyConstants.AUTHORIZATION_ERROR_GENERAL;
63: }
64: }
|