| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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 CHROMEOS_DBUS_AUTH_POLICY_CLIENT_H_ | 5 #ifndef CHROMEOS_DBUS_AUTH_POLICY_CLIENT_H_ |
| 6 #define CHROMEOS_DBUS_AUTH_POLICY_CLIENT_H_ | 6 #define CHROMEOS_DBUS_AUTH_POLICY_CLIENT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "chromeos/chromeos_export.h" | 11 #include "chromeos/chromeos_export.h" |
| 12 #include "chromeos/dbus/dbus_client.h" | 12 #include "chromeos/dbus/dbus_client.h" |
| 13 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 13 | 14 |
| 14 // TODO(rsorokin): Switch to service constants when it's landed. | 15 // TODO(rsorokin): Switch to service constants when it's landed. |
| 15 // (see crbug.com/659732) | 16 // (see crbug.com/659732) |
| 16 namespace authpolicy { | 17 namespace authpolicy { |
| 17 namespace types { | 18 namespace types { |
| 18 enum ADJoinErrorType { | 19 enum ADJoinErrorType { |
| 19 AD_JOIN_ERROR_NONE = 0, | 20 AD_JOIN_ERROR_NONE = 0, |
| 20 AD_JOIN_ERROR_UNKNOWN = 1, | 21 AD_JOIN_ERROR_UNKNOWN = 1, |
| 21 AD_JOIN_ERROR_DBUS_FAIL = 2, | 22 AD_JOIN_ERROR_DBUS_FAIL = 2, |
| 22 }; | 23 }; |
| 23 } // namespace types | 24 } // namespace types |
| 24 } // namespace authpolicy | 25 } // namespace authpolicy |
| 25 | 26 |
| 26 namespace chromeos { | 27 namespace chromeos { |
| 27 | 28 |
| 28 // AuthPolicyClient is used to communicate with the org.chromium.AuthPolicy | 29 // AuthPolicyClient is used to communicate with the org.chromium.AuthPolicy |
| 29 // sevice. All method should be called from the origin thread (UI thread) which | 30 // sevice. All method should be called from the origin thread (UI thread) which |
| 30 // initializes the DBusThreadManager instance. | 31 // initializes the DBusThreadManager instance. |
| 31 class CHROMEOS_EXPORT AuthPolicyClient : public DBusClient { | 32 class CHROMEOS_EXPORT AuthPolicyClient : public DBusClient { |
| 32 public: | 33 public: |
| 34 // |user_id| is a unique id for the users. Using objectGUID from Active |
| 35 // Directory server. |
| 36 using AuthCallback = base::Callback<void(authpolicy::AuthUserErrorType error, |
| 37 const std::string& user_id)>; |
| 33 using JoinCallback = base::Callback<void(int error_code)>; | 38 using JoinCallback = base::Callback<void(int error_code)>; |
| 34 using RefreshPolicyCallback = base::Callback<void(bool success)>; | 39 using RefreshPolicyCallback = base::Callback<void(bool success)>; |
| 35 | 40 |
| 36 ~AuthPolicyClient() override; | 41 ~AuthPolicyClient() override; |
| 37 | 42 |
| 38 // Factory function, creates a new instance and returns ownership. | 43 // Factory function, creates a new instance and returns ownership. |
| 39 // For normal usage, access the singleton via DBusThreadManager::Get(). | 44 // For normal usage, access the singleton via DBusThreadManager::Get(). |
| 40 static AuthPolicyClient* Create(); | 45 static AuthPolicyClient* Create(); |
| 41 | 46 |
| 42 // Calls JoinADDomain. It runs "net ads join ..." which joins machine to | 47 // Calls JoinADDomain. It runs "net ads join ..." which joins machine to |
| 43 // Active directory domain. | 48 // Active directory domain. |
| 44 // |machine_name| is a name for a local machine. |user|, | 49 // |machine_name| is a name for a local machine. |user_principal_name|, |
| 45 // |password_fd| are credentials of the Active directory account which has | 50 // |password_fd| are credentials of the Active directory account which has |
| 46 // right to join the machine to the domain. |password_fd| is a file descriptor | 51 // right to join the machine to the domain. |password_fd| is a file descriptor |
| 47 // password is read from. The caller should close it after the call. | 52 // password is read from. The caller should close it after the call. |
| 48 // |callback| is called after the method call succeeds. | 53 // |callback| is called after getting (or failing to get) D-BUS response. |
| 49 virtual void JoinAdDomain(const std::string& machine_name, | 54 virtual void JoinAdDomain(const std::string& machine_name, |
| 50 const std::string& user, | 55 const std::string& user_principal_name, |
| 51 int password_fd, | 56 int password_fd, |
| 52 const JoinCallback& callback) = 0; | 57 const JoinCallback& callback) = 0; |
| 53 | 58 |
| 59 // Calls AuthenticateUser. It runs "kinit <user_principal_name> .. " which |
| 60 // does kerberos authentication against Active Directory server. |
| 61 // |password_fd| is similar to the one in the JoinAdDomain. |
| 62 // |callback| is called after getting (or failing to get) D-BUS response. |
| 63 virtual void AuthenticateUser(const std::string& user_principal_name, |
| 64 int password_fd, |
| 65 const AuthCallback& callback) = 0; |
| 66 |
| 54 // Calls RefreshDevicePolicy - handle policy for the device. | 67 // Calls RefreshDevicePolicy - handle policy for the device. |
| 55 // Fetch GPO files from Active directory server, parse it, encode it into | 68 // Fetch GPO files from Active directory server, parse it, encode it into |
| 56 // protobuf and send to SessionManager. Callback is called after that. | 69 // protobuf and send to SessionManager. Callback is called after that. |
| 57 virtual void RefreshDevicePolicy(const RefreshPolicyCallback& callback) = 0; | 70 virtual void RefreshDevicePolicy(const RefreshPolicyCallback& callback) = 0; |
| 58 | 71 |
| 59 // Calls RefreshUserPolicy - handle policy for the user specified by | 72 // Calls RefreshUserPolicy - handle policy for the user specified by |
| 60 // |account_id|. Similar to RefreshDevicePolicy. | 73 // |account_id|. Similar to RefreshDevicePolicy. |
| 61 virtual void RefreshUserPolicy(const std::string& account_id, | 74 virtual void RefreshUserPolicy(const std::string& account_id, |
| 62 const RefreshPolicyCallback& callback) = 0; | 75 const RefreshPolicyCallback& callback) = 0; |
| 63 | 76 |
| 64 protected: | 77 protected: |
| 65 // Create() should be used instead. | 78 // Create() should be used instead. |
| 66 AuthPolicyClient(); | 79 AuthPolicyClient(); |
| 67 | 80 |
| 68 private: | 81 private: |
| 69 DISALLOW_COPY_AND_ASSIGN(AuthPolicyClient); | 82 DISALLOW_COPY_AND_ASSIGN(AuthPolicyClient); |
| 70 }; | 83 }; |
| 71 | 84 |
| 72 } // namespace chromeos | 85 } // namespace chromeos |
| 73 | 86 |
| 74 #endif // CHROMEOS_DBUS_AUTH_POLICY_CLIENT_H_ | 87 #endif // CHROMEOS_DBUS_AUTH_POLICY_CLIENT_H_ |
| OLD | NEW |