| OLD | NEW |
| 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.h" | 5 #include "net/http/http_auth_handler.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_util.h" |
| 8 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 9 | 10 |
| 10 namespace net { | 11 namespace net { |
| 11 | 12 |
| 12 HttpAuthHandler::HttpAuthHandler() | 13 HttpAuthHandler::HttpAuthHandler() |
| 13 : auth_scheme_(HttpAuth::AUTH_SCHEME_MAX), | 14 : auth_scheme_(HttpAuth::AUTH_SCHEME_MAX), |
| 14 score_(-1), | 15 score_(-1), |
| 15 target_(HttpAuth::AUTH_NONE), | 16 target_(HttpAuth::AUTH_NONE), |
| 16 properties_(-1), | 17 properties_(-1), |
| 17 original_callback_(NULL), | 18 original_callback_(NULL), |
| (...skipping 21 matching lines...) Expand all Loading... |
| 39 | 40 |
| 40 // Init() is expected to set the scheme, realm, score, and properties. The | 41 // Init() is expected to set the scheme, realm, score, and properties. The |
| 41 // realm may be empty. | 42 // realm may be empty. |
| 42 DCHECK(!ok || score_ != -1); | 43 DCHECK(!ok || score_ != -1); |
| 43 DCHECK(!ok || properties_ != -1); | 44 DCHECK(!ok || properties_ != -1); |
| 44 DCHECK(!ok || auth_scheme_ != HttpAuth::AUTH_SCHEME_MAX); | 45 DCHECK(!ok || auth_scheme_ != HttpAuth::AUTH_SCHEME_MAX); |
| 45 | 46 |
| 46 return ok; | 47 return ok; |
| 47 } | 48 } |
| 48 | 49 |
| 50 // At a minimum, we check for a 'realm' directive in the |
| 51 // authentication challenge. |
| 52 bool HttpAuthHandler::ShouldInvalidateRejectedAuth( |
| 53 HttpAuth::ChallengeTokenizer* challenge) { |
| 54 HttpUtil::NameValuePairsIterator parameters = challenge->param_pairs(); |
| 55 std::string realm; |
| 56 while (parameters.GetNext()) { |
| 57 if (LowerCaseEqualsASCII(parameters.name(), "realm")) { |
| 58 realm = parameters.value(); |
| 59 break; |
| 60 } |
| 61 } |
| 62 return (realm == realm_); |
| 63 } |
| 64 |
| 49 namespace { | 65 namespace { |
| 50 | 66 |
| 51 NetLog::EventType EventTypeFromAuthTarget(HttpAuth::Target target) { | 67 NetLog::EventType EventTypeFromAuthTarget(HttpAuth::Target target) { |
| 52 switch (target) { | 68 switch (target) { |
| 53 case HttpAuth::AUTH_PROXY: | 69 case HttpAuth::AUTH_PROXY: |
| 54 return NetLog::TYPE_AUTH_PROXY; | 70 return NetLog::TYPE_AUTH_PROXY; |
| 55 case HttpAuth::AUTH_SERVER: | 71 case HttpAuth::AUTH_SERVER: |
| 56 return NetLog::TYPE_AUTH_SERVER; | 72 return NetLog::TYPE_AUTH_SERVER; |
| 57 default: | 73 default: |
| 58 NOTREACHED(); | 74 NOTREACHED(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 callback->Run(rv); | 113 callback->Run(rv); |
| 98 } | 114 } |
| 99 | 115 |
| 100 void HttpAuthHandler::FinishGenerateAuthToken() { | 116 void HttpAuthHandler::FinishGenerateAuthToken() { |
| 101 // TOOD(cbentzel): Should this be done in OK case only? | 117 // TOOD(cbentzel): Should this be done in OK case only? |
| 102 net_log_.EndEvent(EventTypeFromAuthTarget(target_), NULL); | 118 net_log_.EndEvent(EventTypeFromAuthTarget(target_), NULL); |
| 103 original_callback_ = NULL; | 119 original_callback_ = NULL; |
| 104 } | 120 } |
| 105 | 121 |
| 106 } // namespace net | 122 } // namespace net |
| OLD | NEW |