com.atlassian.confluence.security
Class SpacePermission

java.lang.Object
  extended by com.atlassian.core.bean.EntityObject
      extended by com.atlassian.confluence.core.ConfluenceEntityObject
          extended by com.atlassian.confluence.security.SpacePermission
All Implemented Interfaces:
Serializable, Cloneable

public class SpacePermission
extends ConfluenceEntityObject
implements Serializable

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.

Version:
$Revision: 1.41 $
Author:
$Author: sleberrigaud $
See Also:
Serialized Form

Field Summary
static String ADMINISTER_SPACE_PERMISSION
           
static String COMMENT_PERMISSION
           
static String CONFLUENCE_ADMINISTRATOR_PERMISSION
          Permission type to do anything in Confluence that can't affect the system on which it runs.
static String CREATE_ATTACHMENT_PERMISSION
           
static String CREATE_SPACE_PERMISSION
           
static String CREATEEDIT_PAGE_PERMISSION
           
static String EDITBLOG_PERMISSION
           
static String EXPORT_PAGE_PERMISSION
          Deprecated. to be removed. Use VIEWSPACE_PERMISSION instead
static String EXPORT_SPACE_PERMISSION
           
static String FORM_PARAMETER_PREFIX
           
static String FORM_PARAMETER_SEPARATOR
           
static String FULL_FORM_PARAMETER_PREFIX
           
static Collection<String> GENERIC_SPACE_PERMISSIONS
          represents all permissions which can be used to build SpacePermissions.
static Collection<String> GLOBAL_PERMISSIONS
          A list of all global permissions
static Collection<String> INVALID_ANONYMOUS_PERMISSIONS
          A list of all permissions that can not be assigned to the anonymous user
static Collection<String> PERMISSION_TYPES
          A list of all possible permissions
static String PERSONAL_SPACE_PERMISSION
           
static String PROFILE_ATTACHMENT_PERMISSION
           
static String REMOVE_ATTACHMENT_PERMISSION
           
static String REMOVE_BLOG_PERMISSION
           
static String REMOVE_COMMENT_PERMISSION
           
static String REMOVE_MAIL_PERMISSION
           
static String REMOVE_PAGE_PERMISSION
           
static String SET_PAGE_PERMISSIONS_PERMISSION
           
static String SYSTEM_ADMINISTRATOR_PERMISSION
          Permission type to do anything at all in Confluence.
static String UPDATE_USER_STATUS_PERMISSION
          A permission type to control whether a user can update their user status.
static String USE_CONFLUENCE_PERMISSION
           
static String VIEW_USER_PROFILES_PERMISSION
          A permission type to control whether a user can view user profiles within the system.
static String VIEWSPACE_PERMISSION
          View content within the space, including pages, blogposts etc.
 
Constructor Summary
SpacePermission()
           
SpacePermission(SpacePermission spacePermission)
          Creates a new SpacePermission with the attributes of another.
SpacePermission(String type)
           
SpacePermission(String type, Space space)
           
SpacePermission(String type, Space space, String group)
           
SpacePermission(String type, Space space, String group, String userName)
          Deprecated. since 3.0, as passing both group and userName leads to an invalid permission
 
Method Summary
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()
          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()
          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)
          Deprecated. As of 2.7.2, use PermissionRow.buildParameterName(String, String).
 String toString()
           
 
Methods inherited from class com.atlassian.confluence.core.ConfluenceEntityObject
getCreatorName, getLastModifierName, getRealClass, isPersistent, setCreatorName, setLastModifierName
 
Methods inherited from class com.atlassian.core.bean.EntityObject
clone, getCreationDate, getCurrentDate, getId, getLastModificationDate, setClock, setCreationDate, setId, setLastModificationDate
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

FORM_PARAMETER_PREFIX

public static final String FORM_PARAMETER_PREFIX
See Also:
Constant Field Values

FORM_PARAMETER_SEPARATOR

public static final String FORM_PARAMETER_SEPARATOR
See Also:
Constant Field Values

FULL_FORM_PARAMETER_PREFIX

public static final String FULL_FORM_PARAMETER_PREFIX
See Also:
Constant Field Values

USE_CONFLUENCE_PERMISSION

public static final String USE_CONFLUENCE_PERMISSION
See Also:
Constant Field Values

UPDATE_USER_STATUS_PERMISSION

public static final String UPDATE_USER_STATUS_PERMISSION
A permission type to control whether a user can update their user status.

See Also:
Constant Field Values

VIEW_USER_PROFILES_PERMISSION

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.

See Also:
Constant Field Values

SYSTEM_ADMINISTRATOR_PERMISSION

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.

See Also:
Constant Field Values

CONFLUENCE_ADMINISTRATOR_PERMISSION

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.

See Also:
Constant Field Values

PERSONAL_SPACE_PERMISSION

public static final String PERSONAL_SPACE_PERMISSION
See Also:
Constant Field Values

CREATE_SPACE_PERMISSION

public static final String CREATE_SPACE_PERMISSION
See Also:
Constant Field Values

PROFILE_ATTACHMENT_PERMISSION

public static final String PROFILE_ATTACHMENT_PERMISSION
See Also:
Constant Field Values

