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.security.permission;
016    
017    /**
018     * @author Brian Wing Shun Chan
019     */
020    public class SimplePermissionChecker extends BasePermissionChecker {
021    
022            @Override
023            public SimplePermissionChecker clone() {
024                    return new SimplePermissionChecker();
025            }
026    
027            @Override
028            public boolean hasOwnerPermission(
029                    long companyId, String name, String primKey, long ownerId,
030                    String actionId) {
031    
032                    return hasPermission(actionId);
033            }
034    
035            @Override
036            public boolean hasPermission(
037                    long groupId, String name, String primKey, String actionId) {
038    
039                    return hasPermission(actionId);
040            }
041    
042            @Override
043            public boolean hasUserPermission(
044                    long groupId, String name, String primKey, String actionId,
045                    boolean checkAdmin) {
046    
047                    return hasPermission(actionId);
048            }
049    
050            @Override
051            public boolean isCompanyAdmin() {
052                    return signedIn;
053            }
054    
055            @Override
056            public boolean isCompanyAdmin(long companyId) {
057                    return signedIn;
058            }
059    
060            @Override
061            public boolean isGroupAdmin(long groupId) {
062                    return signedIn;
063            }
064    
065            @Override
066            public boolean isGroupMember(long groupId) {
067                    return signedIn;
068            }
069    
070            @Override
071            public boolean isGroupOwner(long groupId) {
072                    return signedIn;
073            }
074    
075            @Override
076            public boolean isOrganizationAdmin(long organizationId) {
077                    return signedIn;
078            }
079    
080            @Override
081            public boolean isOrganizationOwner(long organizationId) {
082                    return signedIn;
083            }
084    
085            protected boolean hasPermission(String actionId) {
086                    if (signedIn) {
087                            return true;
088                    }
089    
090                    if (actionId.equals(ActionKeys.VIEW)) {
091                            return true;
092                    }
093                    else {
094                            return false;
095                    }
096            }
097    
098    }