1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.user.api

File XWikiRightService.java

 

Code metrics

0
0
0
1
152
27
0
-
-
0
-

Classes

Class Line # Actions
XWikiRightService 28 0 - 0 0
-1.0 -
 

Contributing tests

No tests hitting this source file were found.

Source view

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 com.xpn.xwiki.user.api;
21   
22    import java.util.List;
23   
24    import com.xpn.xwiki.XWikiContext;
25    import com.xpn.xwiki.XWikiException;
26    import com.xpn.xwiki.doc.XWikiDocument;
27   
 
28    public interface XWikiRightService
29    {
30    /**
31    * The Superadmin username.
32    */
33    String SUPERADMIN_USER = "superadmin";
34   
35    /**
36    * The Superadmin full name.
37    */
38    String SUPERADMIN_USER_FULLNAME = "XWiki." + SUPERADMIN_USER;
39   
40    /**
41    * The Guest username.
42    */
43    String GUEST_USER = "XWikiGuest";
44   
45    /**
46    * The Guest full name.
47    */
48    String GUEST_USER_FULLNAME = "XWiki." + GUEST_USER;
49   
50    /**
51    * The AllGroup username.
52    */
53    String ALLGROUP_GROUP = "XWikiAllGroup";
54   
55    /**
56    * The AllGroup full name.
57    */
58    String ALLGROUP_GROUP_FULLNAME = "XWiki." + ALLGROUP_GROUP;
59   
60    /**
61    * Checks if the wiki current user has the right to execute (@code action} on the document {@code doc}, along with
62    * redirecting to the login if it's not the case and there is no logged in user (the user is the guest user).
63    *
64    * @param action the action to be executed on the document
65    * @param doc the document to perform action on
66    * @param context the xwiki context in which to perform the verification (from which to get the user, for example)
67    * @return {@code true} if the user has right to execute {@code action} on {@code doc}, {@code false} otherwise
68    * <strong> and requests the login from the authentication service (redirecting to the login page in the
69    * case of a form authenticator, for example) when no user is logged in. </strong>
70    * @throws XWikiException if something goes wrong during the rights checking process
71    */
72    boolean checkAccess(String action, XWikiDocument doc, XWikiContext context) throws XWikiException;
73   
74    /**
75    * Verifies if the user identified by {@code username} has the access level identified by {@code right} on the
76    * document with the name {@code docname}.
77    *
78    * @param right the access level to check (for example, 'view' or 'edit' or 'comment').
79    * @param username the name of the user to check the right for
80    * @param docname the document on which to check the right
81    * @param context the xwiki context in which to perform the verification
82    * @return {@code true} if the user has the specified right on the document, {@code false} otherwise
83    * @throws XWikiException if something goes wrong during the rights checking process
84    * @deprecated since 4.0M2, use
85    * {@link org.xwiki.security.authorization.AuthorizationManager#hasAccess(org.xwiki.security.authorization.Right, org.xwiki.model.reference.DocumentReference, org.xwiki.model.reference.EntityReference)}
86    * instead
87    */
88    @Deprecated
89    boolean hasAccessLevel(String right, String username, String docname, XWikiContext context)
90    throws XWikiException;
91   
92    /**
93    * Checks if the author of the context document (last editor of the content of the document) has programming rights
94    * (used to determine if the protected calls in the script contained in the document should be executed or not).
95    *
96    * @param context the xwiki context of this request
97    * @return {@code true} if the author of the context document has programming rights, {@code false} otherwise.
98    * @deprecated since 6.1RC1, use
99    * {@link org.xwiki.security.authorization.ContextualAuthorizationManager#hasAccess(org.xwiki.security.authorization.Right)}
100    * instead
101    */
102    @Deprecated
103    boolean hasProgrammingRights(XWikiContext context);
104   
105    /**
106    * Checks if the author of the passed document (last editor of the content of the document) has programming rights
107    * (used to determine if the protected calls in the script contained in the document should be executed or not).
108    *
109    * @param doc the document to check programming rights for
110    * @param context the xwiki context of this request
111    * @return {@code true} if the author of {@code doc} has programming rights, {@code false} otherwise.
112    * @deprecated since 6.1RC1, use
113    * {@link org.xwiki.security.authorization.ContextualAuthorizationManager#hasAccess(org.xwiki.security.authorization.Right, org.xwiki.model.reference.EntityReference)}
114    * instead
115    */
116    @Deprecated
117    boolean hasProgrammingRights(XWikiDocument doc, XWikiContext context);
118   
119    /**
120    * Checks that the current user in the context (the currently authenticated user) has administration rights either
121    * on the current wiki or on the current space.
122    *
123    * @param context the xwiki context of this request
124    * @return {@code true} if the current user in the context has the {@code admin} right, {@code false} otherwise
125    * @deprecated since 6.1RC1, use
126    * {@link org.xwiki.security.authorization.ContextualAuthorizationManager#hasAccess(org.xwiki.security.authorization.Right)}
127    * instead
128    */
129    @Deprecated
130    boolean hasAdminRights(XWikiContext context);
131   
132    /**
133    * Checks that the current user in the context (the currently authenticated user) has administration rights on the
134    * current wiki, regardless of any space admin rights that might also be available.
135    *
136    * @param context the xwiki context of this request
137    * @return {@code true} if the current user in the context has the {@code admin} right, {@code false} otherwise
138    * @since 3.2M3
139    * @deprecated since 6.1RC1, use
140    * {@link org.xwiki.security.authorization.ContextualAuthorizationManager#hasAccess(org.xwiki.security.authorization.Right, org.xwiki.model.reference.EntityReference)}
141    * instead
142    */
143    @Deprecated
144    boolean hasWikiAdminRights(XWikiContext context);
145   
146    /**
147    * @param context the xwiki context of this request
148    * @return the list of all the known access levels
149    * @throws XWikiException if something goes wrong during the rights checking process
150    */
151    List<String> listAllLevels(XWikiContext context) throws XWikiException;
152    }