1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.security.authorization

File AuthorExecutor.java

 

Code metrics

0
0
0
1
73
13
0
-
-
0
-

Classes

Class Line # Actions
AuthorExecutor 36 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 org.xwiki.security.authorization;
21   
22    import java.util.concurrent.Callable;
23   
24    import org.xwiki.component.annotation.Role;
25    import org.xwiki.model.reference.DocumentReference;
26    import org.xwiki.stability.Unstable;
27   
28    /**
29    * Allow executing some code with the right of a provided user.
30    *
31    * @version $Id: 58b39a438c7897c51ad85cd3ee4e70a5deb63754 $
32    * @since 8.3RC1
33    */
34    @Role
35    @Unstable
 
36    public interface AuthorExecutor
37    {
38    /**
39    * Execute the passed {@link Callable} with the rights of the passed user.
40    *
41    * @param callable the the task to execute
42    * @param authorReference the user to check rights on
43    * @return computed result
44    * @throws Exception if unable to compute a result
45    * @param <V> the result type of method <tt>call</tt>
46    */
47    <V> V call(Callable<V> callable, DocumentReference authorReference) throws Exception;
48   
49    /**
50    * Setup the context so that following code is executed with provided user rights.
51    *
52    * <pre>
53    * {@code
54    * try (AutoCloseable context = this.executor.before(author)) {
55    * ...
56    * }
57    * }
58    * </pre>
59    *
60    * @param authorReference the user to check rights on
61    * @return the context to restore
62    * @see #after(AutoCloseable)
63    */
64    AutoCloseable before(DocumentReference authorReference);
65   
66    /**
67    * Restore the context to it's previous state as defined by the provided {@link AutoCloseable}.
68    *
69    * @param context the context to restore
70    * @see #before(DocumentReference)
71    */
72    void after(AutoCloseable context);
73    }