1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.service.permission;
24  
25  import com.liferay.portal.security.auth.PrincipalException;
26  import com.liferay.portal.security.permission.PermissionChecker;
27  
28  /**
29   * <a href="UserPermissionUtil.java.html"><b><i>View Source</i></b></a>
30   *
31   * @author Brian Wing Shun Chan
32   */
33  public class UserPermissionUtil {
34  
35      public static void check(
36              PermissionChecker permissionChecker, long userId, String actionId)
37          throws PrincipalException {
38  
39          getUserPermission().check(permissionChecker, userId, actionId);
40      }
41  
42      /**
43       * @deprecated
44       */
45      public static void check(
46              PermissionChecker permissionChecker, long userId,
47              long organizationId, long locationId, String actionId)
48          throws PrincipalException {
49  
50          check(
51              permissionChecker, userId, new long[] {organizationId, locationId},
52              actionId);
53      }
54  
55      public static void check(
56              PermissionChecker permissionChecker, long userId,
57              long[] organizationIds, String actionId)
58          throws PrincipalException {
59  
60          getUserPermission().check(
61              permissionChecker, userId, organizationIds, actionId);
62      }
63  
64      public static boolean contains(
65          PermissionChecker permissionChecker, long userId, String actionId) {
66  
67          return getUserPermission().contains(
68              permissionChecker, userId, actionId);
69      }
70  
71      /**
72       * @deprecated
73       */
74      public static boolean contains(
75          PermissionChecker permissionChecker, long userId, long organizationId,
76          long locationId, String actionId) {
77  
78          return contains(
79              permissionChecker, userId, new long[] {organizationId, locationId},
80              actionId);
81      }
82  
83      public static boolean contains(
84          PermissionChecker permissionChecker, long userId,
85          long[] organizationIds, String actionId) {
86  
87          return getUserPermission().contains(
88              permissionChecker, userId, organizationIds, actionId);
89      }
90  
91      public static UserPermission getUserPermission() {
92          return _userPermission;
93      }
94  
95      public void setUserPermission(UserPermission userPermission) {
96          _userPermission = userPermission;
97      }
98  
99      private static UserPermission _userPermission;
100 
101 }