VIEWSPACE_PERMISSION

public static final String VIEWSPACE_PERMISSION
View content within the space, including pages, blogposts etc.

See Also:
Constant Field Values

COMMENT_PERMISSION

public static final String COMMENT_PERMISSION
See Also:
Constant Field Values

CREATEEDIT_PAGE_PERMISSION

public static final String CREATEEDIT_PAGE_PERMISSION
See Also:
Constant Field Values

ADMINISTER_SPACE_PERMISSION

public static final String ADMINISTER_SPACE_PERMISSION
See Also:
Constant Field Values

REMOVE_PAGE_PERMISSION

public static final String REMOVE_PAGE_PERMISSION
See Also:
Constant Field Values

REMOVE_COMMENT_PERMISSION

public static final String REMOVE_COMMENT_PERMISSION
See Also:
Constant Field Values

REMOVE_BLOG_PERMISSION

public static final String REMOVE_BLOG_PERMISSION
See Also:
Constant Field Values

CREATE_ATTACHMENT_PERMISSION

public static final String CREATE_ATTACHMENT_PERMISSION
See Also:
Constant Field Values

REMOVE_ATTACHMENT_PERMISSION

public static final String REMOVE_ATTACHMENT_PERMISSION
See Also:
Constant Field Values

EDITBLOG_PERMISSION

public static final String EDITBLOG_PERMISSION
See Also:
Constant Field Values

EXPORT_PAGE_PERMISSION

@Deprecated
public static final String EXPORT_PAGE_PERMISSION
Deprecated. to be removed. Use VIEWSPACE_PERMISSION instead
See Also:
Constant Field Values

EXPORT_SPACE_PERMISSION

public static final String EXPORT_SPACE_PERMISSION
See Also:
Constant Field Values

REMOVE_MAIL_PERMISSION

public static final String REMOVE_MAIL_PERMISSION
See Also:
Constant Field Values

SET_PAGE_PERMISSIONS_PERMISSION

public static final String SET_PAGE_PERMISSIONS_PERMISSION
See Also:
Constant Field Values

PERMISSION_TYPES

public static final Collection<String> PERMISSION_TYPES
A list of all possible permissions


GENERIC_SPACE_PERMISSIONS

public static final Collection<String> GENERIC_SPACE_PERMISSIONS
represents all permissions which can be used to build SpacePermissions.


GLOBAL_PERMISSIONS

public static final Collection<String> GLOBAL_PERMISSIONS
A list of all global permissions


INVALID_ANONYMOUS_PERMISSIONS

public static final Collection<String> INVALID_ANONYMOUS_PERMISSIONS
A list of all permissions that can not be assigned to the anonymous user

Constructor Detail

SpacePermission

public SpacePermission()

SpacePermission

public SpacePermission(String type)

SpacePermission

public SpacePermission(String type,
                       Space space)

SpacePermission

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

SpacePermission

@Deprecated
public SpacePermission(String type,
                                  Space space,
                                  String group,
                                  String userName)
Deprecated. since 3.0, as passing both group and userName leads to an invalid permission

See Also:
createUserSpacePermission(String, Space, String), createGroupSpacePermission(String, Space, String)

SpacePermission

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.
Method Detail

fromFormParameterName

public static SpacePermission fromFormParameterName(String formParameterName,
                                                    Space space,
                                                    String parameterType)
                                             throws ParseException
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

getSpace

public Space getSpace()
The space of this permission.


setSpace

public void setSpace(Space space)

getSpaceId

public long getSpaceId()

getType

public String getType()

setType

public void setType(String type)

getGroup

public String getGroup()

setGroup

public void setGroup(String group)

getUserName

public String getUserName()

setUserName

public void setUserName(String userName)

isUserPermission

public boolean isUserPermission()

isGroupPermission

public boolean isGroupPermission()

isAnonymousPermission

public boolean isAnonymousPermission()

isGlobalPermission

public boolean isGlobalPermission()

isSpacePermission

public boolean isSpacePermission()

toString

public String toString()
Overrides:
toString in class Object

equals

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.

Overrides:
equals in class com.atlassian.core.bean.EntityObject

hashCode

public int hashCode()
Overrides:
hashCode in class com.atlassian.core.bean.EntityObject

getGenericSpacePermissions

@Deprecated
public static Collection<String> getGenericSpacePermissions()
Deprecated. since 3.0, why do we even need a getter


getDefaultGlobalPermissions

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:
a collection of SpacePermissions.

toFormParameterName

@Deprecated
public String toFormParameterName(String parameterType)
Deprecated. As of 2.7.2, use PermissionRow.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(java.lang.String, com.atlassian.confluence.spaces.Space, java.lang.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.

isAdministrativePermission

@Deprecated
public boolean isAdministrativePermission()
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

isGuardPermission

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.

isDependentOn

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.

isInvalidAnonymousPermission

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

createAnonymousSpacePermission

public static SpacePermission createAnonymousSpacePermission(String type,
                                                             Space space)

createUserSpacePermission

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

createGroupSpacePermission

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


Copyright © 2003-2013 Atlassian. All Rights Reserved.