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 isCompanyAdmin() {
052                    return signedIn;
053            }
054    
055            @Override
056            public boolean isCompanyAdmin(long companyId) {
057                    return signedIn;
058            }
059    
060            @Override
061            public boolean isContentReviewer(long companyId, long groupId) {
062                    return signedIn;
063            }
064    
065            @Override
066            public boolean isGroupAdmin(long groupId) {
067                    return signedIn;
068            }
069    
070            @Override
071            public boolean isGroupMember(long groupId) {
072                    return signedIn;
073            }
074    
075            @Override
076            public boolean isGroupOwner(long groupId) {
077                    return signedIn;
078            }
079    
080            @Override
081            public boolean isOrganizationAdmin(long organizationId) {
082                    return signedIn;
083            }
084    
085            @Override
086            public boolean isOrganizationOwner(long organizationId) {
087                    return signedIn;
088            }
089    
090            protected boolean hasPermission(String actionId) {
091                    if (signedIn) {
092                            return true;
093                    }
094    
095                    if (actionId.equals(ActionKeys.VIEW)) {
096                            return true;
097                    }
098                    else {
099                            return false;
100                    }
101            }
102    
103    }