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