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

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: Fix some nits 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 ca5cadc0fa4e8c62a7799e9be46dd24f98a487f9..b6d60ef1ec2194e5d55ae311772a4ca5d619ebb3 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"
@@ -21,6 +22,7 @@ using content::BrowserThread;
namespace {
+// Names for pref keys in Local State.
// A map from locally managed user local user id to sync user id.
const char kManagedUserSyncId[] =
"ManagedUserSyncId";
@@ -53,10 +55,29 @@ const char kLocallyManagedUserCreationTransactionDisplayName[] =
const char kLocallyManagedUserCreationTransactionUserId[] =
"LocallyManagedUserCreationTransactionUserId";
+// A map from user id to password schema id.
+const char kSupervisedUserPasswordSchema[] =
+ "SupervisedUserPasswordSchema";
+
+// A map from user id to password salt.
+const char kSupervisedUserPasswordSalt[] =
+ "SupervisedUserPasswordSalt";
+
+// A map from user id to password revision.
+const char kSupervisedUserPasswordRevision[] =
+ "SupervisedUserPasswordRevision";
+
} // namespace
namespace chromeos {
+//
Nikita (slow) 2013/12/19 14:53:03 nit: Comment is missing?
Denis Kuznetsov (DE-MUC) 2013/12/19 16:22:17 Done.
+const char kSchemaVersion[] = "SchemaVersion";
+const char kPasswordRevision[] = "PasswordRevision";
+const char kSalt[] = "PasswordSalt";
+const char kEncryptedPassword[] = "EncryptedPassword";
+const int kMinPasswordRevision = 1;
+
// static
void SupervisedUserManager::RegisterPrefs(PrefRegistrySimple* registry) {
registry->RegisterListPref(kLocallyManagedUsersFirstRun);
@@ -69,6 +90,10 @@ void SupervisedUserManager::RegisterPrefs(PrefRegistrySimple* registry) {
registry->RegisterDictionaryPref(kManagedUserManagers);
registry->RegisterDictionaryPref(kManagedUserManagerNames);
registry->RegisterDictionaryPref(kManagedUserManagerDisplayEmails);
+
+ registry->RegisterDictionaryPref(kSupervisedUserPasswordSchema);
+ registry->RegisterDictionaryPref(kSupervisedUserPasswordSalt);
+ registry->RegisterDictionaryPref(kSupervisedUserPasswordRevision);
}
SupervisedUserManagerImpl::SupervisedUserManagerImpl(UserManagerImpl* owner)
@@ -76,6 +101,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 +176,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 +195,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) {
+ std::string holder;
+ if (GetUserValue(user_id, kSupervisedUserPasswordSchema, &holder))
+ result->SetStringWithoutPathExpansion(kSchemaVersion, holder);
+ if (GetUserValue(user_id, kSupervisedUserPasswordRevision, &holder))
+ result->SetStringWithoutPathExpansion(kPasswordRevision, 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, kSupervisedUserPasswordSchema, holder);
+ if (password_info->GetStringWithoutPathExpansion(kPasswordRevision, &holder))
+ SetUserValue(user_id, kSupervisedUserPasswordRevision, 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->SetStringWithoutPathExpansion(user_id, value);
+}
+
const User* SupervisedUserManagerImpl::FindByDisplayName(
const base::string16& display_name) const {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -289,19 +348,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, kSupervisedUserPasswordSchema);
+ CleanPref(user_id, kSupervisedUserPasswordRevision);
+}
- 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 +392,8 @@ void SupervisedUserManagerImpl::UpdateManagerName(const std::string& manager_id,
}
}
+SupervisedUserAuthentication* SupervisedUserManagerImpl::GetAuthentication() {
+ return authentication_.get();
+}
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698