Do not start netconf-impl for css netconf endpoint
[netconf.git] / netconf / netconf-ssh / src / main / java / org / opendaylight / netconf / ssh / SshProxyServerConfiguration.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.netconf.ssh;
10
11 import com.google.common.base.Preconditions;
12 import io.netty.channel.local.LocalAddress;
13 import java.net.InetSocketAddress;
14 import java.util.Optional;
15 import org.apache.sshd.common.keyprovider.KeyPairProvider;
16 import org.apache.sshd.server.auth.pubkey.PublickeyAuthenticator;
17 import org.opendaylight.netconf.auth.AuthProvider;
18
19 public final class SshProxyServerConfiguration {
20     private final InetSocketAddress bindingAddress;
21     private final LocalAddress localAddress;
22     private final AuthProvider authenticator;
23     private final KeyPairProvider keyPairProvider;
24     private final int idleTimeout;
25     private final Optional<PublickeyAuthenticator> publickeyAuthenticator;
26
27     SshProxyServerConfiguration(final InetSocketAddress bindingAddress, final LocalAddress localAddress,
28                     final AuthProvider authenticator, final KeyPairProvider keyPairProvider, final int idleTimeout) {
29         this(bindingAddress, localAddress, authenticator, null, keyPairProvider, idleTimeout);
30     }
31
32     SshProxyServerConfiguration(final InetSocketAddress bindingAddress, final LocalAddress localAddress,
33                                 final AuthProvider authenticator, final PublickeyAuthenticator publickeyAuthenticator,
34                                 final KeyPairProvider keyPairProvider, final int idleTimeout) {
35         this.bindingAddress = Preconditions.checkNotNull(bindingAddress);
36         this.localAddress = Preconditions.checkNotNull(localAddress);
37         this.authenticator = Preconditions.checkNotNull(authenticator);
38         this.keyPairProvider = Preconditions.checkNotNull(keyPairProvider);
39         // Idle timeout cannot be disabled in the sshd by using =< 0 value
40         Preconditions.checkArgument(idleTimeout > 0, "Idle timeout has to be > 0");
41         this.idleTimeout = idleTimeout;
42         this.publickeyAuthenticator = Optional.ofNullable(publickeyAuthenticator);
43     }
44
45     public InetSocketAddress getBindingAddress() {
46         return bindingAddress;
47     }
48
49     public LocalAddress getLocalAddress() {
50         return localAddress;
51     }
52
53     public AuthProvider getAuthenticator() {
54         return authenticator;
55     }
56
57     public KeyPairProvider getKeyPairProvider() {
58         return keyPairProvider;
59     }
60
61     public int getIdleTimeout() {
62         return idleTimeout;
63     }
64
65     public Optional<PublickeyAuthenticator> getPublickeyAuthenticator() {
66         return publickeyAuthenticator;
67     }
68 }