com.atlassian.jira.security
Class AbstractPermissionManager

java.lang.Object
  extended by com.atlassian.jira.security.AbstractPermissionManager
All Implemented Interfaces:
JiraManager, PermissionManager
Direct Known Subclasses:
DefaultPermissionManager

public abstract class AbstractPermissionManager
extends java.lang.Object
implements PermissionManager

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

See Also:
DefaultPermissionManager

Constructor Summary
AbstractPermissionManager()
           
 
Method Summary
 void addPermission(int permissionsId, org.ofbiz.core.entity.GenericValue scheme, java.lang.String parameter, java.lang.String securityType)
          Adds a permission to the system
 java.util.Collection<com.opensymphony.user.Group> getAllGroups(int permissionId, org.ofbiz.core.entity.GenericValue project)
          Retrieve all groups that are used in the permission globally and in the project entity
protected  PermissionSchemeManager getPermissionSchemeManager()
           
protected  ProjectManager getProjectManager()
           
 java.util.Collection<Project> getProjectObjects(int permissionId, com.opensymphony.user.User user)
          Retrieve a list of project objects this user has the permission for
 java.util.Collection<org.ofbiz.core.entity.GenericValue> getProjects(int permissionId, com.opensymphony.user.User user)
          Retrieve a list of projects this user has the permission for
 java.util.Collection<org.ofbiz.core.entity.GenericValue> getProjects(int permissionId, com.opensymphony.user.User user, org.ofbiz.core.entity.GenericValue category)
          Retrieve a list of projects associated with the specified category, that this user has the permissions for
 boolean hasPermission(int permissionsId, org.ofbiz.core.entity.GenericValue projectOrIssue, com.opensymphony.user.User u)
          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 entity, com.opensymphony.user.User u, boolean issueCreation)
          Does the same as PermissionManager.hasPermission(int,org.ofbiz.core.entity.GenericValue,com.opensymphony.user.User) except the entity is a project GenericValue.
 boolean hasPermission(int permissionsId, Issue issue, com.opensymphony.user.User u)
          Does the same as PermissionManager.hasPermission(int,org.ofbiz.core.entity.GenericValue,com.opensymphony.user.User) except the entity is an issue.
 boolean hasPermission(int permissionsId, Project project, com.opensymphony.user.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.opensymphony.user.User user, boolean issueCreation)
          Checks whether the specified user has a specified permission within the context of a specified project.
 boolean hasPermission(int permissionsId, com.opensymphony.user.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
protected  boolean hasProjectPermission(java.lang.Long permissionTypeLong, org.ofbiz.core.entity.GenericValue entity, com.opensymphony.user.User user, boolean issueCreation)
          Return true if the supplied user has the specified permission in the context of the supplied entity
 boolean hasProjects(int permissionId, com.opensymphony.user.User user)
          Can this user see at least one project with this permission
protected  boolean isGlobalPermission(int permissionId)
           
 void removeGroupPermissions(java.lang.String group)
          Remove all permissions that have used this group
 void removeUserPermissions(java.lang.String username)
          Remove all permissions that have used this username
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractPermissionManager

public AbstractPermissionManager()
Method Detail

addPermission

public void addPermission(int permissionsId,
                          org.ofbiz.core.entity.GenericValue scheme,
                          java.lang.String parameter,
                          java.lang.String securityType)
                   throws CreateException
Adds a permission to the system

Specified by:
addPermission in interface PermissionManager
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
Throws:
CreateException

hasPermission

public boolean hasPermission(int permissionsId,
                             com.opensymphony.user.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

Specified by:
hasPermission in interface PermissionManager
Parameters:
permissionsId - permission id
user - user
Returns:
true if user is granted given permission, false otherwise
See Also:
GlobalPermissionManager.hasPermission(int, com.opensymphony.user.User)

hasPermission

public boolean hasPermission(int permissionsId,
                             org.ofbiz.core.entity.GenericValue projectOrIssue,
                             com.opensymphony.user.User u)
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
Parameters:
permissionsId - , not a global permission
projectOrIssue - not null must be Project or Issue
u - 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.opensymphony.user.User u)
Description copied from interface: PermissionManager
Does the same as PermissionManager.hasPermission(int,org.ofbiz.core.entity.GenericValue,com.opensymphony.user.User) except the entity is an 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 defered 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
Parameters:
permissionsId - Not a global permission
issue - Not null.
u - 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.opensymphony.user.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
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,
                             com.opensymphony.user.User 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
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

hasPermission

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

Specified by:
hasPermission in interface PermissionManager
Parameters:
permissionsId - Not a global permission
entity - Not null.
u - 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

hasProjectPermission

protected boolean hasProjectPermission(java.lang.Long permissionTypeLong,
                                       org.ofbiz.core.entity.GenericValue entity,
                                       com.opensymphony.user.User user,
                                       boolean issueCreation)
Return true if the supplied user has the specified permission in the context of the supplied entity

Parameters:
permissionTypeLong - A non-global permission, i.e. a permission that is granted via a context
entity - The entity 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 (passed through the PermissionSchemeManager to SchemeType.hasPermission( org.ofbiz.core.entity.GenericValue, String, com.opensymphony.user.User, boolean))
Returns:
true if the user has the specified permission in the context of the supplied entity

getPermissionSchemeManager

protected PermissionSchemeManager getPermissionSchemeManager()

removeGroupPermissions

public void removeGroupPermissions(java.lang.String group)
                            throws RemoveException
Remove all permissions that have used this group

Specified by:
removeGroupPermissions in interface PermissionManager
Parameters:
group - The name of the group that needs to be removed, must NOT be null and must be a real group
Throws:
RemoveException

removeUserPermissions

public void removeUserPermissions(java.lang.String username)
                           throws RemoveException
Description copied from interface: PermissionManager
Remove all permissions that have used this username

Specified by:
removeUserPermissions in interface PermissionManager
Parameters:
username - username of the user whose permissions are to be removed
Throws:
RemoveException - if permission removal fails

hasProjects

public boolean hasProjects(int permissionId,
                           com.opensymphony.user.User user)
                    throws java.lang.Exception
Can this user see at least one project with this permission

Specified by:
hasProjects in interface PermissionManager
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:
java.lang.Exception

getProjectManager

protected ProjectManager getProjectManager()

getProjects

public java.util.Collection<org.ofbiz.core.entity.GenericValue> getProjects(int permissionId,
                                                                            com.opensymphony.user.User user)
Retrieve a list of projects this user has the permission for

Specified by:
getProjects in interface PermissionManager
Parameters:
permissionId - must NOT be a global permission
user - user
Returns:
a collection of GenericValue objects

getProjectObjects

public java.util.Collection<Project> getProjectObjects(int permissionId,
                                                       com.opensymphony.user.User user)
Description copied from interface: PermissionManager
Retrieve a list of project objects this user has the permission for

Specified by:
getProjectObjects in interface PermissionManager
Parameters:
permissionId - must NOT be a global permission
user - user
Returns:
a collection of Project objects

getProjects

public java.util.Collection<org.ofbiz.core.entity.GenericValue> getProjects(int permissionId,
                                                                            com.opensymphony.user.User user,
                                                                            org.ofbiz.core.entity.GenericValue category)
                                                                     throws org.ofbiz.core.entity.GenericEntityException
Description copied from interface: PermissionManager
Retrieve a list of projects associated with the specified category, that this user has the permissions for

Specified by:
getProjects in interface PermissionManager
Parameters:
permissionId - permission id
user - user
category - GenericValue representing category
Returns:
a collection of GenericValue objects
Throws:
org.ofbiz.core.entity.GenericEntityException

isGlobalPermission

protected boolean isGlobalPermission(int permissionId)

getAllGroups

public java.util.Collection<com.opensymphony.user.Group> getAllGroups(int permissionId,
                                                                      org.ofbiz.core.entity.GenericValue project)
                                                               throws java.lang.Exception
Retrieve all groups that are used in the permission globally and in the project entity

Specified by:
getAllGroups in interface PermissionManager
Parameters:
permissionId - permission id
project - project to retireve groups from
Returns:
a collection of
Throws:
java.lang.Exception - this implementation does not throw any non-runtime exceptions


Copyright © 2002-2010 Atlassian. All Rights Reserved.