libzypp  17.31.31
curlauthdata.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_CURL_AUTH_CURLAUTHDATA_H_INCLUDED
13 #define ZYPP_CURL_AUTH_CURLAUTHDATA_H_INCLUDED
14 
15 #include <zypp-media/auth/AuthData>
16 
17 namespace zypp {
18  namespace media {
22  class CurlAuthData : public AuthData {
23  public:
28  CurlAuthData();
29 
30  CurlAuthData(const AuthData & authData);
31 
32  CurlAuthData(std::string & username, std::string & password, std::string & auth_type)
34  {
35  _auth_type = auth_type_str2long(auth_type);
36  }
37 
38  CurlAuthData(std::string & username, std::string & password, long auth_type)
39  : AuthData(username,password), _auth_type(auth_type)
40  {
42  }
43 
49  virtual bool valid() const;
50 
55  void setAuthType(std::string auth_type)
56  {
57  _auth_type_str = auth_type; _auth_type = auth_type_str2long(auth_type);
58  }
59 
65  void setAuthType(long auth_type)
66  {
67  _auth_type = auth_type;
69  }
70 
71  long authType() const { return _auth_type; }
72  std::string authTypeAsString() const { return _auth_type_str; }
73 
74  std::string getUserPwd() const { return username() + ":" + password(); }
75 
76 
86  static long auth_type_str2long( std::string & auth_type_str );
87  static long auth_type_str2long( const std::string &auth_type_str );
88 
93  static std::string auth_type_long2str(long auth_type);
94 
95  virtual std::ostream & dumpOn( std::ostream & str ) const;
96 
97  private:
98  std::string _auth_type_str;
99  long _auth_type;
100  };
101 
102  typedef shared_ptr<CurlAuthData> CurlAuthData_Ptr;
103  std::ostream & operator << (std::ostream & str, const CurlAuthData & auth_data);
104  }
105 }
106 
107 #endif
std::string password() const
Definition: authdata.h:55
std::ostream & operator<<(std::ostream &str, const MediaHandler &obj)
void setAuthType(std::string auth_type)
Set HTTP authentication type(s) to use.
Definition: curlauthdata.h:55
void setAuthType(long auth_type)
Set HTTP authentication type(s) to use.
Definition: curlauthdata.h:65
std::string getUserPwd() const
Definition: curlauthdata.h:74
String related utilities and Regular expression matching.
std::string authTypeAsString() const
Definition: curlauthdata.h:72
virtual std::ostream & dumpOn(std::ostream &str) const
Definition: curlauthdata.cc:43
CurlAuthData(std::string &username, std::string &password, std::string &auth_type)
Definition: curlauthdata.h:32
std::string username() const
Definition: authdata.h:54
CurlAuthData()
Default constructor.
Definition: curlauthdata.cc:26
shared_ptr< CurlAuthData > CurlAuthData_Ptr
Definition: curlauthdata.h:102
Class for handling media authentication data.
Definition: authdata.h:28
static std::string auth_type_long2str(long auth_type)
Converts a long of ORed CURLAUTH_* identifiers into a string of comma separated list of authenticatio...
CurlAuthData(std::string &username, std::string &password, long auth_type)
Definition: curlauthdata.h:38
static long auth_type_str2long(std::string &auth_type_str)
Converts a string of comma separated list of authetication type names into a long of ORed CURLAUTH_* ...
Definition: curlauthdata.cc:50
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
Curl HTTP authentication data.
Definition: curlauthdata.h:22
virtual bool valid() const
Checks validity of authentication data.
Definition: curlauthdata.cc:38