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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 #include <string> | 10 #include <string> |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // returns - the matched entry or NULL. | 59 // returns - the matched entry or NULL. |
60 Entry* LookupByPath(const GURL& origin, const std::string& path); | 60 Entry* LookupByPath(const GURL& origin, const std::string& path); |
61 | 61 |
62 // Add an entry on server |origin| for realm |handler->realm()| and | 62 // Add an entry on server |origin| for realm |handler->realm()| and |
63 // scheme |handler->scheme()|. If an entry for this (realm,scheme) | 63 // scheme |handler->scheme()|. If an entry for this (realm,scheme) |
64 // already exists, update it rather than replace it -- this preserves the | 64 // already exists, update it rather than replace it -- this preserves the |
65 // paths list. | 65 // paths list. |
66 // |origin| - the {scheme, host, port} of the server. | 66 // |origin| - the {scheme, host, port} of the server. |
67 // |realm| - the auth realm for the challenge. | 67 // |realm| - the auth realm for the challenge. |
68 // |scheme| - the authentication scheme (i.e. basic, negotiate). | 68 // |scheme| - the authentication scheme (i.e. basic, negotiate). |
69 // |username| - login information for the realm. | 69 // |credentials| - login information for the realm. |
70 // |password| - login information for the realm. | |
71 // |path| - absolute path for a resource contained in the protection | 70 // |path| - absolute path for a resource contained in the protection |
72 // space; this will be added to the list of known paths. | 71 // space; this will be added to the list of known paths. |
73 // returns - the entry that was just added/updated. | 72 // returns - the entry that was just added/updated. |
74 Entry* Add(const GURL& origin, | 73 Entry* Add(const GURL& origin, |
75 const std::string& realm, | 74 const std::string& realm, |
76 HttpAuth::Scheme scheme, | 75 HttpAuth::Scheme scheme, |
77 const std::string& auth_challenge, | 76 const std::string& auth_challenge, |
78 const string16& username, | 77 const AuthCredentials& credentials, |
79 const string16& password, | |
80 const std::string& path); | 78 const std::string& path); |
81 | 79 |
82 // Remove entry on server |origin| for realm |realm| and scheme |scheme| | 80 // Remove entry on server |origin| for realm |realm| and scheme |scheme| |
83 // if one exists AND if the cached identity matches (|username|, |password|). | 81 // if one exists AND if the cached credentials matches |credentials|. |
84 // |origin| - the {scheme, host, port} of the server. | 82 // |origin| - the {scheme, host, port} of the server. |
85 // |realm| - case sensitive realm string. | 83 // |realm| - case sensitive realm string. |
86 // |scheme| - the authentication scheme (i.e. basic, negotiate). | 84 // |scheme| - the authentication scheme (i.e. basic, negotiate). |
87 // |username| - condition to match. | 85 // |credentials| - the credentials to match. |
88 // |password| - condition to match. | |
89 // returns - true if an entry was removed. | 86 // returns - true if an entry was removed. |
90 bool Remove(const GURL& origin, | 87 bool Remove(const GURL& origin, |
91 const std::string& realm, | 88 const std::string& realm, |
92 HttpAuth::Scheme scheme, | 89 HttpAuth::Scheme scheme, |
93 const string16& username, | 90 const AuthCredentials& credentials); |
94 const string16& password); | |
95 | 91 |
96 // Updates a stale digest entry on server |origin| for realm |realm| and | 92 // Updates a stale digest entry on server |origin| for realm |realm| and |
97 // scheme |scheme|. The cached auth challenge is replaced with | 93 // scheme |scheme|. The cached auth challenge is replaced with |
98 // |auth_challenge| and the nonce count is reset. | 94 // |auth_challenge| and the nonce count is reset. |
99 // |UpdateStaleChallenge()| returns true if a matching entry exists in the | 95 // |UpdateStaleChallenge()| returns true if a matching entry exists in the |
100 // cache, false otherwise. | 96 // cache, false otherwise. |
101 bool UpdateStaleChallenge(const GURL& origin, | 97 bool UpdateStaleChallenge(const GURL& origin, |
102 const std::string& realm, | 98 const std::string& realm, |
103 HttpAuth::Scheme scheme, | 99 HttpAuth::Scheme scheme, |
104 const std::string& auth_challenge); | 100 const std::string& auth_challenge); |
(...skipping 23 matching lines...) Expand all Loading... |
128 // The authentication scheme of the challenge. | 124 // The authentication scheme of the challenge. |
129 HttpAuth::Scheme scheme() const { | 125 HttpAuth::Scheme scheme() const { |
130 return scheme_; | 126 return scheme_; |
131 } | 127 } |
132 | 128 |
133 // The authentication challenge. | 129 // The authentication challenge. |
134 const std::string auth_challenge() const { | 130 const std::string auth_challenge() const { |
135 return auth_challenge_; | 131 return auth_challenge_; |
136 } | 132 } |
137 | 133 |
138 // The login username. | 134 // The login credentials. |
139 const string16 username() const { | 135 const AuthCredentials& credentials() const { |
140 return username_; | 136 return credentials_; |
141 } | |
142 | |
143 // The login password. | |
144 const string16 password() const { | |
145 return password_; | |
146 } | 137 } |
147 | 138 |
148 int IncrementNonceCount() { | 139 int IncrementNonceCount() { |
149 return ++nonce_count_; | 140 return ++nonce_count_; |
150 } | 141 } |
151 | 142 |
152 void UpdateStaleChallenge(const std::string& auth_challenge); | 143 void UpdateStaleChallenge(const std::string& auth_challenge); |
153 | 144 |
154 private: | 145 private: |
155 friend class HttpAuthCache; | 146 friend class HttpAuthCache; |
(...skipping 18 matching lines...) Expand all Loading... |
174 // true and set |*path_len| to 0. | 165 // true and set |*path_len| to 0. |
175 bool HasEnclosingPath(const std::string& dir, size_t* path_len); | 166 bool HasEnclosingPath(const std::string& dir, size_t* path_len); |
176 | 167 |
177 // |origin_| contains the {protocol, host, port} of the server. | 168 // |origin_| contains the {protocol, host, port} of the server. |
178 GURL origin_; | 169 GURL origin_; |
179 std::string realm_; | 170 std::string realm_; |
180 HttpAuth::Scheme scheme_; | 171 HttpAuth::Scheme scheme_; |
181 | 172 |
182 // Identity. | 173 // Identity. |
183 std::string auth_challenge_; | 174 std::string auth_challenge_; |
184 string16 username_; | 175 AuthCredentials credentials_; |
185 string16 password_; | |
186 | 176 |
187 int nonce_count_; | 177 int nonce_count_; |
188 | 178 |
189 // List of paths that define the realm's protection space. | 179 // List of paths that define the realm's protection space. |
190 PathList paths_; | 180 PathList paths_; |
191 }; | 181 }; |
192 | 182 |
193 } // namespace net | 183 } // namespace net |
194 | 184 |
195 #endif // NET_HTTP_HTTP_AUTH_CACHE_H_ | 185 #endif // NET_HTTP_HTTP_AUTH_CACHE_H_ |
OLD | NEW |