Skip to content
Snippets Groups Projects
Commit 1a6f1b2e authored by Michael Hamann's avatar Michael Hamann
Browse files

XWIKI-22460: XWiki.ComponentClass is missing a required rights analyzer

* Add a required right analyzer for XWiki.ComponentClass.
parent 91752122
No related branches found
No related tags found
No related merge requests found
...@@ -73,6 +73,11 @@ ...@@ -73,6 +73,11 @@
<artifactId>xwiki-platform-rendering-async-default</artifactId> <artifactId>xwiki-platform-rendering-async-default</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-security-requiredrights-api</artifactId>
<version>${project.version}</version>
</dependency>
<!-- Test Dependencies --> <!-- Test Dependencies -->
<dependency> <dependency>
......
/*
* 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)));
}
}
# ---------------------------------------------------------------------------
# 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
...@@ -8,6 +8,7 @@ org.xwiki.component.wiki.internal.DefaultWikiComponentManagerContext ...@@ -8,6 +8,7 @@ org.xwiki.component.wiki.internal.DefaultWikiComponentManagerContext
org.xwiki.component.wiki.internal.DefaultWikiComponentManagerEventListener org.xwiki.component.wiki.internal.DefaultWikiComponentManagerEventListener
org.xwiki.component.wiki.internal.DefaultWikiComponentMethodExecutor org.xwiki.component.wiki.internal.DefaultWikiComponentMethodExecutor
org.xwiki.component.wiki.internal.WikiComponentManagerEventListenerHelper 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.DefaultContentParser
org.xwiki.component.wiki.internal.bridge.DefaultWikiComponentBridge org.xwiki.component.wiki.internal.bridge.DefaultWikiComponentBridge
org.xwiki.component.wiki.internal.bridge.DefaultWikiObjectComponentManagerEventListener org.xwiki.component.wiki.internal.bridge.DefaultWikiObjectComponentManagerEventListener
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment