2 * Copyright (c) 2014 Cisco Systems, Inc. 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.ssh;
10 import static com.google.common.base.Preconditions.checkArgument;
11 import static java.util.Objects.requireNonNull;
13 import io.netty.channel.local.LocalAddress;
14 import java.net.InetSocketAddress;
15 import java.util.Optional;
16 import org.apache.sshd.common.keyprovider.KeyPairProvider;
17 import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
18 import org.opendaylight.netconf.auth.AuthProvider;
20 public final class SshProxyServerConfiguration {
21 private final InetSocketAddress bindingAddress;
22 private final LocalAddress localAddress;
23 private final AuthProvider authenticator;
24 private final KeyPairProvider keyPairProvider;
25 private final int idleTimeout;
26 private final Optional<PublickeyAuthenticator> publickeyAuthenticator;
28 SshProxyServerConfiguration(final InetSocketAddress bindingAddress, final LocalAddress localAddress,
29 final AuthProvider authenticator, final PublickeyAuthenticator publickeyAuthenticator,
30 final KeyPairProvider keyPairProvider, final int idleTimeout) {
31 this.bindingAddress = requireNonNull(bindingAddress);
32 this.localAddress = requireNonNull(localAddress);
33 this.authenticator = requireNonNull(authenticator);
34 this.keyPairProvider = requireNonNull(keyPairProvider);
35 // Idle timeout cannot be disabled in the sshd by using =< 0 value
36 checkArgument(idleTimeout > 0, "Idle timeout has to be > 0");
37 this.idleTimeout = idleTimeout;
38 this.publickeyAuthenticator = Optional.ofNullable(publickeyAuthenticator);
41 public InetSocketAddress getBindingAddress() {
42 return bindingAddress;
45 public LocalAddress getLocalAddress() {
49 public AuthProvider getAuthenticator() {
53 public KeyPairProvider getKeyPairProvider() {
54 return keyPairProvider;
57 public int getIdleTimeout() {
61 public Optional<PublickeyAuthenticator> getPublickeyAuthenticator() {
62 return publickeyAuthenticator;