Platform Configuration API
Last modified by Vincent Massol on 2024/07/05 17:40
Extra Configuration APIs related to platform concepts (e.g. user references) |
Type | JAR |
Category | |
Developed by | |
Rating | |
License | GNU Lesser General Public License 2.1 |
Bundled With | XWiki Standard |
Compatibility | Since XWiki 12.4RC1 |
Table of contents
Description
See the Configuration API for general configuration concepts.
Configuration Permissions
It's possible to implement permission checking for ConfigurationSource properties, to decide who has the rights to view or modify them.
To implement this check for your ConfigurationSource component, you need to implement the following component role:
@Role
public interface ConfigurationSourceAuthorization
{
/**
* @param key the key for which to check the access right for
* @param userReference the reference to the user to check for permissions
* @param right the right to check (e.g. {@code AccessRight.READ})
* @return true if the property can be accessed for the passed right (e.g. READ or WRITE)
*/
boolean hasAccess(String key, UserReference userReference, ConfigurationRight right);
}
public interface ConfigurationSourceAuthorization
{
/**
* @param key the key for which to check the access right for
* @param userReference the reference to the user to check for permissions
* @param right the right to check (e.g. {@code AccessRight.READ})
* @return true if the property can be accessed for the passed right (e.g. READ or WRITE)
*/
boolean hasAccess(String key, UserReference userReference, ConfigurationRight right);
}
Where ConfigurationRight is defined as:
public enum ConfigurationRight
{
/**
* The configuration can be read from.
*/
READ,
/**
* The configuration can be written to.
*/
WRITE
}
{
/**
* The configuration can be read from.
*/
READ,
/**
* The configuration can be written to.
*/
WRITE
}
At the moment, your implementation of ConfigurationSourceAuthorization is not called automatically by the ConfigurationSource, so you'll need to perform the call yourself to check for the rights.