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

Unified Diff: chrome/browser/policy/enterprise_install_attributes.cc

Issue 10443125: Allow re-enrollment to the same domain in case of policy data loss. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments. Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/enterprise_install_attributes.cc
diff --git a/chrome/browser/policy/enterprise_install_attributes.cc b/chrome/browser/policy/enterprise_install_attributes.cc
index bb6f9f2ba3fed2fb186b9ae08f70c00476d920d6..4430d1a8c485106f9e312680e11fec52a793370d 100644
--- a/chrome/browser/policy/enterprise_install_attributes.cc
+++ b/chrome/browser/policy/enterprise_install_attributes.cc
@@ -6,6 +6,7 @@
#include "base/logging.h"
#include "chrome/browser/chromeos/cros/cryptohome_library.h"
+#include "chrome/browser/chromeos/login/authenticator.h"
namespace policy {
@@ -23,16 +24,6 @@ const char kAttrEnterpriseMode[] = "enterprise.mode";
const char kAttrEnterpriseOwned[] = "enterprise.owned";
const char kAttrEnterpriseUser[] = "enterprise.user";
-// Extract the domain from a given email.
-std::string ExtractDomainName(const std::string& email) {
- size_t separator_pos = email.find('@');
- if (separator_pos != email.npos && separator_pos < email.length() - 1)
- return email.substr(separator_pos + 1);
- else
- NOTREACHED() << "Not a proper email address: " << email;
- return std::string();
-}
-
// Translates DeviceMode constants to strings used in the lockbox.
std::string GetDeviceModeString(DeviceMode mode) {
switch (mode) {
@@ -78,9 +69,11 @@ EnterpriseInstallAttributes::LockResult EnterpriseInstallAttributes::LockDevice(
CHECK_NE(device_mode, DEVICE_MODE_PENDING);
CHECK_NE(device_mode, DEVICE_MODE_NOT_SET);
+ std::string domain = chromeos::Authenticator::ExtractDomainName(user);
+
// Check for existing lock first.
if (device_locked_) {
- return !registration_user_.empty() && user == registration_user_ ?
+ return !registration_domain_.empty() && domain == registration_domain_ ?
LOCK_SUCCESS : LOCK_WRONG_USER;
}
@@ -103,7 +96,6 @@ EnterpriseInstallAttributes::LockResult EnterpriseInstallAttributes::LockDevice(
if (!cryptohome_->InstallAttributesIsFirstInstall())
return LOCK_WRONG_USER;
- std::string domain = ExtractDomainName(user);
std::string mode = GetDeviceModeString(device_mode);
// Set values in the InstallAttrs and lock it.
@@ -176,7 +168,8 @@ void EnterpriseInstallAttributes::ReadImmutableAttributes() {
&enterprise_user) &&
enterprise_owned == "true" &&
!enterprise_user.empty()) {
- registration_user_ = enterprise_user;
+ registration_user_ =
+ chromeos::Authenticator::Canonicalize(enterprise_user);
// Initialize the mode to the legacy enterprise mode here and update
// below if more information is present.
@@ -188,7 +181,11 @@ void EnterpriseInstallAttributes::ReadImmutableAttributes() {
// pre 19 revisions of the code, before these new attributes were added.
if (!cryptohome_->InstallAttributesGet(kAttrEnterpriseDomain,
Mattias Nissler (ping if slow) 2012/06/18 16:45:17 nit: Invert the logic so this is easier to follow.
pastarmovj 2012/06/18 17:12:58 Done.
&registration_domain_)) {
- registration_domain_ = ExtractDomainName(registration_user_);
+ registration_domain_ =
+ chromeos::Authenticator::ExtractDomainName(registration_user_);
+ } else {
+ registration_domain_ =
+ chromeos::Authenticator::CanonicalizeDomain(registration_domain_);
}
if (!cryptohome_->InstallAttributesGet(kAttrEnterpriseDeviceId,
&registration_device_id_)) {

Powered by Google App Engine
This is Rietveld 408576698