public interface

PermissionAdminService

com.atlassian.bitbucket.permission.PermissionAdminService

Class Overview

Updates and queries the permissions of users and groups.

Summary

Public Methods
void canAddUserToGroup(String group)
Check if the current user can add users to the given group.
void canDeleteGroup(String group)
Check if the current user can delete a group without affecting their permissions
void canDeleteUser(String userName)
Check if the normal user can be deleted.
void canRemoveUserFromGroup(String username, String group)
Check if a normal user can remove themselves from the given group.
@Nonnull Page<PermittedGroup> findGroupsWithGlobalPermission(String filter, PageRequest pageRequest)
Retrieves a page of groups and their highest global permission.
@Nonnull Page<PermittedGroup> findGroupsWithProjectPermission(Project project, String filter, PageRequest pageRequest)
Retrieves a page of groups and their highest granted permission for the specified project.
@Nonnull Page<PermittedGroup> findGroupsWithRepositoryPermission(Repository repository, String filter, PageRequest pageRequest)
Retrieves a page of groups and their highest granted permission for the specified repository.
@Nonnull Page<String> findGroupsWithoutGlobalPermission(String filter, PageRequest pageRequest)
Retrieves a page of groups who have not been explicitly granted any global permission
@Nonnull Page<String> findGroupsWithoutProjectPermission(Project project, String filter, PageRequest pageRequest)
Retrieves a page of groups who have not been explicitly granted any project permission
@Nonnull Page<String> findGroupsWithoutRepositoryPermission(Repository repository, String filter, PageRequest pageRequest)
Retrieves a page of groups who have not been explicitly granted any repository permission.
@Nonnull Page<ApplicationUser> findLicensedUsersWithoutProjectPermission(Project project, String filter, PageRequest pageRequest)
Retrieves a page of active and licensed users who have not been explicitly granted any project permission
@Nonnull Page<ApplicationUser> findLicensedUsersWithoutRepositoryPermission(Repository repository, String filter, PageRequest pageRequest)
Retrieves a page of active and licensed users who have not been explicitly granted any repository permission.
@Nonnull Page<PermittedUser> findUsersWithGlobalPermission(String filter, PageRequest pageRequest)
Retrieves a page of users and their highest global permission.
@Nonnull Page<PermittedUser> findUsersWithProjectPermission(Project project, String filter, PageRequest pageRequest)
Retrieves a page of users and their highest granted permission for the specified project.
@Nonnull Page<PermittedUser> findUsersWithRepositoryPermission(Repository repository, String filter, PageRequest pageRequest)
Retrieves a page of users and their highest granted permission for the specified repository.
@Nonnull Page<ApplicationUser> findUsersWithoutGlobalPermission(String filter, PageRequest pageRequest)
Retrieves a page of active users who have not been explicitly granted any global permission
void grantAllProjectPermission(Permission permission, Project project)
Grant a project permission to all users users
boolean hasAllProjectPermission(Permission permission, Project project)
Check if the given project permission has been granted to every logged in user for the given project.
void revokeAllGlobalPermissions(ApplicationUser user)
Revoke all global permissions for the given user.
void revokeAllGlobalPermissions(String group)
Revoke all global permissions for the given group.
void revokeAllGroupPermissions(String name)
Revoke all permissions granted to a group.
void revokeAllProjectPermission(Permission permission, Project project)
Revoked a project permission from all users users
void revokeAllProjectPermissions(Project project, String group)
Revoke all project permissions for the given group.
void revokeAllProjectPermissions(Project project, ApplicationUser user)
Revoke all project permissions for the given user.
void revokeAllRepositoryPermissions(Repository repository, ApplicationUser user)
Revoke all repository permissions for the given user.
void revokeAllRepositoryPermissions(Repository repository, String group)
Revoke all repository permissions for the given group.
void revokeAllUserPermissions(ApplicationUser user)
Revoke all permissions from a user.
void revokeAllUserPermissions(String name)
Revoke all permissions from a normal user.
void setPermission(SetPermissionRequest request)
Assigns a permission to multiple users and/or groups.

Public Methods

