public class

SpacePermission

extends ConfluenceEntityObject
implements Serializable
java.lang.Object
   ↳ com.atlassian.core.bean.EntityObject
     ↳ com.atlassian.confluence.core.ConfluenceEntityObject
       ↳ com.atlassian.confluence.security.SpacePermission

Class Overview

A SpacePermission restricts access to different functions on a space. A a SpacePermission is defined for a permissionType then that permissionType is not permitted, otherwise if it's not it's permitted.

Summary

Constants
String ADMINISTER_SPACE_PERMISSION
String COMMENT_PERMISSION
String CONFLUENCE_ADMINISTRATOR_PERMISSION Permission type to do anything in Confluence that can't affect the system on which it runs.
String CREATEEDIT_PAGE_PERMISSION
String CREATE_ATTACHMENT_PERMISSION
String CREATE_SPACE_PERMISSION
String EDITBLOG_PERMISSION
String EXPORT_PAGE_PERMISSION
String EXPORT_SPACE_PERMISSION
String FORM_PARAMETER_PREFIX
String FORM_PARAMETER_SEPARATOR
String FULL_FORM_PARAMETER_PREFIX
String PERSONAL_SPACE_PERMISSION
String PROFILE_ATTACHMENT_PERMISSION
String REMOVE_ATTACHMENT_PERMISSION
String REMOVE_BLOG_PERMISSION
String REMOVE_COMMENT_PERMISSION
String REMOVE_MAIL_PERMISSION
String REMOVE_PAGE_PERMISSION
String SET_PAGE_PERMISSIONS_PERMISSION
String SYSTEM_ADMINISTRATOR_PERMISSION Permission type to do anything at all in Confluence.
String UPDATE_USER_STATUS_PERMISSION A permission type to control whether a user can update their user status.
String USE_CONFLUENCE_PERMISSION
String VIEWSPACE_PERMISSION View content within the space, including pages, blogposts etc.
String VIEW_USER_PROFILES_PERMISSION A permission type to control whether a user can view user profiles within the system.
Fields
public static final Collection<String> GENERIC_SPACE_PERMISSIONS represents all permissions which can be used to build SpacePermissions.
public static final Collection<String> GLOBAL_PERMISSIONS A list of all global permissions
public static final Collection<String> INVALID_ANONYMOUS_PERMISSIONS A list of all permissions that can not be assigned to the anonymous user
public static final Collection<String> PERMISSION_TYPES A list of all possible permissions
Public Constructors
SpacePermission()
SpacePermission(String type)
SpacePermission(String type, Space space)
SpacePermission(String type, Space space, String group)
SpacePermission(String type, Space space, String group, String userName)
This constructor is deprecated. since 3.0, as passing both group and userName leads to an invalid permission
SpacePermission(SpacePermission spacePermission)
Creates a new SpacePermission with the attributes of another.
Public Methods
static SpacePermission createAnonymousSpacePermission(String type, Space space)
static SpacePermission createGroupSpacePermission(String type, Space space, String group)
static SpacePermission createUserSpacePermission(String type, Space space, String userName)
boolean equals(Object obj)
For CONF-9469 the equals implementation will ignore the case of the permission user name and group name.
static SpacePermission fromFormParameterName(String formParameterName, Space space, String parameterType)
Convert a form parameter name into a space permission.
static Collection<SpacePermission> getDefaultGlobalPermissions()
Returns the default global permissions that are created when Confluence is set up.
static Collection<String> getGenericSpacePermissions()
This method is deprecated. since 3.0, why do we even need a getter
String getGroup()
Space getSpace()
The space of this permission.
long getSpaceId()
String getType()
String getUserName()
int hashCode()
boolean isAdministrativePermission()
This method is deprecated. since Confluence 2.7. Not used in Confluence core at the moment.
boolean isAnonymousPermission()
boolean isDependentOn(SpacePermission otherPermission)
One permission is dependent on another if the other permission is a guard permission that applies to the same space/global scope, and to the same group or user as this permission.
boolean isGlobalPermission()
boolean isGroupPermission()
boolean isGuardPermission()
Is this a guard permission, either globally or at the space level? Guard permissions are required before any more permissions can be added for a particular user/group in a particular scope.
boolean isInvalidAnonymousPermission()
Some permissions are not valid as they can not be assigned to the anonymous user.
boolean isSpacePermission()
boolean isUserPermission()
void setGroup(String group)
void setSpace(Space space)
void setType(String type)
void setUserName(String userName)
String toFormParameterName(String parameterType)
This method is deprecated. As of 2.7.2, use buildParameterName(String, String).
String toString()
[Expand]
Inherited Methods
From class com.atlassian.confluence.core.ConfluenceEntityObject
From class com.atlassian.core.bean.EntityObject
From class java.lang.Object

