Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Unified Diff: chromeos/dbus/auth_policy_client.cc

Issue 2519823006: Chromad: Add authentication flow (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chromeos/dbus/auth_policy_client.cc
diff --git a/chromeos/dbus/auth_policy_client.cc b/chromeos/dbus/auth_policy_client.cc
index 076dd58f145ac642e1c99f999d705350f8c922fc..f52d25a119da0997f4534392105b33eff3704497 100644
--- a/chromeos/dbus/auth_policy_client.cc
+++ b/chromeos/dbus/auth_policy_client.cc
@@ -22,20 +22,33 @@ class AuthPolicyClientImpl : public AuthPolicyClient {
// AuthPolicyClient override.
void JoinAdDomain(const std::string& machine_name,
- const std::string& user,
+ const std::string& user_principal_name,
int password_fd,
const JoinCallback& callback) override {
dbus::MethodCall method_call(authpolicy::kAuthPolicyInterface,
authpolicy::kAuthPolicyJoinADDomain);
dbus::MessageWriter writer(&method_call);
writer.AppendString(machine_name);
- writer.AppendString(user);
+ writer.AppendString(user_principal_name);
writer.AppendFileDescriptor(password_fd);
proxy_->CallMethod(&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::Bind(&AuthPolicyClientImpl::HandleJoinCallback,
weak_ptr_factory_.GetWeakPtr(), callback));
}
+ void AuthenticateUser(const std::string& user_principal_name,
+ int password_fd,
+ const AuthCallback& callback) override {
+ dbus::MethodCall method_call(authpolicy::kAuthPolicyInterface,
+ authpolicy::kAuthPolicyAuthenticateUser);
+ dbus::MessageWriter writer(&method_call);
+ writer.AppendString(user_principal_name);
+ writer.AppendFileDescriptor(password_fd);
+ proxy_->CallMethod(&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
+ base::Bind(&AuthPolicyClientImpl::HandleAuthCallback,
+ weak_ptr_factory_.GetWeakPtr(), callback));
+ }
+
void RefreshDevicePolicy(const RefreshPolicyCallback& callback) override {
dbus::MethodCall method_call(authpolicy::kAuthPolicyInterface,
authpolicy::kAuthPolicyRefreshDevicePolicy);
@@ -97,6 +110,31 @@ class AuthPolicyClientImpl : public AuthPolicyClient {
callback.Run(res);
}
+ void HandleAuthCallback(const AuthCallback& callback,
+ dbus::Response* response) {
+ std::string user_id;
+ int res = authpolicy::AUTH_USER_ERROR_DBUS_FAILURE;
+ if (!response) {
+ LOG(ERROR) << "Auth: Failed to call to authpolicy";
+ // TODO(rsorokin): make proper call, after defining possible errors codes.
+ callback.Run(authpolicy::AUTH_USER_ERROR_DBUS_FAILURE, user_id);
+ return;
+ }
+ dbus::MessageReader reader(response);
+ if (!reader.PopInt32(&res)) {
+ LOG(ERROR) << "Auth: Failed to get an error from the response";
+ // TODO(rsorokin): make proper call, after defining possible errors codes.
+ callback.Run(res, user_id);
+ return;
+ }
+ if (!reader.PopString(&user_id)) {
+ LOG(ERROR) << "Auth: Failed to get user_id from the response";
+ callback.Run(res, user_id);
+ return;
+ }
+ callback.Run(res, user_id);
+ }
+
dbus::Bus* bus_ = nullptr;
dbus::ObjectProxy* proxy_ = nullptr;

Powered by Google App Engine
This is Rietveld 408576698