com.liferay.portal.security.permission
Class AdvancedPermissionChecker

java.lang.Object
  extended by com.liferay.portal.security.permission.BasePermissionChecker
      extended by com.liferay.portal.security.permission.AdvancedPermissionChecker
All Implemented Interfaces:
com.liferay.portal.security.permission.PermissionChecker, java.lang.Cloneable

public class AdvancedPermissionChecker
extends BasePermissionChecker

Author:
Charles May, Brian Wing Shun Chan, Raymond Augé, Wesley Gong, Connor McKay

Field Summary
protected  java.util.Map<java.lang.Long,java.lang.Boolean> companyAdmins
           
protected static java.lang.String RESULTS_SEPARATOR
          Deprecated.  
 
Fields inherited from class com.liferay.portal.security.permission.BasePermissionChecker
checkGuest, defaultUserId, omniadmin, ownerRole, signedIn, user
 
Fields inherited from interface com.liferay.portal.security.permission.PermissionChecker
DEFAULT_ROLE_IDS
 
Constructor Summary
AdvancedPermissionChecker()
           
 
Method Summary
protected  void addTeamRoles(long userId, com.liferay.portal.model.Group group, java.util.List<com.liferay.portal.model.Role> roles)
           
 AdvancedPermissionChecker clone()
           
 java.util.List<java.lang.Long> getGuestResourceBlockIds(long companyId, long groupId, java.lang.String name, java.lang.String actionId)
           
 com.liferay.portal.security.permission.ResourceBlockIdsBag getGuestResourceBlockIdsBag(long companyId, long groupId, java.lang.String name)
           
 com.liferay.portal.security.permission.PermissionCheckerBag getGuestUserBag()
          Returns the permission checker bag for the guest user.
 java.util.List<java.lang.Long> getOwnerResourceBlockIds(long companyId, long groupId, java.lang.String name, java.lang.String actionId)
           
 com.liferay.portal.security.permission.ResourceBlockIdsBag getOwnerResourceBlockIdsBag(long companyId, long groupId, java.lang.String name)
           
 java.util.List<java.lang.Long> getResourceBlockIds(long companyId, long groupId, long userId, java.lang.String name, java.lang.String actionId)
           
 com.liferay.portal.security.permission.ResourceBlockIdsBag getResourceBlockIdsBag(long companyId, long groupId, long userId, java.lang.String name)
           
protected  java.util.List<com.liferay.portal.model.Resource> getResources(long companyId, long groupId, java.lang.String name, java.lang.String primKey, java.lang.String actionId)
          Returns representations of the resource at each scope level.
 long[] getRoleIds(long userId, long groupId)
           
 com.liferay.portal.security.permission.PermissionCheckerBag getUserBag(long userId, long groupId)
          Returns the permission checker bag for the user and group.
protected  java.util.List<com.liferay.portal.model.Organization> getUserOrgs(long userId)
          Returns all of the organizations that the user is a member of, including their parent organizations.
protected  boolean hasGuestPermission(long groupId, java.lang.String name, java.lang.String primKey, java.lang.String actionId)
           
 boolean hasOwnerPermission(long companyId, java.lang.String name, java.lang.String primKey, long ownerId, java.lang.String actionId)
           
 boolean hasPermission(long groupId, java.lang.String name, java.lang.String primKey, java.lang.String actionId)
           
protected  boolean hasPermissionImpl(long groupId, java.lang.String name, java.lang.String primKey, java.lang.String actionId)
           
 boolean hasUserPermission(long groupId, java.lang.String name, java.lang.String primKey, java.lang.String actionId, boolean checkAdmin)
           
protected  boolean hasUserPermissionImpl(long groupId, java.lang.String name, java.lang.String primKey, java.lang.String actionId, boolean checkAdmin)
           
 boolean isCompanyAdmin()
           
 boolean isCompanyAdmin(long companyId)
           
protected  boolean isCompanyAdminImpl()
           
protected  boolean isCompanyAdminImpl(long companyId)
           
 boolean isGroupAdmin(long groupId)
           
protected  boolean isGroupAdminImpl(long groupId)
           
 boolean isGroupOwner(long groupId)
           
