1 /**
2 * Copyright 2005-2015 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
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.rice.kew.framework.document.security;
17
18 /**
19 * Authorization response for document routing authorization checks
20 *
21 * @see org.kuali.rice.kew.framework.document.security.DocumentTypeAuthorizer
22 */
23 public final class Authorization {
24 /**
25 * Whether the action was authorized
26 */
27 private final boolean authorized;
28 /**
29 * Authorization or authorization failure reason
30 */
31 private final String reason;
32
33 /**
34 * Short-hand constructor for authorization without a reason
35 * @param authorized whether the authorization check succeeded
36 */
37 public Authorization(boolean authorized) {
38 this.authorized = authorized;
39 this.reason = null;
40 }
41
42 /**
43 * Construct authorization response with a reason
44 * @param authorized whether the authorization check succeeded
45 * @param reason reason message
46 */
47 public Authorization(boolean authorized, String reason) {
48 this.authorized = authorized;
49 this.reason = reason;
50 }
51
52 /**
53 * @return whether authorization succeeded
54 */
55 public boolean isAuthorized() {
56 return authorized;
57 }
58
59 /**
60 * @return success or failure reason
61 */
62 public String getReason() {
63 return reason;
64 }
65 }