Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(286)

Side by Side Diff: net/http/http_auth_handler_ntlm_portable.cc

Issue 6339012: More net/ method ordering. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More done while waiting for previous patch to clear Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/http/http_auth_handler_ntlm.cc ('k') | net/http/http_basic_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/http/http_auth_handler_ntlm.h" 5 #include "net/http/http_auth_handler_ntlm.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 // For gethostname 8 // For gethostname
9 #if defined(OS_POSIX) 9 #if defined(OS_POSIX)
10 #include <unistd.h> 10 #include <unistd.h>
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 HttpAuthHandlerNTLM::GenerateRandomProc 636 HttpAuthHandlerNTLM::GenerateRandomProc
637 HttpAuthHandlerNTLM::generate_random_proc_ = GenerateRandom; 637 HttpAuthHandlerNTLM::generate_random_proc_ = GenerateRandom;
638 638
639 // static 639 // static
640 HttpAuthHandlerNTLM::HostNameProc 640 HttpAuthHandlerNTLM::HostNameProc
641 HttpAuthHandlerNTLM::get_host_name_proc_ = GetHostName; 641 HttpAuthHandlerNTLM::get_host_name_proc_ = GetHostName;
642 642
643 HttpAuthHandlerNTLM::HttpAuthHandlerNTLM() { 643 HttpAuthHandlerNTLM::HttpAuthHandlerNTLM() {
644 } 644 }
645 645
646 HttpAuthHandlerNTLM::~HttpAuthHandlerNTLM() {
647 // Wipe our copy of the password from memory, to reduce the chance of being
648 // written to the paging file on disk.
649 ZapString(&password_);
650 }
651
652 bool HttpAuthHandlerNTLM::NeedsIdentity() { 646 bool HttpAuthHandlerNTLM::NeedsIdentity() {
653 return !auth_data_.empty(); 647 return !auth_data_.empty();
654 } 648 }
655 649
656 bool HttpAuthHandlerNTLM::AllowsDefaultCredentials() { 650 bool HttpAuthHandlerNTLM::AllowsDefaultCredentials() {
657 // Default credentials are not supported in the portable implementation of 651 // Default credentials are not supported in the portable implementation of
658 // NTLM, but are supported in the SSPI implementation. 652 // NTLM, but are supported in the SSPI implementation.
659 return false; 653 return false;
660 } 654 }
661 655
656 int HttpAuthHandlerNTLM::InitializeBeforeFirstChallenge() {
657 return OK;
658 }
659
660 HttpAuthHandlerNTLM::~HttpAuthHandlerNTLM() {
661 // Wipe our copy of the password from memory, to reduce the chance of being
662 // written to the paging file on disk.
663 ZapString(&password_);
664 }
665
662 // static 666 // static
663 HttpAuthHandlerNTLM::GenerateRandomProc 667 HttpAuthHandlerNTLM::GenerateRandomProc
664 HttpAuthHandlerNTLM::SetGenerateRandomProc( 668 HttpAuthHandlerNTLM::SetGenerateRandomProc(
665 GenerateRandomProc proc) { 669 GenerateRandomProc proc) {
666 GenerateRandomProc old_proc = generate_random_proc_; 670 GenerateRandomProc old_proc = generate_random_proc_;
667 generate_random_proc_ = proc; 671 generate_random_proc_ = proc;
668 return old_proc; 672 return old_proc;
669 } 673 }
670 674
671 // static 675 // static
672 HttpAuthHandlerNTLM::HostNameProc HttpAuthHandlerNTLM::SetHostNameProc( 676 HttpAuthHandlerNTLM::HostNameProc HttpAuthHandlerNTLM::SetHostNameProc(
673 HostNameProc proc) { 677 HostNameProc proc) {
674 HostNameProc old_proc = get_host_name_proc_; 678 HostNameProc old_proc = get_host_name_proc_;
675 get_host_name_proc_ = proc; 679 get_host_name_proc_ = proc;
676 return old_proc; 680 return old_proc;
677 } 681 }
678 682
683 HttpAuthHandlerNTLM::Factory::Factory() {
684 }
685
686 HttpAuthHandlerNTLM::Factory::~Factory() {
687 }
688
679 int HttpAuthHandlerNTLM::GetNextToken(const void* in_token, 689 int HttpAuthHandlerNTLM::GetNextToken(const void* in_token,
680 uint32 in_token_len, 690 uint32 in_token_len,
681 void** out_token, 691 void** out_token,
682 uint32* out_token_len) { 692 uint32* out_token_len) {
683 int rv = 0; 693 int rv = 0;
684 694
685 // If in_token is non-null, then assume it contains a type 2 message... 695 // If in_token is non-null, then assume it contains a type 2 message...
686 if (in_token) { 696 if (in_token) {
687 LogToken("in-token", in_token, in_token_len); 697 LogToken("in-token", in_token, in_token_len);
688 std::string hostname = get_host_name_proc_(); 698 std::string hostname = get_host_name_proc_();
689 if (hostname.empty()) 699 if (hostname.empty())
690 return ERR_UNEXPECTED; 700 return ERR_UNEXPECTED;
691 uint8 rand_buf[8]; 701 uint8 rand_buf[8];
692 generate_random_proc_(rand_buf, 8); 702 generate_random_proc_(rand_buf, 8);
693 rv = GenerateType3Msg(domain_, username_, password_, hostname, rand_buf, 703 rv = GenerateType3Msg(domain_, username_, password_, hostname, rand_buf,
694 in_token, in_token_len, out_token, out_token_len); 704 in_token, in_token_len, out_token, out_token_len);
695 } else { 705 } else {
696 rv = GenerateType1Msg(out_token, out_token_len); 706 rv = GenerateType1Msg(out_token, out_token_len);
697 } 707 }
698 708
699 if (rv == OK) 709 if (rv == OK)
700 LogToken("out-token", *out_token, *out_token_len); 710 LogToken("out-token", *out_token, *out_token_len);
701 711
702 return rv; 712 return rv;
703 } 713 }
704 714
705 int HttpAuthHandlerNTLM::InitializeBeforeFirstChallenge() {
706 return OK;
707 }
708
709 HttpAuthHandlerNTLM::Factory::Factory() {
710 }
711
712 HttpAuthHandlerNTLM::Factory::~Factory() {
713 }
714
715 int HttpAuthHandlerNTLM::Factory::CreateAuthHandler( 715 int HttpAuthHandlerNTLM::Factory::CreateAuthHandler(
716 HttpAuth::ChallengeTokenizer* challenge, 716 HttpAuth::ChallengeTokenizer* challenge,
717 HttpAuth::Target target, 717 HttpAuth::Target target,
718 const GURL& origin, 718 const GURL& origin,
719 CreateReason reason, 719 CreateReason reason,
720 int digest_nonce_count, 720 int digest_nonce_count,
721 const BoundNetLog& net_log, 721 const BoundNetLog& net_log,
722 scoped_ptr<HttpAuthHandler>* handler) { 722 scoped_ptr<HttpAuthHandler>* handler) {
723 if (reason == CREATE_PREEMPTIVE) 723 if (reason == CREATE_PREEMPTIVE)
724 return ERR_UNSUPPORTED_AUTH_SCHEME; 724 return ERR_UNSUPPORTED_AUTH_SCHEME;
725 // TODO(cbentzel): Move towards model of parsing in the factory 725 // TODO(cbentzel): Move towards model of parsing in the factory
726 // method and only constructing when valid. 726 // method and only constructing when valid.
727 // NOTE: Default credentials are not supported for the portable implementation 727 // NOTE: Default credentials are not supported for the portable implementation
728 // of NTLM. 728 // of NTLM.
729 scoped_ptr<HttpAuthHandler> tmp_handler(new HttpAuthHandlerNTLM); 729 scoped_ptr<HttpAuthHandler> tmp_handler(new HttpAuthHandlerNTLM);
730 if (!tmp_handler->InitFromChallenge(challenge, target, origin, net_log)) 730 if (!tmp_handler->InitFromChallenge(challenge, target, origin, net_log))
731 return ERR_INVALID_RESPONSE; 731 return ERR_INVALID_RESPONSE;
732 handler->swap(tmp_handler); 732 handler->swap(tmp_handler);
733 return OK; 733 return OK;
734 } 734 }
735 735
736 } // namespace net 736 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_auth_handler_ntlm.cc ('k') | net/http/http_basic_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698