• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 CHROME_BROWSER_CHROMEOS_OPTIONS_WIFI_CONFIG_MODEL_H_
6 #define CHROME_BROWSER_CHROMEOS_OPTIONS_WIFI_CONFIG_MODEL_H_
7 #pragma once
8 
9 #include <string>
10 
11 #include "base/string16.h"
12 #include "net/base/cert_database.h"
13 
14 namespace chromeos {
15 
16 // Data model for Wi-Fi connection configuration dialog.  Mostly concerned
17 // with certificate management for Extensible Authentication Protocol (EAP)
18 // enterprise networks.
19 class WifiConfigModel {
20  public:
21   // Constructs a model with empty lists of certificates.  If you are
22   // configuring a 802.1X network, call UpdateCertificates() to build the
23   // internal cache of certificate names and IDs.
24   WifiConfigModel();
25   ~WifiConfigModel();
26 
27   // Updates the cached certificate lists.
28   void UpdateCertificates();
29 
30   // Returns the number of user certificates.
31   int GetUserCertCount() const;
32 
33   // Returns a user-visible name for a given user certificate.
34   string16 GetUserCertName(int cert_index) const;
35 
36   // Returns the PKCS#11 ID for a given user certificate.
37   std::string GetUserCertPkcs11Id(int cert_index) const;
38 
39   // Returns the cert_index for a given PKCS#11 user certificate ID,
40   // or -1 if no certificate with that ID exists.
41   int GetUserCertIndex(const std::string& pkcs11_id) const;
42 
43   // Returns the number of server CA certificates.
44   int GetServerCaCertCount() const;
45 
46   // Returns a user-visible name for a given server CA certificate.
47   string16 GetServerCaCertName(int cert_index) const;
48 
49   // Returns the NSS nickname for a given server CA certificate.
50   std::string GetServerCaCertNssNickname(int cert_index) const;
51 
52   // Returns the cert_index for a given server CA certificate NSS nickname,
53   // or -1 if no certificate with that ID exists.
54   int GetServerCaCertIndex(const std::string& nss_nickname) const;
55 
56  private:
57   net::CertDatabase cert_db_;
58 
59   // List of user certificates, sorted by name.
60   net::CertificateList user_certs_;
61 
62   // List of server CA certificates, sorted by name.
63   net::CertificateList server_ca_certs_;
64 
65   DISALLOW_COPY_AND_ASSIGN(WifiConfigModel);
66 };
67 
68 }  // namespace chromeos
69 
70 #endif  // CHROME_BROWSER_CHROMEOS_OPTIONS_WIFI_CONFIG_MODEL_H_
71