| 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 <list> | 8 #include <list> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 ~HttpAuthCache(); | 39 ~HttpAuthCache(); |
| 40 | 40 |
| 41 // Find the realm entry on server |origin| for realm |realm| and | 41 // Find the realm entry on server |origin| for realm |realm| and |
| 42 // scheme |scheme|. | 42 // scheme |scheme|. |
| 43 // |origin| - the {scheme, host, port} of the server. | 43 // |origin| - the {scheme, host, port} of the server. |
| 44 // |realm| - case sensitive realm string. | 44 // |realm| - case sensitive realm string. |
| 45 // |scheme| - the authentication scheme (i.e. basic, negotiate). | 45 // |scheme| - the authentication scheme (i.e. basic, negotiate). |
| 46 // returns - the matched entry or NULL. | 46 // returns - the matched entry or NULL. |
| 47 Entry* Lookup(const GURL& origin, | 47 Entry* Lookup(const GURL& origin, |
| 48 const std::string& realm, | 48 const std::string& realm, |
| 49 HttpAuth::Scheme scheme); | 49 const std::string& scheme); |
| 50 | 50 |
| 51 // Find the entry on server |origin| whose protection space includes | 51 // Find the entry on server |origin| whose protection space includes |
| 52 // |path|. This uses the assumption in RFC 2617 section 2 that deeper | 52 // |path|. This uses the assumption in RFC 2617 section 2 that deeper |
| 53 // paths lie in the same protection space. | 53 // paths lie in the same protection space. |
| 54 // |origin| - the {scheme, host, port} of the server. | 54 // |origin| - the {scheme, host, port} of the server. |
| 55 // |path| - absolute path of the resource, or empty string in case of | 55 // |path| - absolute path of the resource, or empty string in case of |
| 56 // proxy auth (which does not use the concept of paths). | 56 // proxy auth (which does not use the concept of paths). |
| 57 // returns - the matched entry or NULL. | 57 // returns - the matched entry or NULL. |
| 58 Entry* LookupByPath(const GURL& origin, const std::string& path); | 58 Entry* LookupByPath(const GURL& origin, const std::string& path); |
| 59 | 59 |
| 60 // Add an entry on server |origin| for realm |handler->realm()| and | 60 // Add an entry on server |origin| for realm |handler->realm()| and |
| 61 // scheme |handler->scheme()|. If an entry for this (realm,scheme) | 61 // scheme |handler->scheme()|. If an entry for this (realm,scheme) |
| 62 // already exists, update it rather than replace it -- this preserves the | 62 // already exists, update it rather than replace it -- this preserves the |
| 63 // paths list. | 63 // paths list. |
| 64 // |origin| - the {scheme, host, port} of the server. | 64 // |origin| - the {scheme, host, port} of the server. |
| 65 // |realm| - the auth realm for the challenge. | 65 // |realm| - the auth realm for the challenge. |
| 66 // |scheme| - the authentication scheme (i.e. basic, negotiate). | 66 // |scheme| - the authentication scheme (i.e. basic, negotiate). |
| 67 // |credentials| - login information for the realm. | 67 // |credentials| - login information for the realm. |
| 68 // |path| - absolute path for a resource contained in the protection | 68 // |path| - absolute path for a resource contained in the protection |
| 69 // space; this will be added to the list of known paths. | 69 // space; this will be added to the list of known paths. |
| 70 // returns - the entry that was just added/updated. | 70 // returns - the entry that was just added/updated. |
| 71 Entry* Add(const GURL& origin, | 71 Entry* Add(const GURL& origin, |
| 72 const std::string& realm, | 72 const std::string& realm, |
| 73 HttpAuth::Scheme scheme, | 73 const std::string& scheme, |
| 74 const std::string& auth_challenge, | 74 const std::string& auth_challenge, |
| 75 const AuthCredentials& credentials, | 75 const AuthCredentials& credentials, |
| 76 const std::string& path); | 76 const std::string& path); |
| 77 | 77 |
| 78 // Remove entry on server |origin| for realm |realm| and scheme |scheme| | 78 // Remove entry on server |origin| for realm |realm| and scheme |scheme| |
| 79 // if one exists AND if the cached credentials matches |credentials|. | 79 // if one exists AND if the cached credentials matches |credentials|. |
| 80 // |origin| - the {scheme, host, port} of the server. | 80 // |origin| - the {scheme, host, port} of the server. |
| 81 // |realm| - case sensitive realm string. | 81 // |realm| - case sensitive realm string. |
| 82 // |scheme| - the authentication scheme (i.e. basic, negotiate). | 82 // |scheme| - the authentication scheme (i.e. basic, negotiate). |
| 83 // |credentials| - the credentials to match. | 83 // |credentials| - the credentials to match. |
| 84 // returns - true if an entry was removed. | 84 // returns - true if an entry was removed. |
| 85 bool Remove(const GURL& origin, | 85 bool Remove(const GURL& origin, |
| 86 const std::string& realm, | 86 const std::string& realm, |
| 87 HttpAuth::Scheme scheme, | 87 const std::string& scheme, |
| 88 const AuthCredentials& credentials); | 88 const AuthCredentials& credentials); |
| 89 | 89 |
| 90 // Updates a stale digest entry on server |origin| for realm |realm| and | 90 // Updates a stale digest entry on server |origin| for realm |realm| and |
| 91 // scheme |scheme|. The cached auth challenge is replaced with | 91 // scheme |scheme|. The cached auth challenge is replaced with |
| 92 // |auth_challenge| and the nonce count is reset. | 92 // |auth_challenge| and the nonce count is reset. |
| 93 // |UpdateStaleChallenge()| returns true if a matching entry exists in the | 93 // |UpdateStaleChallenge()| returns true if a matching entry exists in the |
| 94 // cache, false otherwise. | 94 // cache, false otherwise. |
| 95 bool UpdateStaleChallenge(const GURL& origin, | 95 bool UpdateStaleChallenge(const GURL& origin, |
| 96 const std::string& realm, | 96 const std::string& realm, |
| 97 HttpAuth::Scheme scheme, | 97 const std::string& scheme, |
| 98 const std::string& auth_challenge); | 98 const std::string& auth_challenge); |
| 99 | 99 |
| 100 // Copies all entries from |other| cache. | 100 // Copies all entries from |other| cache. |
| 101 void UpdateAllFrom(const HttpAuthCache& other); | 101 void UpdateAllFrom(const HttpAuthCache& other); |
| 102 | 102 |
| 103 private: | 103 private: |
| 104 typedef std::list<Entry> EntryList; | 104 typedef std::list<Entry> EntryList; |
| 105 EntryList entries_; | 105 EntryList entries_; |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 // An authentication realm entry. | 108 // An authentication realm entry. |
| 109 class NET_EXPORT_PRIVATE HttpAuthCache::Entry { | 109 class NET_EXPORT_PRIVATE HttpAuthCache::Entry { |
| 110 public: | 110 public: |
| 111 ~Entry(); | 111 ~Entry(); |
| 112 | 112 |
| 113 const GURL& origin() const { | 113 const GURL& origin() const { |
| 114 return origin_; | 114 return origin_; |
| 115 } | 115 } |
| 116 | 116 |
| 117 // The case-sensitive realm string of the challenge. | 117 // The case-sensitive realm string of the challenge. |
| 118 const std::string realm() const { | 118 const std::string realm() const { |
| 119 return realm_; | 119 return realm_; |
| 120 } | 120 } |
| 121 | 121 |
| 122 // The authentication scheme of the challenge. | 122 // The authentication scheme of the challenge. |
| 123 HttpAuth::Scheme scheme() const { | 123 std::string scheme() const { |
| 124 return scheme_; | 124 return scheme_; |
| 125 } | 125 } |
| 126 | 126 |
| 127 // The authentication challenge. | 127 // The authentication challenge. |
| 128 const std::string auth_challenge() const { | 128 const std::string auth_challenge() const { |
| 129 return auth_challenge_; | 129 return auth_challenge_; |
| 130 } | 130 } |
| 131 | 131 |
| 132 // The login credentials. | 132 // The login credentials. |
| 133 const AuthCredentials& credentials() const { | 133 const AuthCredentials& credentials() const { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 159 // path is found, |*path_len| is left unmodified. | 159 // path is found, |*path_len| is left unmodified. |
| 160 // | 160 // |
| 161 // Note that proxy auth cache entries are associated with empty | 161 // Note that proxy auth cache entries are associated with empty |
| 162 // paths. Therefore it is possible for HasEnclosingPath() to return | 162 // paths. Therefore it is possible for HasEnclosingPath() to return |
| 163 // true and set |*path_len| to 0. | 163 // true and set |*path_len| to 0. |
| 164 bool HasEnclosingPath(const std::string& dir, size_t* path_len); | 164 bool HasEnclosingPath(const std::string& dir, size_t* path_len); |
| 165 | 165 |
| 166 // |origin_| contains the {protocol, host, port} of the server. | 166 // |origin_| contains the {protocol, host, port} of the server. |
| 167 GURL origin_; | 167 GURL origin_; |
| 168 std::string realm_; | 168 std::string realm_; |
| 169 HttpAuth::Scheme scheme_; | 169 std::string scheme_; |
| 170 | 170 |
| 171 // Identity. | 171 // Identity. |
| 172 std::string auth_challenge_; | 172 std::string auth_challenge_; |
| 173 AuthCredentials credentials_; | 173 AuthCredentials credentials_; |
| 174 | 174 |
| 175 int nonce_count_; | 175 int nonce_count_; |
| 176 | 176 |
| 177 // List of paths that define the realm's protection space. | 177 // List of paths that define the realm's protection space. |
| 178 PathList paths_; | 178 PathList paths_; |
| 179 }; | 179 }; |
| 180 | 180 |
| 181 } // namespace net | 181 } // namespace net |
| 182 | 182 |
| 183 #endif // NET_HTTP_HTTP_AUTH_CACHE_H_ | 183 #endif // NET_HTTP_HTTP_AUTH_CACHE_H_ |
| OLD | NEW |