001/** 002 * Copyright 2005-2017 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.kew.framework.document.security; 017 018/** 019 * Authorization response for document routing authorization checks 020 * 021 * @see org.kuali.rice.kew.framework.document.security.DocumentTypeAuthorizer 022 */ 023public final class Authorization { 024 /** 025 * Whether the action was authorized 026 */ 027 private final boolean authorized; 028 /** 029 * Authorization or authorization failure reason 030 */ 031 private final String reason; 032 033 /** 034 * Short-hand constructor for authorization without a reason 035 * @param authorized whether the authorization check succeeded 036 */ 037 public Authorization(boolean authorized) { 038 this.authorized = authorized; 039 this.reason = null; 040 } 041 042 /** 043 * Construct authorization response with a reason 044 * @param authorized whether the authorization check succeeded 045 * @param reason reason message 046 */ 047 public Authorization(boolean authorized, String reason) { 048 this.authorized = authorized; 049 this.reason = reason; 050 } 051 052 /** 053 * @return whether authorization succeeded 054 */ 055 public boolean isAuthorized() { 056 return authorized; 057 } 058 059 /** 060 * @return success or failure reason 061 */ 062 public String getReason() { 063 return reason; 064 } 065}