| OLD | NEW |
| 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/policy_builder.h" | 5 #include "components/policy/core/common/cloud/policy_builder.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 10 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 // static | 288 // static |
| 289 std::string PolicyBuilder::GetTestOtherSigningKeySignature() { | 289 std::string PolicyBuilder::GetTestOtherSigningKeySignature() { |
| 290 return std::string(reinterpret_cast<const char*>(kNewSigningKeySignature), | 290 return std::string(reinterpret_cast<const char*>(kNewSigningKeySignature), |
| 291 sizeof(kNewSigningKeySignature)); | 291 sizeof(kNewSigningKeySignature)); |
| 292 } | 292 } |
| 293 | 293 |
| 294 void PolicyBuilder::SignData(const std::string& data, | 294 void PolicyBuilder::SignData(const std::string& data, |
| 295 crypto::RSAPrivateKey* key, | 295 crypto::RSAPrivateKey* key, |
| 296 std::string* signature) { | 296 std::string* signature) { |
| 297 scoped_ptr<crypto::SignatureCreator> signature_creator( | 297 scoped_ptr<crypto::SignatureCreator> signature_creator( |
| 298 crypto::SignatureCreator::Create(key)); | 298 crypto::SignatureCreator::Create(key, |
| 299 crypto::SignatureCreator::SHA1)); |
| 299 signature_creator->Update(reinterpret_cast<const uint8*>(data.c_str()), | 300 signature_creator->Update(reinterpret_cast<const uint8*>(data.c_str()), |
| 300 data.size()); | 301 data.size()); |
| 301 std::vector<uint8> signature_bytes; | 302 std::vector<uint8> signature_bytes; |
| 302 CHECK(signature_creator->Final(&signature_bytes)); | 303 CHECK(signature_creator->Final(&signature_bytes)); |
| 303 signature->assign( | 304 signature->assign( |
| 304 reinterpret_cast<const char*>(vector_as_array(&signature_bytes)), | 305 reinterpret_cast<const char*>(vector_as_array(&signature_bytes)), |
| 305 signature_bytes.size()); | 306 signature_bytes.size()); |
| 306 } | 307 } |
| 307 | 308 |
| 308 template<> | 309 template<> |
| 309 TypedPolicyBuilder<em::CloudPolicySettings>::TypedPolicyBuilder() | 310 TypedPolicyBuilder<em::CloudPolicySettings>::TypedPolicyBuilder() |
| 310 : payload_(new em::CloudPolicySettings()) { | 311 : payload_(new em::CloudPolicySettings()) { |
| 311 policy_data().set_policy_type(dm_protocol::kChromeUserPolicyType); | 312 policy_data().set_policy_type(dm_protocol::kChromeUserPolicyType); |
| 312 } | 313 } |
| 313 | 314 |
| 314 // Have the instantiation compiled into the module. | 315 // Have the instantiation compiled into the module. |
| 315 template class TypedPolicyBuilder<em::CloudPolicySettings>; | 316 template class TypedPolicyBuilder<em::CloudPolicySettings>; |
| 316 | 317 |
| 317 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 318 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
| 318 template<> | 319 template<> |
| 319 TypedPolicyBuilder<em::ExternalPolicyData>::TypedPolicyBuilder() | 320 TypedPolicyBuilder<em::ExternalPolicyData>::TypedPolicyBuilder() |
| 320 : payload_(new em::ExternalPolicyData()) { | 321 : payload_(new em::ExternalPolicyData()) { |
| 321 policy_data().set_policy_type(dm_protocol::kChromeExtensionPolicyType); | 322 policy_data().set_policy_type(dm_protocol::kChromeExtensionPolicyType); |
| 322 } | 323 } |
| 323 | 324 |
| 324 template class TypedPolicyBuilder<em::ExternalPolicyData>; | 325 template class TypedPolicyBuilder<em::ExternalPolicyData>; |
| 325 #endif | 326 #endif |
| 326 | 327 |
| 327 } // namespace policy | 328 } // namespace policy |
| OLD | NEW |