public interface

GlobalPermissionManager

com.atlassian.jira.security.GlobalPermissionManager
Known Indirect Subclasses

Class Overview

Use this manager to add/remove or check the following global permissions.

Global permissions are:

For all other project specific permissions use PermissionManager.

To check programmatically if a permission is global use isGlobalPermission(int).

Summary

Public Methods
boolean addPermission(int permissionType, String group)
Grants a user group a global permission.
Collection<String> getGroupNames(int permissionId)
Retrieve all the group names with this permission.
Collection<Group> getGroupsWithPermission(int permissionId)
Retrieve all the groups with this permission.
Collection<JiraPermission> getPermissions(int permissionType)
Retrieve a list of user groups which have been granted a specified permission.
boolean hasPermission(int permissionType, ApplicationUser user)
Check if a global permission for one of the users groups exists.
boolean hasPermission(int permissionType, User user)
This method is deprecated. Use hasPermission(int, ApplicationUser) instead. Since v6.0.
boolean hasPermission(int permissionType)
Check if a global permission is granted for an anonymous user.
boolean removePermission(int permissionType, String group)
Revokes a global permission for a user group
boolean removePermissions(String group)
Revoke all global permissions for a user group.

Public Methods

public boolean addPermission (int permissionType, String group)

Grants a user group a global permission.

Parameters
permissionType the global permission.
group the name of the group. Null means "anyone" group. The JIRA use permission cannot be granted to anyone.
Returns
  • true if the permission was added
Throws
CreateException if the permission creation fails

public Collection<String> getGroupNames (int permissionId)

Retrieve all the group names with this permission. Only group names directly associated with the permission will be returned.

Parameters
permissionId must be a global permission
Returns
  • a Collection of String, group names, will never be null.

public Collection<Group> getGroupsWithPermission (int permissionId)

Retrieve all the groups with this permission. Only groups directly associated with the permission will be returned.

Parameters
permissionId must be a global permission
Returns
  • a Collection of Group's, will never be null.

public Collection<JiraPermission> getPermissions (int permissionType)

Retrieve a list of user groups which have been granted a specified permission. The returned JiraPermission contains a reference to the user group. getScheme() is always NULL, because Global permission are not configured using schemes. getType() will always return "group", because global permissions can only be granted to groups.

Parameters
permissionType The permission. Must be a global permission.
Returns

public boolean hasPermission (int permissionType, ApplicationUser user)

Check if a global permission for one of the users groups exists.

If the permission type is ADMINISTER and the lookup is false then the same query will be executed for the SYSTEM_ADMIN permission type, since it is implied that having a SYSTEM_ADMIN permission grants ADMINISTER rights.

Note: Use hasPermission(int) method is you do not have the user object, i.e. user is anonymous.

If you are using this method directly, consider using hasPermission(int, User) instead as it handles logged in and anonymous users as well.

Parameters
permissionType must be a global permission
user must not be null
Returns
  • true if the given user has the permission of given type, otherwise false

public boolean hasPermission (int permissionType, User user)

This method is deprecated.
Use hasPermission(int, ApplicationUser) instead. Since v6.0.

Check if a global permission for one of the users groups exists.

If the permission type is ADMINISTER and the lookup is false then the same query will be executed for the SYSTEM_ADMIN permission type, since it is implied that having a SYSTEM_ADMIN permission grants ADMINISTER rights.

Note: Use hasPermission(int) method is you do not have the user object, i.e. user is anonymous.

If you are using this method directly, consider using hasPermission(int, User) instead as it handles logged in and anonymous users as well.

Parameters
permissionType must be a global permission
user must not be null
Returns
  • true if the given user has the permission of given type, otherwise false

public boolean hasPermission (int permissionType)

Check if a global permission is granted for an anonymous user.

If the permission is ADMINISTER and the lookup is false then the same query will be executed for the SYSTEM_ADMIN permission type, since it is implied that having a SYSTEM_ADMIN permission grants ADMINISTER rights.

Note: Use hasPermission(int, User) method is you have the user object, i.e. user is not anonymous.

If you are using this method directly, consider using hasPermission(int, User) instead as it handles logged in and anonymous users as well.

Parameters
permissionType must be global permission
Returns
  • true the anonymous user has the permission of given type, false otherwise

public boolean removePermission (int permissionType, String group)

Revokes a global permission for a user group

Parameters
permissionType the global permission.
group the group name. NULL means the anyone group.
Returns
  • true if the permission was revoked, false if not (e.g. the group does not have this permission)
Throws
RemoveException if the permission removal fails

public boolean removePermissions (String group)

Revoke all global permissions for a user group.

Parameters
group cannot NOT be null and the group must exist.
Returns
  • true, if this group does not have any global permissions
Throws
RemoveException if the permission removal fails