Constants

public static final String ADMINISTER_SPACE_PERMISSION

Constant Value: "SETSPACEPERMISSIONS"

public static final String COMMENT_PERMISSION

Constant Value: "COMMENT"

public static final String CONFLUENCE_ADMINISTRATOR_PERMISSION

Permission type to do anything in Confluence that can't affect the system on which it runs. Users with this permission should be allowed to perform most administration tasks but not install plugins or write macros.

Constant Value: "ADMINISTRATECONFLUENCE"

public static final String CREATEEDIT_PAGE_PERMISSION

Constant Value: "EDITSPACE"

public static final String CREATE_ATTACHMENT_PERMISSION

Constant Value: "CREATEATTACHMENT"

public static final String CREATE_SPACE_PERMISSION

Constant Value: "CREATESPACE"

public static final String EDITBLOG_PERMISSION

Constant Value: "EDITBLOG"

public static final String EXPORT_PAGE_PERMISSION

Constant Value: "EXPORTPAGE"

public static final String EXPORT_SPACE_PERMISSION

Constant Value: "EXPORTSPACE"

public static final String FORM_PARAMETER_PREFIX

Constant Value: "confluence"

public static final String FORM_PARAMETER_SEPARATOR

Constant Value: "_"

public static final String FULL_FORM_PARAMETER_PREFIX

Constant Value: "confluence_"

public static final String PERSONAL_SPACE_PERMISSION

Constant Value: "PERSONALSPACE"

public static final String PROFILE_ATTACHMENT_PERMISSION

Constant Value: "PROFILEATTACHMENTS"

public static final String REMOVE_ATTACHMENT_PERMISSION

Constant Value: "REMOVEATTACHMENT"

public static final String REMOVE_BLOG_PERMISSION

Constant Value: "REMOVEBLOG"

public static final String REMOVE_COMMENT_PERMISSION

Constant Value: "REMOVECOMMENT"

public static final String REMOVE_MAIL_PERMISSION

Constant Value: "REMOVEMAIL"

public static final String REMOVE_PAGE_PERMISSION

Constant Value: "REMOVEPAGE"

public static final String SET_PAGE_PERMISSIONS_PERMISSION

Constant Value: "SETPAGEPERMISSIONS"

public static final String SYSTEM_ADMINISTRATOR_PERMISSION

Permission type to do anything at all in Confluence. Users with this permission should be allowed to do virtually anything in Confluence. All actions should check for this permission.

Constant Value: "SYSTEMADMINISTRATOR"

public static final String UPDATE_USER_STATUS_PERMISSION

A permission type to control whether a user can update their user status.

Constant Value: "UPDATEUSERSTATUS"

public static final String USE_CONFLUENCE_PERMISSION

Constant Value: "USECONFLUENCE"

public static final String VIEWSPACE_PERMISSION

View content within the space, including pages, blogposts etc.

Constant Value: "VIEWSPACE"

public static final String VIEW_USER_PROFILES_PERMISSION

A permission type to control whether a user can view user profiles within the system. This only applies to the anonymous user.

Constant Value: "VIEWUSERPROFILES"

Fields

public static final Collection<String> GENERIC_SPACE_PERMISSIONS

represents all permissions which can be used to build SpacePermissions.

public static final Collection<String> GLOBAL_PERMISSIONS

A list of all global permissions

public static final Collection<String> INVALID_ANONYMOUS_PERMISSIONS

A list of all permissions that can not be assigned to the anonymous user

public static final Collection<String> PERMISSION_TYPES

A list of all possible permissions

Public Constructors

public SpacePermission ()

public SpacePermission (String type)

public SpacePermission (String type, Space space)

public SpacePermission (String type, Space space, String group)

