Liferay 6.1.2-ce-ga3

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:
PermissionChecker, Cloneable

public class AdvancedPermissionChecker
extends BasePermissionChecker


Field Summary
protected  Map<Long,Boolean> companyAdmins
           
protected static 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, Group group, List<Role> roles)
           
 AdvancedPermissionChecker clone()
           
 List<Long> getGuestResourceBlockIds(long companyId, long groupId, String name, String actionId)
           
 ResourceBlockIdsBag getGuestResourceBlockIdsBag(long companyId, long groupId, String name)
           
 PermissionCheckerBag getGuestUserBag()
          Returns the permission checker bag for the guest user.
 List<Long> getOwnerResourceBlockIds(long companyId, long groupId, String name, String actionId)
           
 ResourceBlockIdsBag getOwnerResourceBlockIdsBag(long companyId, long groupId, String name)
           
 List<Long> getResourceBlockIds(long companyId, long groupId, long userId, String name, String actionId)
           
 ResourceBlockIdsBag getResourceBlockIdsBag(long companyId, long groupId, long userId, String name)
           
protected  List<Resource> getResources(long companyId, long groupId, String name, String primKey, String actionId)
          Returns representations of the resource at each scope level.
 long[] getRoleIds(long userId, long groupId)
          Returns the primary keys of the roles the user has within the group.
 PermissionCheckerBag getUserBag(long userId, long groupId)
          Returns the permission checker bag for the user and group.
protected  List<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, String name, String primKey, String actionId)
           
 boolean hasOwnerPermission(long companyId, String name, String primKey, long ownerId, String actionId)
          Returns true if the user is the owner of the resource and has permission to perform the action.
 boolean hasPermission(long groupId, String name, String primKey, String actionId)
          Returns true if the user has permission to perform the action on the resource.
protected  boolean hasPermissionImpl(long groupId, String name, String primKey, String actionId)
           
 boolean hasUserPermission(long groupId, String name, String primKey, String actionId, boolean checkAdmin)
          Returns true if the user has permission to perform the action on the resource without using guest permissions.
protected  boolean hasUserPermissionImpl(long groupId, String name, String primKey, String actionId, boolean checkAdmin)
           
 boolean isCompanyAdmin()
          Returns true if the user is an administrator of their company.
 boolean isCompanyAdmin(long companyId)
          Returns true if the user is an administrator of the company.
protected  boolean isCompanyAdminImpl()
           
protected  boolean isCompanyAdminImpl(long companyId)
           
 boolean isGroupAdmin(long groupId)
          Returns true if the user is an administrator of the group.
protected  boolean isGroupAdminImpl(long groupId)
           
 boolean isGroupMember(long groupId)
          Returns true if the user is a member of the group.
protected  boolean isGroupMemberImpl(long groupId)
           
 boolean isGroupOwner(long groupId)
          Returns true if the user is the owner of the group.
protected  boolean isGroupOwnerImpl(long groupId)
           
 boolean isOrganizationAdmin(long organizationId)
          Returns true if the user is an administrator of the organization.
protected  boolean isOrganizationAdminImpl(long organizationId)
           
 boolean isOrganizationOwner(long organizationId)
          Returns true if the user is an owner of the organization.
protected  boolean isOrganizationOwnerImpl(long organizationId)
           
