public class

DefaultPermissionManager

extends Object
implements PermissionManager
java.lang.Object
   ↳ com.atlassian.jira.security.DefaultPermissionManager
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

An abstract PermissionManager that implements a lot of the common functionality to all PermissionManagers.

Summary

Public Constructors
DefaultPermissionManager(ProjectPermissionTypesManager projectPermissionTypesManager)
Public Methods
void addPermission(int permissionsId, GenericValue scheme, String parameter, String securityType)
Adds a permission to the system
Collection<Group> getAllGroups(int permissionId, Project project)
Retrieve all groups that are used in the permission globally and in the project.
Collection<ProjectPermission> getAllProjectPermissions()
Collection<Project> getProjectObjects(int permissionId, User user)
Retrieve a list of project objects this user has the permission for
Option<ProjectPermission> getProjectPermission(ProjectPermissionKey permissionKey)
Returns a project permission matching the specified key.
Collection<ProjectPermission> getProjectPermissions(ProjectPermissionCategory category)
Collection<Project> getProjects(int permissionId, User user, ProjectCategory projectCategory)
Returns the list of projects associated with the specified category, that this user has the permissions for.
Collection<GenericValue> getProjects(int permissionId, User user, GenericValue category)
Retrieve a list of projects associated with the specified category, that this user has the permissions for
Collection<Project> getProjects(int permissionId, ApplicationUser user, ProjectCategory projectCategory)
Returns the list of projects associated with the specified category, that this user has the permissions for.
Collection<Project> getProjects(int permissionId, ApplicationUser user)
Retrieve a list of project objects this user has the permission for
Collection<Project> getProjects(ProjectPermissionKey permissionKey, ApplicationUser user, ProjectCategory projectCategory)
Returns the list of projects associated with the specified category, that this user has the permissions for.
Collection<GenericValue> getProjects(int permissionId, User user)
Retrieve a list of projects this user has the permission for
Collection<Project> getProjects(ProjectPermissionKey permissionKey, ApplicationUser user)
Retrieve a list of project objects this user has the permission for
boolean hasPermission(int permissionsId, ApplicationUser user)
Checks to see if this user has the specified permission.
boolean hasPermission(int permissionsId, Project project, User user)
Checks whether the specified user has a specified permission within the context of a specified project.
boolean hasPermission(ProjectPermissionKey permissionsKey, Project project, ApplicationUser user)
Checks whether the specified user has a specified permission within the context of a specified project.
boolean hasPermission(ProjectPermissionKey permissionsKey, Project project, ApplicationUser user, boolean issueCreation)
Checks whether the specified user has a specified permission within the context of a specified project.
boolean hasPermission(int permissionId, GenericValue entity, User user, boolean issueCreation)
Does the same as hasPermission(int, org.ofbiz.core.entity.GenericValue, User) except the entity is a project GenericValue.
boolean hasPermission(int permissionsId, Project project, User user, boolean issueCreation)
Checks whether the specified user has a specified permission within the context of a specified project.
boolean hasPermission(int permissionsId, Project project, ApplicationUser user, boolean issueCreation)
Checks whether the specified user has a specified permission within the context of a specified project.
boolean hasPermission(int permissionsId, User user)
Checks to see if this user has the specified permission
It will check only global permissions as there are no other permissions to check
boolean hasPermission(int permissionsId, Issue issue, User user)
Checks to see if this user has permission to see the specified issue.
boolean hasPermission(ProjectPermissionKey permissionKey, Issue issue, ApplicationUser user)
Checks to see if this user has permission to see the specified issue.
boolean hasPermission(int permissionId, GenericValue projectOrIssue, User user)
Checks to see if this has permission to see the specified entity
Check Permissions scheme(s) if the entity is project
Check Permissions scheme(s) and issue level security scheme(s) if the entity is an issue
boolean hasPermission(int permissionsId, Project project, ApplicationUser user)
Checks whether the specified user has a specified permission within the context of a specified project.
boolean hasPermission(int permissionsId, Issue issue, ApplicationUser user)
Checks to see if this user has permission to see the specified issue.
boolean hasProjects(ProjectPermissionKey permissionKey, ApplicationUser user)
Can this user see at least one project with this permission
boolean hasProjects(int permissionId, User user)
Can this user see at least one project with this permission
boolean hasProjects(int permissionId, ApplicationUser user)
Can this user see at least one project with this permission
void removeGroupPermissions(String group)
Remove all permissions that have used this group
void removeUserPermissions(String username)
Remove all permissions that have used this username
void removeUserPermissions(ApplicationUser user)
Remove all permissions that have been assigned to this user
void setProjectPermissionTypesManager(ProjectPermissionTypesManager projectPermissionTypesManager)
Protected Methods
boolean doEntityPermissionCheck(ProjectPermissionKey permissionKey, GenericValue entity, User user, boolean issueCreation)
Collection<Project> getProjectObjects(ProjectPermissionKey permissionKey, User user)
boolean hasPermission(ProjectPermissionKey permissionKey, Issue issue, User user)
boolean hasPermission(ProjectPermissionKey permissionKey, Project project, User user)
boolean hasPermission(ProjectPermissionKey permissionKey, GenericValue projectOrIssue, User user, boolean issueCreation)
boolean hasPermission(ProjectPermissionKey permissionKey, GenericValue projectOrIssue, User user)
boolean hasPermission(ProjectPermissionKey permissionKey, Project project, User user, boolean issueCreation)
boolean isGlobalPermission(int permissionId)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.jira.security.PermissionManager

