shill: vpn: Implement NSS database interface class.
Use the NSS class to lookup NSS certificates for OpenVPN.
BUG=chromium-os:28792
TEST=unit tests
Change-Id: I2e0c7924d664f375f5b01bc73506e2b91e6f8720
Reviewed-on: https://gerrit.chromium.org/gerrit/19457
Tested-by: Darin Petkov <petkov@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Ready: Darin Petkov <petkov@chromium.org>
diff --git a/nss.h b/nss.h
new file mode 100644
index 0000000..4c02321
--- /dev/null
+++ b/nss.h
@@ -0,0 +1,55 @@
+// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SHILL_NSS_
+#define SHILL_NSS_
+
+#include <string>
+#include <vector>
+
+#include <base/file_path.h>
+#include <base/lazy_instance.h>
+#include <gtest/gtest_prod.h> // for FRIEND_TEST
+
+namespace shill {
+
+class GLib;
+
+class NSS {
+ public:
+ virtual ~NSS();
+
+ // This is a singleton -- use NSS::GetInstance()->Foo()
+ static NSS *GetInstance();
+
+ void Init(GLib *glib);
+
+ // Returns an empty path on failure.
+ virtual FilePath GetPEMCertfile(const std::string &nickname,
+ const std::vector<char> &id);
+
+ // Returns an empty path on failure.
+ virtual FilePath GetDERCertfile(const std::string &nickname,
+ const std::vector<char> &id);
+
+ protected:
+ NSS();
+
+ private:
+ friend struct base::DefaultLazyInstanceTraits<NSS>;
+ friend class NSSTest;
+ FRIEND_TEST(NSSTest, GetCertfile);
+
+ FilePath GetCertfile(const std::string &nickname,
+ const std::vector<char> &id,
+ const std::string &type);
+
+ GLib *glib_;
+
+ DISALLOW_COPY_AND_ASSIGN(NSS);
+};
+
+} // namespace shill
+
+#endif // SHILL_NSS_