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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_USER_CONTEXT_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_USER_CONTEXT_H_ 7 8 #include <string> 9 10 #include "chrome/browser/chromeos/login/auth/key.h" 11 12 namespace chromeos { 13 14 // 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 // 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 class UserContext { 19 public: 20 // The authentication flow used during sign-in. 21 enum AuthFlow { 22 // Online authentication against GAIA. GAIA did not redirect to a SAML IdP. 23 AUTH_FLOW_GAIA_WITHOUT_SAML, 24 // Online authentication against GAIA. GAIA redirected to a SAML IdP. 25 AUTH_FLOW_GAIA_WITH_SAML, 26 // Offline authentication against a cached key. 27 AUTH_FLOW_OFFLINE 28 }; 29 30 UserContext(); 31 UserContext(const UserContext& other); 32 explicit UserContext(const std::string& user_id); 33 ~UserContext(); 34 35 bool operator==(const UserContext& context) const; 36 bool operator!=(const UserContext& context) const; 37 38 const std::string& GetUserID() const; 39 const Key* GetKey() const; 40 Key* GetKey(); 41 const std::string& GetAuthCode() const; 42 const std::string& GetUserIDHash() const; 43 bool IsUsingOAuth() const; 44 AuthFlow GetAuthFlow() const; 45 46 bool HasCredentials() const; 47 48 void SetUserID(const std::string& user_id); 49 void SetKey(const Key& key); 50 void SetAuthCode(const std::string& auth_code); 51 void SetUserIDHash(const std::string& user_id_hash); 52 void SetIsUsingOAuth(bool is_using_oauth); 53 void SetAuthFlow(AuthFlow auth_flow); 54 55 void ClearSecrets(); 56 57 private: 58 std::string user_id_; 59 Key key_; 60 std::string auth_code_; 61 std::string user_id_hash_; 62 bool is_using_oauth_; 63 AuthFlow auth_flow_; 64 }; 65 66 } // namespace chromeos 67 68 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_AUTH_USER_CONTEXT_H_ 69