1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.query.internal; |
21 |
|
|
22 |
|
import java.util.List; |
23 |
|
import java.util.Set; |
24 |
|
|
25 |
|
import javax.inject.Inject; |
26 |
|
import javax.inject.Named; |
27 |
|
import javax.inject.Singleton; |
28 |
|
|
29 |
|
import org.xwiki.component.annotation.Component; |
30 |
|
import org.xwiki.query.Query; |
31 |
|
import org.xwiki.query.QueryException; |
32 |
|
import org.xwiki.query.QueryExecutorManager; |
33 |
|
import org.xwiki.query.SecureQuery; |
34 |
|
import org.xwiki.security.authorization.ContextualAuthorizationManager; |
35 |
|
import org.xwiki.security.authorization.Right; |
36 |
|
|
37 |
|
|
38 |
|
@link |
39 |
|
|
40 |
|
@version |
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
@Component(roles = { QueryExecutorManager.class }) |
46 |
|
@Named("secure") |
47 |
|
@Singleton |
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 4 |
Complexity Density: 0.57 |
|
48 |
|
public class SecureQueryExecutorManager implements QueryExecutorManager |
49 |
|
{ |
50 |
|
@Inject |
51 |
|
private QueryExecutorManager defaultQueryExecutorManager; |
52 |
|
|
53 |
|
@Inject |
54 |
|
private ContextualAuthorizationManager authorization; |
55 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
56 |
399 |
@Override... |
57 |
|
public <T> List<T> execute(Query query) throws QueryException |
58 |
|
{ |
59 |
399 |
if (query instanceof SecureQuery) { |
60 |
397 |
SecureQuery secureQuery = (SecureQuery) query; |
61 |
|
|
62 |
397 |
secureQuery.checkCurrentAuthor(true); |
63 |
2 |
} else if (!this.authorization.hasAccess(Right.PROGRAM)) { |
64 |
1 |
throw new QueryException("Unsecure query require programming right", query, null); |
65 |
|
} |
66 |
|
|
67 |
398 |
return this.defaultQueryExecutorManager.execute(query); |
68 |
|
} |
69 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
70 |
422 |
@Override... |
71 |
|
public Set<String> getLanguages() |
72 |
|
{ |
73 |
422 |
return this.defaultQueryExecutorManager.getLanguages(); |
74 |
|
} |
75 |
|
} |