public void canAddUserToGroup (String group)

Check if the current user can add users to the given group.

Parameters
group the group to which users will be added.

public void canDeleteGroup (String group)

Check if the current user can delete a group without affecting their permissions

Parameters
group the group to be deleted.

public void canDeleteUser (String userName)

Check if the normal user can be deleted.

Parameters
userName the name of the user being deleted

public void canRemoveUserFromGroup (String username, String group)

Check if a normal user can remove themselves from the given group.

Parameters
username the user to check
group the group from which the user is to be removed.

@Nonnull public Page<PermittedGroup> findGroupsWithGlobalPermission (String filter, PageRequest pageRequest)

Retrieves a page of groups and their highest global permission. Groups which do not have any global permissions explicitly assigned to them will not be returned.

Parameters
filter if non-null non-empty then the groups returned must include this text
pageRequest bounds the page of groups to be returned
Returns
  • a page containing zero or more groups which have been explicitly granted a global permission, and their highest granted permission

@Nonnull public Page<PermittedGroup> findGroupsWithProjectPermission (Project project, String filter, PageRequest pageRequest)

Retrieves a page of groups and their highest granted permission for the specified project. Groups which do not have any permissions explicitly assigned to them for the specified project will not be returned.

Parameters
project the project for which permissions should be considered
filter if non-null non-empty then the groups returned must include this text
pageRequest bounds the page of groups to be returned
Returns
  • a page containing zero or more groups which have been explicitly granted a permission for the specified project, and their highest granted permission

@Nonnull public Page<PermittedGroup> findGroupsWithRepositoryPermission (Repository repository, String filter, PageRequest pageRequest)

Retrieves a page of groups and their highest granted permission for the specified repository. Groups which do not have any permissions explicitly assigned to them for the specified repository will not be returned.

Parameters
repository the repository for which permissions should be considered
filter if non-null non-empty then the groups returned must include this text
pageRequest bounds the page of groups to be returned
Returns
  • a page containing zero or more groups which have been explicitly granted a permission for the specified repository, and their highest granted permission

@Nonnull public Page<String> findGroupsWithoutGlobalPermission (String filter, PageRequest pageRequest)

Retrieves a page of groups who have not been explicitly granted any global permission

Parameters
filter if non-null non-empty then the groups returned must include this text
pageRequest bounds the page of groups to be returned
Returns
  • a page of groupnames.

@Nonnull public Page<String> findGroupsWithoutProjectPermission (Project project, String filter, PageRequest pageRequest)

Retrieves a page of groups who have not been explicitly granted any project permission

Parameters
project the project for which the permissions are required.
filter if non-null non-empty then the groups returned must include this text
pageRequest bounds the page of groups to be returned
Returns
  • a page of groupnames.

@Nonnull public Page<String> findGroupsWithoutRepositoryPermission (Repository repository, String filter, PageRequest pageRequest)

Retrieves a page of groups who have not been explicitly granted any repository permission.

Parameters
repository the repository for which the permissions are required.
filter if non-null non-empty then the groups returned must include this text
pageRequest bounds the page of groups to be returned
Returns
  • a page of groupnames.

@Nonnull public Page<ApplicationUser> findLicensedUsersWithoutProjectPermission (Project project, String filter, PageRequest pageRequest)

Retrieves a page of active and licensed users who have not been explicitly granted any project permission

Parameters
project the project for which the permissions are required.
filter if non-null non-empty then the usernames returned must include this text
pageRequest bounds the page of users to be returned
Returns
  • a page of ApplicationUser instances.

@Nonnull public Page<ApplicationUser> findLicensedUsersWithoutRepositoryPermission (Repository repository, String filter, PageRequest pageRequest)

Retrieves a page of active and licensed users who have not been explicitly granted any repository permission.

Parameters
repository the repository for which the permissions are required.
filter if non-null non-empty then the usernames returned must include this text
pageRequest bounds the page of users to be returned
Returns
  • a page of ApplicationUser instances.

@Nonnull public Page<PermittedUser> findUsersWithGlobalPermission (String filter, PageRequest pageRequest)

