View Javadoc

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  import org.kuali.rice.kew.api.action.ActionType;
19  
20  /**
21   * Encapsulates the type of authorization check the DocumentTypeAuthorizer is making.
22   * @since 2.1.3
23   */
24  public class AuthorizableAction {
25      /**
26       * The authorization check type: either a document action, initiation,
27       * or super user approve action request check
28       */
29      public static enum CheckType {
30          ACTION,
31          INITIATION,
32          SU_APPROVE_ACTION_REQUEST
33      }
34  
35      /**
36       * The document ActionType if application (CheckType.ACTION)
37       */
38      public final ActionType actionType;
39      /**
40       * The CheckType
41       */
42      public final CheckType type;
43  
44      /**
45       * Construct AuthorizableAction for a document action
46       * @param actionType the document action type
47       */
48      public AuthorizableAction(ActionType actionType) {
49          this(CheckType.ACTION, actionType);
50      }
51  
52      /**
53       * Construct AuthorizableAction for non-action CheckType
54       * @param checkType
55       */
56      public AuthorizableAction(CheckType checkType) {
57          this(checkType, null);
58      }
59  
60      public AuthorizableAction(CheckType checkType, ActionType actionType) {
61          if (checkType == null) {
62              throw new IllegalArgumentException("CheckType must not be null");
63          }
64          // if we have specified an action check without an action type
65          // or a non-action check with an action type
66          // this is an illegal combination
67          if ((checkType == CheckType.ACTION) == (actionType == null)) {
68              throw new IllegalArgumentException("ActionType must be specified with ACTION CheckType");
69          }
70          this.type = checkType;
71          this.actionType = actionType;
72      }
73  }