2 * Copyright (c) 2022 PANTHEON.tech, s.r.o. 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.netconf.transport.tls;
10 import com.google.common.util.concurrent.ListenableFuture;
11 import io.netty.bootstrap.Bootstrap;
12 import io.netty.bootstrap.ServerBootstrap;
13 import io.netty.handler.ssl.SslContext;
14 import org.eclipse.jdt.annotation.NonNull;
15 import org.opendaylight.netconf.transport.api.TransportChannelListener;
16 import org.opendaylight.netconf.transport.api.TransportStack;
17 import org.opendaylight.netconf.transport.api.UnsupportedConfigurationException;
18 import org.opendaylight.netconf.transport.tcp.TCPClient;
19 import org.opendaylight.netconf.transport.tcp.TCPServer;
20 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.tcp.client.rev231228.TcpClientGrouping;
21 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.tcp.server.rev231228.TcpServerGrouping;
24 * A {@link TransportStack} acting as a TLS server.
26 public final class TLSServer extends TLSTransportStack {
27 private TLSServer(final TransportChannelListener listener, final SslContext sslContext) {
28 super(listener, sslContext);
31 private TLSServer(final TransportChannelListener listener, final SslHandlerFactory factory) {
32 super(listener, factory);
35 public static @NonNull ListenableFuture<TLSServer> connect(final TransportChannelListener listener,
36 final Bootstrap bootstrap, final TcpClientGrouping connectParams, final SslHandlerFactory factory)
37 throws UnsupportedConfigurationException {
38 final var server = new TLSServer(listener, factory);
39 return transformUnderlay(server, TCPClient.connect(server.asListener(), bootstrap, connectParams));
42 public static @NonNull ListenableFuture<TLSServer> listen(final TransportChannelListener listener,
43 final ServerBootstrap bootstrap, final TcpServerGrouping listenParams, final SslHandlerFactory factory)
44 throws UnsupportedConfigurationException {
45 final var server = new TLSServer(listener, factory);
46 return transformUnderlay(server, TCPServer.listen(server.asListener(), bootstrap, listenParams));