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:
java.io.Serializable, java.lang.Cloneable

public class SpacePermission
extends ConfluenceEntityObject
implements java.io.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 java.lang.String ADMINISTER_SPACE_PERMISSION
           
static java.lang.String COMMENT_PERMISSION
           
static java.lang.String CONFLUENCE_ADMINISTRATOR_PERMISSION
          Permission type to do anything in Confluence that can't affect the system on which it runs.
static java.lang.String CREATE_ATTACHMENT_PERMISSION
           
static java.lang.String CREATE_SPACE_PERMISSION
           
static java.lang.String CREATEEDIT_PAGE_PERMISSION
           
static java.lang.String EDITBLOG_PERMISSION
           
static java.lang.String EXPORT_PAGE_PERMISSION
           
static java.lang.String EXPORT_SPACE_PERMISSION
           
static java.lang.String FORM_PARAMETER_PREFIX
           
static java.lang.String FORM_PARAMETER_SEPARATOR
           
static java.lang.String FULL_FORM_PARAMETER_PREFIX
           
static java.util.Collection<java.lang.String> GENERIC_SPACE_PERMISSIONS
          represents all permissions which can be used to build SpacePermissions.
static java.util.Collection<java.lang.String> GLOBAL_PERMISSIONS
          A list of all global permissions
static java.util.Collection<java.lang.String> INVALID_ANONYMOUS_PERMISSIONS
          A list of all permissions that can not be assigned to the anonymous user
static java.util.Collection<java.lang.String> PERMISSION_TYPES
          A list of all possible permissions
static java.lang.String PERSONAL_SPACE_PERMISSION
           
static java.lang.String PROFILE_ATTACHMENT_PERMISSION
           
static java.lang.String REMOVE_ATTACHMENT_PERMISSION
           
static java.lang.String REMOVE_BLOG_PERMISSION
           
static java.lang.String REMOVE_COMMENT_PERMISSION
           
static java.lang.String REMOVE_MAIL_PERMISSION
           
static java.lang.String REMOVE_PAGE_PERMISSION
           
static java.lang.String SET_PAGE_PERMISSIONS_PERMISSION
           
static java.lang.String SYSTEM_ADMINISTRATOR_PERMISSION
          Permission type to do anything at all in Confluence.
static java.lang.String UPDATE_USER_STATUS_PERMISSION
          A permission type to control whether a user can update their user status.
static java.lang.String USE_CONFLUENCE_PERMISSION
           
static java.lang.String VIEW_USER_PROFILES_PERMISSION
          A permission type to control whether a user can view user profiles within the system.
static java.lang.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(java.lang.String type)
           
SpacePermission(java.lang.String type, Space space)
           
SpacePermission(java.lang.String type, Space space, java.lang.String group)
           
SpacePermission(java.lang.String type, Space space, java.lang.String group, java.lang.String userName)
          Deprecated. since 3.0, as passing both group and userName leads to an invalid permission
 
Method Summary
static SpacePermission createAnonymousSpacePermission(java.lang.String type, Space space)
           
static SpacePermission createGroupSpacePermission(java.lang.String type, Space space, java.lang.String group)
           
static SpacePermission createUserSpacePermission(java.lang.String type, Space space, java.lang.String userName)
           
 boolean equals(java.lang.Object obj)
          For CONF-9469 the equals implementation will ignore the case of the permission user name and group name.
static SpacePermission fromFormParameterName(java.lang.String formParameterName, Space space, java.lang.String parameterType)
          Convert a form parameter name into a space permission.
static java.util.Collection<SpacePermission> getDefaultGlobalPermissions()
          Returns the default global permissions that are created when Confluence is set up.
static java.util.Collection<java.lang.String> getGenericSpacePermissions()
          Deprecated. since 3.0, why do we even need a getter
 java.lang.String getGroup()
           
 Space getSpace()
          The space of this permission.
 long getSpaceId()
           
 java.lang.String getType()
           
 java.lang.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(java.lang.String group)
           
 void setSpace(Space space)
           
 void setType(java.lang.String type)
           
 void setUserName(java.lang.String userName)
           
 java.lang.String toFormParameterName(java.lang.String parameterType)
          Deprecated. As of 2.7.2, use PermissionRow.buildParameterName(String, String).
 java.lang.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 java.lang.String FORM_PARAMETER_PREFIX
See Also:
Constant Field Values

FORM_PARAMETER_SEPARATOR

public static final java.lang.String FORM_PARAMETER_SEPARATOR
See Also:
Constant Field Values

FULL_FORM_PARAMETER_PREFIX

