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