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.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 UserBag getUserBag() {
029                    return null;
030            }
031    
032            @Override
033            public boolean hasOwnerPermission(
034                    long companyId, String name, String primKey, long ownerId,
035                    String actionId) {
036    
037                    return hasPermission(actionId);
038            }
039    
040            @Override
041            public boolean hasPermission(
042                    long groupId, String name, String primKey, String actionId) {
043    
044                    return hasPermission(actionId);
045            }
046    
047            @Override
048            public boolean hasUserPermission(
049                    long groupId, String name, String primKey, String actionId,
050                    boolean checkAdmin) {
051    
052                    return hasPermission(actionId);
053            }
054    
055            @Override
056            public boolean isCompanyAdmin() {
057                    return signedIn;
058            }
059    
060            @Override
061            public boolean isCompanyAdmin(long companyId) {
062                    return signedIn;
063            }
064    
065            @Override
066            public boolean isContentReviewer(long companyId, long groupId) {
067                    return signedIn;
068            }
069    
070            @Override
071            public boolean isGroupAdmin(long groupId) {
072                    return signedIn;
073            }
074    
075            @Override
076            public boolean isGroupMember(long groupId) {
077                    return signedIn;
078            }
079    
080            @Override
081            public boolean isGroupOwner(long groupId) {
082                    return signedIn;
083            }
084    
085            @Override
086            public boolean isOrganizationAdmin(long organizationId) {
087                    return signedIn;
088            }
089    
090            @Override
091            public boolean isOrganizationOwner(long organizationId) {
092                    return signedIn;
093            }
094    
095            protected boolean hasPermission(String actionId) {
096                    if (signedIn) {
097                            return true;
098                    }
099    
100                    if (actionId.equals(ActionKeys.VIEW)) {
101                            return true;
102                    }
103                    else {
104                            return false;
105                    }
106            }
107    
108    }