Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / chromeos / login / auth / user_context.h
blob5ba5b4567600a3e6945f14a3dbf07e106ec24f80
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.
5 #ifndef CHROMEOS_LOGIN_AUTH_USER_CONTEXT_H_
6 #define CHROMEOS_LOGIN_AUTH_USER_CONTEXT_H_
8 #include <string>
10 #include "chromeos/chromeos_export.h"
11 #include "chromeos/login/auth/key.h"
12 #include "components/user_manager/user_type.h"
14 namespace chromeos {
16 // Information that is passed around while authentication is in progress. The
17 // credentials may consist of a |user_id_|, |key_| pair or a GAIA |auth_code_|.
18 // The |user_id_hash_| is used to locate the user's home directory
19 // mount point for the user. It is set when the mount has been completed.
20 class CHROMEOS_EXPORT UserContext {
21 public:
22 // The authentication flow used during sign-in.
23 enum AuthFlow {
24 // Online authentication against GAIA. GAIA did not redirect to a SAML IdP.
25 AUTH_FLOW_GAIA_WITHOUT_SAML,
26 // Online authentication against GAIA. GAIA redirected to a SAML IdP.
27 AUTH_FLOW_GAIA_WITH_SAML,
28 // Offline authentication against a cached key.
29 AUTH_FLOW_OFFLINE
32 UserContext();
33 UserContext(const UserContext& other);
34 explicit UserContext(const std::string& user_id);
35 UserContext(user_manager::UserType user_type, const std::string& user_id);
36 ~UserContext();
38 bool operator==(const UserContext& context) const;
39 bool operator!=(const UserContext& context) const;
41 const std::string& GetUserID() const;
42 const Key* GetKey() const;
43 Key* GetKey();
44 const std::string& GetAuthCode() const;
45 const std::string& GetUserIDHash() const;
46 bool IsUsingOAuth() const;
47 AuthFlow GetAuthFlow() const;
48 user_manager::UserType GetUserType() const;
49 const std::string& GetPublicSessionLocale() const;
50 const std::string& GetPublicSessionInputMethod() const;
52 bool HasCredentials() const;
54 void SetUserID(const std::string& user_id);
55 void SetKey(const Key& key);
56 void SetAuthCode(const std::string& auth_code);
57 void SetUserIDHash(const std::string& user_id_hash);
58 void SetIsUsingOAuth(bool is_using_oauth);
59 void SetAuthFlow(AuthFlow auth_flow);
60 void SetUserType(user_manager::UserType user_type);
61 void SetPublicSessionLocale(const std::string& locale);
62 void SetPublicSessionInputMethod(const std::string& input_method);
64 void ClearSecrets();
66 private:
67 std::string user_id_;
68 Key key_;
69 std::string auth_code_;
70 std::string user_id_hash_;
71 bool is_using_oauth_;
72 AuthFlow auth_flow_;
73 user_manager::UserType user_type_;
74 std::string public_session_locale_;
75 std::string public_session_input_method_;
78 } // namespace chromeos
80 #endif // CHROMEOS_LOGIN_AUTH_USER_CONTEXT_H_