| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/cryptauth/cryptauth_enrollment_manager.h" | 5 #include "components/cryptauth/cryptauth_enrollment_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/base64url.h" | 9 #include "base/base64url.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } | 160 } |
| 161 | 161 |
| 162 std::unique_ptr<SyncScheduler> | 162 std::unique_ptr<SyncScheduler> |
| 163 CryptAuthEnrollmentManager::CreateSyncScheduler() { | 163 CryptAuthEnrollmentManager::CreateSyncScheduler() { |
| 164 return base::MakeUnique<SyncSchedulerImpl>( | 164 return base::MakeUnique<SyncSchedulerImpl>( |
| 165 this, base::TimeDelta::FromDays(kEnrollmentRefreshPeriodDays), | 165 this, base::TimeDelta::FromDays(kEnrollmentRefreshPeriodDays), |
| 166 base::TimeDelta::FromMinutes(kEnrollmentBaseRecoveryPeriodMinutes), | 166 base::TimeDelta::FromMinutes(kEnrollmentBaseRecoveryPeriodMinutes), |
| 167 kEnrollmentMaxJitterRatio, "CryptAuth Enrollment"); | 167 kEnrollmentMaxJitterRatio, "CryptAuth Enrollment"); |
| 168 } | 168 } |
| 169 | 169 |
| 170 std::string CryptAuthEnrollmentManager::GetUserPublicKey() { | 170 std::string CryptAuthEnrollmentManager::GetUserPublicKey() const { |
| 171 std::string public_key; | 171 std::string public_key; |
| 172 if (!base::Base64UrlDecode( | 172 if (!base::Base64UrlDecode( |
| 173 pref_service_->GetString(prefs::kCryptAuthEnrollmentUserPublicKey), | 173 pref_service_->GetString(prefs::kCryptAuthEnrollmentUserPublicKey), |
| 174 base::Base64UrlDecodePolicy::REQUIRE_PADDING, &public_key)) { | 174 base::Base64UrlDecodePolicy::REQUIRE_PADDING, &public_key)) { |
| 175 PA_LOG(ERROR) << "Invalid public key stored in user prefs."; | 175 PA_LOG(ERROR) << "Invalid public key stored in user prefs."; |
| 176 return std::string(); | 176 return std::string(); |
| 177 } | 177 } |
| 178 return public_key; | 178 return public_key; |
| 179 } | 179 } |
| 180 | 180 |
| 181 std::string CryptAuthEnrollmentManager::GetUserPrivateKey() { | 181 std::string CryptAuthEnrollmentManager::GetUserPrivateKey() const { |
| 182 std::string private_key; | 182 std::string private_key; |
| 183 if (!base::Base64UrlDecode( | 183 if (!base::Base64UrlDecode( |
| 184 pref_service_->GetString(prefs::kCryptAuthEnrollmentUserPrivateKey), | 184 pref_service_->GetString(prefs::kCryptAuthEnrollmentUserPrivateKey), |
| 185 base::Base64UrlDecodePolicy::REQUIRE_PADDING, &private_key)) { | 185 base::Base64UrlDecodePolicy::REQUIRE_PADDING, &private_key)) { |
| 186 PA_LOG(ERROR) << "Invalid private key stored in user prefs."; | 186 PA_LOG(ERROR) << "Invalid private key stored in user prefs."; |
| 187 return std::string(); | 187 return std::string(); |
| 188 } | 188 } |
| 189 return private_key; | 189 return private_key; |
| 190 } | 190 } |
| 191 | 191 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 << device_info.gcm_registration_id(); | 295 << device_info.gcm_registration_id(); |
| 296 | 296 |
| 297 cryptauth_enroller_ = enroller_factory_->CreateInstance(); | 297 cryptauth_enroller_ = enroller_factory_->CreateInstance(); |
| 298 cryptauth_enroller_->Enroll( | 298 cryptauth_enroller_->Enroll( |
| 299 GetUserPublicKey(), GetUserPrivateKey(), device_info, invocation_reason, | 299 GetUserPublicKey(), GetUserPrivateKey(), device_info, invocation_reason, |
| 300 base::Bind(&CryptAuthEnrollmentManager::OnEnrollmentFinished, | 300 base::Bind(&CryptAuthEnrollmentManager::OnEnrollmentFinished, |
| 301 weak_ptr_factory_.GetWeakPtr())); | 301 weak_ptr_factory_.GetWeakPtr())); |
| 302 } | 302 } |
| 303 | 303 |
| 304 } // namespace cryptauth | 304 } // namespace cryptauth |
| OLD | NEW |