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