1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rest.internal; |
21 |
|
|
22 |
|
import org.restlet.Restlet; |
23 |
|
import org.restlet.ext.jaxrs.JaxRsApplication; |
24 |
|
import org.restlet.routing.Router; |
25 |
|
import org.restlet.routing.Template; |
26 |
|
import org.xwiki.component.manager.ComponentManager; |
27 |
|
import org.xwiki.rest.internal.resources.BrowserAuthenticationResource; |
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
@version |
36 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 1 |
Complexity Density: 0.06 |
|
37 |
|
public class XWikiRestletJaxRsApplication extends JaxRsApplication |
38 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 1 |
Complexity Density: 0.06 |
|
39 |
18 |
@Override... |
40 |
|
public Restlet createInboundRoot() |
41 |
|
{ |
42 |
|
|
43 |
18 |
XWikiJaxRsApplication xwikiJaxRsApplication = new XWikiJaxRsApplication(getContext()); |
44 |
18 |
add(xwikiJaxRsApplication); |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
18 |
XWikiSetupCleanupFilter setupCleanupFilter = new XWikiSetupCleanupFilter(); |
51 |
|
|
52 |
18 |
XWikiAuthentication xwikiAuthentication = new XWikiAuthentication(getContext()); |
53 |
18 |
ComponentManager componentManager = |
54 |
|
(ComponentManager) getContext().getAttributes().get(Constants.XWIKI_COMPONENT_MANAGER); |
55 |
18 |
xwikiAuthentication.setVerifier(new XWikiSecretVerifier(getContext(), componentManager)); |
56 |
|
|
57 |
|
|
58 |
18 |
Router router = new Router(); |
59 |
18 |
router.attach(BrowserAuthenticationResource.URI_PATTERN, BrowserAuthenticationResource.class); |
60 |
18 |
router.setDefaultMatchingMode(Template.MODE_STARTS_WITH); |
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
18 |
Restlet jaxRsRoot = super.createInboundRoot(); |
67 |
|
|
68 |
|
|
69 |
18 |
getTunnelService().setEnabled(true); |
70 |
18 |
getMetadataService().addCommonExtensions(); |
71 |
18 |
getTunnelService().setQueryTunnel(true); |
72 |
|
|
73 |
18 |
router.attach(jaxRsRoot); |
74 |
|
|
75 |
|
|
76 |
18 |
setupCleanupFilter.setNext(xwikiAuthentication); |
77 |
18 |
xwikiAuthentication.setNext(router); |
78 |
|
|
79 |
|
|
80 |
18 |
return setupCleanupFilter; |
81 |
|
} |
82 |
|
|
83 |
|
} |