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 CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_USER_CONTEXT_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_USER_CONTEXT_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_USER_CONTEXT_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_USER_CONTEXT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
| 10 #include "chrome/browser/chromeos/login/auth/key.h" |
| 11 |
10 namespace chromeos { | 12 namespace chromeos { |
11 | 13 |
12 // Information that is passed around while authentication is in progress. The | 14 // Information that is passed around while authentication is in progress. The |
13 // credentials may consist of a |user_id|, |password| pair or a GAIA | 15 // credentials may consist of a |user_id_|, |key_| pair or a GAIA |auth_code_|. |
14 // |auth_code|. The |user_id_hash| is used to locate the user's home directory | 16 // The |user_id_hash_| is used to locate the user's home directory |
15 // mount point for the user. It is set when the mount has been completed. | 17 // mount point for the user. It is set when the mount has been completed. |
16 class UserContext { | 18 class UserContext { |
17 public: | 19 public: |
18 // The authentication flow used during sign-in. | 20 // The authentication flow used during sign-in. |
19 enum AuthFlow { | 21 enum AuthFlow { |
20 // Online authentication against GAIA. GAIA did not redirect to a SAML IdP. | 22 // Online authentication against GAIA. GAIA did not redirect to a SAML IdP. |
21 AUTH_FLOW_GAIA_WITHOUT_SAML, | 23 AUTH_FLOW_GAIA_WITHOUT_SAML, |
22 // Online authentication against GAIA. GAIA redirected to a SAML IdP. | 24 // Online authentication against GAIA. GAIA redirected to a SAML IdP. |
23 AUTH_FLOW_GAIA_WITH_SAML, | 25 AUTH_FLOW_GAIA_WITH_SAML, |
24 // Offline authentication against a cached key. | 26 // Offline authentication against a cached key. |
25 AUTH_FLOW_OFFLINE | 27 AUTH_FLOW_OFFLINE |
26 }; | 28 }; |
27 | 29 |
28 UserContext(); | 30 UserContext(); |
29 UserContext(const UserContext& other); | 31 UserContext(const UserContext& other); |
30 explicit UserContext(const std::string& user_id); | 32 explicit UserContext(const std::string& user_id); |
31 ~UserContext(); | 33 ~UserContext(); |
32 | 34 |
33 bool operator==(const UserContext& context) const; | 35 bool operator==(const UserContext& context) const; |
| 36 bool operator!=(const UserContext& context) const; |
34 | 37 |
35 const std::string& GetUserID() const; | 38 const std::string& GetUserID() const; |
36 const std::string& GetPassword() const; | 39 const Key* GetKey() const; |
37 bool DoesNeedPasswordHashing() const; | 40 Key* GetKey(); |
38 const std::string& GetKeyLabel() const; | |
39 const std::string& GetAuthCode() const; | 41 const std::string& GetAuthCode() const; |
40 const std::string& GetUserIDHash() const; | 42 const std::string& GetUserIDHash() const; |
41 bool IsUsingOAuth() const; | 43 bool IsUsingOAuth() const; |
42 AuthFlow GetAuthFlow() const; | 44 AuthFlow GetAuthFlow() const; |
43 | 45 |
44 bool HasCredentials() const; | 46 bool HasCredentials() const; |
45 | 47 |
46 void SetUserID(const std::string& user_id); | 48 void SetUserID(const std::string& user_id); |
47 void SetPassword(const std::string& password); | 49 void SetKey(const Key& key); |
48 void SetDoesNeedPasswordHashing(bool does_need_password_hashing); | |
49 void SetKeyLabel(const std::string& key_label); | |
50 void SetAuthCode(const std::string& auth_code); | 50 void SetAuthCode(const std::string& auth_code); |
51 void SetUserIDHash(const std::string& user_id_hash); | 51 void SetUserIDHash(const std::string& user_id_hash); |
52 void SetIsUsingOAuth(bool is_using_oauth); | 52 void SetIsUsingOAuth(bool is_using_oauth); |
53 void SetAuthFlow(AuthFlow auth_flow); | 53 void SetAuthFlow(AuthFlow auth_flow); |
54 | 54 |
55 void ClearSecrets(); | 55 void ClearSecrets(); |
56 | 56 |
57 private: | 57 private: |
58 std::string user_id_; | 58 std::string user_id_; |
59 std::string password_; | 59 Key key_; |
60 bool does_need_password_hashing_; | |
61 std::string key_label_; | |
62 std::string auth_code_; | 60 std::string auth_code_; |
63 std::string user_id_hash_; | 61 std::string user_id_hash_; |
64 bool is_using_oauth_; | 62 bool is_using_oauth_; |
65 AuthFlow auth_flow_; | 63 AuthFlow auth_flow_; |
66 }; | 64 }; |
67 | 65 |
68 } // namespace chromeos | 66 } // namespace chromeos |
69 | 67 |
70 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_USER_CONTEXT_H_ | 68 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_USER_CONTEXT_H_ |
OLD | NEW |