public SpacePermission (String type, Space space, String group, String userName)

This constructor is deprecated.
since 3.0, as passing both group and userName leads to an invalid permission

public SpacePermission (SpacePermission spacePermission)

Creates a new SpacePermission with the attributes of another. Does not copy the id, or other ConfluenceEntityObject state.

Parameters
spacePermission a spacePermission to replicate.

Public Methods

public static SpacePermission createAnonymousSpacePermission (String type, Space space)

public static SpacePermission createGroupSpacePermission (String type, Space space, String group)

public static SpacePermission createUserSpacePermission (String type, Space space, String userName)

public boolean equals (Object obj)

For CONF-9469 the equals implementation will ignore the case of the permission user name and group name. Confluence is supposed to be case insensitive with regard to username and group names.

public static SpacePermission fromFormParameterName (String formParameterName, Space space, String parameterType)

Convert a form parameter name into a space permission. The form parameter name should have been generated from toFormParameterName(String).

Parameters
formParameterName the form parameter name to convert to a space permission
space the space the permission applies to, or null if it is a global permission
parameterType distinguishes the parameter from other parameters created with the same permission. Makes little difference to this method.
Returns
  • the relevant SpacePermission
Throws
ParseException if the form parameter name can not be converted to a permission type

public static Collection<SpacePermission> getDefaultGlobalPermissions ()

Returns the default global permissions that are created when Confluence is set up. These will exist in a newly set up system but may be removed afterwards. Note that the returned objects are freshly created and therefore do not have IDs or other persistence data. By default, confluence-administrators group has admin access, the confluence-users group can view the system and anonymous access is disabled.

Returns

public static Collection<String> getGenericSpacePermissions ()

This method is deprecated.
since 3.0, why do we even need a getter

public String getGroup ()

public Space getSpace ()

The space of this permission.

public long getSpaceId ()

public String getType ()

public String getUserName ()

public int hashCode ()

public boolean isAdministrativePermission ()

This method is deprecated.
since Confluence 2.7. Not used in Confluence core at the moment.

Is this an administrative permission either globally or at a space level? The previous use of this method was to list the top level permission either globally or at space level. At least one top level permission is required globally and for each space to ensure that somebody can administer it. That method could no longer be called isAdministrativePermission because CONFLUENCE_ADMINISTRATOR_PERMISSION is clearly an administrative permission, but not one that is required.

Returns
  • true if this is a global or space administrative permission, false otherwise

public boolean isAnonymousPermission ()

public boolean isDependentOn (SpacePermission otherPermission)

One permission is dependent on another if the other permission is a guard permission that applies to the same space/global scope, and to the same group or user as this permission. It is used when determining which permissions should be removed as the result of removing a guard permission.

Parameters
otherPermission - permission to check against
Returns
  • true if this permission is dependent on otherPermission, false otherwise.

public boolean isGlobalPermission ()

public boolean isGroupPermission ()

public boolean isGuardPermission ()

Is this a guard permission, either globally or at the space level? Guard permissions are required before any more permissions can be added for a particular user/group in a particular scope. Globally, USE_CONFLUENCE is a guard permission, at the space level, VIEWSPACE is theguard.

Returns
  • true if this is a guard permission, false otherwise.

public boolean isInvalidAnonymousPermission ()

Some permissions are not valid as they can not be assigned to the anonymous user. Really, we should just refuse to create such permissions from the outset, but for now we've just got this check.

Returns
  • true if this permission is invalid due to being anonymous, and of a type not available to anonymous users

public boolean isSpacePermission ()

public boolean isUserPermission ()

public void setGroup (String group)

public void setSpace (Space space)

public void setType (String type)

public void setUserName (String userName)

public String toFormParameterName (String parameterType)

This method is deprecated.
As of 2.7.2, use buildParameterName(String, String).

Convert the space permission into a form parameter name that can be used for form checkboxes. The reverse of this method is fromFormParameterName(String, Space, String) The format of the parameter name is:

confluence_[parameterType]_[permissionType]_[user/group/anonymous]_[user/group name]

Note: the space is NOT encoded in the form parameter name, and must be kept separately.

Parameters
parameterType distinguishes the parameter from other parameters created with the same permission.
Returns
  • the space permission as a form parameter.

public String toString ()