1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.mail.internal.factory.template; |
21 |
|
|
22 |
|
import java.util.Map; |
23 |
|
|
24 |
|
import javax.inject.Inject; |
25 |
|
import javax.inject.Named; |
26 |
|
import javax.inject.Singleton; |
27 |
|
import javax.mail.MessagingException; |
28 |
|
|
29 |
|
import org.xwiki.bridge.DocumentAccessBridge; |
30 |
|
import org.xwiki.component.annotation.Component; |
31 |
|
import org.xwiki.model.reference.DocumentReference; |
32 |
|
import org.xwiki.security.authorization.AuthorizationManager; |
33 |
|
import org.xwiki.security.authorization.Right; |
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
@version |
40 |
|
@since |
41 |
|
|
42 |
|
@Component |
43 |
|
@Named("secure") |
44 |
|
@Singleton |
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 3 |
Complexity Density: 0.75 |
|
45 |
|
public class SecureMailTemplateManager implements MailTemplateManager |
46 |
|
{ |
47 |
|
@Inject |
48 |
|
private MailTemplateManager templateManager; |
49 |
|
|
50 |
|
@Inject |
51 |
|
private AuthorizationManager authorizationManager; |
52 |
|
|
53 |
|
@Inject |
54 |
|
private DocumentAccessBridge documentBridge; |
55 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
56 |
7 |
@Override... |
57 |
|
public String evaluate(DocumentReference templateReference, String property, Map<String, Object> velocityVariables, |
58 |
|
Object localeValue) throws MessagingException |
59 |
|
{ |
60 |
|
|
61 |
7 |
if (!this.authorizationManager.hasAccess( |
62 |
|
Right.VIEW, this.documentBridge.getCurrentUserReference(), templateReference)) |
63 |
|
{ |
64 |
1 |
throw new MessagingException( |
65 |
|
String.format("Current user [%s] has no permission to view Mail Template Document [%s]", |
66 |
|
this.documentBridge.getCurrentUserReference(), templateReference)); |
67 |
|
} |
68 |
|
|
69 |
6 |
return this.templateManager.evaluate(templateReference, property, velocityVariables, localeValue); |
70 |
|
} |
71 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
72 |
1 |
@Override... |
73 |
|
public String evaluate(DocumentReference documentReference, String property, |
74 |
|
Map<String, Object> velocityVariables) throws MessagingException |
75 |
|
{ |
76 |
1 |
return evaluate(documentReference, property, velocityVariables, null); |
77 |
|
} |
78 |
|
} |