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