OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NET_BASE_TLS_CLIENT_LOGIN_CACHE_H_ |
| 6 #define NET_BASE_TLS_CLIENT_LOGIN_CACHE_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <string> |
| 10 #include <map> |
| 11 |
| 12 #include "base/ref_counted.h" |
| 13 #include "net/base/auth.h" |
| 14 |
| 15 namespace net { |
| 16 |
| 17 // The TLSClientLoginCache class is a simple cache structure to store TLS |
| 18 // client login credentials. Provides lookup, insertion, and deletion of |
| 19 // entries. The parameter for doing lookups, insertions, and deletions is |
| 20 // the server's host and port. |
| 21 // |
| 22 // TODO(wtc): This class is based on FtpAuthCache. We can extract the common |
| 23 // code to a template class. |
| 24 class TLSClientLoginCache { |
| 25 public: |
| 26 TLSClientLoginCache(); |
| 27 ~TLSClientLoginCache(); |
| 28 |
| 29 // Checks for cached login credentials for TLS server at |server|. |
| 30 // Returns true if a preference is found, and sets |*tls_auth_data| |
| 31 // to the desired client login credentials. |
| 32 // If cached login credentials are not found, returns false. |
| 33 bool Lookup(const std::string& server, |
| 34 scoped_refptr<AuthData>* tls_auth_data); |
| 35 |
| 36 // Add client login credentials for |server| to the cache. If there are |
| 37 // already login credentials for |server|, they will be overwritten. |
| 38 void Add(const std::string& server, AuthData* tls_auth_data); |
| 39 |
| 40 // Remove the client certificate for |server| from the cache, if one exists. |
| 41 void Remove(const std::string& server); |
| 42 |
| 43 private: |
| 44 typedef std::string AuthCacheKey; |
| 45 typedef scoped_refptr<AuthData> AuthCacheValue; |
| 46 typedef std::map<AuthCacheKey, AuthCacheValue> AuthCacheMap; |
| 47 |
| 48 // internal representation of cache, an STL map. |
| 49 AuthCacheMap cache_; |
| 50 }; |
| 51 |
| 52 } // namespace net |
| 53 |
| 54 #endif // NET_BASE_TLS_CLIENT_LOGIN_CACHE_H_ |
OLD | NEW |