| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_LOGIN_AUTH_USER_CONTEXT_H_ | 5 #ifndef CHROMEOS_LOGIN_AUTH_USER_CONTEXT_H_ |
| 6 #define CHROMEOS_LOGIN_AUTH_USER_CONTEXT_H_ | 6 #define CHROMEOS_LOGIN_AUTH_USER_CONTEXT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "chromeos/chromeos_export.h" | 10 #include "chromeos/chromeos_export.h" |
| 11 #include "chromeos/login/auth/key.h" | 11 #include "chromeos/login/auth/key.h" |
| 12 #include "components/signin/core/account_id/account_id.h" | |
| 13 #include "components/user_manager/user_type.h" | 12 #include "components/user_manager/user_type.h" |
| 14 | 13 |
| 15 class AccountId; | |
| 16 | |
| 17 namespace chromeos { | 14 namespace chromeos { |
| 18 | 15 |
| 19 // Information that is passed around while authentication is in progress. The | 16 // Information that is passed around while authentication is in progress. The |
| 20 // credentials may consist of a |account_id_|, |key_| pair or a GAIA | 17 // credentials may consist of a |user_id_|, |key_| pair or a GAIA |auth_code_|. |
| 21 // |auth_code_|. | |
| 22 // The |user_id_hash_| is used to locate the user's home directory | 18 // The |user_id_hash_| is used to locate the user's home directory |
| 23 // mount point for the user. It is set when the mount has been completed. | 19 // mount point for the user. It is set when the mount has been completed. |
| 24 class CHROMEOS_EXPORT UserContext { | 20 class CHROMEOS_EXPORT UserContext { |
| 25 public: | 21 public: |
| 26 // The authentication flow used during sign-in. | 22 // The authentication flow used during sign-in. |
| 27 enum AuthFlow { | 23 enum AuthFlow { |
| 28 // Online authentication against GAIA. GAIA did not redirect to a SAML IdP. | 24 // Online authentication against GAIA. GAIA did not redirect to a SAML IdP. |
| 29 AUTH_FLOW_GAIA_WITHOUT_SAML, | 25 AUTH_FLOW_GAIA_WITHOUT_SAML, |
| 30 // Online authentication against GAIA. GAIA redirected to a SAML IdP. | 26 // Online authentication against GAIA. GAIA redirected to a SAML IdP. |
| 31 AUTH_FLOW_GAIA_WITH_SAML, | 27 AUTH_FLOW_GAIA_WITH_SAML, |
| 32 // Offline authentication against a cached key. | 28 // Offline authentication against a cached key. |
| 33 AUTH_FLOW_OFFLINE, | 29 AUTH_FLOW_OFFLINE, |
| 34 // Offline authentication using and Easy unlock device (e.g. a phone). | 30 // Offline authentication using and Easy unlock device (e.g. a phone). |
| 35 AUTH_FLOW_EASY_UNLOCK, | 31 AUTH_FLOW_EASY_UNLOCK, |
| 36 // Easy bootstrap flow. | 32 // Easy bootstrap flow. |
| 37 AUTH_FLOW_EASY_BOOTSTRAP | 33 AUTH_FLOW_EASY_BOOTSTRAP |
| 38 }; | 34 }; |
| 39 | 35 |
| 40 UserContext(); | 36 UserContext(); |
| 41 UserContext(const UserContext& other); | 37 UserContext(const UserContext& other); |
| 42 explicit UserContext(const AccountId& account_id); | 38 explicit UserContext(const std::string& user_id); |
| 43 UserContext(user_manager::UserType user_type, const std::string& user_id); | 39 UserContext(user_manager::UserType user_type, const std::string& user_id); |
| 44 ~UserContext(); | 40 ~UserContext(); |
| 45 | 41 |
| 46 bool operator==(const UserContext& context) const; | 42 bool operator==(const UserContext& context) const; |
| 47 bool operator!=(const UserContext& context) const; | 43 bool operator!=(const UserContext& context) const; |
| 48 | 44 |
| 49 const AccountId& GetAccountId() const; | 45 const std::string& GetUserID() const; |
| 50 const std::string& GetGaiaID() const; | 46 const std::string& GetGaiaID() const; |
| 51 const Key* GetKey() const; | 47 const Key* GetKey() const; |
| 52 Key* GetKey(); | 48 Key* GetKey(); |
| 53 const std::string& GetAuthCode() const; | 49 const std::string& GetAuthCode() const; |
| 54 const std::string& GetRefreshToken() const; | 50 const std::string& GetRefreshToken() const; |
| 55 const std::string& GetAccessToken() const; | 51 const std::string& GetAccessToken() const; |
| 56 const std::string& GetUserIDHash() const; | 52 const std::string& GetUserIDHash() const; |
| 57 bool IsUsingOAuth() const; | 53 bool IsUsingOAuth() const; |
| 58 AuthFlow GetAuthFlow() const; | 54 AuthFlow GetAuthFlow() const; |
| 59 user_manager::UserType GetUserType() const; | 55 user_manager::UserType GetUserType() const; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 75 void SetAuthFlow(AuthFlow auth_flow); | 71 void SetAuthFlow(AuthFlow auth_flow); |
| 76 void SetUserType(user_manager::UserType user_type); | 72 void SetUserType(user_manager::UserType user_type); |
| 77 void SetPublicSessionLocale(const std::string& locale); | 73 void SetPublicSessionLocale(const std::string& locale); |
| 78 void SetPublicSessionInputMethod(const std::string& input_method); | 74 void SetPublicSessionInputMethod(const std::string& input_method); |
| 79 void SetDeviceId(const std::string& device_id); | 75 void SetDeviceId(const std::string& device_id); |
| 80 void SetGAPSCookie(const std::string& gaps_cookie); | 76 void SetGAPSCookie(const std::string& gaps_cookie); |
| 81 | 77 |
| 82 void ClearSecrets(); | 78 void ClearSecrets(); |
| 83 | 79 |
| 84 private: | 80 private: |
| 85 AccountId account_id_; | 81 std::string user_id_; |
| 86 std::string gaia_id_; | 82 std::string gaia_id_; |
| 87 Key key_; | 83 Key key_; |
| 88 std::string auth_code_; | 84 std::string auth_code_; |
| 89 std::string refresh_token_; | 85 std::string refresh_token_; |
| 90 std::string access_token_; // OAuthLogin scoped access token. | 86 std::string access_token_; // OAuthLogin scoped access token. |
| 91 std::string user_id_hash_; | 87 std::string user_id_hash_; |
| 92 bool is_using_oauth_ = true; | 88 bool is_using_oauth_; |
| 93 AuthFlow auth_flow_ = AUTH_FLOW_OFFLINE; | 89 AuthFlow auth_flow_; |
| 94 user_manager::UserType user_type_ = user_manager::USER_TYPE_REGULAR; | 90 user_manager::UserType user_type_; |
| 95 std::string public_session_locale_; | 91 std::string public_session_locale_; |
| 96 std::string public_session_input_method_; | 92 std::string public_session_input_method_; |
| 97 std::string device_id_; | 93 std::string device_id_; |
| 98 std::string gaps_cookie_; | 94 std::string gaps_cookie_; |
| 99 }; | 95 }; |
| 100 | 96 |
| 101 } // namespace chromeos | 97 } // namespace chromeos |
| 102 | 98 |
| 103 #endif // CHROMEOS_LOGIN_AUTH_USER_CONTEXT_H_ | 99 #endif // CHROMEOS_LOGIN_AUTH_USER_CONTEXT_H_ |
| OLD | NEW |