| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_POLICY_DEVICE_POLICY_IDENTITY_STRATEGY_H_ | 5 #ifndef CHROME_BROWSER_POLICY_DEVICE_POLICY_IDENTITY_STRATEGY_H_ |
| 6 #define CHROME_BROWSER_POLICY_DEVICE_POLICY_IDENTITY_STRATEGY_H_ | 6 #define CHROME_BROWSER_POLICY_DEVICE_POLICY_IDENTITY_STRATEGY_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "chrome/browser/policy/cloud_policy_identity_strategy.h" | 12 #include "chrome/browser/policy/cloud_policy_identity_strategy.h" |
| 13 | 13 |
| 14 class TokenService; | 14 class TokenService; |
| 15 | 15 |
| 16 namespace policy { | 16 namespace policy { |
| 17 | 17 |
| 18 // DM token provider that stores the token in CrOS signed settings. | 18 // DM token provider that stores the token in CrOS signed settings. |
| 19 class DevicePolicyIdentityStrategy : public CloudPolicyIdentityStrategy { | 19 class DevicePolicyIdentityStrategy : public CloudPolicyIdentityStrategy { |
| 20 public: | 20 public: |
| 21 DevicePolicyIdentityStrategy(); | 21 DevicePolicyIdentityStrategy(); |
| 22 virtual ~DevicePolicyIdentityStrategy(); | 22 virtual ~DevicePolicyIdentityStrategy(); |
| 23 | 23 |
| 24 // Sets (GAIA) auth credentials of the owner of the device during device | 24 // Sets (GAIA) auth credentials of the owner of the device during device |
| 25 // enrollment. This automatically triggers fetching a DMToken that can | 25 // enrollment. This automatically triggers fetching a DMToken that can |
| 26 // be used for future authentication with DMServer. | 26 // be used for future authentication with DMServer. |
| 27 void SetAuthCredentials(const std::string& username, | 27 void SetAuthCredentials(const std::string& username, |
| 28 const std::string& auth_token, | 28 const std::string& auth_token); |
| 29 const std::string& machine_id); | |
| 30 | 29 |
| 31 // Sets the device's credentials when they have been read from disk after | 30 // Sets the device's credentials when they have been read from disk after |
| 32 // a reboot. | 31 // a reboot. |
| 33 void SetDeviceManagementCredentials(const std::string& owner_email, | 32 void SetDeviceManagementCredentials(const std::string& owner_email, |
| 34 const std::string& device_id, | 33 const std::string& device_id, |
| 35 const std::string& device_token); | 34 const std::string& device_token); |
| 36 | 35 |
| 37 // CloudPolicyIdentityStrategy implementation: | 36 // CloudPolicyIdentityStrategy implementation: |
| 38 virtual std::string GetDeviceToken() OVERRIDE; | 37 virtual std::string GetDeviceToken() OVERRIDE; |
| 39 virtual std::string GetDeviceID() OVERRIDE; | 38 virtual std::string GetDeviceID() OVERRIDE; |
| 40 virtual std::string GetMachineID() OVERRIDE; | 39 virtual std::string GetMachineID() OVERRIDE; |
| 40 virtual std::string GetMachineModel() OVERRIDE; |
| 41 virtual em::DeviceRegisterRequest_Type GetPolicyRegisterType() OVERRIDE; | 41 virtual em::DeviceRegisterRequest_Type GetPolicyRegisterType() OVERRIDE; |
| 42 virtual std::string GetPolicyType() OVERRIDE; | 42 virtual std::string GetPolicyType() OVERRIDE; |
| 43 virtual bool GetCredentials(std::string* username, | 43 virtual bool GetCredentials(std::string* username, |
| 44 std::string* auth_token) OVERRIDE; | 44 std::string* auth_token) OVERRIDE; |
| 45 virtual void OnDeviceTokenAvailable(const std::string& token) OVERRIDE; | 45 virtual void OnDeviceTokenAvailable(const std::string& token) OVERRIDE; |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 // The e-mail and auth token of the device owner. Set by |SetCredentials()|. | 48 // The e-mail and auth token of the device owner. Set by |SetCredentials()|. |
| 49 std::string username_; | 49 std::string username_; |
| 50 std::string auth_token_; | 50 std::string auth_token_; |
| 51 | 51 |
| 52 // The machine identifier. | 52 // The machine identifier and model. |
| 53 std::string machine_id_; | 53 std::string machine_id_; |
| 54 std::string machine_model_; |
| 54 | 55 |
| 55 // The device identifier to be sent with requests. (This is actually more like | 56 // The device identifier to be sent with requests. (This is actually more like |
| 56 // a session identifier since it is re-generated for each registration | 57 // a session identifier since it is re-generated for each registration |
| 57 // request.) | 58 // request.) |
| 58 std::string device_id_; | 59 std::string device_id_; |
| 59 | 60 |
| 60 // Current token. Empty if not available. | 61 // Current token. Empty if not available. |
| 61 std::string device_token_; | 62 std::string device_token_; |
| 62 | 63 |
| 63 DISALLOW_COPY_AND_ASSIGN(DevicePolicyIdentityStrategy); | 64 DISALLOW_COPY_AND_ASSIGN(DevicePolicyIdentityStrategy); |
| 64 }; | 65 }; |
| 65 | 66 |
| 66 } // namespace policy | 67 } // namespace policy |
| 67 | 68 |
| 68 #endif // CHROME_BROWSER_POLICY_DEVICE_POLICY_IDENTITY_STRATEGY_H_ | 69 #endif // CHROME_BROWSER_POLICY_DEVICE_POLICY_IDENTITY_STRATEGY_H_ |
| OLD | NEW |