001    /**
002     * Copyright (c) 2000-2010 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.security.permission;
016    
017    /**
018     * @author Brian Wing Shun Chan
019     */
020    public class SimplePermissionChecker extends BasePermissionChecker {
021    
022            public boolean hasOwnerPermission(
023                    long companyId, String name, String primKey, long ownerId,
024                    String actionId) {
025    
026                    return hasPermission(actionId);
027            }
028    
029            public boolean hasPermission(
030                    long groupId, String name, String primKey, String actionId) {
031    
032                    return hasPermission(actionId);
033            }
034    
035            public boolean hasUserPermission(
036                    long groupId, String name, String primKey, String actionId,
037                    boolean checkAdmin) {
038    
039                    return hasPermission(actionId);
040            }
041    
042            public boolean isCommunityAdmin(long groupId) {
043                    return signedIn;
044            }
045    
046            public boolean isCommunityOwner(long groupId) {
047                    return signedIn;
048            }
049    
050            public boolean isCompanyAdmin() {
051                    return signedIn;
052            }
053    
054            public boolean isCompanyAdmin(long companyId) {
055                    return signedIn;
056            }
057    
058            protected boolean hasPermission(String actionId) {
059                    if (signedIn) {
060                            return true;
061                    }
062    
063                    if (actionId.equals(ActionKeys.VIEW)) {
064                            return true;
065                    }
066                    else {
067                            return false;
068                    }
069            }
070    
071    }