source: AnnotationManagerN4J/src/main/java/de/mpiwg/itgroup/annotations/restlet/annotations_ui/AnnotationsUiRestlet.java @ 93:3d1a00418b42

admin_ui_rel_links
Last change on this file since 93:3d1a00418b42 was 93:3d1a00418b42, checked in by casties, 9 years ago

starting web admin ui with relative links. doesn't fully work yet.

File size: 3.4 KB
Line 
1package de.mpiwg.itgroup.annotations.restlet.annotations_ui;
2
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
25import java.util.logging.Logger;
26
27import org.restlet.Restlet;
28import org.restlet.data.ChallengeScheme;
29import org.restlet.routing.Router;
30import org.restlet.security.ChallengeAuthenticator;
31import org.restlet.security.MapVerifier;
32
33import de.mpiwg.itgroup.annotations.restlet.BaseRestlet;
34
35/**
36 * @author casties
37 *
38 */
39public class AnnotationsUiRestlet extends BaseRestlet {
40
41    public final String version = "AnnotationManagerN4J/AnnotationsUI 0.4";
42
43    public static Logger logger = Logger.getLogger("de.mpiwg.itgroup.annotations.restlet.annotations_ui.AnnotationsUiRestlet");
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
56        router.attach("/groups", GroupsResource.class);
57        router.attach("/groups/", GroupsResource.class);
58        router.attach("/groups/{id}", GroupResource.class);
59        router.attach("/groups/{id}/", GroupResource.class);
60        router.attach("/groups/{id}/members", GroupMembersResource.class);
61        router.attach("/persons", PersonsResource.class);
62        router.attach("/persons/", PersonsResource.class);
63        router.attach("/persons/{id}", PersonResource.class);
64        router.attach("/persons/{id}/", PersonResource.class);
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);
69
70        router.attach("/", InfoResource.class);
71
72        // use simple password verifier
73        MapVerifier verifier = new MapVerifier();
74        // get user name and password
75        String user = serverConfig.getProperty(BaseRestlet.ADMIN_USER_KEY);
76        String pw = serverConfig.getProperty(BaseRestlet.ADMIN_PASSWORD_KEY);
77        if (user != null && pw != null) {
78            verifier.getLocalSecrets().put(user, pw.toCharArray());
79        } else {
80            logger.severe("Admin user and password missing in serverconfig!");
81        }
82        // Create a Guard
83        ChallengeAuthenticator guard = new ChallengeAuthenticator(getContext(), ChallengeScheme.HTTP_BASIC, "Annotation Server");
84        guard.setVerifier(verifier);
85        // put everything through guard
86        guard.setNext(router);
87        return guard;
88    }
89
90    @Override
91    public String getVersion() {
92        return version;
93    }
94
95}
Note: See TracBrowser for help on using the repository browser.