Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROMEOS_LOGIN_AUTH_AUTHPOLICY_LOGIN_HELPER_H_ | |
| 6 #define CHROMEOS_LOGIN_AUTH_AUTHPOLICY_LOGIN_HELPER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/callback.h" | |
| 11 #include "base/files/scoped_file.h" | |
| 12 #include "base/macros.h" | |
| 13 #include "base/memory/weak_ptr.h" | |
| 14 #include "chromeos/dbus/auth_policy_client.h" | |
| 15 | |
| 16 namespace chromeos { | |
| 17 | |
| 18 // Helper class to use AuthPolicyClient. For Active Directory domain join and | |
| 19 // authenticate users this class should be used instead of AuthPolicyClient. | |
| 20 // Allows cancel all pending calls and restart AuthPolicy service. Used for | |
|
ljusten (tachyonic)
2017/03/31 15:19:33
Allows canceling
and restarting
Roman Sorokin (ftl)
2017/04/04 10:10:49
Done.
| |
| 21 // enrollment and login UI to proper cancel the flows. | |
| 22 class CHROMEOS_EXPORT AuthPolicyLoginHelper { | |
| 23 public: | |
| 24 using AuthCallback = AuthPolicyClient::AuthCallback; | |
| 25 using JoinCallback = AuthPolicyClient::JoinCallback; | |
| 26 | |
| 27 AuthPolicyLoginHelper(); | |
| 28 ~AuthPolicyLoginHelper(); | |
| 29 // See AuthPolicyClient::JoinAdDomain. | |
| 30 void JoinAdDomain(const std::string& machine_name, | |
| 31 const std::string& username, | |
| 32 const std::string& password, | |
| 33 const JoinCallback& callback); | |
| 34 // See AuthPolicyClient::AuthenticateUser. | |
| 35 void AuthenticateUser(const std::string& username, | |
| 36 const std::string& password, | |
| 37 const AuthCallback& callback); | |
| 38 // Cancel pending requests and restarts AuthPolicy service. | |
| 39 void CancelRequestsAndRestart(); | |
| 40 | |
| 41 private: | |
| 42 // Helper function. Called on password written to |password_fd|. | |
| 43 void DoJoinAdDomain(const std::string& machine_name, | |
| 44 const std::string& username, | |
| 45 const JoinCallback& callback, | |
| 46 base::ScopedFD password_fd); | |
| 47 // Called from AuthPolicyClient::JoinAdDomain. | |
| 48 void OnJoinCallback(const JoinCallback& callback, | |
| 49 authpolicy::ErrorType error); | |
| 50 // Helper function. Called on password written to |password_fd|. | |
| 51 void DoAuthenticateUser(const std::string& username, | |
| 52 const AuthCallback& callback, | |
| 53 base::ScopedFD password_fd); | |
| 54 // Called from AuthPolicyClient::AuthenticateUser. | |
| 55 void OnAuthCallback( | |
| 56 const AuthCallback& callback, | |
| 57 authpolicy::ErrorType error, | |
| 58 const authpolicy::ActiveDirectoryAccountData& account_data); | |
| 59 | |
| 60 base::WeakPtrFactory<AuthPolicyLoginHelper> weak_factory_; | |
| 61 DISALLOW_COPY_AND_ASSIGN(AuthPolicyLoginHelper); | |
| 62 }; | |
| 63 | |
| 64 } // namespace chromeos | |
| 65 | |
| 66 #endif // CHROMEOS_LOGIN_AUTH_AUTHPOLICY_LOGIN_HELPER_H_ | |
| OLD | NEW |