diff options
author | Malf Furious <m@lfurio.us> | 2016-04-13 21:05:14 -0400 |
---|---|---|
committer | Malf Furious <m@lfurio.us> | 2016-04-13 21:05:14 -0400 |
commit | 490d36e65ac24e34e3021c2a0947384aee138c88 (patch) | |
tree | 418a229fa60708d7796bc61f90794626aefed9d5 /Keychain.h | |
download | compass-490d36e65ac24e34e3021c2a0947384aee138c88.tar.gz compass-490d36e65ac24e34e3021c2a0947384aee138c88.zip |
Root commit for new Compass repository
This is the Alpha version of ComPASS, originally developed sometime in
2014.
Diffstat (limited to 'Keychain.h')
-rw-r--r-- | Keychain.h | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/Keychain.h b/Keychain.h new file mode 100644 index 0000000..8219424 --- /dev/null +++ b/Keychain.h @@ -0,0 +1,101 @@ +#ifndef KEYCHAIN_H
+#define KEYCHAIN_H
+
+#include <iostream>
+#include <string>
+#include <map>
+#include <vector>
+#include <sstream>
+
+#include "Cryptor.h"
+
+struct Credential {
+ Credential() {
+ username = password = "";
+ reset = false;
+ }
+
+ std::string username;
+ std::string password;
+ bool reset;
+};
+
+class Keychain {
+public:
+ // Structors
+ Keychain(std::string remoteHost, std::string port, std::string directory);
+ virtual ~Keychain();
+
+ // Open/close
+ static Keychain* newKeychain(std::string directory);
+ static Keychain* loadKeychain(std::string remoteHost, std::string port, std::string directory);
+ void saveKeychain();
+
+ // Info/Debug
+ void walk();
+ int getServiceCount(std::string service);
+
+ // Create
+ Credential create(std::string service, std::string username, std::string password);
+ Credential create(std::string service, std::string username, PasswordSpec spec);
+ Credential create(std::string service, std::string password);
+ Credential create(std::string service, PasswordSpec spec);
+
+ // Delete
+ bool _delete(std::string service);
+ bool _delete(std::string service, std::string username);
+ bool _delete(std::string service, int cn);
+
+ // Show
+ void show();
+ void show1(std::string service);
+ void showlike(std::string service);
+
+ // Get
+ Credential get(std::string service);
+ Credential get(std::string service, std::string username);
+ Credential get(std::string service, int cn);
+
+ // Mark Reset
+ int markResetAll();
+ int markResetOne(std::string service);
+
+ // Check Reset
+ int checkResetAll();
+ int checkResetOne(std::string service);
+
+ // Reset Username
+ Credential ruser(std::string service, std::string username);
+ Credential ruser(std::string service);
+ Credential ruser(std::string service, std::string username, int cn);
+ Credential ruser(std::string service, int cn);
+
+ // Reset Password
+ Credential rpass(std::string service, std::string password);
+ Credential rpass(std::string service, PasswordSpec spec);
+ Credential rpass(std::string service, std::string password, std::string username);
+ Credential rpass(std::string service, PasswordSpec spec, std::string username);
+ Credential rpass(std::string service, std::string password, int cn);
+ Credential rpass(std::string service, PasswordSpec spec, int cn);
+
+private:
+ std::map<std::string, std::vector<Credential> > credentials; // map from service name (string) onto list of credentials for that service (vector<Credential>)
+ std::string remoteHost;
+ std::string port;
+ std::string directory;
+
+ // Reset Credentials
+ Credential resetUsername(std::string service, std::string username, int cn);
+ Credential resetPassword(std::string service, std::string password, int cn);
+
+ std::vector<Credential> getCreds(std::string service);
+ int getCredsUsernameCount(std::vector<Credential> creds, std::string username);
+ Credential getCredByUsername(std::vector<Credential> creds, std::string username);
+ int getPosByUsername(std::vector<Credential> creds, std::string username);
+ void printServiceCreds(std::vector<Credential> creds);
+ void promptConfirm();
+ std::vector<std::string> getServicesLike(std::string service);
+ PasswordSpec getUsernameSpec();
+};
+
+#endif // KEYCHAIN_H
|