Public Constructors

public DefaultPermissionManager (ProjectPermissionTypesManager projectPermissionTypesManager)

Public Methods

public void addPermission (int permissionsId, GenericValue scheme, String parameter, String securityType)

Adds a permission to the system

Parameters
permissionsId Permissions value
scheme If null permission is global otherwise it is added to the scheme
parameter Used for e.g. group name
securityType e.g. GroupDropdown.DESC

public Collection<Group> getAllGroups (int permissionId, Project project)

Retrieve all groups that are used in the permission globally and in the project.

Parameters
permissionId permission id
project project from which to retrieve groups
Returns
  • a collection of Groups

public Collection<ProjectPermission> getAllProjectPermissions ()

public Collection<Project> getProjectObjects (int permissionId, User user)

Retrieve a list of project objects this user has the permission for

Parameters
permissionId must NOT be a global permission
user user
Returns

public Option<ProjectPermission> getProjectPermission (ProjectPermissionKey permissionKey)

Returns a project permission matching the specified key.

Parameters
permissionKey A project permission key.
Returns
  • a project permission for the given permission key. none() if there is no permission with this key.

public Collection<ProjectPermission> getProjectPermissions (ProjectPermissionCategory category)

public Collection<Project> getProjects (int permissionId, User user, ProjectCategory projectCategory)

Returns the list of projects associated with the specified category, that this user has the permissions for.

Parameters
permissionId permission id
user user
projectCategory the ProjectCategory
Returns
  • the list of projects associated with the specified category, that this user has the permissions for.

public Collection<GenericValue> getProjects (int permissionId, User user, GenericValue category)

Retrieve a list of projects associated with the specified category, that this user has the permissions for

Parameters
permissionId permission id
user user
category GenericValue representing category
Returns
  • a collection of GenericValue objects

public Collection<Project> getProjects (int permissionId, ApplicationUser user, ProjectCategory projectCategory)

Returns the list of projects associated with the specified category, that this user has the permissions for.

Parameters
permissionId permission id
user user
projectCategory the ProjectCategory
Returns
  • the list of projects associated with the specified category, that this user has the permissions for.

public Collection<Project> getProjects (int permissionId, ApplicationUser user)

Retrieve a list of project objects this user has the permission for

Parameters
permissionId must NOT be a global permission
user user
Returns

public Collection<Project> getProjects (ProjectPermissionKey permissionKey, ApplicationUser user, ProjectCategory projectCategory)

Returns the list of projects associated with the specified category, that this user has the permissions for.

