OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/login/google_authenticator.h" | 5 #include "chrome/browser/chromeos/login/google_authenticator.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/lock.h" | 12 #include "base/lock.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/sha2.h" | 15 #include "base/sha2.h" |
16 #include "base/string_split.h" | |
17 #include "base/string_util.h" | 16 #include "base/string_util.h" |
18 #include "base/third_party/nss/blapi.h" | 17 #include "base/third_party/nss/blapi.h" |
19 #include "base/third_party/nss/sha256.h" | 18 #include "base/third_party/nss/sha256.h" |
20 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
21 #include "chrome/browser/chrome_thread.h" | 20 #include "chrome/browser/chrome_thread.h" |
22 #include "chrome/browser/chromeos/cros/cryptohome_library.h" | 21 #include "chrome/browser/chromeos/cros/cryptohome_library.h" |
23 #include "chrome/browser/chromeos/login/auth_response_handler.h" | 22 #include "chrome/browser/chromeos/login/auth_response_handler.h" |
24 #include "chrome/browser/chromeos/login/authentication_notification_details.h" | 23 #include "chrome/browser/chromeos/login/authentication_notification_details.h" |
25 #include "chrome/browser/chromeos/login/login_status_consumer.h" | 24 #include "chrome/browser/chromeos/login/login_status_consumer.h" |
26 #include "chrome/browser/chromeos/login/ownership_service.h" | 25 #include "chrome/browser/chromeos/login/ownership_service.h" |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 char* hex_string, | 427 char* hex_string, |
429 const unsigned int len) { | 428 const unsigned int len) { |
430 if (len < 2*binary_len) | 429 if (len < 2*binary_len) |
431 return false; | 430 return false; |
432 memset(hex_string, 0, len); | 431 memset(hex_string, 0, len); |
433 for (uint i = 0, j = 0; i < binary_len; i++, j+=2) | 432 for (uint i = 0, j = 0; i < binary_len; i++, j+=2) |
434 snprintf(hex_string + j, len - j, "%02x", binary[i]); | 433 snprintf(hex_string + j, len - j, "%02x", binary[i]); |
435 return true; | 434 return true; |
436 } | 435 } |
437 | 436 |
438 // static | |
439 std::string GoogleAuthenticator::Canonicalize( | |
440 const std::string& email_address) { | |
441 std::vector<std::string> parts; | |
442 char at = '@'; | |
443 SplitString(email_address, at, &parts); | |
444 DCHECK_EQ(parts.size(), 2U) << "email_address should have only one @"; | |
445 RemoveChars(parts[0], ".", &parts[0]); | |
446 if (parts[0].find('+') != std::string::npos) | |
447 parts[0].erase(parts[0].find('+')); | |
448 std::string new_email = StringToLowerASCII(JoinString(parts, at)); | |
449 LOG(INFO) << "Canonicalized " << email_address << " to " << new_email; | |
450 return new_email; | |
451 } | |
452 | |
453 } // namespace chromeos | 437 } // namespace chromeos |
OLD | NEW |