2 * Copyright (c) 2018 Inocybe Technologies and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yanglib.impl;
10 import javax.servlet.ServletException;
11 import javax.ws.rs.core.Application;
12 import org.opendaylight.aaa.web.ServletDetails;
13 import org.opendaylight.aaa.web.WebContext;
14 import org.opendaylight.aaa.web.WebContextBuilder;
15 import org.opendaylight.aaa.web.WebContextRegistration;
16 import org.opendaylight.aaa.web.WebContextSecurer;
17 import org.opendaylight.aaa.web.WebServer;
20 * Initializes the wep app.
22 * @author Thomas Pantelis
24 public class WebInitializer {
25 private final WebContextRegistration registration;
27 public WebInitializer(WebServer webServer, WebContextSecurer webContextSecurer, Application webApp)
28 throws ServletException {
29 WebContextBuilder webContextBuilder = WebContext.builder().contextPath("yanglib").supportsSessions(true)
30 .addServlet(ServletDetails.builder().servlet(
31 new com.sun.jersey.spi.container.servlet.ServletContainer(webApp))
32 .addUrlPattern("/*").build());
34 webContextSecurer.requireAuthentication(webContextBuilder, "/*");
36 registration = webServer.registerWebContext(webContextBuilder.build());