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

Side by Side Diff: net/http/http_auth_cache.h

Issue 8340026: Use AuthCredentials throughout the network stack instead of username/password. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix comments Created 9 years, 1 month 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
« no previous file with comments | « net/http/http_auth.h ('k') | net/http/http_auth_cache.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef NET_HTTP_HTTP_AUTH_CACHE_H_ 5 #ifndef NET_HTTP_HTTP_AUTH_CACHE_H_
6 #define NET_HTTP_HTTP_AUTH_CACHE_H_ 6 #define NET_HTTP_HTTP_AUTH_CACHE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <list> 9 #include <list>
10 #include <string> 10 #include <string>
11 11
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/string16.h"
15 #include "googleurl/src/gurl.h" 14 #include "googleurl/src/gurl.h"
16 #include "net/base/net_export.h" 15 #include "net/base/net_export.h"
17 #include "net/http/http_auth.h" 16 #include "net/http/http_auth.h"
18 17
19 namespace net { 18 namespace net {
20 19
21 // HttpAuthCache stores HTTP authentication identities and challenge info. 20 // HttpAuthCache stores HTTP authentication identities and challenge info.
22 // For each (origin, realm, scheme) triple the cache stores a 21 // For each (origin, realm, scheme) triple the cache stores a
23 // HttpAuthCache::Entry, which holds: 22 // HttpAuthCache::Entry, which holds:
24 // - the origin server {protocol scheme, host, port} 23 // - the origin server {protocol scheme, host, port}
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 // returns - the matched entry or NULL. 58 // returns - the matched entry or NULL.
60 Entry* LookupByPath(const GURL& origin, const std::string& path); 59 Entry* LookupByPath(const GURL& origin, const std::string& path);
61 60
62 // Add an entry on server |origin| for realm |handler->realm()| and 61 // Add an entry on server |origin| for realm |handler->realm()| and
63 // scheme |handler->scheme()|. If an entry for this (realm,scheme) 62 // scheme |handler->scheme()|. If an entry for this (realm,scheme)
64 // already exists, update it rather than replace it -- this preserves the 63 // already exists, update it rather than replace it -- this preserves the
65 // paths list. 64 // paths list.
66 // |origin| - the {scheme, host, port} of the server. 65 // |origin| - the {scheme, host, port} of the server.
67 // |realm| - the auth realm for the challenge. 66 // |realm| - the auth realm for the challenge.
68 // |scheme| - the authentication scheme (i.e. basic, negotiate). 67 // |scheme| - the authentication scheme (i.e. basic, negotiate).
69 // |username| - login information for the realm. 68 // |credentials| - login information for the realm.
70 // |password| - login information for the realm.
71 // |path| - absolute path for a resource contained in the protection 69 // |path| - absolute path for a resource contained in the protection
72 // space; this will be added to the list of known paths. 70 // space; this will be added to the list of known paths.
73 // returns - the entry that was just added/updated. 71 // returns - the entry that was just added/updated.
74 Entry* Add(const GURL& origin, 72 Entry* Add(const GURL& origin,
75 const std::string& realm, 73 const std::string& realm,
76 HttpAuth::Scheme scheme, 74 HttpAuth::Scheme scheme,
77 const std::string& auth_challenge, 75 const std::string& auth_challenge,
78 const string16& username, 76 const AuthCredentials& credentials,
79 const string16& password,
80 const std::string& path); 77 const std::string& path);
81 78
82 // Remove entry on server |origin| for realm |realm| and scheme |scheme| 79 // Remove entry on server |origin| for realm |realm| and scheme |scheme|
83 // if one exists AND if the cached identity matches (|username|, |password|). 80 // if one exists AND if the cached credentials matches |credentials|.
84 // |origin| - the {scheme, host, port} of the server. 81 // |origin| - the {scheme, host, port} of the server.
85 // |realm| - case sensitive realm string. 82 // |realm| - case sensitive realm string.
86 // |scheme| - the authentication scheme (i.e. basic, negotiate). 83 // |scheme| - the authentication scheme (i.e. basic, negotiate).
87 // |username| - condition to match. 84 // |credentials| - the credentials to match.
88 // |password| - condition to match.
89 // returns - true if an entry was removed. 85 // returns - true if an entry was removed.
90 bool Remove(const GURL& origin, 86 bool Remove(const GURL& origin,
91 const std::string& realm, 87 const std::string& realm,
92 HttpAuth::Scheme scheme, 88 HttpAuth::Scheme scheme,
93 const string16& username, 89 const AuthCredentials& credentials);
94 const string16& password);
95 90
96 // Updates a stale digest entry on server |origin| for realm |realm| and 91 // Updates a stale digest entry on server |origin| for realm |realm| and
97 // scheme |scheme|. The cached auth challenge is replaced with 92 // scheme |scheme|. The cached auth challenge is replaced with
98 // |auth_challenge| and the nonce count is reset. 93 // |auth_challenge| and the nonce count is reset.
99 // |UpdateStaleChallenge()| returns true if a matching entry exists in the 94 // |UpdateStaleChallenge()| returns true if a matching entry exists in the
100 // cache, false otherwise. 95 // cache, false otherwise.
101 bool UpdateStaleChallenge(const GURL& origin, 96 bool UpdateStaleChallenge(const GURL& origin,
102 const std::string& realm, 97 const std::string& realm,
103 HttpAuth::Scheme scheme, 98 HttpAuth::Scheme scheme,
104 const std::string& auth_challenge); 99 const std::string& auth_challenge);
(...skipping 23 matching lines...) Expand all
128 // The authentication scheme of the challenge. 123 // The authentication scheme of the challenge.
129 HttpAuth::Scheme scheme() const { 124 HttpAuth::Scheme scheme() const {
130 return scheme_; 125 return scheme_;
131 } 126 }
132 127
133 // The authentication challenge. 128 // The authentication challenge.
134 const std::string auth_challenge() const { 129 const std::string auth_challenge() const {
135 return auth_challenge_; 130 return auth_challenge_;
136 } 131 }
137 132
138 // The login username. 133 // The login credentials.
139 const string16 username() const { 134 const AuthCredentials& credentials() const {
140 return username_; 135 return credentials_;
141 }
142
143 // The login password.
144 const string16 password() const {
145 return password_;
146 } 136 }
147 137
148 int IncrementNonceCount() { 138 int IncrementNonceCount() {
149 return ++nonce_count_; 139 return ++nonce_count_;
150 } 140 }
151 141
152 void UpdateStaleChallenge(const std::string& auth_challenge); 142 void UpdateStaleChallenge(const std::string& auth_challenge);
153 143
154 private: 144 private:
155 friend class HttpAuthCache; 145 friend class HttpAuthCache;
(...skipping 18 matching lines...) Expand all
174 // true and set |*path_len| to 0. 164 // true and set |*path_len| to 0.
175 bool HasEnclosingPath(const std::string& dir, size_t* path_len); 165 bool HasEnclosingPath(const std::string& dir, size_t* path_len);
176 166
177 // |origin_| contains the {protocol, host, port} of the server. 167 // |origin_| contains the {protocol, host, port} of the server.
178 GURL origin_; 168 GURL origin_;
179 std::string realm_; 169 std::string realm_;
180 HttpAuth::Scheme scheme_; 170 HttpAuth::Scheme scheme_;
181 171
182 // Identity. 172 // Identity.
183 std::string auth_challenge_; 173 std::string auth_challenge_;
184 string16 username_; 174 AuthCredentials credentials_;
185 string16 password_;
186 175
187 int nonce_count_; 176 int nonce_count_;
188 177
189 // List of paths that define the realm's protection space. 178 // List of paths that define the realm's protection space.
190 PathList paths_; 179 PathList paths_;
191 }; 180 };
192 181
193 } // namespace net 182 } // namespace net
194 183
195 #endif // NET_HTTP_HTTP_AUTH_CACHE_H_ 184 #endif // NET_HTTP_HTTP_AUTH_CACHE_H_
OLDNEW
« no previous file with comments | « net/http/http_auth.h ('k') | net/http/http_auth_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698