1 /* 2 BAREOS® - Backup Archiving REcovery Open Sourced 3 4 Copyright (C) 2018-2018 Bareos GmbH & Co. KG 5 6 This program is Free Software; you can redistribute it and/or 7 modify it under the terms of version three of the GNU Affero General Public 8 License as published by the Free Software Foundation and included 9 in the file LICENSE. 10 11 This program is distributed in the hope that it will be useful, but 12 WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 Affero General Public License for more details. 15 16 You should have received a copy of the GNU Affero General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19 02110-1301, USA. 20 */ 21 22 #ifndef BAREOS_LIB_TLS_PSK_CREDENTIALS_H_ 23 #define BAREOS_LIB_TLS_PSK_CREDENTIALS_H_ 24 25 #include "include/bareos.h" 26 27 #include <string> 28 29 class PskCredentials { 30 public: PskCredentials()31 PskCredentials() {} 32 PskCredentials(const std::string & identity,const std::string & psk)33 PskCredentials(const std::string& identity, const std::string& psk) 34 : identity_(identity), psk_(psk) 35 { 36 Dmsg1(1000, "Construct PskCredentials: id=%s\n", identity_.c_str()); 37 } 38 PskCredentials(const char * identity,const char * psk)39 PskCredentials(const char* identity, const char* psk) 40 : identity_(std::string(identity)), psk_(std::string(psk)) 41 { 42 Dmsg1(1000, "Construct PskCredentials: id=%s\n", identity_.c_str()); 43 } 44 45 PskCredentials& operator=(const PskCredentials& rhs) 46 { 47 identity_ = rhs.identity_; 48 psk_ = rhs.psk_; 49 return *this; 50 } 51 empty()52 bool empty() const { return identity_.empty() && psk_.empty(); } 53 set_identity(const char * in)54 void set_identity(const char* in) { identity_ = in; } set_psk(const char * in)55 void set_psk(const char* in) { psk_ = in; } 56 get_identity()57 const std::string& get_identity() const { return identity_; } get_psk()58 const std::string& get_psk() const { return psk_; } 59 ~PskCredentials()60 ~PskCredentials() 61 { 62 Dmsg1(1000, "Destruct PskCredentials: id=%s\n", identity_.c_str()); 63 } 64 65 private: 66 std::string identity_; 67 std::string psk_; 68 }; 69 70 #endif /* BAREOS_LIB_TLS_PSK_CREDENTIALS_H_ */ 71