Mercurial > hg > AnnotationManagerN4J
annotate src/main/java/de/mpiwg/itgroup/annotations/restlet/annotations_ui/AnnotationsUiRestlet.java @ 72:4c2cea836bc0
restlet 2.1 works now. (it's the start() method, stupid!)
author | casties |
---|---|
date | Tue, 11 Mar 2014 17:43:00 +0100 |
parents | 2b1e6df5e21a |
children | 25eb2e1df106 |
rev | line source |
---|---|
18 | 1 /** |
2 * | |
3 */ | |
23
d22d01ba953a
reorganised code for annotations and groups ui. work in progress.
casties
parents:
22
diff
changeset
|
4 package de.mpiwg.itgroup.annotations.restlet.annotations_ui; |
18 | 5 |
70 | 6 /* |
7 * #%L | |
8 * AnnotationManager | |
9 * %% | |
10 * Copyright (C) 2012 - 2014 MPIWG Berlin | |
11 * %% | |
12 * This program is free software: you can redistribute it and/or modify | |
13 * it under the terms of the GNU Lesser General Public License as | |
14 * published by the Free Software Foundation, either version 3 of the | |
15 * License, or (at your option) any later version. | |
16 * | |
17 * This program is distributed in the hope that it will be useful, | |
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 * GNU General Lesser Public License for more details. | |
21 * | |
22 * You should have received a copy of the GNU General Lesser Public | |
23 * License along with this program. If not, see | |
24 * <http://www.gnu.org/licenses/lgpl-3.0.html>. | |
25 * #L% | |
26 */ | |
27 | |
18 | 28 import org.apache.log4j.Logger; |
29 import org.restlet.Restlet; | |
49 | 30 import org.restlet.data.ChallengeScheme; |
18 | 31 import org.restlet.routing.Router; |
49 | 32 import org.restlet.security.ChallengeAuthenticator; |
33 import org.restlet.security.MapVerifier; | |
18 | 34 |
23
d22d01ba953a
reorganised code for annotations and groups ui. work in progress.
casties
parents:
22
diff
changeset
|
35 import de.mpiwg.itgroup.annotations.restlet.BaseRestlet; |
d22d01ba953a
reorganised code for annotations and groups ui. work in progress.
casties
parents:
22
diff
changeset
|
36 |
18 | 37 /** |
38 * @author casties | |
39 * | |
40 */ | |
23
d22d01ba953a
reorganised code for annotations and groups ui. work in progress.
casties
parents:
22
diff
changeset
|
41 public class AnnotationsUiRestlet extends BaseRestlet { |
18 | 42 |
50 | 43 public final String version = "AnnotationManagerN4J/AnnotationsUI 0.3"; |
18 | 44 |
23
d22d01ba953a
reorganised code for annotations and groups ui. work in progress.
casties
parents:
22
diff
changeset
|
45 public static Logger logger = Logger.getLogger(AnnotationsUiRestlet.class); |
18 | 46 |
47 /* | |
48 * (non-Javadoc) | |
49 * | |
50 * @see org.restlet.Application#createInboundRoot() | |
51 */ | |
52 @Override | |
53 public Restlet createInboundRoot() { | |
54 // this.authenticator = createAuthenticator(); | |
55 | |
56 Router router = new Router(getContext()); | |
57 | |
23
d22d01ba953a
reorganised code for annotations and groups ui. work in progress.
casties
parents:
22
diff
changeset
|
58 router.attach("/groups", GroupsResource.class); |
d22d01ba953a
reorganised code for annotations and groups ui. work in progress.
casties
parents:
22
diff
changeset
|
59 router.attach("/groups/", GroupsResource.class); |
d22d01ba953a
reorganised code for annotations and groups ui. work in progress.
casties
parents:
22
diff
changeset
|
60 router.attach("/groups/{id}", GroupResource.class); |
d22d01ba953a
reorganised code for annotations and groups ui. work in progress.
casties
parents:
22
diff
changeset
|
61 router.attach("/groups/{id}/", GroupResource.class); |
d22d01ba953a
reorganised code for annotations and groups ui. work in progress.
casties
parents:
22
diff
changeset
|
62 router.attach("/groups/{id}/members", GroupMembersResource.class); |
32
0731c4549065
UI for editing groups and persons works now. (still no authorisation!)
casties
parents:
23
diff
changeset
|
63 router.attach("/persons", PersonsResource.class); |
0731c4549065
UI for editing groups and persons works now. (still no authorisation!)
casties
parents:
23
diff
changeset
|
64 router.attach("/persons/", PersonsResource.class); |
0731c4549065
UI for editing groups and persons works now. (still no authorisation!)
casties
parents:
23
diff
changeset
|
65 router.attach("/persons/{id}", PersonResource.class); |
0731c4549065
UI for editing groups and persons works now. (still no authorisation!)
casties
parents:
23
diff
changeset
|
66 router.attach("/persons/{id}/", PersonResource.class); |
50 | 67 router.attach("/annotations", AnnotationsResource.class); |
68 router.attach("/annotations/", AnnotationsResource.class); | |
69 router.attach("/annotations/{id}", AnnotationResource.class); | |
70 router.attach("/annotations/{id}/", AnnotationResource.class); | |
18 | 71 |
23
d22d01ba953a
reorganised code for annotations and groups ui. work in progress.
casties
parents:
22
diff
changeset
|
72 router.attach("/", InfoResource.class); |
18 | 73 |
50 | 74 // use simple password verifier |
49 | 75 MapVerifier verifier = new MapVerifier(); |
50 | 76 // get user name and password |
77 String user = serverConfig.getProperty(BaseRestlet.ADMIN_USER_KEY); | |
78 String pw = serverConfig.getProperty(BaseRestlet.ADMIN_PASSWORD_KEY); | |
53 | 79 if (user != null && pw != null) { |
80 verifier.getLocalSecrets().put(user, pw.toCharArray()); | |
81 } else { | |
82 logger.error("Admin user and password missing in serverconfig!"); | |
83 } | |
49 | 84 // Create a Guard |
85 ChallengeAuthenticator guard = new ChallengeAuthenticator(getContext(), ChallengeScheme.HTTP_BASIC, "Tutorial"); | |
86 guard.setVerifier(verifier); | |
87 // put everything through guard | |
88 guard.setNext(router); | |
89 return guard; | |
18 | 90 } |
91 | |
92 @Override | |
93 public String getVersion() { | |
94 return version; | |
95 } | |
96 | |
97 } |