Fix translation extraction failure.
[chromium-blink-merge.git] / chromeos / network / certificate_pattern.h
blob3c787643ac0138d1c828c0fc9d0bd7df23c4a67a
1 // Copyright (c) 2012 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.
5 #ifndef CHROMEOS_NETWORK_CERTIFICATE_PATTERN_H_
6 #define CHROMEOS_NETWORK_CERTIFICATE_PATTERN_H_
8 #include <string>
9 #include <vector>
11 #include "base/memory/scoped_ptr.h"
12 #include "chromeos/chromeos_export.h"
14 namespace base {
15 class DictionaryValue;
18 namespace chromeos {
20 // Class to represent the DER fields of an issuer or a subject in a
21 // certificate and compare them.
22 class CHROMEOS_EXPORT IssuerSubjectPattern {
23 public:
24 IssuerSubjectPattern();
25 IssuerSubjectPattern(const std::string& common_name,
26 const std::string& locality,
27 const std::string& organization,
28 const std::string& organizational_unit);
29 ~IssuerSubjectPattern();
31 // Returns true if all fields in the pattern are empty.
32 bool Empty() const;
34 // Clears out all values in this pattern.
35 void Clear();
37 const std::string& common_name() const {
38 return common_name_;
40 const std::string& locality() const {
41 return locality_;
43 const std::string& organization() const {
44 return organization_;
46 const std::string& organizational_unit() const {
47 return organizational_unit_;
50 // Replaces the content of this object with the values of |dictionary|.
51 // |dictionary| should be a valid ONC IssuerSubjectPattern dictionary.
52 void ReadFromONCDictionary(const base::DictionaryValue& dictionary);
54 private:
55 std::string common_name_;
56 std::string locality_;
57 std::string organization_;
58 std::string organizational_unit_;
61 // A class to contain a certificate pattern and find existing matches to the
62 // pattern in the certificate database.
63 class CHROMEOS_EXPORT CertificatePattern {
64 public:
65 CertificatePattern();
66 ~CertificatePattern();
68 // Returns true if this pattern has nothing set (and so would match
69 // all certs). Ignores enrollment_uri_;
70 bool Empty() const;
72 const IssuerSubjectPattern& issuer() const {
73 return issuer_;
75 const IssuerSubjectPattern& subject() const {
76 return subject_;
78 const std::vector<std::string>& issuer_ca_pems() const {
79 return issuer_ca_pems_;
81 const std::vector<std::string>& enrollment_uri_list() const {
82 return enrollment_uri_list_;
85 // Replaces the content of this object with the values of |dictionary|.
86 // |dictionary| should be a valid ONC CertificatePattern dictionary. Returns
87 // whether all required fields were present.
88 bool ReadFromONCDictionary(const base::DictionaryValue& dictionary);
90 private:
91 // Clears out all the values in this pattern.
92 void Clear();
94 std::vector<std::string> issuer_ca_pems_;
95 IssuerSubjectPattern issuer_;
96 IssuerSubjectPattern subject_;
97 std::vector<std::string> enrollment_uri_list_;
100 } // namespace chromeos
102 #endif // CHROMEOS_NETWORK_CERTIFICATE_PATTERN_H_