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

Unified Diff: chrome/browser/chromeos/login/supervised_user_manager_impl.cc

Issue 101283003: Add first implemenation for SU password sync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with ToT Created 7 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/supervised_user_manager_impl.cc
diff --git a/chrome/browser/chromeos/login/supervised_user_manager_impl.cc b/chrome/browser/chromeos/login/supervised_user_manager_impl.cc
index 4d35f0673622d572138949ef9a489ab42dea1a4f..e656ebfa43ec1210805be96e4941866b55a6044b 100644
--- a/chrome/browser/chromeos/login/supervised_user_manager_impl.cc
+++ b/chrome/browser/chromeos/login/supervised_user_manager_impl.cc
@@ -12,6 +12,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chromeos/login/managed/supervised_user_authentication.h"
#include "chrome/browser/chromeos/login/user_manager_impl.h"
#include "chromeos/settings/cros_settings_names.h"
#include "content/public/browser/browser_thread.h"
@@ -53,10 +54,27 @@ const char kLocallyManagedUserCreationTransactionDisplayName[] =
const char kLocallyManagedUserCreationTransactionUserId[] =
"LocallyManagedUserCreationTransactionUserId";
+// A map from user id to password schema version,
Nikita (slow) 2013/12/09 16:42:16 nit: revision, dot at the end.
Denis Kuznetsov (DE-MUC) 2013/12/12 19:45:24 Done.
+const char kSupervisedUserPasswordSchemaVersion[] =
+ "SupervisedUserPasswordSchemaVersion";
+
+// A map from user id to password version.
+const char kSupervisedUserPasswordSalt[] =
+ "SupervisedUserPasswordSalt";
+
+// A map from user id to password salt.
+const char kSupervisedUserPasswordVersion[] =
+ "SupervisedUserPasswordVersion";
+
} // namespace
namespace chromeos {
+const char kSchemaVersion[] = "SchemaVersion";
Nikita (slow) 2013/12/09 16:42:16 nit: One small comment about these would be helpfu
Denis Kuznetsov (DE-MUC) 2013/12/12 19:45:24 Done.
+const char kPasswordVersion[] = "PasswordVersion";
+const char kSalt[] = "PasswordSalt";
+const char kEncryptedPassword[] = "EncryptedPassword";
+
// static
void SupervisedUserManager::RegisterPrefs(PrefRegistrySimple* registry) {
registry->RegisterListPref(kLocallyManagedUsersFirstRun);
@@ -69,6 +87,10 @@ void SupervisedUserManager::RegisterPrefs(PrefRegistrySimple* registry) {
registry->RegisterDictionaryPref(kManagedUserManagers);
registry->RegisterDictionaryPref(kManagedUserManagerNames);
registry->RegisterDictionaryPref(kManagedUserManagerDisplayEmails);
+
+ registry->RegisterDictionaryPref(kSupervisedUserPasswordSchemaVersion);
+ registry->RegisterDictionaryPref(kSupervisedUserPasswordSalt);
+ registry->RegisterDictionaryPref(kSupervisedUserPasswordVersion);
}
SupervisedUserManagerImpl::SupervisedUserManagerImpl(UserManagerImpl* owner)
@@ -76,6 +98,7 @@ SupervisedUserManagerImpl::SupervisedUserManagerImpl(UserManagerImpl* owner)
cros_settings_(CrosSettings::Get()) {
// SupervisedUserManager instance should be used only on UI thread.
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ authentication_.reset(new SupervisedUserAuthentication(this));
}
SupervisedUserManagerImpl::~SupervisedUserManagerImpl() {
@@ -150,11 +173,8 @@ const User* SupervisedUserManagerImpl::CreateUserRecord(
std::string SupervisedUserManagerImpl::GetUserSyncId(const std::string& user_id)
const {
- PrefService* local_state = g_browser_process->local_state();
- const DictionaryValue* sync_ids =
- local_state->GetDictionary(kManagedUserSyncId);
std::string result;
- sync_ids->GetStringWithoutPathExpansion(user_id, &result);
+ GetUserValue(user_id, kManagedUserSyncId, &result);
return result;
}
@@ -172,27 +192,63 @@ string16 SupervisedUserManagerImpl::GetManagerDisplayName(
std::string SupervisedUserManagerImpl::GetManagerUserId(
const std::string& user_id) const {
- PrefService* local_state = g_browser_process->local_state();
- const DictionaryValue* manager_ids =
- local_state->GetDictionary(kManagedUserManagers);
std::string result;
- manager_ids->GetStringWithoutPathExpansion(user_id, &result);
+ GetUserValue(user_id, kManagedUserManagers, &result);
return result;
}
std::string SupervisedUserManagerImpl::GetManagerDisplayEmail(
const std::string& user_id) const {
- PrefService* local_state = g_browser_process->local_state();
- const DictionaryValue* manager_mails =
- local_state->GetDictionary(kManagedUserManagerDisplayEmails);
std::string result;
- if (manager_mails->GetStringWithoutPathExpansion(user_id, &result) &&
- !result.empty()) {
+ if (GetUserValue(user_id, kManagedUserManagerDisplayEmails, &result) &&
+ !result.empty())
return result;
- }
return GetManagerUserId(user_id);
}
+void SupervisedUserManagerImpl::GetPasswordInformation(
+ const std::string& user_id,
+ base::DictionaryValue* result) {
Bernhard Bauer 2013/12/11 14:46:43 You don't really need to pass a dictionary here th
Denis Kuznetsov (DE-MUC) 2013/12/12 19:45:24 I want to keep things simple - same dictionary wil
Bernhard Bauer 2013/12/13 00:30:50 Like I explained above, it won't be the exact same
+ std::string holder;
+ if (GetUserValue(user_id, kSupervisedUserPasswordSchemaVersion, &holder))
+ result->SetStringWithoutPathExpansion(kSchemaVersion, holder);
+ if (GetUserValue(user_id, kSupervisedUserPasswordVersion, &holder))
+ result->SetStringWithoutPathExpansion(kPasswordVersion, holder);
+ if (GetUserValue(user_id, kSupervisedUserPasswordSalt, &holder))
+ result->SetStringWithoutPathExpansion(kSalt, holder);
+}
+
+void SupervisedUserManagerImpl::SetPasswordInformation(
+ const std::string& user_id,
+ const base::DictionaryValue* password_info) {
+ std::string holder;
+ if (password_info->GetStringWithoutPathExpansion(kSchemaVersion, &holder))
+ SetUserValue(user_id, kSupervisedUserPasswordSchemaVersion, holder);
+ if (password_info->GetStringWithoutPathExpansion(kPasswordVersion, &holder))
+ SetUserValue(user_id, kSupervisedUserPasswordVersion, holder);
+ if (password_info->GetStringWithoutPathExpansion(kSalt, &holder))
+ SetUserValue(user_id, kSupervisedUserPasswordSalt, holder);
+ g_browser_process->local_state()->CommitPendingWrite();
+}
+
+bool SupervisedUserManagerImpl::GetUserValue(
+ const std::string& user_id,
+ const char* key,
+ std::string* out_value) const {
+ PrefService* local_state = g_browser_process->local_state();
+ const DictionaryValue* dictionary = local_state->GetDictionary(key);
+ return dictionary->GetStringWithoutPathExpansion(user_id, out_value);
+}
+
+void SupervisedUserManagerImpl::SetUserValue(
+ const std::string& user_id,
+ const char* key,
+ const std::string& value) {
+ PrefService* local_state = g_browser_process->local_state();
+ DictionaryPrefUpdate update(local_state, key);
+ update->SetWithoutPathExpansion(user_id, new base::StringValue(value));
Bernhard Bauer 2013/12/11 14:46:43 SetStringWithoutPathExpansion()
Denis Kuznetsov (DE-MUC) 2013/12/12 19:45:24 Done.
+}
+
const User* SupervisedUserManagerImpl::FindByDisplayName(
const string16& display_name) const {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -289,19 +345,20 @@ void SupervisedUserManagerImpl::RemoveNonCryptohomeData(
ListPrefUpdate prefs_new_users_update(prefs, kLocallyManagedUsersFirstRun);
prefs_new_users_update->Remove(base::StringValue(user_id), NULL);
- DictionaryPrefUpdate synd_id_update(prefs, kManagedUserSyncId);
- synd_id_update->RemoveWithoutPathExpansion(user_id, NULL);
-
- DictionaryPrefUpdate managers_update(prefs, kManagedUserManagers);
- managers_update->RemoveWithoutPathExpansion(user_id, NULL);
-
- DictionaryPrefUpdate manager_names_update(prefs,
- kManagedUserManagerNames);
- manager_names_update->RemoveWithoutPathExpansion(user_id, NULL);
+ CleanPref(user_id, kManagedUserSyncId);
+ CleanPref(user_id, kManagedUserManagers);
+ CleanPref(user_id, kManagedUserManagerNames);
+ CleanPref(user_id, kManagedUserManagerDisplayEmails);
+ CleanPref(user_id, kSupervisedUserPasswordSalt);
+ CleanPref(user_id, kSupervisedUserPasswordSchemaVersion);
+ CleanPref(user_id, kSupervisedUserPasswordVersion);
+}
- DictionaryPrefUpdate manager_emails_update(prefs,
- kManagedUserManagerDisplayEmails);
- manager_emails_update->RemoveWithoutPathExpansion(user_id, NULL);
+void SupervisedUserManagerImpl::CleanPref(const std::string& user_id,
+ const char* key) {
+ PrefService* prefs = g_browser_process->local_state();
+ DictionaryPrefUpdate dict_update(prefs, key);
+ dict_update->RemoveWithoutPathExpansion(user_id, NULL);
}
bool SupervisedUserManagerImpl::CheckForFirstRun(const std::string& user_id) {
@@ -332,5 +389,9 @@ void SupervisedUserManagerImpl::UpdateManagerName(const std::string& manager_id,
}
}
+SupervisedUserAuthentication* SupervisedUserManagerImpl::
+ GetSupervisedUserAuthentication() {
+ return authentication_.get();
+}
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698