| 189 |
pharsh |
1 |
/*
|
|
|
2 |
* To change this template, choose Tools | Templates
|
|
|
3 |
* and open the template in the editor.
|
|
|
4 |
*/
|
|
|
5 |
package vep;
|
|
|
6 |
|
|
|
7 |
import org.restlet.Application;
|
|
|
8 |
import org.restlet.Restlet;
|
| 228 |
pharsh |
9 |
import org.restlet.data.ChallengeScheme;
|
| 189 |
pharsh |
10 |
import org.restlet.routing.Router;
|
| 228 |
pharsh |
11 |
import org.restlet.security.ChallengeAuthenticator;
|
|
|
12 |
import org.restlet.security.MapVerifier;
|
| 189 |
pharsh |
13 |
/**
|
|
|
14 |
*
|
|
|
15 |
* @author piyush
|
|
|
16 |
*/
|
| 733 |
pharsh |
17 |
public class restServerRouter extends Application
|
| 189 |
pharsh |
18 |
{
|
|
|
19 |
@Override
|
|
|
20 |
public synchronized Restlet createInboundRoot()
|
| 733 |
pharsh |
21 |
//public synchronized Restlet createRoot()
|
| 189 |
pharsh |
22 |
{
|
|
|
23 |
// Create a router Restlet that routes each call to a new instance of HelloWorldResource.
|
|
|
24 |
Router router = new Router(getContext());
|
| 733 |
pharsh |
25 |
|
| 189 |
pharsh |
26 |
// Defines only one route
|
| 228 |
pharsh |
27 |
MapVerifier verifier = new MapVerifier();
|
|
|
28 |
verifier.getLocalSecrets().put("admin", "pass1234".toCharArray());
|
|
|
29 |
ChallengeAuthenticator guard = new ChallengeAuthenticator(getContext(), ChallengeScheme.HTTP_BASIC, "VEP REST Interface Access");
|
|
|
30 |
guard.setVerifier(verifier);
|
|
|
31 |
|
| 189 |
pharsh |
32 |
router.attach("/", restServerRootResource.class);
|
| 228 |
pharsh |
33 |
|
| 1398 |
pharsh |
34 |
//router.attach("/host/", guard);
|
|
|
35 |
//guard.setNext(restServerHostResource.class);
|
| 228 |
pharsh |
36 |
|
|
|
37 |
|
| 1398 |
pharsh |
38 |
router.attach("/host/", restServerHostResource.class);
|
| 228 |
pharsh |
39 |
|
| 196 |
pharsh |
40 |
router.attach("/host/{id}", restServerHostDetails.class);
|
| 228 |
pharsh |
41 |
|
|
|
42 |
router.attach("/user/", restServerUserResource.class);
|
| 230 |
pharsh |
43 |
router.attach("/user/{name}", restServerUserResource.class);
|
| 228 |
pharsh |
44 |
|
| 938 |
pharsh |
45 |
router.attach("/ovf/", restServerOVFResource.class);
|
|
|
46 |
router.attach("/ovf/{name}", restServerOVFResource.class);
|
| 973 |
pharsh |
47 |
//router.attach("/ovf/{name}/action/{action}", restServerOVFResource.class);
|
| 931 |
pharsh |
48 |
router.attach("/ovf/id/{sno}", restServerOVFDetails.class);
|
| 973 |
pharsh |
49 |
router.attach("/ovf/id/{sno}/action/{action}", restServerOVFDetails.class);
|
| 842 |
pharsh |
50 |
|
| 1326 |
pharsh |
51 |
router.attach("/vm/", restServerVMResource.class);
|
|
|
52 |
router.attach("/vm/{id}", restServerVMResource.class);
|
|
|
53 |
router.attach("/vm/{id}/action/{action}", restServerVMAction.class);
|
|
|
54 |
|
| 1408 |
pharsh |
55 |
router.attach("/template/", restServerTemplateResource.class);
|
| 3040 |
pharsh |
56 |
router.attach("/template/{id}", restServerTemplateDetails.class);
|
|
|
57 |
router.attach("/template/{id}/action/deploy", restServerTemplateAction.class);
|
| 1408 |
pharsh |
58 |
|
| 228 |
pharsh |
59 |
ChallengeAuthenticator guard1 = new ChallengeAuthenticator(getContext(), ChallengeScheme.HTTP_BASIC, "VEP REST Admin Interface Access");
|
|
|
60 |
MapVerifier verifier1 = new MapVerifier();
|
|
|
61 |
verifier1.getLocalSecrets().put("admin-vep", "pass1234".toCharArray());
|
|
|
62 |
guard1.setVerifier(verifier1);
|
|
|
63 |
router.attach("/admin/", guard1);
|
|
|
64 |
guard1.setNext(restServerAdminControl.class);
|
| 189 |
pharsh |
65 |
return router;
|
|
|
66 |
}
|
|
|
67 |
}
|