| 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 "chrome/browser/policy/cloud/policy_builder.h" | 5 #include "chrome/browser/policy/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 "chrome/browser/policy/cloud/cloud_policy_constants.h" | 10 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 88 |
| 89 // Constants used as dummy data for filling the PolicyData protobuf. | 89 // Constants used as dummy data for filling the PolicyData protobuf. |
| 90 const char PolicyBuilder::kFakeDeviceId[] = "device-id"; | 90 const char PolicyBuilder::kFakeDeviceId[] = "device-id"; |
| 91 const char PolicyBuilder::kFakeDomain[] = "example.com"; | 91 const char PolicyBuilder::kFakeDomain[] = "example.com"; |
| 92 const char PolicyBuilder::kFakeMachineName[] = "machine-name"; | 92 const char PolicyBuilder::kFakeMachineName[] = "machine-name"; |
| 93 const char PolicyBuilder::kFakePolicyType[] = "policy type"; | 93 const char PolicyBuilder::kFakePolicyType[] = "policy type"; |
| 94 const int PolicyBuilder::kFakePublicKeyVersion = 17; | 94 const int PolicyBuilder::kFakePublicKeyVersion = 17; |
| 95 const int64 PolicyBuilder::kFakeTimestamp = 365LL * 24 * 60 * 60 * 1000; | 95 const int64 PolicyBuilder::kFakeTimestamp = 365LL * 24 * 60 * 60 * 1000; |
| 96 const char PolicyBuilder::kFakeToken[] = "token"; | 96 const char PolicyBuilder::kFakeToken[] = "token"; |
| 97 const char PolicyBuilder::kFakeUsername[] = "username@example.com"; | 97 const char PolicyBuilder::kFakeUsername[] = "username@example.com"; |
| 98 const char PolicyBuilder::kFakeServiceAccountIdentity[] = "robot4test@g.com"; |
| 98 | 99 |
| 99 PolicyBuilder::PolicyBuilder() | 100 PolicyBuilder::PolicyBuilder() |
| 100 : policy_data_(new em::PolicyData()), | 101 : policy_data_(new em::PolicyData()), |
| 101 signing_key_(CreateTestSigningKey()) { | 102 signing_key_(CreateTestSigningKey()) { |
| 102 policy_data_->set_policy_type(kFakePolicyType); | 103 policy_data_->set_policy_type(kFakePolicyType); |
| 103 policy_data_->set_timestamp(kFakeTimestamp); | 104 policy_data_->set_timestamp(kFakeTimestamp); |
| 104 policy_data_->set_request_token(kFakeToken); | 105 policy_data_->set_request_token(kFakeToken); |
| 105 policy_data_->set_machine_name(kFakeMachineName); | 106 policy_data_->set_machine_name(kFakeMachineName); |
| 106 policy_data_->set_public_key_version(kFakePublicKeyVersion); | 107 policy_data_->set_public_key_version(kFakePublicKeyVersion); |
| 107 policy_data_->set_username(kFakeUsername); | 108 policy_data_->set_username(kFakeUsername); |
| 108 policy_data_->set_device_id(kFakeDeviceId); | 109 policy_data_->set_device_id(kFakeDeviceId); |
| 109 policy_data_->set_state(em::PolicyData::ACTIVE); | 110 policy_data_->set_state(em::PolicyData::ACTIVE); |
| 111 policy_data_->set_service_account_identity(kFakeServiceAccountIdentity); |
| 110 } | 112 } |
| 111 | 113 |
| 112 PolicyBuilder::~PolicyBuilder() {} | 114 PolicyBuilder::~PolicyBuilder() {} |
| 113 | 115 |
| 114 void PolicyBuilder::Build() { | 116 void PolicyBuilder::Build() { |
| 115 if (policy_data_.get()) | 117 if (policy_data_.get()) |
| 116 CHECK(policy_data_->SerializeToString(policy_.mutable_policy_data())); | 118 CHECK(policy_data_->SerializeToString(policy_.mutable_policy_data())); |
| 117 | 119 |
| 118 // Generate signatures if applicable. | 120 // Generate signatures if applicable. |
| 119 crypto::RSAPrivateKey* policy_signing_key = signing_key_.get(); | 121 crypto::RSAPrivateKey* policy_signing_key = signing_key_.get(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 : payload_(new em::ExternalPolicyData()) { | 193 : payload_(new em::ExternalPolicyData()) { |
| 192 policy_data().set_policy_type(dm_protocol::kChromeExtensionPolicyType); | 194 policy_data().set_policy_type(dm_protocol::kChromeExtensionPolicyType); |
| 193 } | 195 } |
| 194 | 196 |
| 195 | 197 |
| 196 // Have the instantiations compiled into the module. | 198 // Have the instantiations compiled into the module. |
| 197 template class TypedPolicyBuilder<em::CloudPolicySettings>; | 199 template class TypedPolicyBuilder<em::CloudPolicySettings>; |
| 198 template class TypedPolicyBuilder<em::ExternalPolicyData>; | 200 template class TypedPolicyBuilder<em::ExternalPolicyData>; |
| 199 | 201 |
| 200 } // namespace policy | 202 } // namespace policy |
| OLD | NEW |