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

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

Issue 368233004: ONC: Cleanup client certificate related fields. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 void IssuerSubjectPattern::Clear() { 68 void IssuerSubjectPattern::Clear() {
69 common_name_.clear(); 69 common_name_.clear();
70 locality_.clear(); 70 locality_.clear();
71 organization_.clear(); 71 organization_.clear();
72 organizational_unit_.clear(); 72 organizational_unit_.clear();
73 } 73 }
74 74
75 base::DictionaryValue* IssuerSubjectPattern::CreateAsDictionary() const { 75 base::DictionaryValue* IssuerSubjectPattern::CreateAsDictionary() const {
76 base::DictionaryValue* dict = new base::DictionaryValue; 76 base::DictionaryValue* dict = new base::DictionaryValue;
77 if (!common_name_.empty()) 77 if (!common_name_.empty())
78 dict->SetString(onc::certificate::kCommonName, common_name_); 78 dict->SetString(onc::client_cert::kCommonName, common_name_);
79 if (!locality_.empty()) 79 if (!locality_.empty())
80 dict->SetString(onc::certificate::kLocality, locality_); 80 dict->SetString(onc::client_cert::kLocality, locality_);
81 if (!organization_.empty()) 81 if (!organization_.empty())
82 dict->SetString(onc::certificate::kOrganization, organization_); 82 dict->SetString(onc::client_cert::kOrganization, organization_);
83 if (!organizational_unit_.empty()) 83 if (!organizational_unit_.empty())
84 dict->SetString(onc::certificate::kOrganizationalUnit, 84 dict->SetString(onc::client_cert::kOrganizationalUnit,
85 organizational_unit_); 85 organizational_unit_);
86 return dict; 86 return dict;
87 } 87 }
88 88
89 bool IssuerSubjectPattern::ReadFromONCDictionary( 89 bool IssuerSubjectPattern::ReadFromONCDictionary(
90 const base::DictionaryValue& dict) { 90 const base::DictionaryValue& dict) {
91 Clear(); 91 Clear();
92 92
93 dict.GetStringWithoutPathExpansion(onc::certificate::kCommonName, 93 dict.GetStringWithoutPathExpansion(onc::client_cert::kCommonName,
94 &common_name_); 94 &common_name_);
95 dict.GetStringWithoutPathExpansion(onc::certificate::kLocality, &locality_); 95 dict.GetStringWithoutPathExpansion(onc::client_cert::kLocality, &locality_);
96 dict.GetStringWithoutPathExpansion(onc::certificate::kOrganization, 96 dict.GetStringWithoutPathExpansion(onc::client_cert::kOrganization,
97 &organization_); 97 &organization_);
98 dict.GetStringWithoutPathExpansion(onc::certificate::kOrganizationalUnit, 98 dict.GetStringWithoutPathExpansion(onc::client_cert::kOrganizationalUnit,
99 &organizational_unit_); 99 &organizational_unit_);
100 100
101 return true; 101 return true;
102 } 102 }
103 103
104 //////////////////////////////////////////////////////////////////////////////// 104 ////////////////////////////////////////////////////////////////////////////////
105 // CertificatePattern 105 // CertificatePattern
106 106
107 CertificatePattern::CertificatePattern() { 107 CertificatePattern::CertificatePattern() {
108 } 108 }
(...skipping 10 matching lines...) Expand all
119 issuer_.Clear(); 119 issuer_.Clear();
120 subject_.Clear(); 120 subject_.Clear();
121 enrollment_uri_list_.clear(); 121 enrollment_uri_list_.clear();
122 } 122 }
123 123
124 scoped_ptr<base::DictionaryValue> CertificatePattern::CreateONCDictionary() 124 scoped_ptr<base::DictionaryValue> CertificatePattern::CreateONCDictionary()
125 const { 125 const {
126 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); 126 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
127 127
128 if (!issuer_ca_pems_.empty()) { 128 if (!issuer_ca_pems_.empty()) {
129 dict->SetWithoutPathExpansion(onc::certificate::kIssuerCAPEMs, 129 dict->SetWithoutPathExpansion(onc::client_cert::kIssuerCAPEMs,
130 CreateListFromStrings(issuer_ca_pems_)); 130 CreateListFromStrings(issuer_ca_pems_));
131 } 131 }
132 132
133 if (!issuer_.Empty()) 133 if (!issuer_.Empty())
134 dict->SetWithoutPathExpansion(onc::certificate::kIssuer, 134 dict->SetWithoutPathExpansion(onc::client_cert::kIssuer,
135 issuer_.CreateAsDictionary()); 135 issuer_.CreateAsDictionary());
136 136
137 if (!subject_.Empty()) 137 if (!subject_.Empty())
138 dict->SetWithoutPathExpansion(onc::certificate::kSubject, 138 dict->SetWithoutPathExpansion(onc::client_cert::kSubject,
139 subject_.CreateAsDictionary()); 139 subject_.CreateAsDictionary());
140 140
141 if (!enrollment_uri_list_.empty()) 141 if (!enrollment_uri_list_.empty())
142 dict->SetWithoutPathExpansion(onc::certificate::kEnrollmentURI, 142 dict->SetWithoutPathExpansion(onc::client_cert::kEnrollmentURI,
143 CreateListFromStrings(enrollment_uri_list_)); 143 CreateListFromStrings(enrollment_uri_list_));
144 return dict.Pass(); 144 return dict.Pass();
145 } 145 }
146 146
147 bool CertificatePattern::ReadFromONCDictionary( 147 bool CertificatePattern::ReadFromONCDictionary(
148 const base::DictionaryValue& dict) { 148 const base::DictionaryValue& dict) {
149 Clear(); 149 Clear();
150 150
151 const base::DictionaryValue* child_dict = NULL; 151 const base::DictionaryValue* child_dict = NULL;
152 const base::ListValue* child_list = NULL; 152 const base::ListValue* child_list = NULL;
153 153
154 // All of these are optional. 154 // All of these are optional.
155 if (dict.GetListWithoutPathExpansion(onc::certificate::kIssuerCAPEMs, 155 if (dict.GetListWithoutPathExpansion(onc::client_cert::kIssuerCAPEMs,
156 &child_list) && 156 &child_list) &&
157 child_list) { 157 child_list) {
158 if (!GetAsListOfStrings(*child_list, &issuer_ca_pems_)) 158 if (!GetAsListOfStrings(*child_list, &issuer_ca_pems_))
159 return false; 159 return false;
160 } 160 }
161 if (dict.GetDictionaryWithoutPathExpansion(onc::certificate::kIssuer, 161 if (dict.GetDictionaryWithoutPathExpansion(onc::client_cert::kIssuer,
162 &child_dict) && 162 &child_dict) &&
163 child_dict) { 163 child_dict) {
164 if (!issuer_.ReadFromONCDictionary(*child_dict)) 164 if (!issuer_.ReadFromONCDictionary(*child_dict))
165 return false; 165 return false;
166 } 166 }
167 child_dict = NULL; 167 child_dict = NULL;
168 if (dict.GetDictionaryWithoutPathExpansion(onc::certificate::kSubject, 168 if (dict.GetDictionaryWithoutPathExpansion(onc::client_cert::kSubject,
169 &child_dict) && 169 &child_dict) &&
170 child_dict) { 170 child_dict) {
171 if (!subject_.ReadFromONCDictionary(*child_dict)) 171 if (!subject_.ReadFromONCDictionary(*child_dict))
172 return false; 172 return false;
173 } 173 }
174 child_list = NULL; 174 child_list = NULL;
175 if (dict.GetListWithoutPathExpansion(onc::certificate::kEnrollmentURI, 175 if (dict.GetListWithoutPathExpansion(onc::client_cert::kEnrollmentURI,
176 &child_list) && 176 &child_list) &&
177 child_list) { 177 child_list) {
178 if (!GetAsListOfStrings(*child_list, &enrollment_uri_list_)) 178 if (!GetAsListOfStrings(*child_list, &enrollment_uri_list_))
179 return false; 179 return false;
180 } 180 }
181 181
182 return true; 182 return true;
183 } 183 }
184 184
185 } // namespace chromeos 185 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698