com.atlassian.jira.security
Class AbstractPermissionManager

java.lang.Object
  |
  +--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, test.mock.MockPermissionManager

Constructor Summary
AbstractPermissionManager()
           
 
Method Summary
 void addPermission(int permType, org.ofbiz.core.entity.GenericValue scheme, java.lang.String group)
          Add a permission for a particular project and group
 void addPermission(int permType, org.ofbiz.core.entity.GenericValue scheme, java.lang.String group, java.lang.String type)
           
abstract  void addPermission(JiraPermission perm)
          Add a permission using a JiraPermission object
 java.util.Collection getAllGroups(int permType, org.ofbiz.core.entity.GenericValue entity)
          Get all groups that have this permission type, in this entity and globally
abstract  java.util.Collection getGlobalPermissions(int permType)
           
 java.util.Collection getGroups(int permType)
          Get all the groups that have a particular global permission type
abstract  java.util.Collection getPermissions(int permType, org.ofbiz.core.entity.GenericValue entity)
           
abstract  java.util.Collection getProjectGroups(int permType, org.ofbiz.core.entity.GenericValue entity)
          Get a set of groups with this permission type and project
 java.util.Collection getProjects(int permType, java.util.Collection groups)
          Get a collection of projects which these groups can see (for a given permission)
 java.util.Collection getProjects(int permType, com.opensymphony.module.user.User user)
          Get a collection of projects which a user can see (for a given permission)
abstract  java.util.Collection getUsersWithPermission(int permType, org.ofbiz.core.entity.GenericValue entity)
           
protected  boolean hasAnonymousPermission(int permType, org.ofbiz.core.entity.GenericValue project)
           
protected  boolean hasGlobalAnonymousPermission(int permType)
           
protected  boolean hasGlobalPermission(int permType, java.lang.String group)
           
 boolean hasGroupsPermission(int permType, org.ofbiz.core.entity.GenericValue entity, java.util.Collection groups)
          Check if the list of groups given (as Strings) matches any permissions
 boolean hasPermission(int permType, org.ofbiz.core.entity.GenericValue entity, java.lang.String group)
          Checks if the group has permissions for that project and permission.
abstract  boolean hasPermission(JiraPermission perm)
           
 boolean hasProjects(int permType, java.util.Collection groups)
          Return true if there are any projects which match the given permission and groups
 boolean hasProjects(int permType, com.opensymphony.module.user.User user)
          Return true if there are any projects which match the given permission and user
protected  boolean hasUserGroupPermission(int permType, org.ofbiz.core.entity.GenericValue entity, com.opensymphony.module.user.User user, java.util.Collection groups)
          Private method so that hasUserPerm and hasGroupPerm can share logic
 boolean hasUserPermission(int permType, org.ofbiz.core.entity.GenericValue entity, com.opensymphony.module.user.User user)
          Check whether a user has a permission for a project.
abstract  void removeGroupPermissions(java.lang.String group)
           
 boolean removePermission(int permType, org.ofbiz.core.entity.GenericValue scheme, java.lang.String group)
          Remove a permission from a group in a particular scheme
abstract  boolean removePermission(JiraPermission perm)
          Remove a permission
abstract  void removeSchemePermissions(org.ofbiz.core.entity.GenericValue scheme)
           
 
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 abstract void addPermission(JiraPermission perm)
                            throws CreateException
Description copied from interface: PermissionManager
Add a permission using a JiraPermission object

Specified by:
addPermission in interface PermissionManager
CreateException

removePermission

public abstract boolean removePermission(JiraPermission perm)
                                  throws RemoveException
Description copied from interface: PermissionManager
Remove a permission