Parameters
permissionKey permission key
user user
projectCategory the ProjectCategory
Returns
  • the list of projects associated with the specified category, that this user has the permissions for.

public Collection<GenericValue> getProjects (int permissionId, User user)

Retrieve a list of projects this user has the permission for

Parameters
permissionId must NOT be a global permission
user user
Returns
  • a collection of GenericValue objects

public Collection<Project> getProjects (ProjectPermissionKey permissionKey, ApplicationUser user)

Retrieve a list of project objects this user has the permission for

Parameters
permissionKey must NOT be a global permission
user user
Returns

public boolean hasPermission (int permissionsId, ApplicationUser user)

Checks to see if this user has the specified permission. It will check only global permissions as there are no other permissions to check.

Parameters
permissionsId permission id
user user, can be null - anonymous user
Returns
  • true if user is granted given permission, false otherwise

public boolean hasPermission (int permissionsId, Project project, User user)

Checks whether the specified user has a specified permission within the context of a specified project.

Parameters
permissionsId A non-global permission, i.e. a permission that is granted via a project context
project The project that is the context of the permission check.
user The person to perform the permission check for
Returns
  • true if the user has the specified permission in the context of the supplied project

public boolean hasPermission (ProjectPermissionKey permissionsKey, Project project, ApplicationUser user)

Checks whether the specified user has a specified permission within the context of a specified project.

Parameters
permissionsKey A non-global permission, i.e. a permission that is granted via a project context
project The project that is the context of the permission check.
user The person to perform the permission check for
Returns
  • true if the user has the specified permission in the context of the supplied project

public boolean hasPermission (ProjectPermissionKey permissionsKey, Project project, ApplicationUser user, boolean issueCreation)

Checks whether the specified user has a specified permission within the context of a specified project.

Parameters
permissionsKey A non-global permission, i.e. a permission that is granted via a project context
project The project that is the context of the permission check.
user The person to perform the permission check for
issueCreation Whether this permission is being checked during issue creation
Returns
  • true if the user has the specified permission in the context of the supplied project

public boolean hasPermission (int permissionId, GenericValue entity, User user, boolean issueCreation)

Does the same as hasPermission(int, org.ofbiz.core.entity.GenericValue, User) except the entity is a project GenericValue.

Parameters
permissionId Not a global permission
entity Not null.
user User object, possibly null if JIRA is accessed anonymously
issueCreation Whether this permission is being checked during issue creation
Returns
  • True if there are sufficient rights to access the entity supplied

public boolean hasPermission (int permissionsId, Project project, User user, boolean issueCreation)

Checks whether the specified user has a specified permission within the context of a specified project.

Parameters
permissionsId A non-global permission, i.e. a permission that is granted via a project context
project The project that is the context of the permission check.
user The person to perform the permission check for
issueCreation Whether this permission is being checked during issue creation
Returns
  • true if the user has the specified permission in the context of the supplied project

public boolean hasPermission (int permissionsId, Project project, ApplicationUser user, boolean issueCreation)

Checks whether the specified user has a specified permission within the context of a specified project.

Parameters
permissionsId A non-global permission, i.e. a permission that is granted via a project context
project The project that is the context of the permission check.
user The person to perform the permission check for
issueCreation Whether this permission is being checked during issue creation
Returns
  • true if the user has the specified permission in the context of the supplied project

public boolean hasPermission (int permissionsId, User user)

Checks to see if this user has the specified permission
It will check only global permissions as there are no other permissions to check

Parameters
permissionsId permission id
user user
Returns
  • true if user is granted given permission, false otherwise

public boolean hasPermission (int permissionsId, Issue issue, User user)

Checks to see if this user has permission to see the specified issue.

Note that if the issue's generic value is null, it is assumed that the issue is currently being created, and so the permission check call is deferred to the issue's project object, with the issueCreation flag set to true. See JRA-14788 for more info.

Parameters
permissionsId Not a global permission
issue The Issue (cannot be null)
user User object, possibly null if JIRA is accessed anonymously
Returns
  • True if there are sufficient rights to access the entity supplied

