OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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> |
11 #elif defined(OS_WIN) | 11 #elif defined(OS_WIN) |
12 #include <winsock2.h> | 12 #include <winsock2.h> |
13 #endif | 13 #endif |
14 | 14 |
15 #include "base/md5.h" | 15 #include "base/md5.h" |
16 #include "base/rand_util.h" | 16 #include "base/rand_util.h" |
17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
18 #include "base/strings/sys_string_conversions.h" | 18 #include "base/strings/sys_string_conversions.h" |
19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
20 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
21 #include "net/base/net_util.h" | 21 #include "net/base/net_util.h" |
22 #include "net/base/zap.h" | 22 #include "net/base/zap.h" |
23 #include "net/http/des.h" | 23 #include "net/http/des.h" |
24 #include "net/http/md4.h" | 24 #include "net/http/md4.h" |
| 25 #include "url/origin.h" |
25 | 26 |
26 namespace net { | 27 namespace net { |
27 | 28 |
28 // Based on mozilla/security/manager/ssl/src/nsNTLMAuthModule.cpp, | 29 // Based on mozilla/security/manager/ssl/src/nsNTLMAuthModule.cpp, |
29 // CVS rev. 1.14. | 30 // CVS rev. 1.14. |
30 // | 31 // |
31 // TODO(wtc): | 32 // TODO(wtc): |
32 // - The IS_BIG_ENDIAN code is not tested. | 33 // - The IS_BIG_ENDIAN code is not tested. |
33 // - Enable the logging code or just delete it. | 34 // - Enable the logging code or just delete it. |
34 // - Delete or comment out the LM code, which hasn't been tested and isn't | 35 // - Delete or comment out the LM code, which hasn't been tested and isn't |
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 | 707 |
707 if (rv == OK) | 708 if (rv == OK) |
708 LogToken("out-token", *out_token, *out_token_len); | 709 LogToken("out-token", *out_token, *out_token_len); |
709 | 710 |
710 return rv; | 711 return rv; |
711 } | 712 } |
712 | 713 |
713 int HttpAuthHandlerNTLM::Factory::CreateAuthHandler( | 714 int HttpAuthHandlerNTLM::Factory::CreateAuthHandler( |
714 HttpAuthChallengeTokenizer* challenge, | 715 HttpAuthChallengeTokenizer* challenge, |
715 HttpAuth::Target target, | 716 HttpAuth::Target target, |
716 const GURL& origin, | 717 const url::Origin& origin, |
717 CreateReason reason, | 718 CreateReason reason, |
718 int digest_nonce_count, | 719 int digest_nonce_count, |
719 const BoundNetLog& net_log, | 720 const BoundNetLog& net_log, |
720 scoped_ptr<HttpAuthHandler>* handler) { | 721 scoped_ptr<HttpAuthHandler>* handler) { |
721 if (reason == CREATE_PREEMPTIVE) | 722 if (reason == CREATE_PREEMPTIVE) |
722 return ERR_UNSUPPORTED_AUTH_SCHEME; | 723 return ERR_UNSUPPORTED_AUTH_SCHEME; |
723 // TODO(cbentzel): Move towards model of parsing in the factory | 724 // TODO(cbentzel): Move towards model of parsing in the factory |
724 // method and only constructing when valid. | 725 // method and only constructing when valid. |
725 // NOTE: Default credentials are not supported for the portable implementation | 726 // NOTE: Default credentials are not supported for the portable implementation |
726 // of NTLM. | 727 // of NTLM. |
727 scoped_ptr<HttpAuthHandler> tmp_handler(new HttpAuthHandlerNTLM); | 728 scoped_ptr<HttpAuthHandler> tmp_handler(new HttpAuthHandlerNTLM); |
728 if (!tmp_handler->InitFromChallenge(challenge, target, origin, net_log)) | 729 if (!tmp_handler->InitFromChallenge(challenge, target, origin, net_log)) |
729 return ERR_INVALID_RESPONSE; | 730 return ERR_INVALID_RESPONSE; |
730 handler->swap(tmp_handler); | 731 handler->swap(tmp_handler); |
731 return OK; | 732 return OK; |
732 } | 733 } |
733 | 734 |
734 } // namespace net | 735 } // namespace net |
OLD | NEW |