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            public boolean hasOwnerPermission(
028                    long companyId, String name, String primKey, long ownerId,
029                    String actionId) {
030    
031                    return hasPermission(actionId);
032            }
033    
034            public boolean hasPermission(
035                    long groupId, String name, String primKey, String actionId) {
036    
037                    return hasPermission(actionId);
038            }
039    
040            public boolean hasUserPermission(
041                    long groupId, String name, String primKey, String actionId,
042                    boolean checkAdmin) {
043    
044                    return hasPermission(actionId);
045            }
046    
047            public boolean isCompanyAdmin() {
048                    return signedIn;
049            }
050    
051            public boolean isCompanyAdmin(long companyId) {
052                    return signedIn;
053            }
054    
055            public boolean isGroupAdmin(long groupId) {
056                    return signedIn;
057            }
058    
059            public boolean isGroupMember(long groupId) {
060                    return signedIn;
061            }
062    
063            public boolean isGroupOwner(long groupId) {
064                    return signedIn;
065            }
066    
067            public boolean isOrganizationAdmin(long organizationId) {
068                    return signedIn;
069            }
070    
071            public boolean isOrganizationOwner(long organizationId) {
072                    return signedIn;
073            }
074    
075            protected boolean hasPermission(String actionId) {
076                    if (signedIn) {
077                            return true;
078                    }
079    
080                    if (actionId.equals(ActionKeys.VIEW)) {
081                            return true;
082                    }
083                    else {
084                            return false;
085                    }
086            }
087    
088    }