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

Side by Side Diff: services/authentication/accounts_db_manager.h

Issue 1466733002: Google OAuth Device Flow support for FNL (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 10 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
OLDNEW
(Empty)
1 // Copyright 2015 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 SERVICES_AUTHENTICATION_ACCOUNTS_DB_MANAGER_H_
6 #define SERVICES_AUTHENTICATION_ACCOUNTS_DB_MANAGER_H_
7
8 #include <type_traits>
9
10 #include "base/macros.h"
11 #include "mojo/services/files/interfaces/files.mojom.h"
12 #include "services/authentication/authentication_impl_db.mojom.h"
13
14 namespace authentication {
15
16 // Implementation of user account management service on systems like FNL. This
17 // uses native mojo files service as the underlying mechanism to store user
18 // credentials and supports operations such as to add a new user account, update
19 // existing user credentials and fetching current credentials for a given user.
20 class AccountsDbManager {
21 public:
22 AccountsDbManager();
23 explicit AccountsDbManager(const mojo::files::DirectoryPtr directory);
qsr 2016/02/16 14:17:06 Can you add some comment about those 2 constructor
ukode 2016/02/26 21:35:50 Got rid of one constructor.
24 ~AccountsDbManager();
25 // Updates or adds new auth credentials for a given user account.
26 void UpdateAccount(const mojo::String& username,
27 const mojo::String& account_data);
28 // Fetches auth credentials for a given user account.
29 mojo::String GetAccountDataForUser(const mojo::String& username);
30 // Fetches auth credentials for all user accounts.
31 mojo::String GetAllUserAccounts();
qsr 2016/02/16 14:17:06 What is the return value?
ukode 2016/02/26 21:35:50 Made this to return an array of usernames instead.
32 // Returns previously used account name for the given application or null if
33 // not found.
34 mojo::String GetAuthorizedUserForApp(mojo::String app_url);
35 // Updates the grants database for the given application and username.
36 void UpdateAuthorization(mojo::String app_url, mojo::String username);
37
38 private:
39 // Generates new contents of the accounts database during an update operation.
40 // Performs one of the two operations:
41 // 1. If the user already exists, updates the existing record in database.
42 // 2. If its a new user, adds a new record to the existing database content.
43 mojo::String GetUpdatedDbContents(const mojo::String& username,
44 const mojo::String& new_account_data,
45 bool user_exists);
46 // Populates contents with existing user credentials.
47 void Initialize();
48 // Reads from credentials file and populates in-memory contents cache.
49 void OnReadResponse(const mojo::files::Error error,
50 const mojo::Array<uint8_t> bytes_read);
51 // Parses response from credentials file write operation
52 void OnWriteResponse(const mojo::files::Error error,
53 const uint32_t num_bytes_written);
54 // Reads from auth file and populates in-memory grants cache.
55 void OnAuthFileReadResponse(const mojo::files::Error error,
56 const mojo::Array<uint8_t> bytes_read);
57 // Parses response from auth file write operation
58 void OnAuthFileWriteResponse(const mojo::files::Error error,
59 const uint32_t num_bytes_written);
60
61 // File pointer to the stored account credentials db file.
62 mojo::files::FilePtr creds_db_file_;
63 // File pointer to the list of authorized modules.
64 mojo::files::FilePtr auth_db_file_;
65 // Stores the cached account data for all users.
qsr 2016/02/16 14:17:06 What is the format of this string?
ukode 2016/02/26 21:35:50 removed this completely. Made it a credentials db
66 std::string contents_;
67 // In-memory store for list of authorized apps.
68 authentication::Db auth_grants;
qsr 2016/02/16 14:17:06 auth_grants_
ukode 2016/02/26 21:35:49 Done.
69
70 DISALLOW_COPY_AND_ASSIGN(AccountsDbManager);
71 };
72
73 } // namespace authentication
74
75 #endif // SERVICES_AUTHENTICATION_ACCOUNTS_DB_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698