View Javadoc
1   /**
2    * Copyright 2005-2016 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.krad.uif.view;
17  
18  import java.io.Serializable;
19  import java.util.HashMap;
20  import java.util.Map;
21  
22  /**
23   * Provides cache objects for KIM authorization during a single request
24   *
25   * @author Kuali Rice Team (rice.collab@kuali.org)
26   */
27  public class RequestAuthorizationCache implements Serializable {
28      private static final long serialVersionUID = 4773874972787299349L;
29  
30      private Map<String, Boolean> permissionResultCache;
31  
32      public RequestAuthorizationCache() {
33          permissionResultCache = new HashMap<String, Boolean>();
34      }
35  
36      /**
37       * Map that can be used to cache results of permission checks for a request
38       *
39       * @return
40       */
41      public Map<String, Boolean> getPermissionResultCache() {
42          return permissionResultCache;
43      }
44  
45      public boolean hasPermissionResult(String resultKey) {
46          return permissionResultCache.containsKey(resultKey);
47      }
48  
49      public Boolean getPermissionResult(String resultKey) {
50          Boolean result = null;
51  
52          if (hasPermissionResult(resultKey)) {
53              result = Boolean.valueOf(permissionResultCache.get(resultKey));
54          }
55  
56          return result;
57      }
58  
59      public void addPermissionResult(String resultKey, boolean result) {
60          permissionResultCache.put(resultKey, Boolean.valueOf(result));
61      }
62  }