com.atlassian.jira.mock
Class MockPermissionManager

java.lang.Object
  extended by com.atlassian.jira.security.DefaultPermissionManager
      extended by com.atlassian.jira.mock.MockPermissionManager
All Implemented Interfaces:
JiraManager, PermissionManager

public class MockPermissionManager
extends DefaultPermissionManager


Field Summary
protected  Collection<JiraPermission> permissions
           
 
Constructor Summary
MockPermissionManager()
           
MockPermissionManager(boolean defaultPermission)
          Creates a PermissionManager implementation where, by default, all permissions are given or denied based on the given value.
 
Method Summary
 boolean hasPermission(int permissionsId, ApplicationUser user)
          Checks to see if this user has the specified permission.
 boolean hasPermission(int permissionId, org.ofbiz.core.entity.GenericValue projectOrIssue, com.atlassian.crowd.embedded.api.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, org.ofbiz.core.entity.GenericValue project, com.atlassian.crowd.embedded.api.User user, boolean issueCreation)
          Does the same as PermissionManager.hasPermission(int,org.ofbiz.core.entity.GenericValue,User) except the entity is a project GenericValue.
 boolean hasPermission(int permissionsId, Issue issue, ApplicationUser user)
          Checks to see if this user has permission to see the specified issue.
 boolean hasPermission(int permissionsId, Issue issue, com.atlassian.crowd.embedded.api.User user)
          Checks to see if this user has permission to see the specified 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, 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, Project project, com.atlassian.crowd.embedded.api.User user)
          Checks whether the specified user has a specified permission within the context of a specified project.
 boolean hasPermission(int permissionsId, Project project, com.atlassian.crowd.embedded.api.User u, boolean issueCreation)
          Checks whether the specified user has a specified permission within the context of a specified project.
 boolean hasPermission(int permissionsId, com.atlassian.crowd.embedded.api.User u)
          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 hasProjects(int permissionId, ApplicationUser user)
          Can this user see at least one project with this permission
 boolean hasProjects(int permissionId, com.atlassian.crowd.embedded.api.User user)
          Can this user see at least one project with this permission
 boolean isDefaultPermission()
           
 void removeGroupPermissions(String group)
          Remove all permissions that have used this group
 void setDefaultPermission(boolean defaultPermission)
           
 
Methods inherited from class com.atlassian.jira.security.DefaultPermissionManager
addPermission, getAllGroups, getAllProjectPermissions, getProjectObjects, getProjectObjects, getProjectPermission, getProjectPermissions, getProjects, getProjects, getProjects, getProjects, getProjects, getProjects, getProjects, hasPermission, hasPermission, hasPermission, hasPermission, hasPermission, hasPermission, hasPermission, hasPermission, hasProjects, isGlobalPermission, removeUserPermissions, removeUserPermissions, setProjectPermissionTypesManager
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

permissions

protected Collection<JiraPermission> permissions
Constructor Detail

MockPermissionManager

public MockPermissionManager()

MockPermissionManager

public MockPermissionManager(boolean defaultPermission)
Creates a PermissionManager implementation where, by default, all permissions are given or denied based on the given value.

Parameters:
defaultPermission - if true, everything is permitted, if false, everything is denied.
Method Detail

isDefaultPermission

public boolean isDefaultPermission()

setDefaultPermission

public void setDefaultPermission(boolean defaultPermission)

removeGroupPermissions

public void removeGroupPermissions(String group)
                            throws RemoveException
Description copied from class: DefaultPermissionManager
Remove all permissions that have used this group

Specified by:
removeGroupPermissions in interface PermissionManager
Overrides:
removeGroupPermissions in class DefaultPermissionManager
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

hasPermission

public boolean hasPermission(int permissionsId,
                             Project project,
                             com.atlassian.crowd.embedded.api.User u,
                             boolean issueCreation)
Description copied from interface: PermissionManager
Checks whether the specified user has a specified permission within the context of a specified project.

Specified by:
hasPermission in interface PermissionManager
Overrides:
hasPermission in class DefaultPermissionManager
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.
u - 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

hasPermission

