// Path: src/com/atsebak/embeddedlinuxjvm/protocol/ssh/jsch/EmbeddedSSHClient.java
// @Builder
// public class EmbeddedSSHClient {
//     private String username;
//     @Nullable
//     private String password;
//     @Nullable
//     private String key;
//     private boolean useKey;
//     private String hostname;
//     @NotNull
//     private int port;
// 
//     /**
//      * Gets SSH Client
//      *
//      * @return
//      */
//     @SneakyThrows(JSchException.class)
//     public Session get() {
//         JSch jsch = new JSch();
//         UserInfo userInfo;
//         Session session = jsch.getSession(username, hostname, port);
//         if (useKey) {
//             jsch.addIdentity(key);
//             userInfo = new EmbeddedUserInfoInteractive();
//         } else {
//             session.setPassword(password);
//             session.setConfig("StrictHostKeyChecking", "no");
//             userInfo = EmbeddedUserInfo.builder().password(password).build();
//         }
//         session.setUserInfo(userInfo);
//         session.setConfig("HashKnownHosts", "yes");
//         session.setTimeout(10000);
//         session.connect();
//         return session;
//     }
// }


import com.atsebak.embeddedlinuxjvm.protocol.ssh.jsch.EmbeddedSSHClient;
import com.jcraft.jsch.Session;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.net.InetAddress;
package com.atsebak.embeddedlinuxjvm.protocol.ssh;



@Builder
public class SSHConnectionValidator {

    private String ip;
    private String username;
    @Nullable
    private String password;
    @Nullable
    private String key;
    private boolean useKey;
    private int port;

    /**
     * Pings to see if it can contact hostname
     *
     * @return
     */
    public boolean canConnectToHostname(int timeout) {
        try {
            return InetAddress.getByName(ip).isReachable(timeout);
        } catch (IOException e) {
            return false;
        }
    }

    /**
     * Can connect to remote target
     *
     * @return status
     */
    public SSHConnectionState checkSSHConnection() {
        try {
// Path: src/com/atsebak/embeddedlinuxjvm/protocol/ssh/jsch/EmbeddedSSHClient.java
// @Builder
// public class EmbeddedSSHClient {
//     private String username;
//     @Nullable
//     private String password;
//     @Nullable
//     private String key;
//     private boolean useKey;
//     private String hostname;
//     @NotNull
//     private int port;
// 
//     /**
//      * Gets SSH Client
//      *
//      * @return
//      */
//     @SneakyThrows(JSchException.class)
//     public Session get() {
//         JSch jsch = new JSch();
//         UserInfo userInfo;
//         Session session = jsch.getSession(username, hostname, port);
//         if (useKey) {
//             jsch.addIdentity(key);
//             userInfo = new EmbeddedUserInfoInteractive();
//         } else {
//             session.setPassword(password);
//             session.setConfig("StrictHostKeyChecking", "no");
//             userInfo = EmbeddedUserInfo.builder().password(password).build();
//         }
//         session.setUserInfo(userInfo);
//         session.setConfig("HashKnownHosts", "yes");
//         session.setTimeout(10000);
//         session.connect();
//         return session;
//     }
// }


// Path: src/com/atsebak/embeddedlinuxjvm/protocol/ssh/SSHConnectionValidator.java
import com.atsebak.embeddedlinuxjvm.protocol.ssh.jsch.EmbeddedSSHClient;
import com.jcraft.jsch.Session;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.net.InetAddress;

package com.atsebak.embeddedlinuxjvm.protocol.ssh;



@Builder
public class SSHConnectionValidator {

    private String ip;
    private String username;
    @Nullable
    private String password;
    @Nullable
    private String key;
    private boolean useKey;
    private int port;

    /**
     * Pings to see if it can contact hostname
     *
     * @return
     */
    public boolean canConnectToHostname(int timeout) {
        try {
            return InetAddress.getByName(ip).isReachable(timeout);
        } catch (IOException e) {
            return false;
        }
    }

    /**
     * Can connect to remote target
     *
     * @return status
     */
    public SSHConnectionState checkSSHConnection() {
        try {
            EmbeddedSSHClient sshClient = EmbeddedSSHClient