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

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

Issue 1157333005: [net/http auth] Use strings to identify authentication schemes. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « net/http/http_auth.cc ('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 7
8 #include <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 10
(...skipping 20 matching lines...) Expand all
31 public: 31 public:
32 ~Entry(); 32 ~Entry();
33 33
34 const GURL& origin() const { 34 const GURL& origin() const {
35 return origin_; 35 return origin_;
36 } 36 }
37 37
38 // The case-sensitive realm string of the challenge. 38 // The case-sensitive realm string of the challenge.
39 const std::string& realm() const { return realm_; } 39 const std::string& realm() const { return realm_; }
40 40
41 // The authentication scheme of the challenge. 41 // The normalized authentication scheme of the challenge. See
42 HttpAuth::Scheme scheme() const { 42 // HttpAuth::IsValidNormalizedScheme().
43 return scheme_; 43 const std::string& scheme() const { return scheme_; }
44 }
45 44
46 // The authentication challenge. 45 // The authentication challenge.
47 const std::string& auth_challenge() const { return auth_challenge_; } 46 const std::string& auth_challenge() const { return auth_challenge_; }
48 47
49 // The login credentials. 48 // The login credentials.
50 const AuthCredentials& credentials() const { 49 const AuthCredentials& credentials() const {
51 return credentials_; 50 return credentials_;
52 } 51 }
53 52
54 int IncrementNonceCount() { 53 int IncrementNonceCount() {
(...skipping 21 matching lines...) Expand all
76 // path is found, |*path_len| is left unmodified. 75 // path is found, |*path_len| is left unmodified.
77 // 76 //
78 // Note that proxy auth cache entries are associated with empty 77 // Note that proxy auth cache entries are associated with empty
79 // paths. Therefore it is possible for HasEnclosingPath() to return 78 // paths. Therefore it is possible for HasEnclosingPath() to return
80 // true and set |*path_len| to 0. 79 // true and set |*path_len| to 0.
81 bool HasEnclosingPath(const std::string& dir, size_t* path_len); 80 bool HasEnclosingPath(const std::string& dir, size_t* path_len);
82 81
83 // |origin_| contains the {protocol, host, port} of the server. 82 // |origin_| contains the {protocol, host, port} of the server.
84 GURL origin_; 83 GURL origin_;
85 std::string realm_; 84 std::string realm_;
86 HttpAuth::Scheme scheme_; 85 std::string scheme_;
87 86
88 // Identity. 87 // Identity.
89 std::string auth_challenge_; 88 std::string auth_challenge_;
90 AuthCredentials credentials_; 89 AuthCredentials credentials_;
91 90
92 int nonce_count_; 91 int nonce_count_;
93 92
94 // List of paths that define the realm's protection space. 93 // List of paths that define the realm's protection space.
95 PathList paths_; 94 PathList paths_;
96 95
(...skipping 10 matching lines...) Expand all
107 enum { kMaxNumPathsPerRealmEntry = 10 }; 106 enum { kMaxNumPathsPerRealmEntry = 10 };
108 enum { kMaxNumRealmEntries = 10 }; 107 enum { kMaxNumRealmEntries = 10 };
109 108
110 HttpAuthCache(); 109 HttpAuthCache();
111 ~HttpAuthCache(); 110 ~HttpAuthCache();
112 111
113 // Find the realm entry on server |origin| for realm |realm| and 112 // Find the realm entry on server |origin| for realm |realm| and
114 // scheme |scheme|. 113 // scheme |scheme|.
115 // |origin| - the {scheme, host, port} of the server. 114 // |origin| - the {scheme, host, port} of the server.
116 // |realm| - case sensitive realm string. 115 // |realm| - case sensitive realm string.
117 // |scheme| - the authentication scheme (i.e. basic, negotiate). 116 // |scheme| - the normalized authentication scheme (i.e. basic, negotiate).
118 // returns - the matched entry or NULL. 117 // returns - the matched entry or NULL.
119 Entry* Lookup(const GURL& origin, 118 Entry* Lookup(const GURL& origin,
120 const std::string& realm, 119 const std::string& realm,
121 HttpAuth::Scheme scheme); 120 const std::string& scheme);
122 121
123 // Find the entry on server |origin| whose protection space includes 122 // Find the entry on server |origin| whose protection space includes
124 // |path|. This uses the assumption in RFC 2617 section 2 that deeper 123 // |path|. This uses the assumption in RFC 2617 section 2 that deeper
125 // paths lie in the same protection space. 124 // paths lie in the same protection space.
126 // |origin| - the {scheme, host, port} of the server. 125 // |origin| - the {scheme, host, port} of the server.
127 // |path| - absolute path of the resource, or empty string in case of 126 // |path| - absolute path of the resource, or empty string in case of
128 // proxy auth (which does not use the concept of paths). 127 // proxy auth (which does not use the concept of paths).
129 // returns - the matched entry or NULL. 128 // returns - the matched entry or NULL.
130 Entry* LookupByPath(const GURL& origin, const std::string& path); 129 Entry* LookupByPath(const GURL& origin, const std::string& path);
131 130
132 // Add an entry on server |origin| for realm |handler->realm()| and 131 // Add an entry on server |origin| for realm |handler->realm()| and
133 // scheme |handler->scheme()|. If an entry for this (realm,scheme) 132 // scheme |handler->scheme()|. If an entry for this (realm,scheme)
134 // already exists, update it rather than replace it -- this preserves the 133 // already exists, update it rather than replace it -- this preserves the
135 // paths list. 134 // paths list.
136 // |origin| - the {scheme, host, port} of the server. 135 // |origin| - the {scheme, host, port} of the server.
137 // |realm| - the auth realm for the challenge. 136 // |realm| - the auth realm for the challenge.
138 // |scheme| - the authentication scheme (i.e. basic, negotiate). 137 // |scheme| - the normalized authentication scheme (i.e. basic,
138 // negotiate).
139 // |credentials| - login information for the realm. 139 // |credentials| - login information for the realm.
140 // |path| - absolute path for a resource contained in the protection 140 // |path| - absolute path for a resource contained in the protection
141 // space; this will be added to the list of known paths. 141 // space; this will be added to the list of known paths.
142 // returns - the entry that was just added/updated. 142 // returns - the entry that was just added/updated.
143 Entry* Add(const GURL& origin, 143 Entry* Add(const GURL& origin,
144 const std::string& realm, 144 const std::string& realm,
145 HttpAuth::Scheme scheme, 145 const std::string& scheme,
146 const std::string& auth_challenge, 146 const std::string& auth_challenge,
147 const AuthCredentials& credentials, 147 const AuthCredentials& credentials,
148 const std::string& path); 148 const std::string& path);
149 149
150 // Remove entry on server |origin| for realm |realm| and scheme |scheme| 150 // Remove entry on server |origin| for realm |realm| and scheme |scheme|
151 // if one exists AND if the cached credentials matches |credentials|. 151 // if one exists AND if the cached credentials matches |credentials|.
152 // |origin| - the {scheme, host, port} of the server. 152 // |origin| - the {scheme, host, port} of the server.
153 // |realm| - case sensitive realm string. 153 // |realm| - case sensitive realm string.
154 // |scheme| - the authentication scheme (i.e. basic, negotiate). 154 // |scheme| - the normalized authentication scheme (i.e. basic,
155 // negotiate).
155 // |credentials| - the credentials to match. 156 // |credentials| - the credentials to match.
156 // returns - true if an entry was removed. 157 // returns - true if an entry was removed.
157 bool Remove(const GURL& origin, 158 bool Remove(const GURL& origin,
158 const std::string& realm, 159 const std::string& realm,
159 HttpAuth::Scheme scheme, 160 const std::string& scheme,
160 const AuthCredentials& credentials); 161 const AuthCredentials& credentials);
161 162
162 // Clears the cache. 163 // Clears the cache.
163 void Clear(); 164 void Clear();
164 165
165 // Updates a stale digest entry on server |origin| for realm |realm| and 166 // Updates a stale digest entry on server |origin| for realm |realm| and
166 // scheme |scheme|. The cached auth challenge is replaced with 167 // normalized scheme |scheme|. The cached auth challenge is replaced with
167 // |auth_challenge| and the nonce count is reset. 168 // |auth_challenge| and the nonce count is reset.
168 // |UpdateStaleChallenge()| returns true if a matching entry exists in the 169 // |UpdateStaleChallenge()| returns true if a matching entry exists in the
169 // cache, false otherwise. 170 // cache, false otherwise.
170 bool UpdateStaleChallenge(const GURL& origin, 171 bool UpdateStaleChallenge(const GURL& origin,
171 const std::string& realm, 172 const std::string& realm,
172 HttpAuth::Scheme scheme, 173 const std::string& scheme,
173 const std::string& auth_challenge); 174 const std::string& auth_challenge);
174 175
175 // Copies all entries from |other| cache. 176 // Copies all entries from |other| cache.
176 void UpdateAllFrom(const HttpAuthCache& other); 177 void UpdateAllFrom(const HttpAuthCache& other);
177 178
178 private: 179 private:
179 typedef std::list<Entry> EntryList; 180 typedef std::list<Entry> EntryList;
180 EntryList entries_; 181 EntryList entries_;
181 }; 182 };
182 183
183 // An authentication realm entry. 184 // An authentication realm entry.
184 } // namespace net 185 } // namespace net
185 186
186 #endif // NET_HTTP_HTTP_AUTH_CACHE_H_ 187 #endif // NET_HTTP_HTTP_AUTH_CACHE_H_
OLDNEW
« no previous file with comments | « net/http/http_auth.cc ('k') | net/http/http_auth_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698