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 #ifndef COMPONENTS_POLICY_CORE_COMMON_CLOUD_CLOUD_POLICY_CLIENT_H_ | 5 #ifndef COMPONENTS_POLICY_CORE_COMMON_CLOUD_CLOUD_POLICY_CLIENT_H_ |
6 #define COMPONENTS_POLICY_CORE_COMMON_CLOUD_CLOUD_POLICY_CLIENT_H_ | 6 #define COMPONENTS_POLICY_CORE_COMMON_CLOUD_CLOUD_POLICY_CLIENT_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <memory> | 11 #include <memory> |
12 #include <set> | 12 #include <set> |
13 #include <string> | 13 #include <string> |
14 #include <utility> | 14 #include <utility> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "base/callback.h" | 17 #include "base/callback.h" |
18 #include "base/macros.h" | 18 #include "base/macros.h" |
19 #include "base/memory/scoped_vector.h" | 19 #include "base/memory/scoped_vector.h" |
20 #include "base/observer_list.h" | 20 #include "base/observer_list.h" |
21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
22 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 22 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
23 #include "components/policy/core/common/remote_commands/remote_command_job.h" | 23 #include "components/policy/core/common/remote_commands/remote_command_job.h" |
24 #include "components/policy/policy_export.h" | 24 #include "components/policy/policy_export.h" |
25 #include "components/policy/proto/device_management_backend.pb.h" | 25 #include "components/policy/proto/device_management_backend.pb.h" |
26 | 26 |
27 namespace cryptohome { | |
28 class AsyncMethodCaller; | |
29 } | |
30 | |
31 namespace net { | 27 namespace net { |
32 class URLRequestContextGetter; | 28 class URLRequestContextGetter; |
33 } | 29 } |
34 | 30 |
35 namespace policy { | 31 namespace policy { |
36 | 32 |
37 class DeviceManagementRequestJob; | 33 class DeviceManagementRequestJob; |
38 class DeviceManagementService; | 34 class DeviceManagementService; |
| 35 class SigningService; |
39 | 36 |
40 // Implements the core logic required to talk to the device management service. | 37 // Implements the core logic required to talk to the device management service. |
41 // Also keeps track of the current state of the association with the service, | 38 // Also keeps track of the current state of the association with the service, |
42 // such as whether there is a valid registration (DMToken is present in that | 39 // such as whether there is a valid registration (DMToken is present in that |
43 // case) and whether and what errors occurred in the latest request. | 40 // case) and whether and what errors occurred in the latest request. |
44 // | 41 // |
45 // Note that CloudPolicyClient doesn't do any validation of policy responses | 42 // Note that CloudPolicyClient doesn't do any validation of policy responses |
46 // such as signature and time stamp checks. These happen once the policy gets | 43 // such as signature and time stamp checks. These happen once the policy gets |
47 // installed in the cloud policy cache. | 44 // installed in the cloud policy cache. |
48 class POLICY_EXPORT CloudPolicyClient { | 45 class POLICY_EXPORT CloudPolicyClient { |
(...skipping 27 matching lines...) Expand all Loading... |
76 | 73 |
77 // Called when a request for device robot OAuth2 authorization tokens | 74 // Called when a request for device robot OAuth2 authorization tokens |
78 // returns successfully. Only occurs during enrollment. Optional | 75 // returns successfully. Only occurs during enrollment. Optional |
79 // (default implementation is a noop). | 76 // (default implementation is a noop). |
80 virtual void OnRobotAuthCodesFetched(CloudPolicyClient* client); | 77 virtual void OnRobotAuthCodesFetched(CloudPolicyClient* client); |
81 | 78 |
82 // Indicates there's been an error in a previously-issued request. | 79 // Indicates there's been an error in a previously-issued request. |
83 virtual void OnClientError(CloudPolicyClient* client) = 0; | 80 virtual void OnClientError(CloudPolicyClient* client) = 0; |
84 }; | 81 }; |
85 | 82 |
86 // Data signing interface. | 83 // |service| and |signing_service| are weak pointers and it's the caller's |
87 class POLICY_EXPORT SigningService { | |
88 public: | |
89 using SigningCallback = base::Callback<void(bool success, | |
90 enterprise_management::SignedData signed_data)>; | |
91 | |
92 // Signs |data| and calls |callback| with the signed data. | |
93 virtual void SignData(const std::string& data, | |
94 const SigningCallback& callback) = 0; | |
95 }; | |
96 | |
97 // |provider| and |service| are weak pointers and it's the caller's | |
98 // responsibility to keep them valid for the lifetime of CloudPolicyClient. | 84 // responsibility to keep them valid for the lifetime of CloudPolicyClient. |
99 // |verification_key_hash| contains an identifier telling the DMServer which | 85 // |verification_key_hash| contains an identifier telling the DMServer which |
100 // verification key to use. The |signing_service| is used to sign sensitive | 86 // verification key to use. The |signing_service| is used to sign sensitive |
101 // requests. | 87 // requests. |
102 CloudPolicyClient( | 88 CloudPolicyClient( |
103 const std::string& machine_id, | 89 const std::string& machine_id, |
104 const std::string& machine_model, | 90 const std::string& machine_model, |
105 const std::string& verification_key_hash, | 91 const std::string& verification_key_hash, |
106 DeviceManagementService* service, | 92 DeviceManagementService* service, |
107 scoped_refptr<net::URLRequestContextGetter> request_context, | 93 scoped_refptr<net::URLRequestContextGetter> request_context, |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 | 417 |
432 // Used to create tasks which run delayed on the UI thread. | 418 // Used to create tasks which run delayed on the UI thread. |
433 base::WeakPtrFactory<CloudPolicyClient> weak_ptr_factory_; | 419 base::WeakPtrFactory<CloudPolicyClient> weak_ptr_factory_; |
434 | 420 |
435 DISALLOW_COPY_AND_ASSIGN(CloudPolicyClient); | 421 DISALLOW_COPY_AND_ASSIGN(CloudPolicyClient); |
436 }; | 422 }; |
437 | 423 |
438 } // namespace policy | 424 } // namespace policy |
439 | 425 |
440 #endif // COMPONENTS_POLICY_CORE_COMMON_CLOUD_CLOUD_POLICY_CLIENT_H_ | 426 #endif // COMPONENTS_POLICY_CORE_COMMON_CLOUD_CLOUD_POLICY_CLIENT_H_ |
OLD | NEW |