001/** 002 * Copyright 2005-2016 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 018import org.kuali.rice.kew.api.action.ActionType; 019 020/** 021 * Encapsulates the type of authorization check the DocumentTypeAuthorizer is making. 022 * @since 2.1.3 023 */ 024public class AuthorizableAction { 025 /** 026 * The authorization check type: either a document action, initiation, 027 * or super user approve action request check 028 */ 029 public static enum CheckType { 030 ACTION, 031 INITIATION, 032 SU_APPROVE_ACTION_REQUEST 033 } 034 035 /** 036 * The document ActionType if application (CheckType.ACTION) 037 */ 038 public final ActionType actionType; 039 /** 040 * The CheckType 041 */ 042 public final CheckType type; 043 044 /** 045 * Construct AuthorizableAction for a document action 046 * @param actionType the document action type 047 */ 048 public AuthorizableAction(ActionType actionType) { 049 this(CheckType.ACTION, actionType); 050 } 051 052 /** 053 * Construct AuthorizableAction for non-action CheckType 054 * @param checkType 055 */ 056 public AuthorizableAction(CheckType checkType) { 057 this(checkType, null); 058 } 059 060 public AuthorizableAction(CheckType checkType, ActionType actionType) { 061 if (checkType == null) { 062 throw new IllegalArgumentException("CheckType must not be null"); 063 } 064 // if we have specified an action check without an action type 065 // or a non-action check with an action type 066 // this is an illegal combination 067 if ((checkType == CheckType.ACTION) == (actionType == null)) { 068 throw new IllegalArgumentException("ActionType must be specified with ACTION CheckType"); 069 } 070 this.type = checkType; 071 this.actionType = actionType; 072 } 073}