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_BASE_SSL_CLIENT_AUTH_CACHE_H_ | 5 #ifndef NET_BASE_SSL_CLIENT_AUTH_CACHE_H_ |
6 #define NET_BASE_SSL_CLIENT_AUTH_CACHE_H_ | 6 #define NET_BASE_SSL_CLIENT_AUTH_CACHE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <map> | 10 #include <map> |
11 | 11 |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "net/base/cert_database.h" | 13 #include "net/base/cert_database.h" |
14 #include "net/base/net_api.h" | 14 #include "net/base/net_api.h" |
15 | 15 |
16 namespace net { | 16 namespace net { |
17 | 17 |
18 class X509Certificate; | 18 class X509Certificate; |
19 | 19 |
20 // The SSLClientAuthCache class is a simple cache structure to store SSL | 20 // The SSLClientAuthCache class is a simple cache structure to store SSL |
21 // client certificates. Provides lookup, insertion, and deletion of entries. | 21 // client certificates. Provides lookup, insertion, and deletion of entries. |
22 // The parameter for doing lookups, insertions, and deletions is the server's | 22 // The parameter for doing lookups, insertions, and deletions is the server's |
23 // host and port. | 23 // host and port. |
24 // | 24 // |
25 // TODO(wtc): This class is based on FtpAuthCache. We can extract the common | 25 // TODO(wtc): This class is based on FtpAuthCache. We can extract the common |
26 // code to a template class. | 26 // code to a template class. |
27 class NET_TEST SSLClientAuthCache : public CertDatabase::Observer { | 27 class NET_TEST SSLClientAuthCache : public CertDatabase::Observer { |
28 public: | 28 public: |
29 SSLClientAuthCache(); | 29 SSLClientAuthCache(); |
30 ~SSLClientAuthCache(); | 30 virtual ~SSLClientAuthCache(); |
31 | 31 |
32 // Checks for a client certificate preference for SSL server at |server|. | 32 // Checks for a client certificate preference for SSL server at |server|. |
33 // Returns true if a preference is found, and sets |*certificate| to the | 33 // Returns true if a preference is found, and sets |*certificate| to the |
34 // desired client certificate. The desired certificate may be NULL, which | 34 // desired client certificate. The desired certificate may be NULL, which |
35 // indicates a preference to not send any certificate to |server|. | 35 // indicates a preference to not send any certificate to |server|. |
36 // If a certificate preference is not found, returns false. | 36 // If a certificate preference is not found, returns false. |
37 bool Lookup(const std::string& server, | 37 bool Lookup(const std::string& server, |
38 scoped_refptr<X509Certificate>* certificate); | 38 scoped_refptr<X509Certificate>* certificate); |
39 | 39 |
40 // Add a client certificate for |server| to the cache. If there is already | 40 // Add a client certificate for |server| to the cache. If there is already |
(...skipping 13 matching lines...) Expand all Loading... |
54 typedef scoped_refptr<X509Certificate> AuthCacheValue; | 54 typedef scoped_refptr<X509Certificate> AuthCacheValue; |
55 typedef std::map<AuthCacheKey, AuthCacheValue> AuthCacheMap; | 55 typedef std::map<AuthCacheKey, AuthCacheValue> AuthCacheMap; |
56 | 56 |
57 // internal representation of cache, an STL map. | 57 // internal representation of cache, an STL map. |
58 AuthCacheMap cache_; | 58 AuthCacheMap cache_; |
59 }; | 59 }; |
60 | 60 |
61 } // namespace net | 61 } // namespace net |
62 | 62 |
63 #endif // NET_BASE_SSL_CLIENT_AUTH_CACHE_H_ | 63 #endif // NET_BASE_SSL_CLIENT_AUTH_CACHE_H_ |
OLD | NEW |