com.atlassian.jira.security
Class DefaultGlobalPermissionManager

java.lang.Object
  extended by com.atlassian.jira.security.DefaultGlobalPermissionManager
All Implemented Interfaces:
Startable, GlobalPermissionManager

public class DefaultGlobalPermissionManager
extends Object
implements GlobalPermissionManager, Startable


Constructor Summary
DefaultGlobalPermissionManager(com.atlassian.event.api.EventPublisher eventPublisher, com.atlassian.crowd.embedded.api.CrowdService crowdService)
           
 
Method Summary
 boolean addPermission(int permissionId, String group)
          Adds a global permission
 Collection<String> getGroupNames(int permissionId)
          Retrieve all the group names with this permission.
 Collection<Group> getGroups(int permissionId)
          Retrieve all the groups with this permission
 Collection<com.atlassian.crowd.embedded.api.Group> getGroupsWithPermission(int permissionId)
          Retrieve all the groups with this permission.
 Collection<JiraPermission> getPermissions(int permissionType)
          Retrieve all the global permissions of a particular type
 boolean hasPermission(int permissionId)
          Check if a global anonymous permission exists
 boolean hasPermission(int permissionId, com.atlassian.crowd.embedded.api.User u)
          Check if a global permission for one of the users groups exists
 boolean hasPermission(int permissionType, User u)
          Check if a global permission for one of the users groups exists.
protected  boolean hasPermission(JiraPermission jiraPermission)
           
 void onClearCache(ClearCacheEvent event)
           
 boolean removePermission(int permissionId, String group)
          Removes a global permission
 boolean removePermissions(String group)
          Remove a global permissions that the group passed in
 void start()
          This method wil be called after the plugin system is fully initialised and all components added to the dependency injection framework.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultGlobalPermissionManager

public DefaultGlobalPermissionManager(com.atlassian.event.api.EventPublisher eventPublisher,
                                      com.atlassian.crowd.embedded.api.CrowdService crowdService)
Method Detail

start

public void start()
           throws Exception
Description copied from interface: Startable
This method wil be called after the plugin system is fully initialised and all components added to the dependency injection framework.

Specified by:
start in interface Startable
Throws:
Exception - Allows implementations to throw an Exception.

onClearCache

@EventListener
public void onClearCache(ClearCacheEvent event)

addPermission

public boolean addPermission(int permissionId,
                             String group)
                      throws CreateException
Adds a global permission

Specified by:
addPermission in interface GlobalPermissionManager
Parameters:
permissionId - must be a global permission type
group - can be null if it is anyone permission
Returns:
True if the permission was added
Throws:
CreateException

getPermissions

public Collection<JiraPermission> getPermissions(int permissionType)
Description copied from interface: GlobalPermissionManager
Retrieve all the global permissions of a particular type

Specified by:
getPermissions in interface GlobalPermissionManager
Parameters:
permissionType - must be a global permission
Returns:
Collection of JiraPermission, must never return null

removePermission

public boolean removePermission(int permissionId,
                                String group)
                         throws RemoveException
Removes a global permission

Specified by:
removePermission in interface GlobalPermissionManager
Parameters:
permissionId - must be a global permission type
group - can be null if it is anyone permission
Returns:
True if the permission was removed, false if not (usually it didn't exist)
Throws:
RemoveException

removePermissions

public boolean removePermissions(String group)
                          throws RemoveException
Remove a global permissions that the group passed in

Specified by:
removePermissions in interface GlobalPermissionManager
Parameters:
group - must NOT be null and the group must exist
Returns:
True all the permissions are removed
Throws:
RemoveException - if the permission removal fails

hasPermission

public boolean hasPermission(int permissionId)
Check if a global anonymous permission exists

Specified by:
hasPermission in interface GlobalPermissionManager
Parameters:
permissionId - must be global permission
Returns:
true the anonymous user has the permission of given type, false otherwise
See Also:
GlobalPermissionManager.hasPermission(int, User)

hasPermission

public boolean hasPermission(int permissionId,
                             com.atlassian.crowd.embedded.api.User u)
Check if a global permission for one of the users groups exists

Specified by:
hasPermission in interface GlobalPermissionManager
Parameters:
permissionId - must be a global permission
u - must not be null
Returns:
true if the given user has the permission of given type, otherwise false
See Also:
GlobalPermissionManager.hasPermission(int), PermissionManager.hasPermission(int, User)

getGroups

public Collection<Group> getGroups(int permissionId)
Retrieve all the groups with this permission

Specified by:
getGroups in interface GlobalPermissionManager
Parameters:
permissionId - must be a global permission
Returns:
a collection of Group objects, never null

getGroupsWithPermission

public Collection<com.atlassian.crowd.embedded.api.Group> getGroupsWithPermission(int permissionId)
Description copied from interface: GlobalPermissionManager
Retrieve all the groups with this permission. Only groups directly associated with the permission will be returned.

Specified by:
getGroupsWithPermission in interface GlobalPermissionManager
Parameters:
permissionId - must be a global permission
Returns:
a Collection of Group's, will never be null.

getGroupNames

public Collection<String> getGroupNames(int permissionId)
Description copied from interface: GlobalPermissionManager
Retrieve all the group names with this permission. Only group names directly associated with the permission will be returned.

Specified by:
getGroupNames in interface GlobalPermissionManager
Parameters:
permissionId - must be a global permission
Returns:
a Collection of String, group names, will never be null.

hasPermission

protected boolean hasPermission(JiraPermission jiraPermission)

hasPermission

public boolean hasPermission(int permissionType,
                             User u)
Description copied from interface: GlobalPermissionManager
Check if a global permission for one of the users groups exists.

If the permission type is Permissions.ADMINISTER and the lookup is false then the same query will be executed for the Permissions.SYSTEM_ADMIN permission type, since it is implied that having a Permissions.SYSTEM_ADMIN permission grants Permissions.ADMINISTER rights.

Note: Use GlobalPermissionManager.hasPermission(int) method is you do not have the user object, i.e. user is anonymous.

If you are using this method directly, consider using PermissionManager.hasPermission(int, User) instead as it handles logged in and anonymous users as well.

Specified by:
hasPermission in interface GlobalPermissionManager
Parameters:
permissionType - must be a global permission
u - must not be null
Returns:
true if the given user has the permission of given type, otherwise false
See Also:
GlobalPermissionManager.hasPermission(int), PermissionManager.hasPermission(int, User)


Copyright © 2002-2011 Atlassian. All Rights Reserved.