Specified by:
removePermission in interface PermissionManager
Returns:
True if the permission was removed, false if not (usually it didn't exist)
RemoveException

getGlobalPermissions

public abstract java.util.Collection getGlobalPermissions(int permType)
Specified by:
getGlobalPermissions in interface PermissionManager

getPermissions

public abstract java.util.Collection getPermissions(int permType,
                                                    org.ofbiz.core.entity.GenericValue entity)
Specified by:
getPermissions in interface PermissionManager

removeSchemePermissions

public abstract void removeSchemePermissions(org.ofbiz.core.entity.GenericValue scheme)
                                      throws RemoveException
Specified by:
removeSchemePermissions in interface PermissionManager
RemoveException

removeGroupPermissions

public abstract void removeGroupPermissions(java.lang.String group)
                                     throws RemoveException
Specified by:
removeGroupPermissions in interface PermissionManager
RemoveException

getProjectGroups

public abstract java.util.Collection getProjectGroups(int permType,
                                                      org.ofbiz.core.entity.GenericValue entity)
                                               throws java.lang.Exception
Description copied from interface: PermissionManager
Get a set of groups with this permission type and project

Specified by:
getProjectGroups in interface PermissionManager
java.lang.Exception

getUsersWithPermission

public abstract java.util.Collection getUsersWithPermission(int permType,
                                                            org.ofbiz.core.entity.GenericValue entity)
                                                     throws java.lang.Exception
Specified by:
getUsersWithPermission in interface PermissionManager
java.lang.Exception

hasPermission

public abstract boolean hasPermission(JiraPermission perm)
Specified by:
hasPermission in interface PermissionManager

addPermission

public void addPermission(int permType,
                          org.ofbiz.core.entity.GenericValue scheme,
                          java.lang.String group)
                   throws CreateException
Description copied from interface: PermissionManager
Add a permission for a particular project and group

Specified by:
addPermission in interface PermissionManager
CreateException

addPermission

public void addPermission(int permType,
                          org.ofbiz.core.entity.GenericValue scheme,
                          java.lang.String group,
                          java.lang.String type)
                   throws CreateException
CreateException

removePermission

public boolean removePermission(int permType,
                                org.ofbiz.core.entity.GenericValue scheme,
                                java.lang.String group)
                         throws RemoveException
Description copied from interface: PermissionManager
Remove a permission from a group in a particular scheme

Specified by:
removePermission in interface PermissionManager
Returns:
True if the permission was removed, false if not (usually it didn't exist)
RemoveException

hasPermission

public boolean hasPermission(int permType,
                             org.ofbiz.core.entity.GenericValue entity,
                             java.lang.String group)
Checks if the group has permissions for that project and permission. As permissions are done at scheme level, if the project is not null then the permission scheme that is associated with that project is retrieved and a check is made to see whether the group has permissions for that scheme and permission. If the project is null then a check will be made to see if there is a global permission for that group and permission

Specified by:
hasPermission in interface PermissionManager
Parameters:
permType -
entity -
group -
Returns:

hasUserPermission

public boolean hasUserPermission(int permType,
                                 org.ofbiz.core.entity.GenericValue entity,
                                 com.opensymphony.module.user.User user)
Check whether a user has a permission for a project. This also checks anyone and global permissions.

Specified by:
hasUserPermission in interface PermissionManager

hasGroupsPermission

public boolean hasGroupsPermission(int permType,
                                   org.ofbiz.core.entity.GenericValue entity,
                                   java.util.Collection groups)
Check if the list of groups given (as Strings) matches any permissions

Specified by:
hasGroupsPermission in interface PermissionManager

hasAnonymousPermission

protected boolean hasAnonymousPermission(int permType,
                                         org.ofbiz.core.entity.GenericValue project)

hasGlobalPermission

protected boolean hasGlobalPermission(int permType,
                                      java.lang.String group)

hasGlobalAnonymousPermission

protected boolean hasGlobalAnonymousPermission(int permType)

getProjects

public java.util.Collection getProjects(int permType,
                                        com.opensymphony.module.user.User user)
                                 throws java.lang.Exception
Get a collection of projects which a user can see (for a given permission)

Specified by:
getProjects in interface PermissionManager
java.lang.Exception

getProjects

public java.util.Collection getProjects(int permType,
                                        java.util.Collection groups)
                                 throws java.lang.Exception
Get a collection of projects which these groups can see (for a given permission)

Specified by:
getProjects in interface PermissionManager
java.lang.Exception

hasProjects

public boolean hasProjects(int permType,
                           com.opensymphony.module.user.User user)
                    throws java.lang.Exception
Return true if there are any projects which match the given permission and user

Specified by:
hasProjects in interface PermissionManager
java.lang.Exception

hasProjects

public boolean hasProjects(int permType,
                           java.util.Collection groups)
                    throws java.lang.Exception
Return true if there are any projects which match the given permission and groups

Specified by:
hasProjects in interface PermissionManager
java.lang.Exception

getGroups

public java.util.Collection getGroups(int permType)
                               throws java.lang.Exception
Get all the groups that have a particular global permission type

Specified by:
getGroups in interface PermissionManager
java.lang.Exception

getAllGroups

public java.util.Collection getAllGroups(int permType,
                                         org.ofbiz.core.entity.GenericValue entity)
                                  throws java.lang.Exception
Get all groups that have this permission type, in this entity and globally

Specified by:
getAllGroups in interface PermissionManager
java.lang.Exception

hasUserGroupPermission

protected boolean hasUserGroupPermission(int permType,
                                         org.ofbiz.core.entity.GenericValue entity,
                                         com.opensymphony.module.user.User user,
                                         java.util.Collection groups)
Private method so that hasUserPerm and hasGroupPerm can share logic



Copyright © 2002-2003 Atlassian. All Rights Reserved.