Skip to content

Commit 1a6f1b2

Browse files
committed
XWIKI-22460: XWiki.ComponentClass is missing a required rights analyzer
* Add a required right analyzer for XWiki.ComponentClass.
1 parent 9175212 commit 1a6f1b2

4 files changed

Lines changed: 123 additions & 0 deletions

File tree

xwiki-platform-core/xwiki-platform-component/xwiki-platform-component-wiki/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@
7373
<artifactId>xwiki-platform-rendering-async-default</artifactId>
7474
<version>${project.version}</version>
7575
</dependency>
76+
<dependency>
77+
<groupId>org.xwiki.platform</groupId>
78+
<artifactId>xwiki-platform-security-requiredrights-api</artifactId>
79+
<version>${project.version}</version>
80+
</dependency>
7681

7782
<!-- Test Dependencies -->
7883
<dependency>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* See the NOTICE file distributed with this work for additional
3+
* information regarding copyright ownership.
4+
*
5+
* This is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU Lesser General Public License as
7+
* published by the Free Software Foundation; either version 2.1 of
8+
* the License, or (at your option) any later version.
9+
*
10+
* This software is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public
16+
* License along with this software; if not, write to the Free
17+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19+
*/
20+
package org.xwiki.component.wiki.internal;
21+
22+
import java.util.List;
23+
24+
import javax.inject.Inject;
25+
import javax.inject.Named;
26+
import javax.inject.Singleton;
27+
28+
import org.xwiki.component.annotation.Component;
29+
import org.xwiki.platform.security.requiredrights.RequiredRight;
30+
import org.xwiki.platform.security.requiredrights.RequiredRightAnalysisResult;
31+
import org.xwiki.platform.security.requiredrights.RequiredRightAnalyzer;
32+
import org.xwiki.platform.security.requiredrights.RequiredRightsException;
33+
import org.xwiki.platform.security.requiredrights.display.BlockSupplierProvider;
34+
35+
import com.xpn.xwiki.objects.BaseObject;
36+
37+
/**
38+
* A {@link RequiredRightAnalyzer} for wiki component XObjects.
39+
*
40+
* @since 15.10.12
41+
* @since 16.4.3
42+
* @since 16.8.0RC1
43+
* @version $Id$
44+
*/
45+
@Component
46+
@Singleton
47+
@Named("XWiki.ComponentClass")
48+
public class WikiComponentRequiredRightAnalyzer implements RequiredRightAnalyzer<BaseObject>
49+
{
50+
@Inject
51+
@Named("translation")
52+
private BlockSupplierProvider<String> translationMessageSupplierProvider;
53+
54+
@Inject
55+
private BlockSupplierProvider<BaseObject> objectBlockSupplierProvider;
56+
57+
@Override
58+
public List<RequiredRightAnalysisResult> analyze(BaseObject object) throws RequiredRightsException
59+
{
60+
return List.of(new RequiredRightAnalysisResult(object.getReference(),
61+
this.translationMessageSupplierProvider.get("platform.component.wiki.programmingRightRequiredMessage"),
62+
this.objectBlockSupplierProvider.get(object),
63+
List.of(RequiredRight.PROGRAM)));
64+
}
65+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# ---------------------------------------------------------------------------
2+
# See the NOTICE file distributed with this work for additional
3+
# information regarding copyright ownership.
4+
#
5+
# This is free software; you can redistribute it and/or modify it
6+
# under the terms of the GNU Lesser General Public License as
7+
# published by the Free Software Foundation; either version 2.1 of
8+
# the License, or (at your option) any later version.
9+
#
10+
# This software is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
# Lesser General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU Lesser General Public
16+
# License along with this software; if not, write to the Free
17+
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18+
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19+
# ---------------------------------------------------------------------------
20+
21+
###############################################################################
22+
# Wiki Component localization
23+
#
24+
# This contains the translations of the module in the default language
25+
# (generally English).
26+
#
27+
# Translation key syntax:
28+
# <short top level project name>.<short module name>.<propertyName>
29+
# where:
30+
# * <short top level project name> = top level project name without the "xwiki-" prefix,
31+
# for example: commons, rendering, platform, enterprise, manager, etc
32+
# * <short module name> = the name of the Maven module without the <short top level project name> prefix,
33+
# for example: oldcore, scheduler, activitystream, etc
34+
# * <propertyName> = the name of the property using camel case,
35+
# for example updateJobClassCommitComment
36+
#
37+
# Comments: it's possible to add some detail about a key to make easier to
38+
# translate it by adding a comment before it. To make sure a comment is not
39+
# assigned to the following key use at least three sharps (###) for the comment
40+
# or after it.
41+
#
42+
# Deprecated keys:
43+
# * when deleting a key it should be moved to deprecated section at the end
44+
# of the file (between #@deprecatedstart and #@deprecatedend) and associated to the
45+
# first version in which it started to be deprecated
46+
# * when renaming a key, it should be moved to the same deprecated section
47+
# and a comment should be added with the following syntax:
48+
# #@deprecated new.key.name
49+
# old.key.name=Some translation
50+
###############################################################################
51+
52+
platform.component.wiki.programmingRightRequiredMessage=Registering wiki components requires programming rights

xwiki-platform-core/xwiki-platform-component/xwiki-platform-component-wiki/src/main/resources/META-INF/components.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ org.xwiki.component.wiki.internal.DefaultWikiComponentManagerContext
88
org.xwiki.component.wiki.internal.DefaultWikiComponentManagerEventListener
99
org.xwiki.component.wiki.internal.DefaultWikiComponentMethodExecutor
1010
org.xwiki.component.wiki.internal.WikiComponentManagerEventListenerHelper
11+
org.xwiki.component.wiki.internal.WikiComponentRequiredRightAnalyzer
1112
org.xwiki.component.wiki.internal.bridge.DefaultContentParser
1213
org.xwiki.component.wiki.internal.bridge.DefaultWikiComponentBridge
1314
org.xwiki.component.wiki.internal.bridge.DefaultWikiObjectComponentManagerEventListener

0 commit comments

Comments
 (0)