001    /**
002     * Copyright (c) 2000-present 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            @Deprecated
030            public static void check(
031                            PermissionChecker permissionChecker, long userId,
032                            long organizationId, long locationId, String actionId)
033                    throws PrincipalException {
034    
035                    check(
036                            permissionChecker, userId, new long[] {organizationId, locationId},
037                            actionId);
038            }
039    
040            public static void check(
041                            PermissionChecker permissionChecker, long userId,
042                            long[] organizationIds, String actionId)
043                    throws PrincipalException {
044    
045                    getUserPermission().check(
046                            permissionChecker, userId, organizationIds, actionId);
047            }
048    
049            public static void check(
050                            PermissionChecker permissionChecker, long userId, String actionId)
051                    throws PrincipalException {
052    
053                    getUserPermission().check(permissionChecker, userId, actionId);
054            }
055    
056            /**
057             * @deprecated As of 6.1.0
058             */
059            @Deprecated
060            public static boolean contains(
061                    PermissionChecker permissionChecker, long userId, long organizationId,
062                    long locationId, String actionId) {
063    
064                    return contains(
065                            permissionChecker, userId, new long[] {organizationId, locationId},
066                            actionId);
067            }
068    
069            public static boolean contains(
070                    PermissionChecker permissionChecker, long userId,
071                    long[] organizationIds, String actionId) {
072    
073                    return getUserPermission().contains(
074                            permissionChecker, userId, organizationIds, actionId);
075            }
076    
077            public static boolean contains(
078                    PermissionChecker permissionChecker, long userId, String actionId) {
079    
080                    return getUserPermission().contains(
081                            permissionChecker, userId, actionId);
082            }
083    
084            public static UserPermission getUserPermission() {
085                    PortalRuntimePermission.checkGetBeanProperty(UserPermissionUtil.class);
086    
087                    return _userPermission;
088            }
089    
090            public void setUserPermission(UserPermission userPermission) {
091                    PortalRuntimePermission.checkSetBeanProperty(getClass());
092    
093                    _userPermission = userPermission;
094            }
095    
096            private static UserPermission _userPermission;
097    
098    }