public static final java.lang.String FULL_FORM_PARAMETER_PREFIX
See Also:
Constant Field Values

USE_CONFLUENCE_PERMISSION

public static final java.lang.String USE_CONFLUENCE_PERMISSION
See Also:
Constant Field Values

UPDATE_USER_STATUS_PERMISSION

public static final java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.String PERSONAL_SPACE_PERMISSION
See Also:
Constant Field Values

CREATE_SPACE_PERMISSION

public static final java.lang.String CREATE_SPACE_PERMISSION
See Also:
Constant Field Values

PROFILE_ATTACHMENT_PERMISSION

public static final java.lang.String PROFILE_ATTACHMENT_PERMISSION
See Also:
Constant Field Values

VIEWSPACE_PERMISSION

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

See Also:
Constant Field Values

COMMENT_PERMISSION

public static final java.lang.String COMMENT_PERMISSION
See Also:
Constant Field Values

CREATEEDIT_PAGE_PERMISSION

public static final java.lang.String CREATEEDIT_PAGE_PERMISSION
See Also:
Constant Field Values

ADMINISTER_SPACE_PERMISSION

public static final java.lang.String ADMINISTER_SPACE_PERMISSION
See Also:
Constant Field Values

REMOVE_PAGE_PERMISSION

public static final java.lang.String REMOVE_PAGE_PERMISSION
See Also:
Constant Field Values

REMOVE_COMMENT_PERMISSION

public static final java.lang.String REMOVE_COMMENT_PERMISSION
See Also:
Constant Field Values

REMOVE_BLOG_PERMISSION

public static final java.lang.String REMOVE_BLOG_PERMISSION
See Also:
Constant Field Values

CREATE_ATTACHMENT_PERMISSION

public static final java.lang.String CREATE_ATTACHMENT_PERMISSION
See Also:
Constant Field Values

REMOVE_ATTACHMENT_PERMISSION

public static final java.lang.String REMOVE_ATTACHMENT_PERMISSION
See Also:
Constant Field Values

EDITBLOG_PERMISSION

public static final java.lang.String EDITBLOG_PERMISSION
See Also:
Constant Field Values

EXPORT_PAGE_PERMISSION

public static final java.lang.String EXPORT_PAGE_PERMISSION
See Also:
Constant Field Values

EXPORT_SPACE_PERMISSION

public static final java.lang.String EXPORT_SPACE_PERMISSION
See Also:
Constant Field Values

REMOVE_MAIL_PERMISSION

public static final java.lang.String REMOVE_MAIL_PERMISSION
See Also:
Constant Field Values

SET_PAGE_PERMISSIONS_PERMISSION

public static final java.lang.String SET_PAGE_PERMISSIONS_PERMISSION
See Also:
Constant Field Values

PERMISSION_TYPES

public static final java.util.Collection<java.lang.String> PERMISSION_TYPES
A list of all possible permissions


GENERIC_SPACE_PERMISSIONS

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


GLOBAL_PERMISSIONS

public static final java.util.Collection<java.lang.String> GLOBAL_PERMISSIONS
A list of all global permissions


INVALID_ANONYMOUS_PERMISSIONS

public static final java.util.Collection<java.lang.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(java.lang.String type)

SpacePermission

public SpacePermission(java.lang.String type,
                       Space space)

SpacePermission

public SpacePermission(java.lang.String type,
                       Space space,
                       java.lang.String group)

SpacePermission

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


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(java.lang.String formParameterName,
                                                    Space space,
                                                    java.lang.String parameterType)
                                             throws java.text.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:
java.text.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 java.lang.String getType()

setType

public void setType(java.lang.String type)

getGroup

public java.lang.String getGroup()

setGroup

public void setGroup(java.lang.String group)

getUserName

public java.lang.String getUserName()

setUserName

public void setUserName(java.lang.String userName)

isUserPermission

public boolean isUserPermission()

isGroupPermission

public boolean isGroupPermission()

isAnonymousPermission

public boolean isAnonymousPermission()

isGlobalPermission

public boolean isGlobalPermission()

isSpacePermission

public boolean isSpacePermission()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.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 java.util.Collection<java.lang.String> getGenericSpacePermissions()
Deprecated. since 3.0, why do we even need a getter


getDefaultGlobalPermissions

public static java.util.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.

Returns:
a collection of SpacePermissions.

toFormParameterName

public java.lang.String toFormParameterName(java.lang.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

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(java.lang.String type,
                                                             Space space)

createUserSpacePermission

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

createGroupSpacePermission

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


Copyright © 2003-2010 Atlassian. All Rights Reserved.