+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright © 2017 Red Hat, Inc. and others.
-
- 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
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>single-feature-parent</artifactId>
- <version>4.0.9</version>
- <relativePath/>
- </parent>
-
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>odl-restconf-nb-bierman02-base</artifactId>
- <version>1.10.0-SNAPSHOT</version>
- <packaging>feature</packaging>
-
- <name>OpenDaylight :: Restconf :: NB :: bierman02 :: Base</name>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>3.0.6</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>restconf-artifacts</artifactId>
- <version>1.10.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>odl-mdsal-model-draft-bierman-netconf-restconf-02</artifactId>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>odl-restconf-common</artifactId>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>restconf-nb-bierman02</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>sal-rest-connector-config</artifactId>
- <version>${project.version}</version>
- <type>cfg</type>
- <classifier>restconf</classifier>
- </dependency>
- </dependencies>
-</project>
<name>OpenDaylight :: Restconf :: NB :: bierman02</name>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-artifacts</artifactId>
+ <version>3.0.6</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>restconf-artifacts</artifactId>
+ <version>1.10.0-SNAPSHOT</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
<dependencies>
+ <dependency>
+ <groupId>org.opendaylight.mdsal.model</groupId>
+ <artifactId>odl-mdsal-model-draft-bierman-netconf-restconf-02</artifactId>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
<dependency>
<groupId>org.opendaylight.netconf</groupId>
- <artifactId>odl-restconf-nb-bierman02-base</artifactId>
- <version>${project.version}</version>
+ <artifactId>odl-restconf-common</artifactId>
<type>xml</type>
<classifier>features</classifier>
</dependency>
<dependency>
<groupId>org.opendaylight.netconf</groupId>
- <artifactId>restconf-nb-bierman02-auth</artifactId>
+ <artifactId>restconf-nb-bierman02</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>sal-rest-connector-config</artifactId>
<version>${project.version}</version>
+ <type>cfg</type>
+ <classifier>restconf</classifier>
</dependency>
</dependencies>
</project>
<module>odl-restconf</module>
<module>odl-restconf-common</module>
<module>odl-restconf-nb-bierman02</module>
- <module>odl-restconf-nb-bierman02-base</module>
<module>odl-restconf-nb-rfc8040</module>
</modules>
<module>restconf-common-models</module>
<module>restconf-common</module>
<module>restconf-nb-bierman02</module>
- <module>restconf-nb-bierman02-auth</module>
<module>restconf-nb-rfc8040</module>
<module>sal-rest-connector-config</module>
<module>sal-rest-docgen</module>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (c) 2018 Inocybe Technologies 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
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>restconf-parent</artifactId>
- <version>1.10.0-SNAPSHOT</version>
- <relativePath>../restconf-parent</relativePath>
- </parent>
-
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>restconf-nb-bierman02-auth</artifactId>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>restconf-nb-bierman02</artifactId>
- </dependency>
- </dependencies>
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2018 Inocybe Technologies 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.restconf.nb.bierman02.web.auth;
-
-import org.opendaylight.netconf.sal.restconf.web.Bierman02WebRegistrar;
-
-/**
- * Initializes the bierman-02 endpoint with authentication.
- *
- * @author Thomas Pantelis
- */
-public class WebInitializer {
- public WebInitializer(Bierman02WebRegistrar registrar) {
- registrar.registerWithAuthentication();
- }
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (c) 2018 Inocybe Technologies 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
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <reference id="webRegistrar" interface="org.opendaylight.netconf.sal.restconf.web.Bierman02WebRegistrar"/>
-
- <bean class="org.opendaylight.restconf.nb.bierman02.web.auth.WebInitializer">
- <argument ref="webRegistrar"/>
- </bean>
-
-</blueprint>
+++ /dev/null
-/*
- * Copyright (c) 2018 Inocybe Technologies 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.netconf.sal.restconf.web;
-
-/**
- * Registers the web components for the restconf bierman-02 endpoint.
- *
- * @author Thomas Pantelis
- */
-public interface Bierman02WebRegistrar {
-
- void registerWithAuthentication();
-
- void registerWithoutAuthentication();
-}
+++ /dev/null
-/*
- * Copyright (c) 2018 Inocybe Technologies 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.netconf.sal.restconf.web;
-
-import java.util.concurrent.atomic.AtomicBoolean;
-import javax.servlet.ServletException;
-import javax.ws.rs.core.Application;
-import org.opendaylight.aaa.filterchain.configuration.CustomFilterAdapterConfiguration;
-import org.opendaylight.aaa.filterchain.filters.CustomFilterAdapter;
-import org.opendaylight.aaa.web.FilterDetails;
-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;
-import org.opendaylight.aaa.web.servlet.ServletSupport;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Implementation of Bierman02WebRegistrar.
- *
- * @author Thomas Pantelis
- */
-public class Bierman02WebRegistrarImpl implements Bierman02WebRegistrar {
- private static final Logger LOG = LoggerFactory.getLogger(Bierman02WebRegistrarImpl.class);
-
- private final WebServer webServer;
- private final WebContextSecurer webContextSecurer;
- private final ServletSupport servletSupport;
- private final Application webApp;
- private final CustomFilterAdapterConfiguration customFilterAdapterConfig;
- private volatile WebContextRegistration registraton;
- private final AtomicBoolean registered = new AtomicBoolean(false);
-
- public Bierman02WebRegistrarImpl(WebServer webServer, WebContextSecurer webContextSecurer,
- ServletSupport servletSupport, Application webApp,
- CustomFilterAdapterConfiguration customFilterAdapterConfig) {
- this.webServer = webServer;
- this.webContextSecurer = webContextSecurer;
- this.servletSupport = servletSupport;
- this.webApp = webApp;
- this.customFilterAdapterConfig = customFilterAdapterConfig;
- }
-
- public void close() {
- if (registered.compareAndSet(true, false)) {
- if (registraton != null) {
- registraton.close();
- }
- }
- }
-
- @Override
- public void registerWithAuthentication() {
- register(true);
- }
-
- @Override
- public void registerWithoutAuthentication() {
- register(false);
- }
-
- private void register(boolean authenticate) {
- if (!registered.compareAndSet(false, true)) {
- LOG.warn("Web context has already been registered", new Exception("call site"));
- return;
- }
-
- WebContextBuilder webContextBuilder = WebContext.builder().contextPath("restconf").supportsSessions(true)
- .addServlet(ServletDetails.builder().servlet(servletSupport.createHttpServletBuilder(webApp).build())
- .addUrlPattern("/*").build())
-
- // Allows user to add javax.servlet.Filter(s) in front of REST services
- .addFilter(FilterDetails.builder().filter(new CustomFilterAdapter(customFilterAdapterConfig))
- .addUrlPattern("/*").build())
-
- .addFilter(FilterDetails.builder().filter(new org.eclipse.jetty.servlets.GzipFilter())
- .putInitParam("mimeTypes",
- "application/xml,application/yang.data+xml,xml,application/json,application/yang.data+json")
- .addUrlPattern("/*").build());
-
- if (authenticate) {
- webContextSecurer.requireAuthentication(webContextBuilder, "/*");
- }
-
- try {
- registraton = webServer.registerWebContext(webContextBuilder.build());
- } catch (ServletException e) {
- throw new RuntimeException("Failed to register the web context", e);
- }
- }
-}
--- /dev/null
+/*
+ * Copyright (c) 2018 Inocybe Technologies 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.netconf.sal.restconf.web;
+
+import javax.servlet.ServletException;
+import javax.ws.rs.core.Application;
+import org.opendaylight.aaa.filterchain.configuration.CustomFilterAdapterConfiguration;
+import org.opendaylight.aaa.filterchain.filters.CustomFilterAdapter;
+import org.opendaylight.aaa.web.FilterDetails;
+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;
+import org.opendaylight.aaa.web.servlet.ServletSupport;
+
+/**
+ * Initializes the bierman-02 endpoint.
+ *
+ * @author Thomas Pantelis
+ */
+public class WebInitializer {
+ private final WebContextRegistration registration;
+
+ public WebInitializer(final WebServer webServer, final WebContextSecurer webContextSecurer,
+ final ServletSupport servletSupport, final Application webApp,
+ final CustomFilterAdapterConfiguration customFilterAdapterConfig) throws ServletException {
+
+ final WebContextBuilder webContextBuilder = WebContext.builder().contextPath("restconf").supportsSessions(true)
+ .addServlet(ServletDetails.builder().servlet(servletSupport.createHttpServletBuilder(webApp).build())
+ .addUrlPattern("/*").build())
+
+ // Allows user to add javax.servlet.Filter(s) in front of REST services
+ .addFilter(FilterDetails.builder().filter(new CustomFilterAdapter(customFilterAdapterConfig))
+ .addUrlPattern("/*").build())
+
+ .addFilter(FilterDetails.builder().filter(new org.eclipse.jetty.servlets.GzipFilter())
+ .putInitParam("mimeTypes",
+ "application/xml,application/yang.data+xml,xml,application/json,application/yang.data+json")
+ .addUrlPattern("/*").build());
+
+ webContextSecurer.requireAuthentication(webContextBuilder, "/*");
+
+ registration = webServer.registerWebContext(webContextBuilder.build());
+ }
+
+ public void close() {
+ if (registration != null) {
+ registration.close();
+ }
+ }
+}
<service ref="jsonRestconfServiceDraft02" odl:type="default"
interface="org.opendaylight.netconf.sal.restconf.api.JSONRestconfService" />
- <!-- Bierman02WebRegistrar -->
+ <!-- Web app registration -->
<reference id="customFilterAdapterConfig"
interface="org.opendaylight.aaa.filterchain.configuration.CustomFilterAdapterConfiguration"/>
<reference id="servletSupport" interface="org.opendaylight.aaa.web.servlet.ServletSupport" />
- <bean id="webRegistrar" class="org.opendaylight.netconf.sal.restconf.web.Bierman02WebRegistrarImpl"
- destroy-method="close">
+ <bean class="org.opendaylight.netconf.sal.restconf.web.WebInitializer">
<argument ref="webServer"/>
<argument ref="webContextSecurer"/>
<argument ref="servletSupport"/>
<argument ref="customFilterAdapterConfig"/>
</bean>
- <service ref="webRegistrar"
- interface="org.opendaylight.netconf.sal.restconf.web.Bierman02WebRegistrar" />
-
</blueprint>