Apply modernizations
[netconf.git] / netconf / mdsal-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 package org.opendaylight.netconf.ssh;
9
10 import static com.google.common.base.Preconditions.checkArgument;
11 import static java.util.Objects.requireNonNull;
12
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;
19
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;
27
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);
39     }
40
41     public InetSocketAddress getBindingAddress() {
42         return bindingAddress;
43     }
44
45     public LocalAddress getLocalAddress() {
46         return localAddress;
47     }
48
49     public AuthProvider getAuthenticator() {
50         return authenticator;
51     }
52
53     public KeyPairProvider getKeyPairProvider() {
54         return keyPairProvider;
55     }
56
57     public int getIdleTimeout() {
58         return idleTimeout;
59     }
60
61     public Optional<PublickeyAuthenticator> getPublickeyAuthenticator() {
62         return publickeyAuthenticator;
63     }
64 }