sessionworker.hh 2.75 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#ifndef RSM_RSMCORE_SESSIONWORKER_HH_
#define RSM_RSMCORE_SESSIONWORKER_HH_

#include <QObject>

#include "rsmcore/declspec.hh"

namespace rsm
{
class SessionWorkerImpl;
class RSM_PUBLIC SessionWorker : public QObject
{
  Q_OBJECT
 private:
  // Private implementation
  SessionWorkerImpl* p;

 public:
  enum class Verbosity
  {
    None,
    Warning,
    Protocal,
    Packet,
    Functions
  };

28
29
30
  /**
   * Basic Constructor
   */
31
  SessionWorker(QObject* parent = nullptr);
32
33
34
  /**
   * Contructs with host name
   */
35
36
  SessionWorker(QString host, QObject* parent = nullptr);
  ~SessionWorker();
37
  QByteArray readExecOutput();
38
39

 public slots:
40
41
42
43

  /**
   * Set the remote host to connect to
   */
44
  void setHost(QString host);
45
46
47
  /**
   * Set the Log verbosity
   */
48
  void setLogVerbosity(Verbosity level);
49
50
51
  /**
   * Set the ssh port number
   */
52
  void setPort(int port);
53
54
55
56
  /**
   * Set the user
   * Defaults to system user
   */
57
  void setUser(QString name);
58
59
60
  /**
   * Perform hand-shake to connect to host.
   */
61
  void connect();
62
63
64
  /**
   * Disconnect ssh session
   */
65
  void disconnect();
66
67
68
69
70
71
72
73
  /**
   * Perform known host verification.
   * Checks known_host file to validate remote host SHA
   * Can emit hostUnknown(QString host_hash).
   * Can emit hostPublicKeyChanged(QString host_hash).
   * Can emit hostPublicKeyUnavailable().
   * Can emit knownHostError().
   */
74
  void verifyKnownHost();
75
76
77
78
  /**
   * Performs a request to accept/save the host's public key,
   * updating the known_hosts
   */
79
  void acceptHostPublicKeyUpdate();
80
81
82
83
84
85
  /**
   * Attempts to authenticate using public key or password.
   * Can emit authenticationError(QString message).
   * Can emit authenticationSucceeded() upon acceptance of public key.
   * Can emit passworedRequested().
   */
86
  void authenticate();
87
88
89
90
91
92
  /**
   * Attempts to authenticate with username and password.
   * Can emit authenticationError(QString message).
   * Can emit authenticationSuccessed() upon acceptance of password.
   * Can emit loginBannerIssued(QString message) give availability.
   */
93
94
  void authenticateWithPassword(QString pswd);

95
96
97
98
99
100
  /**
   * Requests remote execution of command
   * @param command - QString command to execute
   */
  void requestExec(QString command);

101
102
103
104
105
106
107
108
109
110
111
 signals:
  void getServerPublicKeyFailed();
  void hostUnknown(QString host_hash);
  void hostPublicKeyChanged(QString host_hash);
  void hostPublicKeyUnavailable();
  void knownHostError(QString message);
  void updateKnownHostsFailed();
  void authenticationError(QString message);
  void authenticationSucceeded();
  void passwordRequested();
  void loginBannerIssued(QString message);
112
  void execOutputReady();
113
114
  void execFailed(QString message);
  void execFinished();
115
116
117
118

};  // class SessionWorker
}  // namespace rsm
#endif /* RSM_RSMCORE_SESSIONWORKER_HH_*/