/** * */ package de.mpiwg.itgroup.annotations.restlet.annotations_ui; /* * #%L * AnnotationManager * %% * Copyright (C) 2012 - 2014 MPIWG Berlin * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Lesser Public License for more details. * * You should have received a copy of the GNU General Lesser Public * License along with this program. If not, see * . * #L% */ import org.apache.log4j.Logger; import org.restlet.Context; import org.restlet.Restlet; import org.restlet.data.ChallengeScheme; import org.restlet.routing.Router; import org.restlet.security.ChallengeAuthenticator; import org.restlet.security.MapVerifier; import de.mpiwg.itgroup.annotations.restlet.BaseRestlet; /** * @author casties * */ public class AnnotationsUiRestlet extends BaseRestlet { public final String version = "AnnotationManagerN4J/AnnotationsUI 0.3"; public static Logger logger = Logger.getLogger(AnnotationsUiRestlet.class); public AnnotationsUiRestlet(Context context) { super(context); logger.info(version); } /* * (non-Javadoc) * * @see org.restlet.Application#createInboundRoot() */ @Override public Restlet createInboundRoot() { // this.authenticator = createAuthenticator(); Router router = new Router(getContext()); router.attach("/groups", GroupsResource.class); router.attach("/groups/", GroupsResource.class); router.attach("/groups/{id}", GroupResource.class); router.attach("/groups/{id}/", GroupResource.class); router.attach("/groups/{id}/members", GroupMembersResource.class); router.attach("/persons", PersonsResource.class); router.attach("/persons/", PersonsResource.class); router.attach("/persons/{id}", PersonResource.class); router.attach("/persons/{id}/", PersonResource.class); router.attach("/annotations", AnnotationsResource.class); router.attach("/annotations/", AnnotationsResource.class); router.attach("/annotations/{id}", AnnotationResource.class); router.attach("/annotations/{id}/", AnnotationResource.class); router.attach("/", InfoResource.class); // use simple password verifier MapVerifier verifier = new MapVerifier(); // get user name and password String user = serverConfig.getProperty(BaseRestlet.ADMIN_USER_KEY); String pw = serverConfig.getProperty(BaseRestlet.ADMIN_PASSWORD_KEY); if (user != null && pw != null) { verifier.getLocalSecrets().put(user, pw.toCharArray()); } else { logger.error("Admin user and password missing in serverconfig!"); } // Create a Guard ChallengeAuthenticator guard = new ChallengeAuthenticator(getContext(), ChallengeScheme.HTTP_BASIC, "Tutorial"); guard.setVerifier(verifier); // put everything through guard guard.setNext(router); return guard; } @Override public String getVersion() { return version; } }