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.kernel.service.permission;
016    
017    import com.liferay.portal.kernel.security.auth.PrincipalException;
018    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
019    import com.liferay.portal.kernel.security.permission.PermissionChecker;
020    
021    /**
022     * @author Brian Wing Shun Chan
023     */
024    public class UserPermissionUtil {
025    
026            public static void check(
027                            PermissionChecker permissionChecker, long userId,
028                            long[] organizationIds, String actionId)
029                    throws PrincipalException {
030    
031                    getUserPermission().check(
032                            permissionChecker, userId, organizationIds, actionId);
033            }
034    
035            public static void check(
036                            PermissionChecker permissionChecker, long userId, String actionId)
037                    throws PrincipalException {
038    
039                    getUserPermission().check(permissionChecker, userId, actionId);
040            }
041    
042            public static boolean contains(
043                    PermissionChecker permissionChecker, long userId,
044                    long[] organizationIds, String actionId) {
045    
046                    return getUserPermission().contains(
047                            permissionChecker, userId, organizationIds, actionId);
048            }
049    
050            public static boolean contains(
051                    PermissionChecker permissionChecker, long userId, String actionId) {
052    
053                    return getUserPermission().contains(
054                            permissionChecker, userId, actionId);
055            }
056    
057            public static UserPermission getUserPermission() {
058                    PortalRuntimePermission.checkGetBeanProperty(UserPermissionUtil.class);
059    
060                    return _userPermission;
061            }
062    
063            public void setUserPermission(UserPermission userPermission) {
064                    PortalRuntimePermission.checkSetBeanProperty(getClass());
065    
066                    _userPermission = userPermission;
067            }
068    
069            private static UserPermission _userPermission;
070    
071    }