Darin Petkov | 3c5e4dc | 2012-04-02 14:44:27 +0200 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS 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 SHILL_NSS_ |
| 6 | #define SHILL_NSS_ |
| 7 | |
| 8 | #include <string> |
| 9 | #include <vector> |
| 10 | |
| 11 | #include <base/file_path.h> |
| 12 | #include <base/lazy_instance.h> |
| 13 | #include <gtest/gtest_prod.h> // for FRIEND_TEST |
| 14 | |
| 15 | namespace shill { |
| 16 | |
| 17 | class GLib; |
| 18 | |
| 19 | class NSS { |
| 20 | public: |
| 21 | virtual ~NSS(); |
| 22 | |
| 23 | // This is a singleton -- use NSS::GetInstance()->Foo() |
| 24 | static NSS *GetInstance(); |
| 25 | |
| 26 | void Init(GLib *glib); |
| 27 | |
| 28 | // Returns an empty path on failure. |
| 29 | virtual FilePath GetPEMCertfile(const std::string &nickname, |
| 30 | const std::vector<char> &id); |
| 31 | |
| 32 | // Returns an empty path on failure. |
| 33 | virtual FilePath GetDERCertfile(const std::string &nickname, |
| 34 | const std::vector<char> &id); |
| 35 | |
| 36 | protected: |
| 37 | NSS(); |
| 38 | |
| 39 | private: |
| 40 | friend struct base::DefaultLazyInstanceTraits<NSS>; |
| 41 | friend class NSSTest; |
| 42 | FRIEND_TEST(NSSTest, GetCertfile); |
| 43 | |
| 44 | FilePath GetCertfile(const std::string &nickname, |
| 45 | const std::vector<char> &id, |
| 46 | const std::string &type); |
| 47 | |
| 48 | GLib *glib_; |
| 49 | |
| 50 | DISALLOW_COPY_AND_ASSIGN(NSS); |
| 51 | }; |
| 52 | |
| 53 | } // namespace shill |
| 54 | |
| 55 | #endif // SHILL_NSS_ |