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

Side by Side Diff: chrome/browser/chromeos/login/login_utils.cc

Issue 7756025: Changed OAuth token+secret encryption to use supplemental user key. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/login_utils.h" 5 #include "chrome/browser/chromeos/login/login_utils.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 } 926 }
927 927
928 PrefService* pref_service = user_profile->GetPrefs(); 928 PrefService* pref_service = user_profile->GetPrefs();
929 std::string encoded_token = pref_service->GetString(prefs::kOAuth1Token); 929 std::string encoded_token = pref_service->GetString(prefs::kOAuth1Token);
930 std::string encoded_secret = pref_service->GetString(prefs::kOAuth1Secret); 930 std::string encoded_secret = pref_service->GetString(prefs::kOAuth1Secret);
931 if (!encoded_token.length() || !encoded_secret.length()) 931 if (!encoded_token.length() || !encoded_secret.length())
932 return false; 932 return false;
933 933
934 std::string decoded_token = authenticator_->DecryptToken(encoded_token); 934 std::string decoded_token = authenticator_->DecryptToken(encoded_token);
935 std::string decoded_secret = authenticator_->DecryptToken(encoded_secret); 935 std::string decoded_secret = authenticator_->DecryptToken(encoded_secret);
936 if (!decoded_token.length() || !decoded_secret.length()) 936 if (!decoded_token.length() || !decoded_secret.length()) {
937 return false; 937 // TODO(zelidrag): Remove legacy encryption support in R16.
938 // Check if tokens were encoded with the legacy encryption instead.
939 decoded_token = authenticator_->DecryptLegacyToken(encoded_token);
940 decoded_secret = authenticator_->DecryptLegacyToken(encoded_secret);
941 if (!decoded_token.length() || !decoded_secret.length()) {
942 return false;
943 } else {
wtc 2011/09/06 21:35:17 Nit: omit "else" after a return statement.
zel 2011/09/06 22:33:35 Done.
944 pref_service->SetString(prefs::kOAuth1Token,
945 authenticator_->EncryptToken(decoded_token));
946 pref_service->SetString(prefs::kOAuth1Secret,
947 authenticator_->EncryptToken(decoded_secret));
948 }
949 }
938 950
939 *token = decoded_token; 951 *token = decoded_token;
940 *secret = decoded_secret; 952 *secret = decoded_secret;
941 return true; 953 return true;
942 } 954 }
943 955
944 void LoginUtilsImpl::StoreOAuth1AccessToken(Profile* user_profile, 956 void LoginUtilsImpl::StoreOAuth1AccessToken(Profile* user_profile,
945 const std::string& token, 957 const std::string& token,
946 const std::string& secret) { 958 const std::string& secret) {
947 // First store OAuth1 token + service for the current user profile... 959 // First store OAuth1 token + service for the current user profile...
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 // Mark login host for deletion after browser starts. This 1040 // Mark login host for deletion after browser starts. This
1029 // guarantees that the message loop will be referenced by the 1041 // guarantees that the message loop will be referenced by the
1030 // browser before it is dereferenced by the login host. 1042 // browser before it is dereferenced by the login host.
1031 if (login_host) { 1043 if (login_host) {
1032 login_host->OnSessionStart(); 1044 login_host->OnSessionStart();
1033 login_host = NULL; 1045 login_host = NULL;
1034 } 1046 }
1035 } 1047 }
1036 1048
1037 } // namespace chromeos 1049 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698