<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-servlet</artifactId>
+ </dependency>
<dependency>
<groupId>org.codehaus.enunciate</groupId>
<artifactId>enunciate-core-annotations</artifactId>
<artifactId>neutron-spi</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-servlets</artifactId>
+ </dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
</dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.aaa.web</groupId>
+ <artifactId>web-api</artifactId>
+ <version>0.8.0-SNAPSHOT</version>
+ </dependency>
</dependencies>
<build>
<plugins>
+ <plugin>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>blueprint-maven-plugin</artifactId>
+ </plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<Import-Package>
com.sun.jersey.spi.container.servlet,
org.eclipse.jetty.servlets,
- org.opendaylight.aaa.shiro.filters,
- org.opendaylight.aaa.shiro.realm,
- org.opendaylight.aaa.shiro.web.env,
- org.apache.shiro.web.env,
!org.codehaus.enunciate.jaxrs,
com.sun.xml.bind;resolution:=optional,
*
</Import-Package>
- <Web-ContextPath>/controller/nb/v2/neutron</Web-ContextPath>
-
<!-- Workaround for javax.ws.rs version mismatch with jackson/jersey/moxy -->
<Embed-Transitive>true</Embed-Transitive>
<Embed-Dependency>org.eclipse.persistence.moxy;inline</Embed-Dependency>
--- /dev/null
+/*
+ * Copyright (c) 2018 Red Hat, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.neutron.northbound.api;
+
+import javax.annotation.PreDestroy;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import javax.servlet.ServletException;
+import org.opendaylight.aaa.web.ServletDetails;
+import org.opendaylight.aaa.web.WebContext;
+import org.opendaylight.aaa.web.WebContextBuilder;
+import org.opendaylight.aaa.web.WebContextRegistration;
+import org.opendaylight.aaa.web.WebContextSecurer;
+import org.opendaylight.aaa.web.WebServer;
+
+/**
+ * Initializer for web components.
+ *
+ * @author Michael Vorburger.ch
+ */
+@Singleton
+public class WebInitializer {
+
+ private final WebContextRegistration registraton;
+
+ @Inject
+ public WebInitializer(WebServer webServer, WebContextSecurer webContextSecurer) throws ServletException {
+ WebContextBuilder webContextBuilder = WebContext.builder()
+ .contextPath("/controller/nb/v2/neutron").supportsSessions(true)
+ // TODO confirm through testing that Jersey & Neutron are fine without sessions, and false instead true
+
+ .addServlet(ServletDetails.builder()
+ .servlet(new com.sun.jersey.spi.container.servlet.ServletContainer(
+ new NeutronNorthboundRSApplication()))
+ .addUrlPattern("/*").build());
+
+ webContextSecurer.requireAuthentication(webContextBuilder, "/*");
+
+ this.registraton = webServer.registerWebContext(webContextBuilder.build());
+ }
+
+ @PreDestroy
+ public void close() {
+ registraton.close();
+ }
+
+}
+++ /dev/null
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- Copyright (c) 2018 Intel Corporation and others. All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 which accompanies this distribution,
- and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
- version="3.0">
- <servlet>
- <servlet-name>JAXRSNeutron</servlet-name>
- <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
- <init-param>
- <param-name>javax.ws.rs.Application</param-name>
- <param-value>org.opendaylight.neutron.northbound.api.NeutronNorthboundRSApplication</param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>JAXRSNeutron</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
-
- <context-param>
- <param-name>shiroEnvironmentClass</param-name>
- <param-value>org.opendaylight.aaa.shiro.web.env.KarafIniWebEnvironment</param-value>
- </context-param>
-
- <listener>
- <listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
- </listener>
-
- <filter>
- <filter-name>ShiroFilter</filter-name>
- <filter-class>org.opendaylight.aaa.shiro.filters.AAAShiroFilter</filter-class>
- </filter>
-
- <filter-mapping>
- <filter-name>ShiroFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
- <filter>
- <filter-name>cross-origin-restconf</filter-name>
- <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>
- <init-param>
- <param-name>allowedOrigins</param-name>
- <param-value>*</param-value>
- </init-param>
- <init-param>
- <param-name>allowedMethods</param-name>
- <param-value>GET,POST,OPTIONS,DELETE,PUT,HEAD</param-value>
- </init-param>
- <init-param>
- <param-name>allowedHeaders</param-name>
- <param-value>origin, content-type, accept, authorization</param-value>
- </init-param>
- </filter>
- <filter-mapping>
- <filter-name>cross-origin-restconf</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-</web-app>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0">
+
+ <reference id="webServer" interface="org.opendaylight.aaa.web.WebServer" />
+
+ <reference id="webContextSecurer" interface="org.opendaylight.aaa.web.WebContextSecurer" />
+
+</blueprint>
<plugin>
<groupId>org.apache.aries.blueprint</groupId>
<artifactId>blueprint-maven-plugin</artifactId>
+ <configuration>
+ <scanPaths>
+ <!-- This is required so that the @Singleton @Inject annotations used in northbound-api,
+ which is a dependency of this project JUST for its BadRequestException, do not cause
+ the autowire.xml generated in this project to include the <bean> etc. of northbound-api
+ to be repeated (which would be wrong and causes e.g. "Unresolved ref/idref to component: webContextSecurer");
+ see also https://wiki.opendaylight.org/view/BestPractices/DI_Guidelines#Nota_Bene for more background about this.
+ A better solution may be to move the BadRequestException to a new artifact ("common" ?), or perhaps, seeing that it
+ extends javax.ws.rs.WebApplicationException, make transcriber have its own Exception to be independent of JAX WS. -->
+ <scanPath>org.opendaylight.neutron.transcriber</scanPath>
+ </scanPaths>
+ </configuration>
</plugin>
</plugins>
</build>