1 /* 2 * Copyright 2019, Andrew Lindesay <apl@lindesay.co.nz>. 3 * 4 * All rights reserved. Distributed under the terms of the MIT License. 5 */ 6 #ifndef USER_CREDENTIALS_H 7 #define USER_CREDENTIALS_H 8 9 10 #include <Archivable.h> 11 #include <String.h> 12 13 14 /*! This object represents the tuple of the user's nickname (username) and 15 password. It also carries a boolean that indicates if an authentication 16 with these credentials was successful or failed. 17 */ 18 19 class UserCredentials : public BArchivable { 20 public: 21 UserCredentials(BMessage* from); 22 UserCredentials(const BString& nickname, 23 const BString& passwordClear); 24 UserCredentials(const UserCredentials& other); 25 UserCredentials(); 26 virtual ~UserCredentials(); 27 28 UserCredentials& operator=(const UserCredentials& other); 29 bool operator==(const UserCredentials& other) const; 30 bool operator!=(const UserCredentials& other) const; 31 32 const BString& Nickname() const; 33 const BString& PasswordClear() const; 34 const bool IsSuccessful() const; 35 const bool IsValid() const; 36 37 void SetNickname(const BString& value); 38 void SetPasswordClear(const BString& value); 39 void SetIsSuccessful(bool value); 40 41 status_t Archive(BMessage* into, bool deep = true) const; 42 private: 43 BString fNickname; 44 BString fPasswordClear; 45 bool fIsSuccessful; 46 }; 47 48 49 #endif // USER_CREDENTIALS_H 50