protected  void logHasUserPermission(long groupId, String name, String primKey, 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, 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 String RESULTS_SEPARATOR
Deprecated. 
See Also:
Constant Field Values

companyAdmins

protected Map<Long,Boolean> companyAdmins
Constructor Detail

AdvancedPermissionChecker

public AdvancedPermissionChecker()
Method Detail

clone

public AdvancedPermissionChecker clone()
Specified by:
clone in interface PermissionChecker
Specified by:
clone in class BasePermissionChecker

getGuestResourceBlockIds

public List<Long> getGuestResourceBlockIds(long companyId,
                                           long groupId,
                                           String name,
                                           String actionId)
Specified by:
getGuestResourceBlockIds in interface PermissionChecker
Overrides:
getGuestResourceBlockIds in class BasePermissionChecker

getGuestResourceBlockIdsBag

public ResourceBlockIdsBag getGuestResourceBlockIdsBag(long companyId,
                                                       long groupId,
                                                       String name)
                                                throws Exception
Throws:
Exception

getGuestUserBag

public PermissionCheckerBag getGuestUserBag()
                                     throws Exception
Returns the permission checker bag for the guest user.

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

getOwnerResourceBlockIds

public List<Long> getOwnerResourceBlockIds(long companyId,
                                           long groupId,
                                           String name,
                                           String actionId)
Specified by:
getOwnerResourceBlockIds in interface PermissionChecker
Overrides:
getOwnerResourceBlockIds in class BasePermissionChecker

getOwnerResourceBlockIdsBag

public ResourceBlockIdsBag getOwnerResourceBlockIdsBag(long companyId,
                                                       long groupId,
                                                       String name)
                                                throws SystemException
Throws:
SystemException

getResourceBlockIds

public List<Long> getResourceBlockIds(long companyId,
                                      long groupId,
                                      long userId,
                                      String name,
                                      String actionId)
Specified by:
getResourceBlockIds in interface PermissionChecker
Overrides:
getResourceBlockIds in class BasePermissionChecker

getResourceBlockIdsBag

public ResourceBlockIdsBag getResourceBlockIdsBag(long companyId,
                                                  long groupId,
                                                  long userId,
                                                  String name)
                                           throws Exception
Throws:
Exception

getRoleIds

public long[] getRoleIds(long userId,
                         long groupId)
Description copied from interface: PermissionChecker
Returns the primary keys of the roles the user has within the group.

Specified by:
getRoleIds in interface PermissionChecker
Overrides:
getRoleIds in class BasePermissionChecker
Parameters:
userId - the primary key of the user
groupId - the primary key of the group
Returns:
the primary keys of the roles the user has within the group

getUserBag

public PermissionCheckerBag getUserBag(long userId,
                                       long groupId)
                                throws 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:
Exception - if a user or group with the primary key could not be found

hasOwnerPermission

public boolean hasOwnerPermission(long companyId,
                                  String name,
                                  String primKey,
                                  long ownerId,
                                  String actionId)
Description copied from interface: PermissionChecker
Returns true if the user is the owner of the resource and has permission to perform the action.

Parameters:
companyId - the primary key of the user's company
name - the resource's name, which can be either a class name or a portlet ID
primKey - the primary key of the resource
ownerId - the primary key of the resource's owner
actionId - the action ID
Returns:
true if the user is the owner of the resource and has permission to perform the action; false otherwise

hasPermission

public boolean hasPermission(long groupId,
                             String name,
                             String primKey,
                             String actionId)
Description copied from interface: PermissionChecker
Returns true if the user has permission to perform the action on the resource.

Parameters:
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 - the action ID
Returns:
true if the user has permission to perform the action on the resource; false otherwise

hasUserPermission

public boolean hasUserPermission(long groupId,
                                 String name,
                                 String primKey,
                                 String actionId,
                                 boolean checkAdmin)
Description copied from interface: PermissionChecker
Returns true if the user has permission to perform the action on the resource without using guest permissions.

Parameters:
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 - the action ID
checkAdmin - whether to use permissions gained from administrator roles
Returns:
true if the user has permission to perform the action on the resource without using guest permissions; false otherwise

isCompanyAdmin

public boolean isCompanyAdmin()
Description copied from interface: PermissionChecker
Returns true if the user is an administrator of their company.

Returns:
true if the user is an administrator of their company; false otherwise

isCompanyAdmin

public boolean isCompanyAdmin(long companyId)
Description copied from interface: PermissionChecker
Returns true if the user is an administrator of the company.

Parameters:
companyId - the primary key of the company
Returns:
true if the user is an administrator of the company; false otherwise

isGroupAdmin

public boolean isGroupAdmin(long groupId)
Description copied from interface: PermissionChecker
Returns true if the user is an administrator of the group.

Parameters:
groupId - the primary key of the group
Returns:
true if the user is an administrator of the group; false otherwise

isGroupMember

public boolean isGroupMember(long groupId)
Description copied from interface: PermissionChecker
Returns true if the user is a member of the group.

Parameters:
groupId - the primary key of the group
Returns:
true if the user is a member of the group; false otherwise

isGroupOwner

public boolean isGroupOwner(long groupId)
Description copied from interface: PermissionChecker
Returns true if the user is the owner of the group.

Parameters:
groupId - the primary key of the group
Returns:
true if the user is the owner of the group; false otherwise

isOrganizationAdmin

public boolean isOrganizationAdmin(long organizationId)
Description copied from interface: PermissionChecker
Returns true if the user is an administrator of the organization.

Parameters:
organizationId - the primary key of the organization
Returns:
true if the user is an administrator of the organization; false otherwise

isOrganizationOwner

public boolean isOrganizationOwner(long organizationId)
Description copied from interface: PermissionChecker
Returns true if the user is an owner of the organization.

Parameters:
organizationId - the primary key of the organization
Returns:
true if the user is an owner of the organization; false otherwise

addTeamRoles

protected void addTeamRoles(long userId,
                            Group group,
                            List<Role> roles)
                     throws Exception
Throws:
Exception

getResources

protected List<Resource> getResources(long companyId,
                                      long groupId,
                                      String name,
                                      String primKey,
                                      String actionId)
                               throws 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:
Exception - if an exception occurred

getUserOrgs

protected List<Organization> getUserOrgs(long userId)
                                  throws 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:
Exception - if a user with the primary key could not be found

hasGuestPermission

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

hasPermissionImpl

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

hasUserPermissionImpl

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

isCompanyAdminImpl

protected boolean isCompanyAdminImpl()
                              throws Exception
Throws:
Exception

isCompanyAdminImpl

protected boolean isCompanyAdminImpl(long companyId)
                              throws Exception
Throws:
Exception

isGroupAdminImpl

protected boolean isGroupAdminImpl(long groupId)
                            throws Exception
Throws:
Exception

isGroupMemberImpl

protected boolean isGroupMemberImpl(long groupId)
                             throws Exception
Throws:
Exception

isGroupOwnerImpl

protected boolean isGroupOwnerImpl(long groupId)
                            throws Exception
Throws:
Exception

isOrganizationAdminImpl

protected boolean isOrganizationAdminImpl(long organizationId)
                                   throws Exception
Throws:
Exception

isOrganizationOwnerImpl

protected boolean isOrganizationOwnerImpl(long organizationId)
                                   throws Exception
Throws:
Exception

logHasUserPermission

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

Liferay 6.1.2-ce-ga3