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

Side by Side Diff: components/policy/core/common/cloud/cloud_policy_client.cc

Issue 116273002: Added support for signed policy blobs on desktop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix for ios. Created 6 years, 10 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 "components/policy/core/common/cloud/cloud_policy_client.h" 5 #include "components/policy/core/common/cloud/cloud_policy_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/guid.h" 8 #include "base/guid.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 CloudPolicyClient::Observer::~Observer() {} 43 CloudPolicyClient::Observer::~Observer() {}
44 44
45 void CloudPolicyClient::Observer::OnRobotAuthCodesFetched( 45 void CloudPolicyClient::Observer::OnRobotAuthCodesFetched(
46 CloudPolicyClient* client) {} 46 CloudPolicyClient* client) {}
47 47
48 CloudPolicyClient::StatusProvider::~StatusProvider() {} 48 CloudPolicyClient::StatusProvider::~StatusProvider() {}
49 49
50 CloudPolicyClient::CloudPolicyClient( 50 CloudPolicyClient::CloudPolicyClient(
51 const std::string& machine_id, 51 const std::string& machine_id,
52 const std::string& machine_model, 52 const std::string& machine_model,
53 const std::string& verification_key_hash,
53 UserAffiliation user_affiliation, 54 UserAffiliation user_affiliation,
54 StatusProvider* status_provider, 55 StatusProvider* status_provider,
55 DeviceManagementService* service, 56 DeviceManagementService* service,
56 scoped_refptr<net::URLRequestContextGetter> request_context) 57 scoped_refptr<net::URLRequestContextGetter> request_context)
57 : machine_id_(machine_id), 58 : machine_id_(machine_id),
58 machine_model_(machine_model), 59 machine_model_(machine_model),
60 verification_key_hash_(verification_key_hash),
59 user_affiliation_(user_affiliation), 61 user_affiliation_(user_affiliation),
60 device_mode_(DEVICE_MODE_NOT_SET), 62 device_mode_(DEVICE_MODE_NOT_SET),
61 submit_machine_id_(false), 63 submit_machine_id_(false),
62 public_key_version_(-1), 64 public_key_version_(-1),
63 public_key_version_valid_(false), 65 public_key_version_valid_(false),
64 invalidation_version_(0), 66 invalidation_version_(0),
65 fetched_invalidation_version_(0), 67 fetched_invalidation_version_(0),
66 service_(service), // Can be NULL for unit tests. 68 service_(service), // Can be NULL for unit tests.
67 status_provider_(status_provider), // Can be NULL for unit tests. 69 status_provider_(status_provider), // Can be NULL for unit tests.
68 status_(DM_STATUS_SUCCESS), 70 status_(DM_STATUS_SUCCESS),
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 156
155 // Build policy fetch requests. 157 // Build policy fetch requests.
156 em::DevicePolicyRequest* policy_request = request->mutable_policy_request(); 158 em::DevicePolicyRequest* policy_request = request->mutable_policy_request();
157 for (NamespaceSet::iterator it = namespaces_to_fetch_.begin(); 159 for (NamespaceSet::iterator it = namespaces_to_fetch_.begin();
158 it != namespaces_to_fetch_.end(); ++it) { 160 it != namespaces_to_fetch_.end(); ++it) {
159 em::PolicyFetchRequest* fetch_request = policy_request->add_request(); 161 em::PolicyFetchRequest* fetch_request = policy_request->add_request();
160 fetch_request->set_policy_type(it->first); 162 fetch_request->set_policy_type(it->first);
161 if (!it->second.empty()) 163 if (!it->second.empty())
162 fetch_request->set_settings_entity_id(it->second); 164 fetch_request->set_settings_entity_id(it->second);
163 165
164 #if defined(OS_CHROMEOS) 166 // Request signed policy blobs to help prevent tampering on the client.
165 // All policy types on ChromeOS ask for a signed policy blob.
166 fetch_request->set_signature_type(em::PolicyFetchRequest::SHA1_RSA); 167 fetch_request->set_signature_type(em::PolicyFetchRequest::SHA1_RSA);
167 #else
168 // Don't request signed blobs for desktop policy.
169 fetch_request->set_signature_type(em::PolicyFetchRequest::NONE);
170 #endif
171 if (public_key_version_valid_) 168 if (public_key_version_valid_)
172 fetch_request->set_public_key_version(public_key_version_); 169 fetch_request->set_public_key_version(public_key_version_);
173 170
171 if (!verification_key_hash_.empty())
172 fetch_request->set_verification_key_hash(verification_key_hash_);
173
174 // These fields are included only in requests for chrome policy. 174 // These fields are included only in requests for chrome policy.
175 if (IsChromePolicy(it->first)) { 175 if (IsChromePolicy(it->first)) {
176 if (submit_machine_id_ && !machine_id_.empty()) 176 if (submit_machine_id_ && !machine_id_.empty())
177 fetch_request->set_machine_id(machine_id_); 177 fetch_request->set_machine_id(machine_id_);
178 if (!last_policy_timestamp_.is_null()) { 178 if (!last_policy_timestamp_.is_null()) {
179 base::TimeDelta timestamp( 179 base::TimeDelta timestamp(
180 last_policy_timestamp_ - base::Time::UnixEpoch()); 180 last_policy_timestamp_ - base::Time::UnixEpoch());
181 fetch_request->set_timestamp(timestamp.InMilliseconds()); 181 fetch_request->set_timestamp(timestamp.InMilliseconds());
182 } 182 }
183 if (!invalidation_payload_.empty()) { 183 if (!invalidation_payload_.empty()) {
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 449
450 void CloudPolicyClient::NotifyRobotAuthCodesFetched() { 450 void CloudPolicyClient::NotifyRobotAuthCodesFetched() {
451 FOR_EACH_OBSERVER(Observer, observers_, OnRobotAuthCodesFetched(this)); 451 FOR_EACH_OBSERVER(Observer, observers_, OnRobotAuthCodesFetched(this));
452 } 452 }
453 453
454 void CloudPolicyClient::NotifyClientError() { 454 void CloudPolicyClient::NotifyClientError() {
455 FOR_EACH_OBSERVER(Observer, observers_, OnClientError(this)); 455 FOR_EACH_OBSERVER(Observer, observers_, OnClientError(this));
456 } 456 }
457 457
458 } // namespace policy 458 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698