--- /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>3.1.0</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>odl-restconf-base</artifactId>
+ <version>1.8.0-SNAPSHOT</version>
+ <packaging>feature</packaging>
+
+ <name>OpenDaylight :: Restconf :: Base</name>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>restconf-artifacts</artifactId>
+ <version>1.8.0-SNAPSHOT</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <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>
<dependencies>
<dependency>
<groupId>org.opendaylight.netconf</groupId>
- <artifactId>odl-restconf-common</artifactId>
+ <artifactId>odl-restconf-base</artifactId>
+ <version>${project.version}</version>
<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>
+ <artifactId>restconf-nb-bierman02-noauth</artifactId>
<version>${project.version}</version>
- <type>cfg</type>
- <classifier>restconf</classifier>
</dependency>
</dependencies>
</project>
<name>OpenDaylight :: Restconf</name>
<dependencies>
- <!-- Enables AAA through aaa-shiro-act -->
- <dependency>
- <groupId>org.opendaylight.aaa</groupId>
- <artifactId>odl-aaa-shiro-act</artifactId>
- <version>0.8.0-SNAPSHOT</version>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
<dependency>
<groupId>org.opendaylight.netconf</groupId>
- <artifactId>odl-restconf-noauth</artifactId>
+ <artifactId>odl-restconf-base</artifactId>
<version>${project.version}</version>
<type>xml</type>
<classifier>features</classifier>
</dependency>
-
<dependency>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>odl-jackson-2.8</artifactId>
- <version>3.1.0</version>
- <type>xml</type>
- <classifier>features</classifier>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>restconf-nb-bierman02-auth</artifactId>
+ <version>${project.version}</version>
</dependency>
</dependencies>
</project>
<module>features-restconf</module>
<module>odl-mdsal-apidocs</module>
<module>odl-restconf</module>
+ <module>odl-restconf-base</module>
<module>odl-restconf-all</module>
<module>odl-restconf-common</module>
<module>odl-restconf-noauth</module>
<module>restconf-common-models</module>
<module>restconf-common</module>
<module>restconf-nb-bierman02</module>
+ <module>restconf-nb-bierman02-auth</module>
+ <module>restconf-nb-bierman02-noauth</module>
<module>restconf-nb-rfc8040</module>
<module>sal-rest-connector-config</module>
<module>sal-rest-docgen</module>
<scope>test</scope>
</dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Import-Package>
- !javax.annotation,
- javax.ws.rs.*;version="[1.1.0,2.0.0)",
- *
- </Import-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
--- /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.8.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
+<?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.8.0-SNAPSHOT</version>
+ <relativePath>../restconf-parent</relativePath>
+ </parent>
+
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>restconf-nb-bierman02-noauth</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.noauth;
+
+import org.opendaylight.netconf.sal.restconf.web.Bierman02WebRegistrar;
+
+/**
+ * Initializes the bierman-02 endpoint without authentication.
+ *
+ * @author Thomas Pantelis
+ */
+public class WebInitializer {
+ public WebInitializer(Bierman02WebRegistrar registrar) {
+ registrar.registerWithoutAuthentication();
+ }
+}
--- /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.noauth.WebInitializer">
+ <argument ref="webRegistrar"/>
+ </bean>
+
+</blueprint>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.aaa.web</groupId>
+ <artifactId>web-api</artifactId>
+ <version>0.8.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.aaa</groupId>
+ <artifactId>aaa-filterchain</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-servlet</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-servlets</artifactId>
+ </dependency>
<!-- Testing Dependencies -->
<dependency>
org.opendaylight.netconf.md.sal.rest.common.*,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.rest.connector.rev140724.*,
</Private-Package>
- <Import-Package>
- !javax.annotation,
- javax.ws.rs.*;version="[1.1.0,2.0.0)",
- *,
- 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.opendaylight.aaa.filterchain.filters,
- org.opendaylight.aaa.api,
- org.apache.shiro.web.env
- </Import-Package>
- <Web-ContextPath>/restconf</Web-ContextPath>
</instructions>
</configuration>
</plugin>
import org.opendaylight.netconf.sal.restconf.impl.StatisticsRestconfServiceWrapper;
public class RestconfApplication extends Application {
+ private final ControllerContext controllerContext;
+ private final BrokerFacade brokerFacade;
+ private final StatisticsRestconfServiceWrapper statsServiceWrapper;
+
+ public RestconfApplication(ControllerContext controllerContext, BrokerFacade brokerFacade,
+ StatisticsRestconfServiceWrapper statsServiceWrapper) {
+ this.controllerContext = controllerContext;
+ this.brokerFacade = brokerFacade;
+ this.statsServiceWrapper = statsServiceWrapper;
+ }
@Override
public Set<Class<?>> getClasses() {
@Override
public Set<Object> getSingletons() {
final Set<Object> singletons = new HashSet<>();
- final ControllerContext controllerContext = ControllerContext.getInstance();
- final BrokerFacade brokerFacade = BrokerFacade.getInstance();
final SchemaRetrievalServiceImpl schemaRetrieval = new SchemaRetrievalServiceImpl(controllerContext);
singletons.add(controllerContext);
singletons.add(brokerFacade);
singletons.add(schemaRetrieval);
- singletons.add(new RestconfCompositeWrapper(StatisticsRestconfServiceWrapper.getInstance(), schemaRetrieval));
+ singletons.add(new RestconfCompositeWrapper(statsServiceWrapper, schemaRetrieval));
singletons.add(new RestconfDocumentedExceptionMapper(controllerContext));
singletons.add(new XmlNormalizedNodeBodyReader(controllerContext));
singletons.add(new JsonNormalizedNodeBodyReader(controllerContext));
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
+import java.util.Objects;
import java.util.concurrent.CountDownLatch;
import javax.annotation.Nullable;
import javax.ws.rs.core.Response.Status;
@SuppressWarnings("checkstyle:FinalClass")
public class BrokerFacade implements Closeable {
private static final Logger LOG = LoggerFactory.getLogger(BrokerFacade.class);
- private static final BrokerFacade INSTANCE = new BrokerFacade();
private volatile DOMRpcService rpcService;
- private DOMDataBroker domDataBroker;
- private DOMNotificationService domNotification;
- private ControllerContext controllerContext;
-
- // Temporary until the static instance is removed.
- @Deprecated
- private BrokerFacade() {
- }
+ private final DOMDataBroker domDataBroker;
+ private final DOMNotificationService domNotification;
+ private final ControllerContext controllerContext;
private BrokerFacade(DOMRpcService rpcService, DOMDataBroker domDataBroker, DOMNotificationService domNotification,
ControllerContext controllerContext) {
- this.rpcService = rpcService;
- this.domDataBroker = domDataBroker;
- this.domNotification = domNotification;
- this.controllerContext = controllerContext;
- }
-
- @Deprecated
- public static BrokerFacade getInstance() {
- return BrokerFacade.INSTANCE;
+ this.rpcService = Objects.requireNonNull(rpcService);
+ this.domDataBroker = Objects.requireNonNull(domDataBroker);
+ this.domNotification = Objects.requireNonNull(domNotification);
+ this.controllerContext = Objects.requireNonNull(controllerContext);
}
public static BrokerFacade newInstance(DOMRpcService rpcService, DOMDataBroker domDataBroker,
DOMNotificationService domNotification, ControllerContext controllerContext) {
- INSTANCE.rpcService = rpcService;
- INSTANCE.domDataBroker = domDataBroker;
- INSTANCE.controllerContext = controllerContext;
- INSTANCE.domNotification = domNotification;
- return INSTANCE;
- //return new BrokerFacade(pcService, domDataBroker, controllerContext);
+ return new BrokerFacade(rpcService, domDataBroker, domNotification, controllerContext);
}
@Override
public void close() {
- domDataBroker = null;
- }
-
- private void checkPreconditions() {
- if (this.domDataBroker == null) {
- throw new RestconfDocumentedException(Status.SERVICE_UNAVAILABLE);
- }
}
/**
* @return read date
*/
public NormalizedNode<?, ?> readConfigurationData(final YangInstanceIdentifier path, final String withDefa) {
- checkPreconditions();
try (DOMDataReadOnlyTransaction tx = this.domDataBroker.newReadOnlyTransaction()) {
return readDataViaTransaction(tx, CONFIGURATION, path, withDefa);
}
* @return read data
*/
public NormalizedNode<?, ?> readOperationalData(final YangInstanceIdentifier path) {
- checkPreconditions();
-
try (DOMDataReadOnlyTransaction tx = this.domDataBroker.newReadOnlyTransaction()) {
return readDataViaTransaction(tx, OPERATIONAL, path);
}
Preconditions.checkNotNull(path);
Preconditions.checkNotNull(payload);
- checkPreconditions();
-
final DOMDataReadWriteTransaction newReadWriteTransaction = this.domDataBroker.newReadWriteTransaction();
final Status status = readDataViaTransaction(newReadWriteTransaction, CONFIGURATION, path) != null ? Status.OK
: Status.CREATED;
public CheckedFuture<Void, TransactionCommitFailedException> commitConfigurationDataPost(
final SchemaContext globalSchema, final YangInstanceIdentifier path, final NormalizedNode<?, ?> payload,
final String insert, final String point) {
- checkPreconditions();
return postDataViaTransaction(this.domDataBroker.newReadWriteTransaction(), CONFIGURATION, path, payload,
globalSchema, insert, point);
}
// DELETE configuration
public CheckedFuture<Void, TransactionCommitFailedException> commitConfigurationDataDelete(
final YangInstanceIdentifier path) {
- checkPreconditions();
return deleteDataViaTransaction(this.domDataBroker.newReadWriteTransaction(), CONFIGURATION, path);
}
// RPC
public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final SchemaPath type,
final NormalizedNode<?, ?> input) {
- checkPreconditions();
if (this.rpcService == null) {
throw new RestconfDocumentedException(Status.SERVICE_UNAVAILABLE);
}
public void registerToListenDataChanges(final LogicalDatastoreType datastore, final DataChangeScope scope,
final ListenerAdapter listener) {
- checkPreconditions();
-
if (listener.isListening()) {
return;
}
}
public void registerToListenNotification(final NotificationListenerAdapter listener) {
- checkPreconditions();
-
if (listener.isListening()) {
return;
}
private static final Logger LOG = LoggerFactory.getLogger(ControllerContext.class);
- // FIXME: this should be the current instance which is mutated
- private static final ControllerContext INSTANCE = new ControllerContext();
-
private static final String NULL_VALUE = "null";
private static final String MOUNT_MODULE = "yang-ext";
private final AtomicReference<Map<QName, RpcDefinition>> qnameToRpc = new AtomicReference<>(Collections.emptyMap());
- private DOMMountPointService mountService;
- private DOMYangTextSourceProvider yangTextSourceProvider;
- private ListenerRegistration<SchemaContextListener> listenerRegistration;
+ private final DOMMountPointService mountService;
+ private final DOMYangTextSourceProvider yangTextSourceProvider;
+ private final ListenerRegistration<SchemaContextListener> listenerRegistration;
private volatile SchemaContext globalSchema;
private volatile DataNormalizer dataNormalizer;
this.mountService = mountService;
this.yangTextSourceProvider = yangTextSourceProvider;
- setGlobalSchema(schemaService.getGlobalContext());
+ onGlobalContextUpdated(schemaService.getGlobalContext());
listenerRegistration = schemaService.registerSchemaContextListener(this);
}
- // Temporary until the static instance is removed.
- @Deprecated
- private ControllerContext() {
- }
-
public static ControllerContext newInstance(SchemaService schemaService, DOMMountPointService mountService,
DOMSchemaService domSchemaService) {
final DOMYangTextSourceProvider yangTextSourceProvider =
(DOMYangTextSourceProvider) domSchemaService.getSupportedExtensions().get(DOMYangTextSourceProvider.class);
- INSTANCE.mountService = mountService;
- INSTANCE.yangTextSourceProvider = yangTextSourceProvider;
-
- INSTANCE.onGlobalContextUpdated(schemaService.getGlobalContext());
- INSTANCE.listenerRegistration = schemaService.registerSchemaContextListener(INSTANCE);
-
- return INSTANCE;
- //return new ControllerContext(schemaService, mountService, domSchemaServiceExtension);
- }
-
- @Deprecated
- public static ControllerContext getInstance() {
- return INSTANCE;
+ return new ControllerContext(schemaService, mountService, yangTextSourceProvider);
}
private void setGlobalSchema(final SchemaContext globalSchema) {
AtomicLong failurePut = new AtomicLong();
AtomicLong failureDelete = new AtomicLong();
- private static final StatisticsRestconfServiceWrapper INSTANCE = new StatisticsRestconfServiceWrapper();
-
- private RestconfService delegate;
-
- @Deprecated
- private StatisticsRestconfServiceWrapper() {
- }
+ private final RestconfService delegate;
private StatisticsRestconfServiceWrapper(final RestconfService delegate) {
this.delegate = delegate;
}
- @Deprecated
- public static StatisticsRestconfServiceWrapper getInstance() {
- return INSTANCE;
- }
-
public static StatisticsRestconfServiceWrapper newInstance(RestconfService delegate) {
- INSTANCE.delegate = delegate;
- return INSTANCE;
- //return new StatisticsRestconfServiceWrapper(delegate);
+ return new StatisticsRestconfServiceWrapper(delegate);
}
@Override
--- /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 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;
+
+/**
+ * Implementation of Bierman02WebRegistrar.
+ *
+ * @author Thomas Pantelis
+ */
+public class Bierman02WebRegistrarImpl implements Bierman02WebRegistrar {
+
+ private WebContextRegistration registraton;
+ private final WebServer webServer;
+ private final WebContextSecurer webContextSecurer;
+ private final Application webApp;
+ private final CustomFilterAdapterConfiguration customFilterAdapterConfig;
+
+ public Bierman02WebRegistrarImpl(WebServer webServer, WebContextSecurer webContextSecurer,
+ Application webApp, CustomFilterAdapterConfiguration customFilterAdapterConfig) {
+ this.webServer = webServer;
+ this.webContextSecurer = webContextSecurer;
+ this.webApp = webApp;
+ this.customFilterAdapterConfig = customFilterAdapterConfig;
+ }
+
+ public void close() {
+ if (registraton != null) {
+ registraton.close();
+ }
+ }
+
+ @Override
+ public void registerWithAuthentication() {
+ register(true);
+ }
+
+ @Override
+ public void registerWithoutAuthentication() {
+ register(false);
+ }
+
+ private void register(boolean authenticate) {
+ WebContextBuilder webContextBuilder = WebContext.builder().contextPath("restconf").supportsSessions(true)
+ .addServlet(ServletDetails.builder().servlet(
+ new com.sun.jersey.spi.container.servlet.ServletContainer(webApp))
+ .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
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<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>JAXRSRestconf</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.netconf.sal.rest.impl.RestconfApplication</param-value>
- </init-param>
- <load-on-startup>0</load-on-startup>
- </servlet>
-
- <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.AAAFilter</filter-class>
- </filter>
-
- <filter-mapping>
- <filter-name>ShiroFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
- <filter>
- <filter-name>DynamicFilterChain</filter-name>
- <filter-class>org.opendaylight.aaa.filterchain.filters.CustomFilterAdapter</filter-class>
- </filter>
-
- <filter-mapping>
- <filter-name>DynamicFilterChain</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
-
- <servlet-mapping>
- <servlet-name>JAXRSRestconf</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
-
- <filter>
- <filter-name>GzipFilter</filter-name>
- <filter-class>org.eclipse.jetty.servlets.GzipFilter</filter-class>
- <init-param>
- <param-name>mimeTypes</param-name>
- <param-value>application/xml,application/yang.data+xml,xml,application/json,application/yang.data+json</param-value>
- </init-param>
- </filter>
- <filter-mapping>
- <filter-name>GzipFilter</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>
- <init-param>
- <param-name>exposedHeaders</param-name>
- <param-value>location</param-value>
- </init-param>
- </filter>
- <filter-mapping>
- <filter-name>cross-origin-restconf</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
- <security-constraint>
- <web-resource-collection>
- <web-resource-name>NB api</web-resource-name>
- <url-pattern>/*</url-pattern>
- <http-method>POST</http-method>
- <http-method>GET</http-method>
- <http-method>PUT</http-method>
- <http-method>PATCH</http-method>
- <http-method>DELETE</http-method>
- <http-method>HEAD</http-method>
- </web-resource-collection>
- </security-constraint>
-
-</web-app>
</cm:default-properties>
</cm:property-placeholder>
- <!-- We need the AAAService available even though we don't use it -->
- <reference interface="org.opendaylight.aaa.api.AAAService"/>
-
<reference id="schemaService" interface="org.opendaylight.controller.sal.core.api.model.SchemaService"/>
<reference id="domRpcService" interface="org.opendaylight.controller.md.sal.dom.api.DOMRpcService"/>
<reference id="domMountPointService" interface="org.opendaylight.controller.md.sal.dom.api.DOMMountPointService"/>
<argument ref="webSocketPort"/>
</bean>
+ <bean id="restconfApplication" class="org.opendaylight.netconf.sal.rest.impl.RestconfApplication">
+ <argument ref="controllerContext"/>
+ <argument ref="brokerFacade"/>
+ <argument ref="statsServiceWrapper"/>
+ </bean>
+
<!-- JSONRestconfService -->
<bean id="jsonRestconfServiceDraft02"
class="org.opendaylight.netconf.sal.restconf.impl.JSONRestconfServiceImpl"
<service ref="jsonRestconfServiceDraft02" odl:type="default"
interface="org.opendaylight.netconf.sal.restconf.api.JSONRestconfService" />
+ <!-- Bierman02WebRegistrar -->
+
+ <reference id="customFilterAdapterConfig"
+ interface="org.opendaylight.aaa.filterchain.configuration.CustomFilterAdapterConfiguration"/>
+
+ <reference id="webServer" interface="org.opendaylight.aaa.web.WebServer" />
+
+ <reference id="webContextSecurer" interface="org.opendaylight.aaa.web.WebContextSecurer" />
+
+ <bean id="webRegistrar" class="org.opendaylight.netconf.sal.restconf.web.Bierman02WebRegistrarImpl"
+ destroy-method="close">
+ <argument ref="webServer"/>
+ <argument ref="webContextSecurer"/>
+ <argument ref="restconfApplication"/>
+ <argument ref="customFilterAdapterConfig"/>
+ </bean>
+
+ <service ref="webRegistrar"
+ interface="org.opendaylight.netconf.sal.restconf.web.Bierman02WebRegistrar" />
+
</blueprint>
assertSame("readOperationalData", this.dummyNode, actualNode);
}
- @Test(expected = RestconfDocumentedException.class)
- public void testReadOperationalDataWithNoDataBroker() {
- this.brokerFacade.close();
-
- this.brokerFacade.readOperationalData(this.instanceID);
- }
-
@Test
public void test503() throws Exception {
final RpcError error = RpcResultBuilder.newError(
assertSame("invokeRpc", expResult, actualResult);
}
- @Test(expected = RestconfDocumentedException.class)
- public void testInvokeRpcWithNoConsumerSession() {
- brokerFacade.close();
- this.brokerFacade.invokeRpc(this.type, this.dummyNode);
- }
-
@Test
public void testCommitConfigurationDataPut() throws Exception {
@SuppressWarnings("unchecked")