public boolean hasPermission (ProjectPermissionKey permissionKey, Issue issue, ApplicationUser user)

Checks to see if this user has permission to see the specified issue.

Note that if the issue's generic value is null, it is assumed that the issue is currently being created, and so the permission check call is deferred to the issue's project object, with the issueCreation flag set to true. See JRA-14788 for more info.

Parameters
permissionKey Not a global permission key
issue The Issue (cannot be null)
user User object, possibly null if JIRA is accessed anonymously
Returns
  • True if there are sufficient rights to access the entity supplied

public boolean hasPermission (int permissionId, GenericValue projectOrIssue, User user)

Checks to see if this has permission to see the specified entity
Check Permissions scheme(s) if the entity is project
Check Permissions scheme(s) and issue level security scheme(s) if the entity is an issue

Parameters
permissionId Not a global permission
projectOrIssue not null must be Project or Issue
user User object, possibly null if JIRA is accessed anonymously
Returns
  • True if there are sufficient rights to access the entity supplied

public boolean hasPermission (int permissionsId, Project project, ApplicationUser user)

Checks whether the specified user has a specified permission within the context of a specified project.

Parameters
permissionsId A non-global permission, i.e. a permission that is granted via a project context
project The project that is the context of the permission check.
user The person to perform the permission check for
Returns
  • true if the user has the specified permission in the context of the supplied project

public boolean hasPermission (int permissionsId, Issue issue, ApplicationUser user)

Checks to see if this user has permission to see the specified issue.

Note that if the issue's generic value is null, it is assumed that the issue is currently being created, and so the permission check call is deferred to the issue's project object, with the issueCreation flag set to true. See JRA-14788 for more info.

Parameters
permissionsId Not a global permission
issue The Issue (cannot be null)
user User object, possibly null if JIRA is accessed anonymously
Returns
  • True if there are sufficient rights to access the entity supplied

public boolean hasProjects (ProjectPermissionKey permissionKey, ApplicationUser user)

Can this user see at least one project with this permission

Parameters
permissionKey must NOT be a global permission
user user being checked
Returns
  • true the given user can see at least one project with the given permission, false otherwise

public boolean hasProjects (int permissionId, User user)

Can this user see at least one project with this permission

Parameters
permissionId must NOT be a global permission
user user
Returns
  • true the given user can see at least one project with the given permission, false otherwise
Throws
IllegalArgumentException if the passed in permission id matches a global permission

public boolean hasProjects (int permissionId, ApplicationUser user)

Can this user see at least one project with this permission

Parameters
permissionId must NOT be a global permission
user user being checked
Returns
  • true the given user can see at least one project with the given permission, false otherwise

public void removeGroupPermissions (String group)

Remove all permissions that have used this group

Parameters
group The name of the group that needs to be removed, must NOT be null and must be a real group

public void removeUserPermissions (String username)

Remove all permissions that have used this username

Parameters
username username of the user whose permissions are to be removed

public void removeUserPermissions (ApplicationUser user)

Remove all permissions that have been assigned to this user

Parameters
user the user whose permissions are to be removed

public void setProjectPermissionTypesManager (ProjectPermissionTypesManager projectPermissionTypesManager)

Protected Methods

protected boolean doEntityPermissionCheck (ProjectPermissionKey permissionKey, GenericValue entity, User user, boolean issueCreation)

protected Collection<Project> getProjectObjects (ProjectPermissionKey permissionKey, User user)

protected boolean hasPermission (ProjectPermissionKey permissionKey, Issue issue, User user)

protected boolean hasPermission (ProjectPermissionKey permissionKey, Project project, User user)

protected boolean hasPermission (ProjectPermissionKey permissionKey, GenericValue projectOrIssue, User user, boolean issueCreation)

protected boolean hasPermission (ProjectPermissionKey permissionKey, GenericValue projectOrIssue, User user)

protected boolean hasPermission (ProjectPermissionKey permissionKey, Project project, User user, boolean issueCreation)

protected boolean isGlobalPermission (int permissionId)