OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 "UT", "GMT", "EST", "EDT", "CST", "CDT", "MST", "MDT", "PST", "PDT", | 334 "UT", "GMT", "EST", "EDT", "CST", "CDT", "MST", "MDT", "PST", "PDT", |
335 "A", "B", "C", "D", "E", "F", "G", "H", "I", "K", "L", "M", | 335 "A", "B", "C", "D", "E", "F", "G", "H", "I", "K", "L", "M", |
336 "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y" | 336 "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y" |
337 }; | 337 }; |
338 const int kTimeZoneOffsets[] = { | 338 const int kTimeZoneOffsets[] = { |
339 0, 0, -5, -4, -6, -5, -7, -6, -8, -7, | 339 0, 0, -5, -4, -6, -5, -7, -6, -8, -7, |
340 -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, | 340 -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, |
341 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 | 341 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 |
342 }; | 342 }; |
343 | 343 |
344 RTC_DCHECK(NULL != seconds); | 344 RTC_DCHECK(nullptr != seconds); |
345 struct tm tval; | 345 struct tm tval; |
346 memset(&tval, 0, sizeof(tval)); | 346 memset(&tval, 0, sizeof(tval)); |
347 char month[4], zone[6]; | 347 char month[4], zone[6]; |
348 memset(month, 0, sizeof(month)); | 348 memset(month, 0, sizeof(month)); |
349 memset(zone, 0, sizeof(zone)); | 349 memset(zone, 0, sizeof(zone)); |
350 | 350 |
351 if (7 != sscanf(date.c_str(), "%*3s, %d %3s %d %d:%d:%d %5c", | 351 if (7 != sscanf(date.c_str(), "%*3s, %d %3s %d %d:%d:%d %5c", |
352 &tval.tm_mday, month, &tval.tm_year, | 352 &tval.tm_mday, month, &tval.tm_year, |
353 &tval.tm_hour, &tval.tm_min, &tval.tm_sec, zone)) { | 353 &tval.tm_hour, &tval.tm_min, &tval.tm_sec, zone)) { |
354 return false; | 354 return false; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 } | 474 } |
475 | 475 |
476 void HttpData::setContent(const std::string& content_type, | 476 void HttpData::setContent(const std::string& content_type, |
477 StreamInterface* document) { | 477 StreamInterface* document) { |
478 setHeader(HH_CONTENT_TYPE, content_type); | 478 setHeader(HH_CONTENT_TYPE, content_type); |
479 setDocumentAndLength(document); | 479 setDocumentAndLength(document); |
480 } | 480 } |
481 | 481 |
482 void HttpData::setDocumentAndLength(StreamInterface* document) { | 482 void HttpData::setDocumentAndLength(StreamInterface* document) { |
483 // TODO: Consider calling Rewind() here? | 483 // TODO: Consider calling Rewind() here? |
484 RTC_DCHECK(!hasHeader(HH_CONTENT_LENGTH, NULL)); | 484 RTC_DCHECK(!hasHeader(HH_CONTENT_LENGTH, nullptr)); |
485 RTC_DCHECK(!hasHeader(HH_TRANSFER_ENCODING, NULL)); | 485 RTC_DCHECK(!hasHeader(HH_TRANSFER_ENCODING, nullptr)); |
486 RTC_DCHECK(document != NULL); | 486 RTC_DCHECK(document != nullptr); |
487 this->document.reset(document); | 487 this->document.reset(document); |
488 size_t content_length = 0; | 488 size_t content_length = 0; |
489 if (this->document->GetAvailable(&content_length)) { | 489 if (this->document->GetAvailable(&content_length)) { |
490 char buffer[32]; | 490 char buffer[32]; |
491 sprintfn(buffer, sizeof(buffer), "%d", content_length); | 491 sprintfn(buffer, sizeof(buffer), "%d", content_length); |
492 setHeader(HH_CONTENT_LENGTH, buffer); | 492 setHeader(HH_CONTENT_LENGTH, buffer); |
493 } else { | 493 } else { |
494 setHeader(HH_TRANSFER_ENCODING, "chunked"); | 494 setHeader(HH_TRANSFER_ENCODING, "chunked"); |
495 } | 495 } |
496 } | 496 } |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 | 712 |
713 HttpAuthResult HttpAuthenticate( | 713 HttpAuthResult HttpAuthenticate( |
714 const char * challenge, size_t len, | 714 const char * challenge, size_t len, |
715 const SocketAddress& server, | 715 const SocketAddress& server, |
716 const std::string& method, const std::string& uri, | 716 const std::string& method, const std::string& uri, |
717 const std::string& username, const CryptString& password, | 717 const std::string& username, const CryptString& password, |
718 HttpAuthContext *& context, std::string& response, std::string& auth_method) | 718 HttpAuthContext *& context, std::string& response, std::string& auth_method) |
719 { | 719 { |
720 HttpAttributeList args; | 720 HttpAttributeList args; |
721 HttpParseAttributes(challenge, len, args); | 721 HttpParseAttributes(challenge, len, args); |
722 HttpHasNthAttribute(args, 0, &auth_method, NULL); | 722 HttpHasNthAttribute(args, 0, &auth_method, nullptr); |
723 | 723 |
724 if (context && (context->auth_method != auth_method)) | 724 if (context && (context->auth_method != auth_method)) |
725 return HAR_IGNORE; | 725 return HAR_IGNORE; |
726 | 726 |
727 // BASIC | 727 // BASIC |
728 if (_stricmp(auth_method.c_str(), "basic") == 0) { | 728 if (_stricmp(auth_method.c_str(), "basic") == 0) { |
729 if (context) | 729 if (context) |
730 return HAR_CREDENTIALS; // Bad credentials | 730 return HAR_CREDENTIALS; // Bad credentials |
731 if (username.empty()) | 731 if (username.empty()) |
732 return HAR_CREDENTIALS; // Missing credentials | 732 return HAR_CREDENTIALS; // Missing credentials |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 #if 1 | 818 #if 1 |
819 bool want_negotiate = (_stricmp(auth_method.c_str(), "negotiate") == 0); | 819 bool want_negotiate = (_stricmp(auth_method.c_str(), "negotiate") == 0); |
820 bool want_ntlm = (_stricmp(auth_method.c_str(), "ntlm") == 0); | 820 bool want_ntlm = (_stricmp(auth_method.c_str(), "ntlm") == 0); |
821 // SPNEGO & NTLM | 821 // SPNEGO & NTLM |
822 if (want_negotiate || want_ntlm) { | 822 if (want_negotiate || want_ntlm) { |
823 const size_t MAX_MESSAGE = 12000, MAX_SPN = 256; | 823 const size_t MAX_MESSAGE = 12000, MAX_SPN = 256; |
824 char out_buf[MAX_MESSAGE], spn[MAX_SPN]; | 824 char out_buf[MAX_MESSAGE], spn[MAX_SPN]; |
825 | 825 |
826 #if 0 // Requires funky windows versions | 826 #if 0 // Requires funky windows versions |
827 DWORD len = MAX_SPN; | 827 DWORD len = MAX_SPN; |
828 if (DsMakeSpn("HTTP", server.HostAsURIString().c_str(), NULL, | 828 if (DsMakeSpn("HTTP", server.HostAsURIString().c_str(), nullptr, |
829 server.port(), | 829 server.port(), |
830 0, &len, spn) != ERROR_SUCCESS) { | 830 0, &len, spn) != ERROR_SUCCESS) { |
831 LOG_F(WARNING) << "(Negotiate) - DsMakeSpn failed"; | 831 LOG_F(WARNING) << "(Negotiate) - DsMakeSpn failed"; |
832 return HAR_IGNORE; | 832 return HAR_IGNORE; |
833 } | 833 } |
834 #else | 834 #else |
835 sprintfn(spn, MAX_SPN, "HTTP/%s", server.ToString().c_str()); | 835 sprintfn(spn, MAX_SPN, "HTTP/%s", server.ToString().c_str()); |
836 #endif | 836 #endif |
837 | 837 |
838 SecBuffer out_sec; | 838 SecBuffer out_sec; |
(...skipping 29 matching lines...) Expand all Loading... |
868 NegotiateAuthContext * neg = static_cast<NegotiateAuthContext *>(context); | 868 NegotiateAuthContext * neg = static_cast<NegotiateAuthContext *>(context); |
869 if (neg) { | 869 if (neg) { |
870 const size_t max_steps = 10; | 870 const size_t max_steps = 10; |
871 if (++neg->steps >= max_steps) { | 871 if (++neg->steps >= max_steps) { |
872 LOG(WARNING) << "AsyncHttpsProxySocket::Authenticate(Negotiate) too many
retries"; | 872 LOG(WARNING) << "AsyncHttpsProxySocket::Authenticate(Negotiate) too many
retries"; |
873 return HAR_ERROR; | 873 return HAR_ERROR; |
874 } | 874 } |
875 steps = neg->steps; | 875 steps = neg->steps; |
876 | 876 |
877 std::string challenge, decoded_challenge; | 877 std::string challenge, decoded_challenge; |
878 if (HttpHasNthAttribute(args, 1, &challenge, NULL) | 878 if (HttpHasNthAttribute(args, 1, &challenge, nullptr) && |
879 && Base64::Decode(challenge, Base64::DO_STRICT, | 879 Base64::Decode(challenge, Base64::DO_STRICT, &decoded_challenge, |
880 &decoded_challenge, NULL)) { | 880 nullptr)) { |
881 SecBuffer in_sec; | 881 SecBuffer in_sec; |
882 in_sec.pvBuffer = const_cast<char *>(decoded_challenge.data()); | 882 in_sec.pvBuffer = const_cast<char *>(decoded_challenge.data()); |
883 in_sec.cbBuffer = static_cast<unsigned long>(decoded_challenge.size())
; | 883 in_sec.cbBuffer = static_cast<unsigned long>(decoded_challenge.size())
; |
884 in_sec.BufferType = SECBUFFER_TOKEN; | 884 in_sec.BufferType = SECBUFFER_TOKEN; |
885 | 885 |
886 SecBufferDesc in_buf_desc; | 886 SecBufferDesc in_buf_desc; |
887 in_buf_desc.ulVersion = 0; | 887 in_buf_desc.ulVersion = 0; |
888 in_buf_desc.cBuffers = 1; | 888 in_buf_desc.cBuffers = 1; |
889 in_buf_desc.pBuffers = &in_sec; | 889 in_buf_desc.pBuffers = &in_sec; |
890 | 890 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 } | 1000 } |
1001 #endif | 1001 #endif |
1002 #endif // WEBRTC_WIN | 1002 #endif // WEBRTC_WIN |
1003 | 1003 |
1004 return HAR_IGNORE; | 1004 return HAR_IGNORE; |
1005 } | 1005 } |
1006 | 1006 |
1007 ////////////////////////////////////////////////////////////////////// | 1007 ////////////////////////////////////////////////////////////////////// |
1008 | 1008 |
1009 } // namespace rtc | 1009 } // namespace rtc |
OLD | NEW |