protected  boolean isGroupOwnerImpl(long groupId)
           
protected  void logHasUserPermission(long groupId, java.lang.String name, java.lang.String primKey, java.lang.String actionId, org.apache.commons.lang.time.StopWatch stopWatch, int block)
           
 
Methods inherited from class com.liferay.portal.security.permission.BasePermissionChecker
getCompanyId, getOwnerRoleId, getUserId, hasOwnerPermission, hasPermission, init, isCheckGuest, isCommunityAdmin, isCommunityOwner, isOmniadmin, isSignedIn, resetValues, setCheckGuest, setValues
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESULTS_SEPARATOR

protected static final java.lang.String RESULTS_SEPARATOR
Deprecated. 
See Also:
Constant Field Values

companyAdmins

protected java.util.Map<java.lang.Long,java.lang.Boolean> companyAdmins
Constructor Detail

AdvancedPermissionChecker

public AdvancedPermissionChecker()
Method Detail

clone

public AdvancedPermissionChecker clone()
Specified by:
clone in interface com.liferay.portal.security.permission.PermissionChecker
Specified by:
clone in class BasePermissionChecker

getRoleIds

public long[] getRoleIds(long userId,
                         long groupId)
Specified by:
getRoleIds in interface com.liferay.portal.security.permission.PermissionChecker
Overrides:
getRoleIds in class BasePermissionChecker

getGuestResourceBlockIds

public java.util.List<java.lang.Long> getGuestResourceBlockIds(long companyId,
                                                               long groupId,
                                                               java.lang.String name,
                                                               java.lang.String actionId)
Specified by:
getGuestResourceBlockIds in interface com.liferay.portal.security.permission.PermissionChecker
Overrides:
getGuestResourceBlockIds in class BasePermissionChecker

getGuestResourceBlockIdsBag

public com.liferay.portal.security.permission.ResourceBlockIdsBag getGuestResourceBlockIdsBag(long companyId,
                                                                                              long groupId,
                                                                                              java.lang.String name)
                                                                                       throws java.lang.Exception
Throws:
java.lang.Exception

getGuestUserBag

public com.liferay.portal.security.permission.PermissionCheckerBag getGuestUserBag()
                                                                            throws java.lang.Exception
Returns the permission checker bag for the guest user.

Returns:
the permission checker bag for the guest user
Throws:
java.lang.Exception - if an exception occurred

getOwnerResourceBlockIds

public java.util.List<java.lang.Long> getOwnerResourceBlockIds(long companyId,
                                                               long groupId,
                                                               java.lang.String name,
                                                               java.lang.String actionId)
Specified by:
getOwnerResourceBlockIds in interface com.liferay.portal.security.permission.PermissionChecker
Overrides:
getOwnerResourceBlockIds in class BasePermissionChecker

getOwnerResourceBlockIdsBag

public com.liferay.portal.security.permission.ResourceBlockIdsBag getOwnerResourceBlockIdsBag(long companyId,
                                                                                              long groupId,
                                                                                              java.lang.String name)
                                                                                       throws com.liferay.portal.kernel.exception.SystemException
Throws:
com.liferay.portal.kernel.exception.SystemException

getResourceBlockIds

public java.util.List<java.lang.Long> getResourceBlockIds(long companyId,
                                                          long groupId,
                                                          long userId,
                                                          java.lang.String name,
                                                          java.lang.String actionId)
Specified by:
getResourceBlockIds in interface com.liferay.portal.security.permission.PermissionChecker
Overrides:
getResourceBlockIds in class BasePermissionChecker

getResourceBlockIdsBag

public com.liferay.portal.security.permission.ResourceBlockIdsBag getResourceBlockIdsBag(long companyId,
                                                                                         long groupId,
                                                                                         long userId,
                                                                                         java.lang.String name)
                                                                                  throws java.lang.Exception
Throws:
java.lang.Exception

getUserBag

public com.liferay.portal.security.permission.PermissionCheckerBag getUserBag(long userId,
                                                                              long groupId)
                                                                       throws java.lang.Exception
Returns the permission checker bag for the user and group. Users can have different roles and permissions in different groups.

