Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "net/base/net_export.h" | 16 #include "net/base/net_export.h" |
| 17 #include "net/http/http_auth.h" | 17 #include "net/http/http_auth.h" |
| 18 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 19 | 19 |
| 20 namespace net { | 20 namespace net { |
| 21 | 21 |
| 22 // HttpAuthCache stores HTTP authentication identities and challenge info. | 22 // HttpAuthCache stores HTTP authentication identities and challenge info. |
| 23 // For each (origin, realm, scheme) triple the cache stores a | 23 // For each (origin, realm, scheme) triple the cache stores a |
| 24 // HttpAuthCache::Entry, which holds: | 24 // HttpAuthCache::Entry, which holds: |
| 25 // - the origin server {protocol scheme, host, port} | 25 // - the origin server {protocol scheme, host, port} |
| 26 // - the last identity used (username/password) | 26 // - the last identity used (username/password) |
| 27 // - the last auth handler used (contains realm and authentication scheme) | 27 // - the last auth handler used (contains realm and authentication scheme) |
| 28 // - the list of paths which used this realm | 28 // - the list of paths which used this realm |
| 29 // Entries can be looked up by either (origin, realm, scheme) or (origin, path). | 29 // Entries can be looked up by either (origin, realm, scheme) or (origin, path). |
| 30 class NET_EXPORT_PRIVATE HttpAuthCache { | 30 class NET_EXPORT_PRIVATE HttpAuthCache { |
|
mmenke
2016/07/29 14:08:48
This should presumably be NET_EXPORT, if we're usi
| |
| 31 public: | 31 public: |
| 32 class NET_EXPORT_PRIVATE Entry { | 32 class NET_EXPORT_PRIVATE Entry { |
| 33 public: | 33 public: |
| 34 Entry(const Entry& other); | 34 Entry(const Entry& other); |
| 35 ~Entry(); | 35 ~Entry(); |
| 36 | 36 |
| 37 const GURL& origin() const { | 37 const GURL& origin() const { |
| 38 return origin_; | 38 return origin_; |
| 39 } | 39 } |
| 40 | 40 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 // |origin| - the {scheme, host, port} of the server. | 155 // |origin| - the {scheme, host, port} of the server. |
| 156 // |realm| - case sensitive realm string. | 156 // |realm| - case sensitive realm string. |
| 157 // |scheme| - the authentication scheme (i.e. basic, negotiate). | 157 // |scheme| - the authentication scheme (i.e. basic, negotiate). |
| 158 // |credentials| - the credentials to match. | 158 // |credentials| - the credentials to match. |
| 159 // returns - true if an entry was removed. | 159 // returns - true if an entry was removed. |
| 160 bool Remove(const GURL& origin, | 160 bool Remove(const GURL& origin, |
| 161 const std::string& realm, | 161 const std::string& realm, |
| 162 HttpAuth::Scheme scheme, | 162 HttpAuth::Scheme scheme, |
| 163 const AuthCredentials& credentials); | 163 const AuthCredentials& credentials); |
| 164 | 164 |
| 165 // Clears the cache. | 165 // Clears cache entries created within |duration| of base::TimeTicks::Now(). |
| 166 void Clear(); | 166 void Clear(base::TimeDelta duration); |
|
mmenke
2016/07/29 14:08:48
This method name is unclear. Maybe make it take a
| |
| 167 | 167 |
| 168 // Updates a stale digest entry on server |origin| for realm |realm| and | 168 // Updates a stale digest entry on server |origin| for realm |realm| and |
| 169 // scheme |scheme|. The cached auth challenge is replaced with | 169 // scheme |scheme|. The cached auth challenge is replaced with |
| 170 // |auth_challenge| and the nonce count is reset. | 170 // |auth_challenge| and the nonce count is reset. |
| 171 // |UpdateStaleChallenge()| returns true if a matching entry exists in the | 171 // |UpdateStaleChallenge()| returns true if a matching entry exists in the |
| 172 // cache, false otherwise. | 172 // cache, false otherwise. |
| 173 bool UpdateStaleChallenge(const GURL& origin, | 173 bool UpdateStaleChallenge(const GURL& origin, |
| 174 const std::string& realm, | 174 const std::string& realm, |
| 175 HttpAuth::Scheme scheme, | 175 HttpAuth::Scheme scheme, |
| 176 const std::string& auth_challenge); | 176 const std::string& auth_challenge); |
| 177 | 177 |
| 178 // Copies all entries from |other| cache. | 178 // Copies all entries from |other| cache. |
| 179 void UpdateAllFrom(const HttpAuthCache& other); | 179 void UpdateAllFrom(const HttpAuthCache& other); |
| 180 | 180 |
| 181 private: | 181 private: |
| 182 typedef std::list<Entry> EntryList; | 182 typedef std::list<Entry> EntryList; |
| 183 EntryList entries_; | 183 EntryList entries_; |
| 184 }; | 184 }; |
| 185 | 185 |
| 186 // An authentication realm entry. | 186 // An authentication realm entry. |
| 187 } // namespace net | 187 } // namespace net |
| 188 | 188 |
| 189 #endif // NET_HTTP_HTTP_AUTH_CACHE_H_ | 189 #endif // NET_HTTP_HTTP_AUTH_CACHE_H_ |
| OLD | NEW |