Dangerous SNMP
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
usm.hpp
1 #pragma once
2 
3 #include "../securitymodel.hpp"
4 #include "../types.hpp"
5 
6 #include <string>
7 #include <chrono>
8 
9 namespace dangerous { namespace snmp { namespace securitymodel {
10 
36 class USM : public SecurityModel {
37 public:
42  USM();
43 
55  USM( const std::string& username, Authentication::Type authentication, const std::string& authenticationPassword, Encryption::Type encryption, const std::string& encryptionPassword ) throw( Exception );
56 
61  USM( const USM& usm );
62 
63 public:
68  std::string authoritativeEngineID() const { return _authoritativeEngineID; }
69 
76  void authoritativeEngineID( const std::string& authoritativeEngineID );
77 
84 
91 
98  std::chrono::seconds authoritativeEngineTime() const { return _authoritativeEngineTime; }
99 
109  void authoritativeEngineTime( std::chrono::seconds authoritativeEngineTime ) {
111  lastUpdateTime = std::chrono::system_clock::now();
112  }
113 
114  bool isAuthenticated() const;
115 
116 public:
125  std::chrono::seconds changeInTime = std::chrono::duration_cast<std::chrono::seconds>( std::chrono::system_clock::now() - lastUpdateTime );
126  // TODO: Check for negative result?
127 
128  // Update the engine time.
130  }
131 
132 public:
137  std::string username() const { return _username; };
138 
144 
150  std::string authenticationPassword() const { return _authenticationPassword; };
151 
156  std::string authenticationKey() const { return _authenticationKey; };
157 
163 
169  std::string encryptionPassword() const { return _encryptionPassword; }
170 
175  std::string encryptionKey() const { return _encryptionKey; }
176 
177 protected:
178  /*
179  * These parameters are generally given as input; they must
180  * be known in advance.
181  */
182 
185  std::string _username;
186 
189 
197 
204  std::string _authenticationKey;
205 
210 
216  std::string _encryptionPassword;
217 
224  std::string _encryptionKey;
225 
226 protected:
227  /*
228  * These parameters are "discoverable"; they pertain to the target
229  * and do not need to be known in advance. However, they can be.
230  */
231 
235 
240 
245  std::chrono::seconds _authoritativeEngineTime;
246 
247 protected:
248  /*
249  * This is for internal use only.
250  */
251 
254  std::chrono::system_clock::time_point lastUpdateTime;
255 };
256 
257 } } }
258 
uint32_t authoritativeEngineBoots() const
This returns the number of times that the engine has booted.
Definition: usm.hpp:83
void updateTimeFromClock()
This will update the value of "authoritativeEngineTime" based on the amount of wall time elapsed sinc...
Definition: usm.hpp:122
Authentication::Type authentication() const
This returns the type of authentication used.
Definition: usm.hpp:143
Encryption::Type _encryption
The type of encryption used.
Definition: usm.hpp:209
uint32_t _authoritativeEngineBoots
The number of times that the engine has booted.
Definition: usm.hpp:239
std::string authenticationPassword() const
This returns the authentication password.
Definition: usm.hpp:150
Type
This defines the type of encryption.
Definition: types.hpp:44
void authoritativeEngineTime(std::chrono::seconds authoritativeEngineTime)
This updates the number of time since the last boot of the engine.
Definition: usm.hpp:109
std::string _encryptionPassword
If encryption is to be used, then the user will have a secret encryption password.
Definition: usm.hpp:216
The User-based Security Model (USM) associates a user (by "user name") with security information...
Definition: usm.hpp:36
std::string authoritativeEngineID() const
This returns the authoritative engine ID.
Definition: usm.hpp:68
Type
This defines the type of authentication.
Definition: types.hpp:24
std::chrono::seconds _authoritativeEngineTime
The amount of time since the last boot of the engine, measured in seconds.
Definition: usm.hpp:245
std::chrono::seconds authoritativeEngineTime() const
This returns the amount of time since the last boot of the engine, measured in seconds.
Definition: usm.hpp:98
std::string _encryptionKey
This is the actual encryption "key" to be used.
Definition: usm.hpp:224
std::string authenticationKey() const
This returns the authentication key.
Definition: usm.hpp:156
std::string _authenticationKey
This is the actual authentication "key" to be used.
Definition: usm.hpp:204
bool isAuthenticated() const
TODO: THIS.
This defines the base exception class for Dangerous SNMP.
Definition: exception.hpp:10
std::string _authenticationPassword
If authentication is to be used, then the user will have a secret authentication password.
Definition: usm.hpp:196
Authentication::Type _authentication
The type of authentication used.
Definition: usm.hpp:188
std::string _authoritativeEngineID
The authoritative engine ID OCTET STRING.
Definition: usm.hpp:234
Encryption::Type encryption() const
This returns the type of encryption used.
Definition: usm.hpp:162
std::string _username
The user name.
Definition: usm.hpp:185
std::string encryptionPassword() const
This returns the encryption password.
Definition: usm.hpp:169
This class is the base class for all security models.
Definition: securitymodel.hpp:29
void authoritativeEngineBoots(uint32_t authoritativeEngineBoots)
This updates the number of times that the engine has booted.
Definition: usm.hpp:90
USM()
Default constructor; this is essentially "noAuthNoPriv".
std::string encryptionKey() const
This returns the encryption key.
Definition: usm.hpp:175
std::string username() const
This returns the user name.
Definition: usm.hpp:137
std::chrono::system_clock::time_point lastUpdateTime
This is the last time that authoritative engine information was updated.
Definition: usm.hpp:254