Hyunsun Moon | fba9701 | 2016-02-05 16:55:33 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | 8e57fd5 | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Hyunsun Moon | fba9701 | 2016-02-05 16:55:33 -0800 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Hyunsun Moon | f948020 | 2016-04-14 16:13:42 -0700 | [diff] [blame^] | 16 | package org.onosproject.cordvtn.api; |
Hyunsun Moon | fba9701 | 2016-02-05 16:55:33 -0800 | [diff] [blame] | 17 | |
| 18 | import com.google.common.base.MoreObjects; |
| 19 | import org.onlab.packet.Ip4Address; |
| 20 | import org.onlab.packet.TpPort; |
| 21 | |
| 22 | import java.util.Objects; |
| 23 | |
Hyunsun Moon | d05b32e | 2016-03-02 19:27:26 -0800 | [diff] [blame] | 24 | import static com.google.common.base.Preconditions.checkNotNull; |
| 25 | |
Hyunsun Moon | fba9701 | 2016-02-05 16:55:33 -0800 | [diff] [blame] | 26 | /** |
| 27 | * Representation of SSH access information. |
| 28 | */ |
| 29 | public final class SshAccessInfo { |
| 30 | |
| 31 | private final Ip4Address remoteIp; |
| 32 | private final TpPort port; |
| 33 | private final String user; |
| 34 | private final String privateKey; |
| 35 | |
| 36 | /** |
| 37 | * Creates a new SSH access information. |
| 38 | * |
| 39 | * @param remoteIp ssh remote ip address |
| 40 | * @param port ssh port number |
| 41 | * @param user user name |
| 42 | * @param privateKey path of ssh private key |
| 43 | */ |
| 44 | public SshAccessInfo(Ip4Address remoteIp, TpPort port, String user, String privateKey) { |
Hyunsun Moon | d05b32e | 2016-03-02 19:27:26 -0800 | [diff] [blame] | 45 | this.remoteIp = checkNotNull(remoteIp); |
| 46 | this.port = checkNotNull(port); |
| 47 | this.user = checkNotNull(user); |
| 48 | this.privateKey = checkNotNull(privateKey); |
Hyunsun Moon | fba9701 | 2016-02-05 16:55:33 -0800 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Returns the remote IP address. |
| 53 | * |
| 54 | * @return ip address |
| 55 | */ |
| 56 | public Ip4Address remoteIp() { |
| 57 | return this.remoteIp; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Returns the port number. |
| 62 | * |
| 63 | * @return ssh port |
| 64 | */ |
| 65 | public TpPort port() { |
| 66 | return this.port; |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Returns the user name. |
| 71 | * |
| 72 | * @return user name |
| 73 | */ |
| 74 | public String user() { |
| 75 | return this.user; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Returns the private key path. |
| 80 | * |
| 81 | * @return privateKey |
| 82 | */ |
| 83 | public String privateKey() { |
| 84 | return privateKey; |
| 85 | } |
| 86 | |
| 87 | @Override |
| 88 | public boolean equals(Object obj) { |
| 89 | if (this == obj) { |
| 90 | return true; |
| 91 | } |
| 92 | |
| 93 | if (obj instanceof SshAccessInfo) { |
| 94 | SshAccessInfo that = (SshAccessInfo) obj; |
| 95 | if (Objects.equals(remoteIp, that.remoteIp) && |
| 96 | Objects.equals(port, that.port) && |
| 97 | Objects.equals(user, that.user) && |
| 98 | Objects.equals(privateKey, that.privateKey)) { |
| 99 | return true; |
| 100 | } |
| 101 | } |
| 102 | return false; |
| 103 | } |
| 104 | |
| 105 | @Override |
| 106 | public int hashCode() { |
| 107 | return Objects.hash(remoteIp, port, user, privateKey); |
| 108 | } |
| 109 | |
| 110 | @Override |
| 111 | public String toString() { |
| 112 | return MoreObjects.toStringHelper(getClass()) |
| 113 | .add("remoteIp", remoteIp) |
| 114 | .add("port", port) |
| 115 | .add("user", user) |
| 116 | .add("privateKey", privateKey) |
| 117 | .toString(); |
| 118 | } |
| 119 | } |