From: Jakub Morvay Date: Sat, 2 Feb 2019 10:01:00 +0000 (+0100) Subject: Merge bierman02-auth and bierman02-base features X-Git-Tag: release/sodium~106 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;ds=sidebyside;h=b29d73875b2cecfbe6b52e99aa1506eb388f17a0;hp=88231b5f1993eca598e15f00351ba99eec85842e;p=netconf.git Merge bierman02-auth and bierman02-base features We do not need odl-restconf-nb-bierman02-base feature now. It is bierman-02 restconf implementations and used to be pulled by both bierman02-auth and bierman02-noauth features. These two features just initialized the web application (with or without authentication). Since bierman02-noauth is no longer with us, merge remaining two features into odl-restconf-nb-bierman02 feature. Change-Id: I121e3c109ca1b5f60aac66e76af011cef0774f7d Signed-off-by: Jakub Morvay --- diff --git a/features/restconf/odl-restconf-nb-bierman02-base/pom.xml b/features/restconf/odl-restconf-nb-bierman02-base/pom.xml deleted file mode 100644 index 860e37eb3f..0000000000 --- a/features/restconf/odl-restconf-nb-bierman02-base/pom.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - 4.0.0 - - - org.opendaylight.odlparent - single-feature-parent - 4.0.9 - - - - org.opendaylight.netconf - odl-restconf-nb-bierman02-base - 1.10.0-SNAPSHOT - feature - - OpenDaylight :: Restconf :: NB :: bierman02 :: Base - - - - - org.opendaylight.mdsal - mdsal-artifacts - 3.0.6 - pom - import - - - org.opendaylight.netconf - restconf-artifacts - 1.10.0-SNAPSHOT - pom - import - - - - - - - org.opendaylight.mdsal.model - odl-mdsal-model-draft-bierman-netconf-restconf-02 - xml - features - - - org.opendaylight.netconf - odl-restconf-common - xml - features - - - org.opendaylight.netconf - restconf-nb-bierman02 - ${project.version} - - - org.opendaylight.netconf - sal-rest-connector-config - ${project.version} - cfg - restconf - - - diff --git a/features/restconf/odl-restconf-nb-bierman02/pom.xml b/features/restconf/odl-restconf-nb-bierman02/pom.xml index 1234b62c53..b7d3103470 100644 --- a/features/restconf/odl-restconf-nb-bierman02/pom.xml +++ b/features/restconf/odl-restconf-nb-bierman02/pom.xml @@ -23,18 +23,49 @@ OpenDaylight :: Restconf :: NB :: bierman02 + + + + org.opendaylight.mdsal + mdsal-artifacts + 3.0.6 + pom + import + + + org.opendaylight.netconf + restconf-artifacts + 1.10.0-SNAPSHOT + pom + import + + + + + + org.opendaylight.mdsal.model + odl-mdsal-model-draft-bierman-netconf-restconf-02 + xml + features + org.opendaylight.netconf - odl-restconf-nb-bierman02-base - ${project.version} + odl-restconf-common xml features org.opendaylight.netconf - restconf-nb-bierman02-auth + restconf-nb-bierman02 + ${project.version} + + + org.opendaylight.netconf + sal-rest-connector-config ${project.version} + cfg + restconf diff --git a/features/restconf/pom.xml b/features/restconf/pom.xml index 4844d3fc98..a7dcd5bf43 100644 --- a/features/restconf/pom.xml +++ b/features/restconf/pom.xml @@ -32,7 +32,6 @@ odl-restconf odl-restconf-common odl-restconf-nb-bierman02 - odl-restconf-nb-bierman02-base odl-restconf-nb-rfc8040 diff --git a/restconf/pom.xml b/restconf/pom.xml index 858bff6f15..9ee1e5309a 100644 --- a/restconf/pom.xml +++ b/restconf/pom.xml @@ -34,7 +34,6 @@ restconf-common-models restconf-common restconf-nb-bierman02 - restconf-nb-bierman02-auth restconf-nb-rfc8040 sal-rest-connector-config sal-rest-docgen diff --git a/restconf/restconf-nb-bierman02-auth/pom.xml b/restconf/restconf-nb-bierman02-auth/pom.xml deleted file mode 100644 index 741713afd6..0000000000 --- a/restconf/restconf-nb-bierman02-auth/pom.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - 4.0.0 - - org.opendaylight.netconf - restconf-parent - 1.10.0-SNAPSHOT - ../restconf-parent - - - org.opendaylight.netconf - restconf-nb-bierman02-auth - bundle - - - - org.opendaylight.netconf - restconf-nb-bierman02 - - - diff --git a/restconf/restconf-nb-bierman02-auth/src/main/java/org/opendaylight/restconf/nb/bierman02/web/auth/WebInitializer.java b/restconf/restconf-nb-bierman02-auth/src/main/java/org/opendaylight/restconf/nb/bierman02/web/auth/WebInitializer.java deleted file mode 100644 index 4f1af41e6c..0000000000 --- a/restconf/restconf-nb-bierman02-auth/src/main/java/org/opendaylight/restconf/nb/bierman02/web/auth/WebInitializer.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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(); - } -} diff --git a/restconf/restconf-nb-bierman02-auth/src/main/resources/OSGI-INF/blueprint/bierman02-auth.xml b/restconf/restconf-nb-bierman02-auth/src/main/resources/OSGI-INF/blueprint/bierman02-auth.xml deleted file mode 100644 index 0a0b21fafd..0000000000 --- a/restconf/restconf-nb-bierman02-auth/src/main/resources/OSGI-INF/blueprint/bierman02-auth.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - diff --git a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/web/Bierman02WebRegistrar.java b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/web/Bierman02WebRegistrar.java deleted file mode 100644 index 7e441e9d19..0000000000 --- a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/web/Bierman02WebRegistrar.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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(); -} diff --git a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/web/Bierman02WebRegistrarImpl.java b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/web/Bierman02WebRegistrarImpl.java deleted file mode 100644 index fb6f5bc821..0000000000 --- a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/web/Bierman02WebRegistrarImpl.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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); - } - } -} diff --git a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/web/WebInitializer.java b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/web/WebInitializer.java new file mode 100644 index 0000000000..245925cd38 --- /dev/null +++ b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/netconf/sal/restconf/web/WebInitializer.java @@ -0,0 +1,58 @@ +/* + * 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(); + } + } +} diff --git a/restconf/restconf-nb-bierman02/src/main/resources/OSGI-INF/blueprint/restconf-config.xml b/restconf/restconf-nb-bierman02/src/main/resources/OSGI-INF/blueprint/restconf-config.xml index cad9c3d6a0..f6e57f7f92 100644 --- a/restconf/restconf-nb-bierman02/src/main/resources/OSGI-INF/blueprint/restconf-config.xml +++ b/restconf/restconf-nb-bierman02/src/main/resources/OSGI-INF/blueprint/restconf-config.xml @@ -99,7 +99,7 @@ - + @@ -110,8 +110,7 @@ - + @@ -119,7 +118,4 @@ - -