com.atlassian.jira.security
Class DefaultGlobalPermissionManager

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

public class DefaultGlobalPermissionManager
extends Object
implements GlobalPermissionManager


Constructor Summary
DefaultGlobalPermissionManager(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<com.atlassian.crowd.embedded.api.Group> getGroupsWithPermission(int permissionId)
          Retrieve all the groups with this permission.
 Collection<JiraPermission> getPermissions(int permissionType)
          Retrieve a list of user groups which have been granted a specified permission.
 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
protected  boolean hasPermission(JiraPermission jiraPermission)
           
 void onClearCache(ClearCacheEvent event)
           
 boolean removePermission(int permissionId, String group)
          Revokes a global permission for a user group
 boolean removePermissions(String group)
          Revoke all global permissions for a user group.
 
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.crowd.embedded.api.CrowdService crowdService)
Method Detail

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 a list of user groups which have been granted a specified permission. The returned JiraPermission contains a reference to the user group. JiraPermission.getScheme() is always NULL, because Global permission are not configured using schemes. JiraPermission.getType() will always return "group", because global permissions can only be granted to groups.

Specified by:
getPermissions in interface GlobalPermissionManager
Parameters:
permissionType - The permission. Must be a global permission.
Returns:
Collection of JiraPermission.getPermType(), must never return null.

removePermission

public boolean removePermission(int permissionId,
                                String group)
                         throws RemoveException
Description copied from interface: GlobalPermissionManager
Revokes a global permission for a user group

Specified by:
removePermission in interface GlobalPermissionManager
Parameters:
permissionId - the global permission.
group - the group name. NULL means the anyone group.
Returns:
true if the permission was revoked, false if not (e.g. the group does not have this permission)
Throws:
RemoveException - if the permission removal fails

removePermissions

public boolean removePermissions(String group)
                          throws RemoveException
Description copied from interface: GlobalPermissionManager
Revoke all global permissions for a user group.

Specified by:
removePermissions in interface GlobalPermissionManager
Parameters:
group - cannot NOT be null and the group must exist.
Returns:
true, if this group does not have any global permissions
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)

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)


Copyright © 2002-2013 Atlassian. All Rights Reserved.