public enum Permission extends Enum<Permission>
Enum Constant and Description |
---|
ADMIN
Allows access to common administration tasks, such as granting global permissions.
|
LICENSED_USER
Allows access to the application.
|
PROJECT_ADMIN
Allows administrative access to a project and any repository it contains.
|
PROJECT_CREATE
Allows project creation.
|
PROJECT_READ
Allows read access to a project and any repository it contains.
|
PROJECT_VIEW
Allow view access to a project.
|
PROJECT_WRITE
Allows write access to a project and any repository it contains.
|
REPO_ADMIN
Allows to administer a repository.
|
REPO_READ
Allows read access to a repository.
|
REPO_WRITE
Allows write access to a repository.
|
SYS_ADMIN
Allows access to advanced administration tasks.
|
USER_ADMIN
Allows access to change account configuration for a given user such as SSH keys, GPG keys, personal tokens,
and password.
|
Modifier and Type | Method and Description |
---|---|
static Permission |
fromId(int id)
Gets a permission by its id.
|
static Permission |
fromWeight(int weight)
Gets a permission by its weight.
|
static Set<Permission> |
getGlobalPermissions()
Gets all the global permissions.
|
PermissionI18n |
getI18n() |
int |
getId() |
Set<Permission> |
getImplyingPermissions()
Get the set of permissions that inherit this permission (excluding this permission).
|
Set<Permission> |
getInheritedPermissions()
Gets all permissions this permission inherits.
|
Set<Permission> |
getInheritingPermissions()
Gets all permissions that inherit this permission (including this permission).
|
static Set<Permission> |
getPermissionsOn(Class<?> resourceClass)
Gets all the permissions associated with a resource.
|
Set<Class<?>> |
getResourceTypes()
Return all resource types that this permission applies to.
|
int |
getWeight()
Retrieves the weight of this permission relative to other permissions.
|
boolean |
isGlobal()
Indicates whether this
Permission can be granted globally. |
boolean |
isGrantable() |
boolean |
isGrantableToAll()
Indicates whether this permission may be granted to all users,
or if it must be granted to users or groups individually.
|
boolean |
isResource()
Indicates whether this
Permission only applies to specific resource(s),
such as projects and repositories. |
boolean |
isResource(Class<?> resourceClass)
Indicates whether this permission applies to a given resource type.
|
static Permission |
max(Permission p1,
Permission p2)
Gets the permission with the maximum
weigth . |
static Permission |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static Permission[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final Permission USER_ADMIN
This permission can not be granted to any user/group it is implied for any user for their own account. This permission is not implied for personal tokens.
Users with SYS_ADMIN gains this permission for all users. Users with ADMIN gains this for all users except SYS_ADMIN users.
public static final Permission PROJECT_VIEW
This permission cannot be granted to a user/group. It is an implied permission for any user which has at least read access one or more repositories within the project
public static final Permission REPO_READ
This allows cloning and pulling changes from a repository, adding comments and declining pull requests that target the repository. It also allows creating pull requests if the user has the permission on both the source and target repository.
public static final Permission REPO_WRITE
In addition to the permissions already granted by REPO_READ
, this allows pushing changes
to a repository and merging pull requests targeting the repository.
public static final Permission REPO_ADMIN
In addition to the permissions already granted by REPO_WRITE
, this allows accessing and updating
the configuration of the repository, such as adding or revoking branch permissions, adding or revoking other
repository permissions, renaming or deleting the repository.
public static final Permission PROJECT_READ
This allows listing and viewing all the repositories in a project. It also grants
REPO_READ
to all the repositories in the project.
public static final Permission PROJECT_WRITE
In addition to the permissions already granted by PROJECT_READ
, this also grants
REPO_WRITE
on all the repositories in the project.
public static final Permission PROJECT_ADMIN
In addition to the permissions already granted by PROJECT_WRITE
, this allows accessing and updating
the configuration of the project itself (such as adding other project permissions, configuring the project's
avatar, renaming or deleting the project). This also grants REPO_ADMIN
on all the repositories in
the project.
public static final Permission LICENSED_USER
This allows the user to authenticate and counts their account towards the license limit.
public static final Permission PROJECT_CREATE
This allows the user to create new projects.
public static final Permission ADMIN
This grants overall admin access, implying PROJECT_ADMIN
to all the projects.
public static final Permission SYS_ADMIN
In addition to the permissions already granted by ADMIN
, this grants the user full access to
the restricted admin functions, such as enabling SSH access, updating the license or migrating databases.
public static Permission[] values()
for (Permission c : Permission.values()) System.out.println(c);
public static Permission valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null@Nonnull public static Permission fromId(int id)
id
- id of the permissionIllegalArgumentException
- if no Permission is associated with the given id
@Nullable public static Permission fromWeight(int weight)
weight
- weight of the permissionnull
if no permission matches the weight@Nonnull public static Set<Permission> getGlobalPermissions()
isGlobal()
@Nonnull public static Set<Permission> getPermissionsOn(Class<?> resourceClass)
For example, getPermissionsOn(Project.class)
returns all the permissions that applies
to the resource, excluding global
permissions.
resourceClass
- resource the permission must be applicable toisResource(Class)
@Nullable public static Permission max(Permission p1, Permission p2)
weigth
.p1
- permission 1 (can be null
)p2
- permission 2 (can be null
)@Nonnull public PermissionI18n getI18n()
public int getId()
@Nonnull public Set<Permission> getImplyingPermissions()
@Nonnull public Set<Permission> getInheritedPermissions()
@Nonnull public Set<Permission> getInheritingPermissions()
@Nonnull public Set<Class<?>> getResourceTypes()
global permissions
.isGlobal()
,
isResource()
public int getWeight()
Higher weight implies the permission has precedence over its lesser counterpart(s). Weight can be used to perform an in-order traversal of the permission hierarchy.
public boolean isGlobal()
Permission
can be granted globally.
Global permissions applies to all resources.
true
if this permission applies globally to all resources; or
false
if this permission applied to specific resource(s)public boolean isGrantable()
true
if the permission can be granted to a user, group or all users,
false
otherwisepublic boolean isGrantableToAll()
true
if the permission may be blanket granted to all users; or
false
if it may only be granted individually to users or groupspublic boolean isResource()
Permission
only applies to specific resource(s),
such as projects and repositories.
This is the logical negation of isGlobal()
; a permission cannot be both global and resource.
true
if this permission can be applied to a specific resource; or
false
if this is a global
permissionisGlobal()
public boolean isResource(Class<?> resourceClass)
Caveat: global permissions (that applies to all resources) will return false
.
resourceClass
- the type of the resourcetrue
if this permission applies to instances of resourceClass
isGlobal()
,
isResource()
Copyright © 2022 Atlassian. All rights reserved.