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; |
21 |
|
|
22 |
|
import java.util.Map; |
23 |
|
import java.util.Properties; |
24 |
|
|
25 |
|
import javax.inject.Inject; |
26 |
|
import javax.inject.Singleton; |
27 |
|
import javax.mail.Session; |
28 |
|
|
29 |
|
import org.xwiki.component.annotation.Component; |
30 |
|
import org.xwiki.mail.MailSenderConfiguration; |
31 |
|
import org.xwiki.mail.SessionFactory; |
32 |
|
import org.xwiki.mail.XWikiAuthenticator; |
33 |
|
|
34 |
|
|
35 |
|
@link |
36 |
|
|
37 |
|
|
38 |
|
@version |
39 |
|
@since |
40 |
|
|
41 |
|
@Component |
42 |
|
@Singleton |
|
|
| 72.7% |
Uncovered Elements: 3 (11) |
Complexity: 2 |
Complexity Density: 0.25 |
|
43 |
|
public class DefaultSessionFactory implements SessionFactory |
44 |
|
{ |
45 |
|
@Inject |
46 |
|
private MailSenderConfiguration configuration; |
47 |
|
|
|
|
| 70% |
Uncovered Elements: 3 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
48 |
38 |
@Override... |
49 |
|
public Session create(Map<String, String> additionProperties) |
50 |
|
{ |
51 |
38 |
Session session; |
52 |
|
|
53 |
38 |
Properties properties = this.configuration.getAllProperties(); |
54 |
38 |
for (Map.Entry<String, String> entry : additionProperties.entrySet()) { |
55 |
0 |
properties.setProperty(entry.getKey(), entry.getValue()); |
56 |
|
} |
57 |
|
|
58 |
38 |
if (this.configuration.usesAuthentication()) { |
59 |
0 |
session = Session.getInstance(properties, new XWikiAuthenticator(this.configuration)); |
60 |
|
} else { |
61 |
38 |
session = Session.getInstance(properties); |
62 |
|
} |
63 |
|
|
64 |
38 |
return session; |
65 |
|
} |
66 |
|
} |