#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 directory); virtual ~Keychain(); // Open/close static Keychain* newKeychain(std::string directory); static Keychain* loadKeychain(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 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