public enum

Permission

extends Enum<E extends Enum<E>>
java.lang.Object
   ↳ java.lang.Enum<E extends java.lang.Enum<E>>
     ↳ com.atlassian.stash.user.Permission

Class Overview

Permissions available in Stash.

Summary

Enum Values
Permission  ADMIN  Allows access to the common administration tasks in Stash, such as granting global permissions. 
Permission  LICENSED_USER  Allows access to Stash. 
Permission  PROJECT_ADMIN  Allows administrative access to a project and any repository it contains. 
Permission  PROJECT_CREATE  Allows project creation. 
Permission  PROJECT_READ  Allows read access to a project and any repository it contains. 
Permission  PROJECT_VIEW  Allow view access to a project. 
Permission  PROJECT_WRITE  Allows write access to a project and any repository it contains. 
Permission  REPO_ADMIN  Allows to administer a repository. 
Permission  REPO_READ  Allows read access to a repository. 
Permission  REPO_WRITE  Allows write access to a repository. 
Permission  SYS_ADMIN  Allows access to the advanced administration tasks in Stash. 
Public Methods
@Nullable static Permission fromId(int id)
Gets a permission by its id.
@Nullable static Permission fromWeight(int weight)
Gets a permission by its weight.
static Set<Permission> getGlobalPermissions()
Gets all the global permissions.
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.
@Deprecated static Set<Permission> getResourcePermissions()
This method is deprecated. use getPermissionsOn(Class), this will removed in 3.0
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.
@Deprecated boolean isGrantableToAnonymous()
This method is deprecated. in 2.4. Scheduled for removal in 3.0. Stash currently does not support anonymous access. Stash may have anonymous access in the future, but it may or may not use this method to help implement it.
@Deprecated boolean isProjectRelated()
This method is deprecated. in 2.4. Scheduled for remove in 3.0. Use isResource(Class) with Project.class instead.
boolean isResource()
Indicates whether this Permission only applies to specific resource(s), such as projects and repositories.
boolean isResource(Class<?> resourceClass)
Indicates whether a permission applies to a resource type.
@Nullable static Permission max(Permission p1, Permission p2)
Gets the permission with the maximum #weight weigth.
static Permission valueOf(String name)
final static Permission[] values()
[Expand]
Inherited Methods
From class java.lang.Enum
From class java.lang.Object
From interface java.lang.Comparable

Enum Values

public static final Permission ADMIN

Allows access to the common administration tasks in Stash, such as granting global permissions.

This grants overall admin access to Stash, and PROJECT_ADMIN to all the projects in Stash.

public static final Permission LICENSED_USER

Allows access to Stash.

This allows the user to authenticate against Stash and counts him or her towards the license limit.

public static final Permission PROJECT_ADMIN

Allows administrative access to a project and any repository it contains.

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 PROJECT_CREATE

Allows project creation.

This allows the user to create new projects in Stash.

public static final Permission PROJECT_READ

Allows read access to a project and any repository it contains.

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_VIEW

Allow view access to a project.

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 PROJECT_WRITE

Allows write access to a project and any repository it contains.

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 REPO_ADMIN

Allows to administer a repository.

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 REPO_READ

Allows read access to a repository.

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

Allows write access to a repository.

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 SYS_ADMIN

Allows access to the advanced administration tasks in Stash.

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 for Stash or migrating databases.

Public Methods

@Nullable public static Permission fromId (int id)

Gets a permission by its id.

Parameters
id id of the permission
Returns
  • the permission, or null if no permission matches the id

@Nullable public static Permission fromWeight (int weight)

Gets a permission by its weight.

Parameters
weight weight of the permission
Returns
  • the permission, or null if no permission matches the weight

public static Set<Permission> getGlobalPermissions ()

Gets all the global permissions.

See Also

public int getId ()

Returns
  • the id of this permission

public Set<Permission> getImplyingPermissions ()

Get the set of permissions that inherit this permission (excluding this permission).

public Set<Permission> getInheritedPermissions ()

Gets all permissions this permission inherits.

public Set<Permission> getInheritingPermissions ()

Gets all permissions that inherit this permission (including this permission).

public static Set<Permission> getPermissionsOn (Class<?> resourceClass)

Gets all the permissions associated with a resource.

For example, getPermissionsOn(Project.class) returns all the permissions that applies to the resource, excluding global permissions.

Parameters
resourceClass resource the permission must be applicable to

@Deprecated public static Set<Permission> getResourcePermissions ()

This method is deprecated.
use getPermissionsOn(Class), this will removed in 3.0

Gets all the resource permissions.

public int getWeight ()

Retrieves the weight of this permission relative to other permissions.

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.

Returns
  • the weight of this permission

public boolean isGlobal ()

Indicates whether this Permission can be granted globally.

Global permissions applies to all resources.

Returns
  • true if this permission applies globally to all resources; or false if this permission applied to specific resource(s)

public boolean isGrantable ()

Returns
  • true if the permission can be granted to a user, group or all users, false otherwise

public boolean isGrantableToAll ()

Indicates whether this permission may be granted to all users, or if it must be granted to users or groups individually.

Returns
  • true if the permission may be blanket granted to all users; or false if it may only be granted individually to users or groups

@Deprecated public boolean isGrantableToAnonymous ()

This method is deprecated.
in 2.4. Scheduled for removal in 3.0. Stash currently does not support anonymous access. Stash may have anonymous access in the future, but it may or may not use this method to help implement it.

Indicates whether a permission may be granted to anonymous users.

Returns
  • true if the permission can be granted to anonymous users

@Deprecated public boolean isProjectRelated ()

This method is deprecated.
in 2.4. Scheduled for remove in 3.0. Use isResource(Class) with Project.class instead.

Indicates whether a permission is valid for project resources.

Returns
  • true if the permission applies to project resources and is not global

public boolean isResource ()

Indicates whether this 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.

Returns
  • true if this permission can be applied to a specific resource; or false if this is a global permission
See Also

public boolean isResource (Class<?> resourceClass)

Indicates whether a permission applies to a resource type.

Caveat: global permissions (that applies to all resources) will return false.

Parameters
resourceClass the type of the resource
Returns
  • true if the permission applies to the resource

@Nullable public static Permission max (Permission p1, Permission p2)

Gets the permission with the maximum #weight weigth.

Parameters
p1 permission 1 (can be null)
p2 permission 2 (can be null)
Returns
  • the permission with the maximum weight

public static Permission valueOf (String name)

public static final Permission[] values ()