diff --git a/xwiki-platform-core/xwiki-platform-component/xwiki-platform-component-wiki/pom.xml b/xwiki-platform-core/xwiki-platform-component/xwiki-platform-component-wiki/pom.xml index 4c132e6e892e36ff828b4cffe2e97fc2a8f0f628..d02a6733e821b2635bd29758a80bfb9bb20feee8 100644 --- a/xwiki-platform-core/xwiki-platform-component/xwiki-platform-component-wiki/pom.xml +++ b/xwiki-platform-core/xwiki-platform-component/xwiki-platform-component-wiki/pom.xml @@ -73,6 +73,11 @@ <artifactId>xwiki-platform-rendering-async-default</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.xwiki.platform</groupId> + <artifactId>xwiki-platform-security-requiredrights-api</artifactId> + <version>${project.version}</version> + </dependency> <!-- Test Dependencies --> <dependency> diff --git a/xwiki-platform-core/xwiki-platform-component/xwiki-platform-component-wiki/src/main/java/org/xwiki/component/wiki/internal/WikiComponentRequiredRightAnalyzer.java b/xwiki-platform-core/xwiki-platform-component/xwiki-platform-component-wiki/src/main/java/org/xwiki/component/wiki/internal/WikiComponentRequiredRightAnalyzer.java new file mode 100644 index 0000000000000000000000000000000000000000..9088929942b915e2adb2d5e0e6b791b4e1499a39 --- /dev/null +++ b/xwiki-platform-core/xwiki-platform-component/xwiki-platform-component-wiki/src/main/java/org/xwiki/component/wiki/internal/WikiComponentRequiredRightAnalyzer.java @@ -0,0 +1,65 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.xwiki.component.wiki.internal; + +import java.util.List; + +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + +import org.xwiki.component.annotation.Component; +import org.xwiki.platform.security.requiredrights.RequiredRight; +import org.xwiki.platform.security.requiredrights.RequiredRightAnalysisResult; +import org.xwiki.platform.security.requiredrights.RequiredRightAnalyzer; +import org.xwiki.platform.security.requiredrights.RequiredRightsException; +import org.xwiki.platform.security.requiredrights.display.BlockSupplierProvider; + +import com.xpn.xwiki.objects.BaseObject; + +/** + * A {@link RequiredRightAnalyzer} for wiki component XObjects. + * + * @since 15.10.12 + * @since 16.4.3 + * @since 16.8.0RC1 + * @version $Id$ + */ +@Component +@Singleton +@Named("XWiki.ComponentClass") +public class WikiComponentRequiredRightAnalyzer implements RequiredRightAnalyzer<BaseObject> +{ + @Inject + @Named("translation") + private BlockSupplierProvider<String> translationMessageSupplierProvider; + + @Inject + private BlockSupplierProvider<BaseObject> objectBlockSupplierProvider; + + @Override + public List<RequiredRightAnalysisResult> analyze(BaseObject object) throws RequiredRightsException + { + return List.of(new RequiredRightAnalysisResult(object.getReference(), + this.translationMessageSupplierProvider.get("platform.component.wiki.programmingRightRequiredMessage"), + this.objectBlockSupplierProvider.get(object), + List.of(RequiredRight.PROGRAM))); + } +} diff --git a/xwiki-platform-core/xwiki-platform-component/xwiki-platform-component-wiki/src/main/resources/ApplicationResources.properties b/xwiki-platform-core/xwiki-platform-component/xwiki-platform-component-wiki/src/main/resources/ApplicationResources.properties new file mode 100644 index 0000000000000000000000000000000000000000..14db1cfbdef57983c02658b45d6a556515d2130c --- /dev/null +++ b/xwiki-platform-core/xwiki-platform-component/xwiki-platform-component-wiki/src/main/resources/ApplicationResources.properties @@ -0,0 +1,52 @@ +# --------------------------------------------------------------------------- +# See the NOTICE file distributed with this work for additional +# information regarding copyright ownership. +# +# This is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation; either version 2.1 of +# the License, or (at your option) any later version. +# +# This software is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this software; if not, write to the Free +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +# 02110-1301 USA, or see the FSF site: http://www.fsf.org. +# --------------------------------------------------------------------------- + +############################################################################### +# Wiki Component localization +# +# This contains the translations of the module in the default language +# (generally English). +# +# Translation key syntax: +# <short top level project name>.<short module name>.<propertyName> +# where: +# * <short top level project name> = top level project name without the "xwiki-" prefix, +# for example: commons, rendering, platform, enterprise, manager, etc +# * <short module name> = the name of the Maven module without the <short top level project name> prefix, +# for example: oldcore, scheduler, activitystream, etc +# * <propertyName> = the name of the property using camel case, +# for example updateJobClassCommitComment +# +# Comments: it's possible to add some detail about a key to make easier to +# translate it by adding a comment before it. To make sure a comment is not +# assigned to the following key use at least three sharps (###) for the comment +# or after it. +# +# Deprecated keys: +# * when deleting a key it should be moved to deprecated section at the end +# of the file (between #@deprecatedstart and #@deprecatedend) and associated to the +# first version in which it started to be deprecated +# * when renaming a key, it should be moved to the same deprecated section +# and a comment should be added with the following syntax: +# #@deprecated new.key.name +# old.key.name=Some translation +############################################################################### + +platform.component.wiki.programmingRightRequiredMessage=Registering wiki components requires programming rights diff --git a/xwiki-platform-core/xwiki-platform-component/xwiki-platform-component-wiki/src/main/resources/META-INF/components.txt b/xwiki-platform-core/xwiki-platform-component/xwiki-platform-component-wiki/src/main/resources/META-INF/components.txt index 15892a0805538b4f0c9ef0679b9379c3622cdd40..814a4e571490f385f5866f61c689da3aa0c0f10d 100644 --- a/xwiki-platform-core/xwiki-platform-component/xwiki-platform-component-wiki/src/main/resources/META-INF/components.txt +++ b/xwiki-platform-core/xwiki-platform-component/xwiki-platform-component-wiki/src/main/resources/META-INF/components.txt @@ -8,6 +8,7 @@ org.xwiki.component.wiki.internal.DefaultWikiComponentManagerContext org.xwiki.component.wiki.internal.DefaultWikiComponentManagerEventListener org.xwiki.component.wiki.internal.DefaultWikiComponentMethodExecutor org.xwiki.component.wiki.internal.WikiComponentManagerEventListenerHelper +org.xwiki.component.wiki.internal.WikiComponentRequiredRightAnalyzer org.xwiki.component.wiki.internal.bridge.DefaultContentParser org.xwiki.component.wiki.internal.bridge.DefaultWikiComponentBridge org.xwiki.component.wiki.internal.bridge.DefaultWikiObjectComponentManagerEventListener