Class DefaultPermissionManager
- All Implemented Interfaces:
PermissionManager
- Direct Known Subclasses:
MockPermissionManager,WorkflowBasedPermissionManager
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultPermissionManager(ProjectPermissionTypesManager projectPermissionTypesManager, ProjectPermissionOverrideDescriptorCache projectPermissionOverrideDescriptorCache, ScopesRequestCacheDelegate scopesRequestCacheDelegate) -
Method Summary
Modifier and TypeMethodDescriptionvoidFlushes any cached project permissions for all users.Collection<com.atlassian.crowd.embedded.api.Group> getAllGroups(int permissionId, Project project) Retrieve all groups that are used in the permission globally and in the project.protected Collection<Project> getArchivedProjectObjects(ProjectPermissionKey permissionKey, ApplicationUser user) getArchivedProjects(ProjectPermissionKey permissionKey, ApplicationUser user) Retrieve a list of archived project objects this user has the permission forprotected Collection<Project> getProjectObjects(ProjectPermissionKey permissionKey, ApplicationUser user) io.atlassian.fugue.Option<ProjectPermission> getProjectPermission(ProjectPermissionKey permissionKey) Returns a project permission matching the specified key.getProjects(int permissionId, ApplicationUser user, ProjectCategory projectCategory) getProjects(ProjectPermissionKey permissionKey, ApplicationUser user) Retrieve a list of project objects this user has the permission forgetProjects(ProjectPermissionKey permissionKey, ApplicationUser user, ProjectCategory projectCategory) Returns the list of projects associated with the specified category, that this user has the permissions for.booleanhasPermission(int permissionsId, Issue issue, ApplicationUser user) Checks to see if this user has permission to see the specified issue.booleanhasPermission(int permissionsId, Project project, ApplicationUser user) Checks whether the specified user has a specified permission within the context of a specified project.booleanhasPermission(int permissionsId, Project project, ApplicationUser user, boolean issueCreation) Checks whether the specified user has a specified permission within the context of a specified project.booleanhasPermission(int permissionsId, ApplicationUser user) Checks to see if this user has the specified permission.booleanhasPermission(ProjectPermissionKey permissionKey, Issue issue, ApplicationUser user) Checks to see if this user has permission to see the specified issue.booleanhasPermission(ProjectPermissionKey permissionKey, Issue issue, ApplicationUser user, Status status) Checks to see if this user has the given permission to the specified issue if the issue was in the given status.booleanhasPermission(ProjectPermissionKey permissionKey, Issue issue, ApplicationUser user, com.opensymphony.workflow.loader.ActionDescriptor actionDescriptor) Checks to see if this user has the given permission to the specified issue after the given workflow transition takes effect.booleanhasPermission(ProjectPermissionKey permissionKey, Project project, ApplicationUser user) Checks whether the specified user has a specified permission within the context of a specified project.booleanhasPermission(ProjectPermissionKey permissionKey, Project project, ApplicationUser user, boolean issueCreation) Checks whether the specified user has a specified permission within the context of a specified project.booleanhasProjects(int permissionId, ApplicationUser user) Can this user see at least one project with this permissionbooleanhasProjects(ProjectPermissionKey permissionKey, ApplicationUser user) Can this user see at least one project with this permissionhasProjectWidePermission(ProjectPermissionKey permissionKey, Project project, ApplicationUser user) Checks whether a user has a particular permission in the given project.protected booleanisGlobalPermission(int permissionId) voidremoveGroupPermissions(String group) Remove all permissions that have used this groupvoidRemove all permissions that have been assigned to this userstatic booleanserviceAccountCanAccessProject(ProjectPermissionKey permissionKey, Issue issue, ServiceAccountApplicationUser user) static booleanserviceAccountCanAccessProject(ProjectPermissionKey permissionKey, Project project, ServiceAccountApplicationUser user) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.atlassian.jira.security.PermissionManager
hasPublicAccess
-
Constructor Details
-
DefaultPermissionManager
public DefaultPermissionManager(ProjectPermissionTypesManager projectPermissionTypesManager, ProjectPermissionOverrideDescriptorCache projectPermissionOverrideDescriptorCache, ScopesRequestCacheDelegate scopesRequestCacheDelegate)
-
-
Method Details
-
getAllProjectPermissions
- Specified by:
getAllProjectPermissionsin interfacePermissionManager- Returns:
- all project permissions.
-
getProjectPermissions
public Collection<ProjectPermission> getProjectPermissions(@Nonnull ProjectPermissionCategory category) - Specified by:
getProjectPermissionsin interfacePermissionManager- Parameters:
category- project permission category.- Returns:
- all project permissions of the specified category.
-
getProjectPermission
public io.atlassian.fugue.Option<ProjectPermission> getProjectPermission(@Nonnull ProjectPermissionKey permissionKey) Description copied from interface:PermissionManagerReturns a project permission matching the specified key.- Specified by:
getProjectPermissionin interfacePermissionManager- Parameters:
permissionKey- A project permission key.- Returns:
- a project permission for the given permission key.
Option.none()if there is no permission with this key.
-
hasPermission
Description copied from interface:PermissionManagerChecks to see if this user has the specified permission. It will check only global permissions as there are no other permissions to check.- Specified by:
hasPermissionin interfacePermissionManager- Parameters:
permissionsId- permission iduser- user, can be null - anonymous user- Returns:
- true if user is granted given permission, false otherwise
- See Also:
-
hasPermission
public boolean hasPermission(@Nonnull ProjectPermissionKey permissionKey, @Nonnull Issue issue, @Nullable ApplicationUser user) Description copied from interface:PermissionManagerChecks 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.
- Specified by:
hasPermissionin interfacePermissionManager- Parameters:
permissionKey- Not a global permission keyissue- 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
-
hasPermission
public boolean hasPermission(@Nonnull ProjectPermissionKey permissionKey, @Nonnull Issue issue, @Nullable ApplicationUser user, @Nullable com.opensymphony.workflow.loader.ActionDescriptor actionDescriptor) Description copied from interface:PermissionManagerChecks to see if this user has the given permission to the specified issue after the given workflow transition takes effect.- Specified by:
hasPermissionin interfacePermissionManager- Parameters:
permissionKey- The project permission key.issue- The Issue (cannot be null)user- User object, possibly null if JIRA is accessed anonymouslyactionDescriptor- Represents the current workflow transition- Returns:
- True if there are sufficient rights to access the entity supplied
-
hasPermission
public boolean hasPermission(@Nonnull ProjectPermissionKey permissionKey, @Nonnull Issue issue, @Nullable ApplicationUser user, @Nonnull Status status) Description copied from interface:PermissionManagerChecks to see if this user has the given permission to the specified issue if the issue was in the given status.This method is useful during a workflow transition to check what the permissions will be in the new status, or (after the status is updated in the Issue object) to check what the permission would have been in the old status.
- Specified by:
hasPermissionin interfacePermissionManager- Parameters:
permissionKey- The project permission key.issue- The Issue (cannot be null)user- User object, possibly null if JIRA is accessed anonymouslystatus- Represents the state we are checking permissions against- Returns:
- True if there are sufficient rights to access the entity supplied
-
hasPermission
Description copied from interface:PermissionManagerChecks 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.
- Specified by:
hasPermissionin interfacePermissionManager- Parameters:
permissionsId- Not a global permissionissue- 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
-
hasPermission
public boolean hasPermission(@Nonnull ProjectPermissionKey permissionKey, @Nonnull Project project, @Nullable ApplicationUser user) Description copied from interface:PermissionManagerChecks whether the specified user has a specified permission within the context of a specified project.- Specified by:
hasPermissionin interfacePermissionManager- Parameters:
permissionKey- A non-global permission, i.e. a permission that is granted via a project contextproject- 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
- See Also:
-
hasPermission
Description copied from interface:PermissionManagerChecks whether the specified user has a specified permission within the context of a specified project.- Specified by:
hasPermissionin interfacePermissionManager- Parameters:
permissionsId- A non-global permission, i.e. a permission that is granted via a project contextproject- 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
-
hasProjectWidePermission
@Nonnull public ProjectWidePermission hasProjectWidePermission(@Nonnull ProjectPermissionKey permissionKey, @Nonnull Project project, @Nullable ApplicationUser user) Description copied from interface:PermissionManagerChecks whether a user has a particular permission in the given project.This method returns a tri-state enum in order to convey information about permissions that are granted on a per-issue basis.
- ALL_ISSUES : this user has the given permission for all issues in this project
- NO_ISSUES : this user definitely does not have the given permission for any issues in this project
- ISSUE_SPECIFIC : the user may have this permission on some issues, but not others
ISSUE_SPECIFIC, it may be that there are no issues for which the user has the permission granted.- Specified by:
hasProjectWidePermissionin interfacePermissionManager- Parameters:
permissionKey- A project permissionproject- The project that is the context of the permission check.user- The person to perform the permission check for (null means anonymous)- Returns:
ALL_ISSUES,NO_ISSUES, orISSUE_SPECIFIC- See Also:
-
hasPermission
public boolean hasPermission(int permissionsId, Project project, ApplicationUser user, boolean issueCreation) Description copied from interface:PermissionManagerChecks whether the specified user has a specified permission within the context of a specified project.- Specified by:
hasPermissionin interfacePermissionManager- Parameters:
permissionsId- A non-global permission, i.e. a permission that is granted via a project contextproject- The project that is the context of the permission check.user- The person to perform the permission check forissueCreation- 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
-
hasPermission
public boolean hasPermission(@Nonnull ProjectPermissionKey permissionKey, @Nonnull Project project, @Nullable ApplicationUser user, boolean issueCreation) Description copied from interface:PermissionManagerChecks whether the specified user has a specified permission within the context of a specified project.- Specified by:
hasPermissionin interfacePermissionManager- Parameters:
permissionKey- A non-global permission, i.e. a permission that is granted via a project contextproject- The project that is the context of the permission check.user- The person to perform the permission check forissueCreation- 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
-
serviceAccountCanAccessProject
public static boolean serviceAccountCanAccessProject(ProjectPermissionKey permissionKey, Project project, ServiceAccountApplicationUser user) -
serviceAccountCanAccessProject
public static boolean serviceAccountCanAccessProject(ProjectPermissionKey permissionKey, Issue issue, ServiceAccountApplicationUser user) -
removeGroupPermissions
Remove all permissions that have used this group- Specified by:
removeGroupPermissionsin interfacePermissionManager- Parameters:
group- The name of the group that needs to be removed, must NOT be null and must be a real group- Throws:
RemoveException- if permission removal fails
-
removeUserPermissions
Description copied from interface:PermissionManagerRemove all permissions that have been assigned to this user- Specified by:
removeUserPermissionsin interfacePermissionManager- Parameters:
user- the user whose permissions are to be removed- Throws:
RemoveException
-
hasProjects
Description copied from interface:PermissionManagerCan this user see at least one project with this permission- Specified by:
hasProjectsin interfacePermissionManager- Parameters:
permissionId- must NOT be a global permissionuser- user being checked- Returns:
- true the given user can see at least one project with the given permission, false otherwise
-
hasProjects
public boolean hasProjects(@Nonnull ProjectPermissionKey permissionKey, @Nullable ApplicationUser user) Description copied from interface:PermissionManagerCan this user see at least one project with this permission- Specified by:
hasProjectsin interfacePermissionManager- Parameters:
permissionKey- must NOT be a global permissionuser- user being checked- Returns:
- true the given user can see at least one project with the given permission, false otherwise
-
getProjects
public Collection<Project> getProjects(@Nonnull ProjectPermissionKey permissionKey, ApplicationUser user) Description copied from interface:PermissionManagerRetrieve a list of project objects this user has the permission for- Specified by:
getProjectsin interfacePermissionManager- Parameters:
permissionKey- must NOT be a global permissionuser- user- Returns:
- a collection of
Projectobjects
-
getProjectObjects
protected Collection<Project> getProjectObjects(ProjectPermissionKey permissionKey, ApplicationUser user) -
getProjects
public Collection<Project> getProjects(int permissionId, ApplicationUser user, ProjectCategory projectCategory) -
getProjects
public Collection<Project> getProjects(@Nonnull ProjectPermissionKey permissionKey, @Nullable ApplicationUser user, @Nullable ProjectCategory projectCategory) Description copied from interface:PermissionManagerReturns the list of projects associated with the specified category, that this user has the permissions for.- Specified by:
getProjectsin interfacePermissionManager- Parameters:
permissionKey- permission keyuser- userprojectCategory- the ProjectCategory - null means find projects with no category.- Returns:
- the list of projects associated with the specified category, that this user has the permissions for.
-
getArchivedProjects
public Collection<Project> getArchivedProjects(@Nonnull ProjectPermissionKey permissionKey, ApplicationUser user) Description copied from interface:PermissionManagerRetrieve a list of archived project objects this user has the permission for- Specified by:
getArchivedProjectsin interfacePermissionManager- Parameters:
permissionKey- must NOT be a global permissionuser- user- Returns:
- a collection of
Projectobjects
-
getArchivedProjectObjects
protected Collection<Project> getArchivedProjectObjects(ProjectPermissionKey permissionKey, ApplicationUser user) -
flushCache
public void flushCache()Description copied from interface:PermissionManagerFlushes any cached project permissions for all users.- Specified by:
flushCachein interfacePermissionManager
-
isGlobalPermission
protected boolean isGlobalPermission(int permissionId) -
getAllGroups
public Collection<com.atlassian.crowd.embedded.api.Group> getAllGroups(int permissionId, Project project) Description copied from interface:PermissionManagerRetrieve all groups that are used in the permission globally and in the project.- Specified by:
getAllGroupsin interfacePermissionManager- Parameters:
permissionId- permission idproject- project from which to retrieve groups- Returns:
- a collection of Groups
-