libzypp  17.37.5
authdata.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_MEDIA_AUTH_DATA_H
13 #define ZYPP_MEDIA_AUTH_DATA_H
14 
15 #include <zypp-core/Url.h>
17 
18 #include <utility>
19 
20 namespace zypp {
21  namespace media {
22 
24 
25 
31 {
32 public:
34  {}
35 
36  AuthData(const Url & url);
37 
38  AuthData(std::string username, std::string password)
39  : _username(std::move(username)), _password(std::move(password)), _lastChange(0)
40  {}
41 
42  virtual ~AuthData() {};
43 
49  virtual bool valid() const;
50 
51  void setUrl(const Url & url) { _url = url; }
52  void setUsername(const std::string & username) { _username = username; }
53  void setPassword(const std::string & password) { _password = password; }
54 
55  Url url() const { return _url; }
56  std::string username() const { return _username; }
57  std::string password() const { return _password; }
58 
63  time_t lastDatabaseUpdate () const;
64  void setLastDatabaseUpdate ( time_t time );
65 
66  const std::map<std::string, std::string> &extraValues() const;
67  std::map<std::string, std::string> &extraValues();
68 
69  virtual std::ostream & dumpOn( std::ostream & str ) const;
70 
71  virtual std::ostream & dumpAsIniOn( std::ostream & str ) const;
72 
73 private:
75  std::string _username;
76  std::string _password;
77  time_t _lastChange; //< timestamp of the last change to the database this credential is stored in
78  std::map<std::string, std::string> _extraValues;
79 };
80 
81 using AuthData_Ptr = shared_ptr<AuthData>;
82 std::ostream & operator << (std::ostream & str, const AuthData & auth_data);
83 
85 
86  } // namespace media
87 } // namespace zypp
88 
89 #endif // ZYPP_MEDIA_AUTH_DATA_H
std::string password() const
Definition: authdata.h:57
std::ostream & operator<<(std::ostream &str, const MediaHandler &obj)
void setPassword(const std::string &password)
Definition: authdata.h:53
std::map< std::string, std::string > _extraValues
Definition: authdata.h:78
virtual ~AuthData()
Definition: authdata.h:42
std::string _username
Definition: authdata.h:75
String related utilities and Regular expression matching.
Definition: Arch.h:363
AuthData(std::string username, std::string password)
Definition: authdata.h:38
zypp::Url _url
void setUrl(const Url &url)
Definition: authdata.h:51
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition: ResTraits.h:93
zypp::media::AuthData AuthData
Definition: authdata.h:21
shared_ptr< AuthData > AuthData_Ptr
Definition: authdata.h:81
std::string username() const
Definition: authdata.h:56
Url url() const
Definition: authdata.h:55
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Definition: Capability.cc:580
Class for handling media authentication data.
Definition: authdata.h:30
void setUsername(const std::string &username)
Definition: authdata.h:52
Easy-to use interface to the ZYPP dependency resolver.
Definition: Application.cc:19
time_t _lastChange
std::string _password
Definition: authdata.h:76
Url manipulation class.
Definition: Url.h:92