Retrieves a page of users and their highest global permission. Users which do not have any global permissions explicitly assigned to them will not be returned.

Parameters
filter if non-null non-empty then the usernames returned must include this text
pageRequest bounds the page of users to be returned
Returns
  • a page containing zero or more users who have been explicitly granted a global permission, and their highest granted permission

@Nonnull public Page<PermittedUser> findUsersWithProjectPermission (Project project, String filter, PageRequest pageRequest)

Retrieves a page of users and their highest granted permission for the specified project. Users which do not have any permissions explicitly assigned to them for the specified project will not be returned.

Parameters
project the project for which permissions should be considered
filter if non-null non-empty then the usernames returned must include this text
pageRequest bounds the page of users to be returned
Returns
  • a page containing zero or more users who have been explicitly granted a permission for the specified project, and their highest granted permission

@Nonnull public Page<PermittedUser> findUsersWithRepositoryPermission (Repository repository, String filter, PageRequest pageRequest)

Retrieves a page of users and their highest granted permission for the specified repository. Users which do not have any permissions explicitly assigned to them for the specified repository will not be returned.

Parameters
repository the repository for which permissions should be considered
filter if non-null non-empty then the usernames returned must include this text
pageRequest bounds the page of users to be returned
Returns
  • a page containing zero or more users who have been explicitly granted a permission for the specified repository, and their highest granted permission

@Nonnull public Page<ApplicationUser> findUsersWithoutGlobalPermission (String filter, PageRequest pageRequest)

Retrieves a page of active users who have not been explicitly granted any global permission

Parameters
filter if non-null non-empty then the usernames returned must include this text
pageRequest bounds the page of users to be returned
Returns
  • a page of ApplicationUser instances.

public void grantAllProjectPermission (Permission permission, Project project)

Grant a project permission to all users users

Parameters
permission the project permission to be granted
project the project on which permission is to be revoked

public boolean hasAllProjectPermission (Permission permission, Project project)

Check if the given project permission has been granted to every logged in user for the given project.

Parameters
permission the permission to be checked.
project the project for which the permissions are required.
Returns
  • true if the given global permission is granted to all users.

public void revokeAllGlobalPermissions (ApplicationUser user)

Revoke all global permissions for the given user.

Parameters
user user to revoke permissions from

public void revokeAllGlobalPermissions (String group)

Revoke all global permissions for the given group.

Parameters
group name of the group

public void revokeAllGroupPermissions (String name)

Revoke all permissions granted to a group.

Parameters
name name of the group

public void revokeAllProjectPermission (Permission permission, Project project)

Revoked a project permission from all users users

Parameters
permission the project permission to be revoked
project the project on which permission is to be revoked

public void revokeAllProjectPermissions (Project project, String group)

Revoke all project permissions for the given group.

Parameters
project the project on which permissions are to be revoked
group name of the group

public void revokeAllProjectPermissions (Project project, ApplicationUser user)

Revoke all project permissions for the given user.

Parameters
project the project on which permissions are to be revoked
user user to revoke permissions from

public void revokeAllRepositoryPermissions (Repository repository, ApplicationUser user)

Revoke all repository permissions for the given user.

Parameters
repository the repository on which permissions are to be revoked
user user to revoke permissions from

public void revokeAllRepositoryPermissions (Repository repository, String group)

Revoke all repository permissions for the given group.

Parameters
repository the repository on which permissions are to be revoked
group name of the group

public void revokeAllUserPermissions (ApplicationUser user)

Revoke all permissions from a user.

Parameters
user the user

public void revokeAllUserPermissions (String name)

Revoke all permissions from a normal user. service users can not be identified by username hence their permission cannot be revoked by this method.

Parameters
name name of the normal user

public void setPermission (SetPermissionRequest request)

Assigns a permission to multiple users and/or groups.

Note that:

  • granting a global permission to users or groups will remove their other global permissions,
  • granting a project permission to users or groups will remove their other project permissions on the same project,
  • granting a repository permission to users or groups will remove their other repository permissions on the same repository.

Parameters
request request specifying which permission to grant to which users and/or groups