Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(583)

Side by Side Diff: chrome/browser/sync/engine/authenticator.h

Issue 194065: Initial commit of sync engine code to browser/sync.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Fixes to gtest include path, reverted syncapi. Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2006-2009 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 // The authenticator is a cross-platform class that handles authentication for
6 // the sync client.
7 //
8 // Current State:
9 // The authenticator is currently only used to authenticate tokens using the
10 // newer protocol buffer request.
11
12 #ifndef CHROME_BROWSER_SYNC_ENGINE_AUTHENTICATOR_H_
13 #define CHROME_BROWSER_SYNC_ENGINE_AUTHENTICATOR_H_
14
15 #include <string>
16
17 #include "base/basictypes.h"
18 #include "base/port.h"
19
20 namespace sync_pb {
21 class UserIdentification;
22 }
23
24 namespace browser_sync {
25
26 class ServerConnectionManager;
27 class UserSettings;
28
29 class Authenticator {
30 public:
31 // Single return enum.
32 enum AuthenticationResult {
33 SUCCESS = 0,
34 // We couldn't log on because we don't have saved credentials.
35 NO_SAVED_CREDENTIALS,
36 // We can't reach auth server (i.e. we're offline or server's down).
37 NOT_CONNECTED,
38 // Server's up, but we're down.
39 SERVICE_DOWN,
40 // We contacted the server, but the response didn't make sense.
41 CORRUPT_SERVER_RESPONSE,
42 // Bad username/password.
43 BAD_CREDENTIALS,
44 // Credentials are fine, but the user hasn't signed up.
45 USER_NOT_ACTIVATED,
46
47 // Return values for internal use.
48
49 // We will never return this to the user unless they call AuthenticateToken
50 // directly. Other auth functions retry and then return
51 // CORRUPT_SERVER_RESPONSE.
52 // TODO(sync): Implement retries.
53 BAD_AUTH_TOKEN,
54 // We should never return this, it's a placeholder during development.
55 // TODO(sync): Remove this
56 UNSPECIFIC_ERROR_RETURN,
57 };
58
59 // Constructor. This class will keep the connection authenticated.
60 // TODO(sync): Make it work as described.
61 // TODO(sync): Require a UI callback mechanism.
62 Authenticator(ServerConnectionManager* manager, UserSettings* settings);
63
64 // Constructor for a simple authenticator used for programmatic login from
65 // test programs.
66 explicit Authenticator(ServerConnectionManager* manager);
67
68 // This version of Authenticate tries to use saved credentials, if we have
69 // any.
70 AuthenticationResult Authenticate();
71
72 // If save_credentials is set we save the long-lived auth token to local disk.
73 // In all cases we save the username and password in memory (if given) so we
74 // can refresh the long-lived auth token if it expires.
75 // Also we save a 10-bit hash of the password to allow offline login.
76 // TODO(sync): Make it work as described.
77 // TODO(sync): Arguments for desired domain.
78 AuthenticationResult Authenticate(std::string username, std::string password,
79 bool save_credentials);
80 // A version of the auth token to authenticate cookie portion of
81 // authentication. It uses the new proto buffer based call instead of the HTTP
82 // GET based one we currently use.
83 // Can return one of SUCCESS, SERVICE_DOWN, CORRUPT_SERVER_RESPONSE,
84 // USER_NOT_ACTIVATED or BAD_AUTH_TOKEN. See above for the meaning of these
85 // values.
86 // TODO(sync): Make this function private when we're done.
87 AuthenticationResult AuthenticateToken(std::string auth_token);
88
89 const char * display_email() const { return display_email_.c_str(); }
90 const char * display_name() const { return display_name_.c_str(); }
idana 2009/09/10 05:44:37 nit: "const char *" -> "const char*" in above two
91 private:
92 // Stores the information in the UserIdentification returned from the server.
93 AuthenticationResult HandleSuccessfulTokenRequest(
94 const sync_pb::UserIdentification* user);
95 // The server connection manager that we're looking after.
96 ServerConnectionManager* server_connection_manager_;
97 // Returns SUCCESS or the value that should be returned to the user.
98 std::string display_email_;
99 std::string display_name_;
100 std::string obfuscated_id_;
101 UserSettings* const settings_;
102 };
103
104 } // namespace browser_sync
105
106 #endif // CHROME_BROWSER_SYNC_ENGINE_AUTHENTICATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698