From 490d36e65ac24e34e3021c2a0947384aee138c88 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Wed, 13 Apr 2016 21:05:14 -0400 Subject: Root commit for new Compass repository This is the Alpha version of ComPASS, originally developed sometime in 2014. --- Keychain.h | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 Keychain.h (limited to 'Keychain.h') 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 +#include +#include +#include +#include + +#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 > credentials; // map from service name (string) onto list of credentials for that service (vector) + 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 getCreds(std::string service); + int getCredsUsernameCount(std::vector creds, std::string username); + Credential getCredByUsername(std::vector creds, std::string username); + int getPosByUsername(std::vector creds, std::string username); + void printServiceCreds(std::vector creds); + void promptConfirm(); + std::vector getServicesLike(std::string service); + PasswordSpec getUsernameSpec(); +}; + +#endif // KEYCHAIN_H -- cgit v1.2.3