Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: chromeos/network/certificate_pattern.cc

Issue 370623002: Remove most of NetworkUIData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed yet-another unused function. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chromeos/network/certificate_pattern.h ('k') | chromeos/network/client_cert_resolver.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 #include "chromeos/network/certificate_pattern.h" 5 #include "chromeos/network/certificate_pattern.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "components/onc/onc_constants.h" 9 #include "components/onc/onc_constants.h"
10 10
(...skipping 10 matching lines...) Expand all
21 result->reserve(list->GetSize()); 21 result->reserve(list->GetSize());
22 for (size_t i = 0; i < list->GetSize(); i++) { 22 for (size_t i = 0; i < list->GetSize(); i++) {
23 std::string item; 23 std::string item;
24 if (!list->GetString(i, &item)) 24 if (!list->GetString(i, &item))
25 return false; 25 return false;
26 result->push_back(item); 26 result->push_back(item);
27 } 27 }
28 return true; 28 return true;
29 } 29 }
30 30
31 base::ListValue* CreateListFromStrings(
32 const std::vector<std::string>& strings) {
33 base::ListValue* new_list = new base::ListValue;
34 for (std::vector<std::string>::const_iterator iter = strings.begin();
35 iter != strings.end();
36 ++iter) {
37 new_list->AppendString(*iter);
38 }
39 return new_list;
40 }
41
42 } // namespace 31 } // namespace
43 32
44 //////////////////////////////////////////////////////////////////////////////// 33 ////////////////////////////////////////////////////////////////////////////////
45 // IssuerSubjectPattern 34 // IssuerSubjectPattern
46 IssuerSubjectPattern::IssuerSubjectPattern( 35 IssuerSubjectPattern::IssuerSubjectPattern(
47 const std::string& common_name, 36 const std::string& common_name,
48 const std::string& locality, 37 const std::string& locality,
49 const std::string& organization, 38 const std::string& organization,
50 const std::string& organizational_unit) 39 const std::string& organizational_unit)
51 : common_name_(common_name), 40 : common_name_(common_name),
(...skipping 13 matching lines...) Expand all
65 organizational_unit_.empty(); 54 organizational_unit_.empty();
66 } 55 }
67 56
68 void IssuerSubjectPattern::Clear() { 57 void IssuerSubjectPattern::Clear() {
69 common_name_.clear(); 58 common_name_.clear();
70 locality_.clear(); 59 locality_.clear();
71 organization_.clear(); 60 organization_.clear();
72 organizational_unit_.clear(); 61 organizational_unit_.clear();
73 } 62 }
74 63
75 scoped_ptr<base::DictionaryValue> IssuerSubjectPattern::CreateONCDictionary()
76 const {
77 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
78 if (!common_name_.empty())
79 dict->SetString(onc::client_cert::kCommonName, common_name_);
80 if (!locality_.empty())
81 dict->SetString(onc::client_cert::kLocality, locality_);
82 if (!organization_.empty())
83 dict->SetString(onc::client_cert::kOrganization, organization_);
84 if (!organizational_unit_.empty())
85 dict->SetString(onc::client_cert::kOrganizationalUnit,
86 organizational_unit_);
87 return dict.Pass();
88 }
89
90 void IssuerSubjectPattern::ReadFromONCDictionary( 64 void IssuerSubjectPattern::ReadFromONCDictionary(
91 const base::DictionaryValue& dict) { 65 const base::DictionaryValue& dict) {
92 Clear(); 66 Clear();
93 67
94 dict.GetStringWithoutPathExpansion(onc::client_cert::kCommonName, 68 dict.GetStringWithoutPathExpansion(onc::client_cert::kCommonName,
95 &common_name_); 69 &common_name_);
96 dict.GetStringWithoutPathExpansion(onc::client_cert::kLocality, &locality_); 70 dict.GetStringWithoutPathExpansion(onc::client_cert::kLocality, &locality_);
97 dict.GetStringWithoutPathExpansion(onc::client_cert::kOrganization, 71 dict.GetStringWithoutPathExpansion(onc::client_cert::kOrganization,
98 &organization_); 72 &organization_);
99 dict.GetStringWithoutPathExpansion(onc::client_cert::kOrganizationalUnit, 73 dict.GetStringWithoutPathExpansion(onc::client_cert::kOrganizationalUnit,
(...skipping 13 matching lines...) Expand all
113 return issuer_ca_pems_.empty() && issuer_.Empty() && subject_.Empty(); 87 return issuer_ca_pems_.empty() && issuer_.Empty() && subject_.Empty();
114 } 88 }
115 89
116 void CertificatePattern::Clear() { 90 void CertificatePattern::Clear() {
117 issuer_ca_pems_.clear(); 91 issuer_ca_pems_.clear();
118 issuer_.Clear(); 92 issuer_.Clear();
119 subject_.Clear(); 93 subject_.Clear();
120 enrollment_uri_list_.clear(); 94 enrollment_uri_list_.clear();
121 } 95 }
122 96
123 scoped_ptr<base::DictionaryValue> CertificatePattern::CreateONCDictionary()
124 const {
125 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
126
127 if (!issuer_ca_pems_.empty()) {
128 dict->SetWithoutPathExpansion(onc::client_cert::kIssuerCAPEMs,
129 CreateListFromStrings(issuer_ca_pems_));
130 }
131
132 if (!issuer_.Empty())
133 dict->SetWithoutPathExpansion(onc::client_cert::kIssuer,
134 issuer_.CreateONCDictionary().release());
135
136 if (!subject_.Empty())
137 dict->SetWithoutPathExpansion(onc::client_cert::kSubject,
138 subject_.CreateONCDictionary().release());
139
140 if (!enrollment_uri_list_.empty())
141 dict->SetWithoutPathExpansion(onc::client_cert::kEnrollmentURI,
142 CreateListFromStrings(enrollment_uri_list_));
143 return dict.Pass();
144 }
145
146 bool CertificatePattern::ReadFromONCDictionary( 97 bool CertificatePattern::ReadFromONCDictionary(
147 const base::DictionaryValue& dict) { 98 const base::DictionaryValue& dict) {
148 Clear(); 99 Clear();
149 100
150 const base::DictionaryValue* child_dict = NULL; 101 const base::DictionaryValue* child_dict = NULL;
151 const base::ListValue* child_list = NULL; 102 const base::ListValue* child_list = NULL;
152 103
153 // All of these are optional. 104 // All of these are optional.
154 if (dict.GetListWithoutPathExpansion(onc::client_cert::kIssuerCAPEMs, 105 if (dict.GetListWithoutPathExpansion(onc::client_cert::kIssuerCAPEMs,
155 &child_list) && 106 &child_list) &&
(...skipping 17 matching lines...) Expand all
173 &child_list) && 124 &child_list) &&
174 child_list) { 125 child_list) {
175 if (!GetAsListOfStrings(*child_list, &enrollment_uri_list_)) 126 if (!GetAsListOfStrings(*child_list, &enrollment_uri_list_))
176 return false; 127 return false;
177 } 128 }
178 129
179 return true; 130 return true;
180 } 131 }
181 132
182 } // namespace chromeos 133 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/certificate_pattern.h ('k') | chromeos/network/client_cert_resolver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698