001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.permission;
016    
017    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
018    import com.liferay.portal.security.auth.PrincipalException;
019    import com.liferay.portal.security.permission.PermissionChecker;
020    
021    /**
022     * @author Brian Wing Shun Chan
023     */
024    public class UserPermissionUtil {
025    
026            /**
027             * @deprecated As of 6.1.0
028             */
029            public static void check(
030                            PermissionChecker permissionChecker, long userId,
031                            long organizationId, long locationId, String actionId)
032                    throws PrincipalException {
033    
034                    check(
035                            permissionChecker, userId, new long[] {organizationId, locationId},
036                            actionId);
037            }
038    
039            public static void check(
040                            PermissionChecker permissionChecker, long userId,
041                            long[] organizationIds, String actionId)
042                    throws PrincipalException {
043    
044                    getUserPermission().check(
045                            permissionChecker, userId, organizationIds, actionId);
046            }
047    
048            public static void check(
049                            PermissionChecker permissionChecker, long userId, String actionId)
050                    throws PrincipalException {
051    
052                    getUserPermission().check(permissionChecker, userId, actionId);
053            }
054    
055            /**
056             * @deprecated As of 6.1.0
057             */
058            public static boolean contains(
059                    PermissionChecker permissionChecker, long userId, long organizationId,
060                    long locationId, String actionId) {
061    
062                    return contains(
063                            permissionChecker, userId, new long[] {organizationId, locationId},
064                            actionId);
065            }
066    
067            public static boolean contains(
068                    PermissionChecker permissionChecker, long userId,
069                    long[] organizationIds, String actionId) {
070    
071                    return getUserPermission().contains(
072                            permissionChecker, userId, organizationIds, actionId);
073            }
074    
075            public static boolean contains(
076                    PermissionChecker permissionChecker, long userId, String actionId) {
077    
078                    return getUserPermission().contains(
079                            permissionChecker, userId, actionId);
080            }
081    
082            public static UserPermission getUserPermission() {
083                    PortalRuntimePermission.checkGetBeanProperty(UserPermissionUtil.class);
084    
085                    return _userPermission;
086            }
087    
088            public void setUserPermission(UserPermission userPermission) {
089                    PortalRuntimePermission.checkSetBeanProperty(getClass());
090    
091                    _userPermission = userPermission;
092            }
093    
094            private static UserPermission _userPermission;
095    
096    }