public boolean hasPermission(int permissionsId,
                             org.ofbiz.core.entity.GenericValue project,
                             com.atlassian.crowd.embedded.api.User user,
                             boolean issueCreation)
Description copied from interface: PermissionManager
Does the same as PermissionManager.hasPermission(int,org.ofbiz.core.entity.GenericValue,User) except the entity is a project GenericValue.

Specified by:
hasPermission in interface PermissionManager
Overrides:
hasPermission in class DefaultPermissionManager
Parameters:
permissionsId - Not a global permission
project - 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

hasPermission

public boolean hasPermission(int permissionsId,
                             com.atlassian.crowd.embedded.api.User u)
Description copied from class: DefaultPermissionManager
Checks 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:
hasPermission in interface PermissionManager
Overrides:
hasPermission in class DefaultPermissionManager
Parameters:
permissionsId - permission id
u - user
Returns:
true if user is granted given permission, false otherwise
See Also:
GlobalPermissionManager.hasPermission(int, User)

hasPermission

public boolean hasPermission(int permissionsId,
                             ApplicationUser user)
Description copied from interface: PermissionManager
Checks 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:
hasPermission in interface PermissionManager
Overrides:
hasPermission in class DefaultPermissionManager
Parameters:
permissionsId - permission id
user - user, can be null - anonymous user
Returns:
true if user is granted given permission, false otherwise
See Also:
GlobalPermissionManager.hasPermission(int, User)

hasPermission

public boolean hasPermission(int permissionId,
                             org.ofbiz.core.entity.GenericValue projectOrIssue,
                             com.atlassian.crowd.embedded.api.User user)
Description copied from class: DefaultPermissionManager
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

Specified by:
hasPermission in interface PermissionManager
Overrides:
hasPermission in class DefaultPermissionManager
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

hasPermission

public boolean hasPermission(int permissionsId,
                             Issue issue,
                             com.atlassian.crowd.embedded.api.User user)
Description copied from interface: PermissionManager
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.

Specified by:
hasPermission in interface PermissionManager
Overrides:
hasPermission in class DefaultPermissionManager
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

hasPermission

public boolean hasPermission(int permissionsId,
                             Issue issue,
                             ApplicationUser user)
Description copied from interface: PermissionManager
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.

Specified by:
hasPermission in interface PermissionManager
Overrides:
hasPermission in class DefaultPermissionManager
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

hasPermission

public boolean hasPermission(int permissionsId,
                             Project project,
                             com.atlassian.crowd.embedded.api.User user)
Description copied from interface: PermissionManager
Checks whether the specified user has a specified permission within the context of a specified project.

Specified by:
hasPermission in interface PermissionManager
Overrides:
hasPermission in class DefaultPermissionManager
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

hasPermission

public boolean hasPermission(int permissionsId,
                             Project project,
                             ApplicationUser user)
Description copied from interface: PermissionManager
Checks whether the specified user has a specified permission within the context of a specified project.

Specified by:
hasPermission in interface PermissionManager
Overrides:
hasPermission in class DefaultPermissionManager
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

hasPermission

public boolean hasPermission(int permissionsId,
                             Project project,
                             ApplicationUser user,
                             boolean issueCreation)
Description copied from interface: PermissionManager
Checks whether the specified user has a specified permission within the context of a specified project.

Specified by:
hasPermission in interface PermissionManager
Overrides:
hasPermission in class DefaultPermissionManager
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

hasProjects

public boolean hasProjects(int permissionId,
                           com.atlassian.crowd.embedded.api.User user)
Description copied from class: DefaultPermissionManager
Can this user see at least one project with this permission

Specified by:
hasProjects in interface PermissionManager
Overrides:
hasProjects in class DefaultPermissionManager
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

hasProjects

public boolean hasProjects(int permissionId,
                           ApplicationUser user)
Description copied from interface: PermissionManager
Can this user see at least one project with this permission

Specified by:
hasProjects in interface PermissionManager
Overrides:
hasProjects in class DefaultPermissionManager
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


Copyright © 2002-2014 Atlassian. All Rights Reserved.