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

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: Moved the domain extraction to Authenticator and added custom error message. 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..10e826fb8fbe45645c4b91735906e2fead65ec1a 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.
@@ -188,7 +180,8 @@ void EnterpriseInstallAttributes::ReadImmutableAttributes() {
// pre 19 revisions of the code, before these new attributes were added.
if (!cryptohome_->InstallAttributesGet(kAttrEnterpriseDomain,
&registration_domain_)) {
- registration_domain_ = ExtractDomainName(registration_user_);
+ registration_domain_ =
+ chromeos::Authenticator::ExtractDomainName(registration_user_);
}
if (!cryptohome_->InstallAttributesGet(kAttrEnterpriseDeviceId,
&registration_device_id_)) {

Powered by Google App Engine
This is Rietveld 408576698