14 #include <curl/curl.h>
16 #include <boost/format.hpp>
46 str <<
"username: '" <<
_username <<
"'" << std::endl
47 <<
"password: " << (
_password.empty() ?
"<empty>" :
"<non-empty>")
72 , _auth_type(CURLAUTH_NONE)
78 , _auth_type(CURLAUTH_NONE)
95 curl_version_info_data *curl_info = curl_version_info(CURLVERSION_NOW);
97 std::vector<std::string> list;
98 std::vector<std::string>::const_iterator it;
99 long auth_type = CURLAUTH_NONE;
103 for(it = list.begin(); it != list.end(); ++it)
107 auth_type |= CURLAUTH_BASIC;
112 auth_type |= CURLAUTH_DIGEST;
115 if((curl_info && (curl_info->features & CURL_VERSION_NTLM)) &&
118 auth_type |= CURLAUTH_NTLM;
121 if((curl_info && (curl_info->features & CURL_VERSION_SPNEGO)) &&
122 (*it ==
"spnego" || *it ==
"negotiate"))
125 auth_type |= CURLAUTH_GSSNEGOTIATE;
128 if((curl_info && (curl_info->features & CURL_VERSION_GSSNEGOTIATE)) &&
129 (*it ==
"gssnego" || *it ==
"negotiate"))
131 auth_type |= CURLAUTH_GSSNEGOTIATE;
135 std::string msg = boost::str(
136 boost::format (
_(
"Unsupported HTTP authentication method '%s'")) % *it);
147 std::list<std::string> auth_list;
149 if(auth_type & CURLAUTH_GSSNEGOTIATE)
150 auth_list.push_back(
"negotiate");
152 if(auth_type & CURLAUTH_NTLM)
153 auth_list.push_back(
"ntlm");
155 if(auth_type & CURLAUTH_DIGEST)
156 auth_list.push_back(
"digest");
158 if(auth_type & CURLAUTH_BASIC)
159 auth_list.push_back(
"basic");
static const ViewOption WITH_USERNAME
Option to include username in the URL string.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
unsigned split(const C_Str &line_r, _OutputIterator result_r, const C_Str &sepchars_r=" \t")
Split line_r into words.
std::string getUsername(EEncoding eflag=zypp::url::E_DECODED) const
Returns the username from the URL authority.
bool isValid() const
Verifies the Url.
Url::asString() view options.
std::string asString() const
Returns a default string representation of the Url object.
std::string join(_Iterator begin, _Iterator end, const C_Str &sep_r=" ")
Join strings using separator sep_r (defaults to BLANK).
#define _(MSG)
Return translated text.
static const ViewOption WITH_PASSWORD
Option to include password in the URL string.
std::string getPassword(EEncoding eflag=zypp::url::E_DECODED) const
Returns the password from the URL authority.