Parameters:
userId - the primary key of the user
groupId - the primary key of the group
Returns:
the permission checker bag for the user and group
Throws:
java.lang.Exception - if a user or group with the primary key could not be found

hasOwnerPermission

public boolean hasOwnerPermission(long companyId,
                                  java.lang.String name,
                                  java.lang.String primKey,
                                  long ownerId,
                                  java.lang.String actionId)

hasPermission

public boolean hasPermission(long groupId,
                             java.lang.String name,
                             java.lang.String primKey,
                             java.lang.String actionId)

hasUserPermission

public boolean hasUserPermission(long groupId,
                                 java.lang.String name,
                                 java.lang.String primKey,
                                 java.lang.String actionId,
                                 boolean checkAdmin)

isCompanyAdmin

public boolean isCompanyAdmin()

isCompanyAdmin

public boolean isCompanyAdmin(long companyId)

isGroupAdmin

public boolean isGroupAdmin(long groupId)

isGroupOwner

public boolean isGroupOwner(long groupId)

addTeamRoles

protected void addTeamRoles(long userId,
                            com.liferay.portal.model.Group group,
                            java.util.List<com.liferay.portal.model.Role> roles)
                     throws java.lang.Exception
Throws:
java.lang.Exception

getResources

protected java.util.List<com.liferay.portal.model.Resource> getResources(long companyId,
                                                                         long groupId,
                                                                         java.lang.String name,
                                                                         java.lang.String primKey,
                                                                         java.lang.String actionId)
                                                                  throws java.lang.Exception
Returns representations of the resource at each scope level.

For example, if the class name and primary key of a blog entry were passed to this method, it would return a resource for the blog entry itself (individual scope), a resource representing all blog entries within its group (group scope), a resource standing for all blog entries within a group the user has a suitable role in (group-template scope), and a resource signifying all blog entries within the company (company scope).

Parameters:
companyId - the primary key of the company
groupId - the primary key of the group containing the resource
name - the resource's name, which can be either a class name or a portlet ID
primKey - the primary key of the resource
actionId - unused
Returns:
representations of the resource at each scope level
Throws:
java.lang.Exception - if an exception occurred

getUserOrgs

protected java.util.List<com.liferay.portal.model.Organization> getUserOrgs(long userId)
                                                                     throws java.lang.Exception
Returns all of the organizations that the user is a member of, including their parent organizations.

Parameters:
userId - the primary key of the user
Returns:
all of the organizations that the user is a member of, including their parent organizations
Throws:
java.lang.Exception - if a user with the primary key could not be found

hasGuestPermission

protected boolean hasGuestPermission(long groupId,
                                     java.lang.String name,
                                     java.lang.String primKey,
                                     java.lang.String actionId)
                              throws java.lang.Exception
Throws:
java.lang.Exception

hasPermissionImpl

protected boolean hasPermissionImpl(long groupId,
                                    java.lang.String name,
                                    java.lang.String primKey,
                                    java.lang.String actionId)

hasUserPermissionImpl

protected boolean hasUserPermissionImpl(long groupId,
                                        java.lang.String name,
                                        java.lang.String primKey,
                                        java.lang.String actionId,
                                        boolean checkAdmin)
                                 throws java.lang.Exception
Throws:
java.lang.Exception

isCompanyAdminImpl

protected boolean isCompanyAdminImpl()
                              throws java.lang.Exception
Throws:
java.lang.Exception

isCompanyAdminImpl

protected boolean isCompanyAdminImpl(long companyId)
                              throws java.lang.Exception
Throws:
java.lang.Exception

isGroupAdminImpl

protected boolean isGroupAdminImpl(long groupId)
                            throws java.lang.Exception
Throws:
java.lang.Exception

isGroupOwnerImpl

protected boolean isGroupOwnerImpl(long groupId)
                            throws java.lang.Exception
Throws:
java.lang.Exception

logHasUserPermission

protected void logHasUserPermission(long groupId,
                                    java.lang.String name,
                                    java.lang.String primKey,
                                    java.lang.String actionId,
                                    org.apache.commons.lang.time.StopWatch stopWatch,
                                    int block)