| 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/cros/login_library.h" | 5 #include "chrome/browser/chromeos/cros/login_library.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "chrome/browser/browser_thread.h" | 8 #include "chrome/browser/browser_thread.h" |
| 9 #include "chrome/browser/chromeos/cros/cros_library.h" | 9 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 chromeos::DisconnectSession(session_connection_); | 24 chromeos::DisconnectSession(session_connection_); |
| 25 } | 25 } |
| 26 } | 26 } |
| 27 | 27 |
| 28 bool EmitLoginPromptReady() { | 28 bool EmitLoginPromptReady() { |
| 29 return chromeos::EmitLoginPromptReady(); | 29 return chromeos::EmitLoginPromptReady(); |
| 30 } | 30 } |
| 31 | 31 |
| 32 bool CheckWhitelist(const std::string& email, | 32 bool CheckWhitelist(const std::string& email, |
| 33 std::vector<uint8>* OUT_signature) { | 33 std::vector<uint8>* OUT_signature) { |
| 34 return chromeos::CheckWhitelist(email.c_str(), OUT_signature); | 34 CryptoBlob* sig = NULL; |
| 35 if (chromeos::CheckWhitelistSafe(email.c_str(), &sig)) { |
| 36 OUT_signature->assign(sig->data, sig->data + sig->length); |
| 37 chromeos::FreeCryptoBlob(sig); |
| 38 return true; |
| 39 } |
| 40 return false; |
| 35 } | 41 } |
| 36 | 42 |
| 37 bool RetrieveProperty(const std::string& name, | 43 bool RetrieveProperty(const std::string& name, |
| 38 std::string* OUT_value, | 44 std::string* OUT_value, |
| 39 std::vector<uint8>* OUT_signature) { | 45 std::vector<uint8>* OUT_signature) { |
| 40 return chromeos::RetrieveProperty(name.c_str(), OUT_value, OUT_signature); | 46 Property* prop = NULL; |
| 47 if (chromeos::RetrievePropertySafe(name.c_str(), &prop)) { |
| 48 OUT_value->assign(prop->value); |
| 49 CryptoBlob* sig = prop->signature; |
| 50 OUT_signature->assign(sig->data, sig->data + sig->length); |
| 51 chromeos::FreeProperty(prop); |
| 52 return true; |
| 53 } |
| 54 return false; |
| 41 } | 55 } |
| 42 | 56 |
| 43 bool SetOwnerKeyAsync(const std::vector<uint8>& public_key_der, | 57 bool SetOwnerKeyAsync(const std::vector<uint8>& public_key_der, |
| 44 Delegate* callback) { | 58 Delegate* callback) { |
| 45 DCHECK(callback) << "must provide a callback to SetOwnerKeyAsync()"; | 59 DCHECK(callback) << "must provide a callback to SetOwnerKeyAsync()"; |
| 46 if (set_owner_key_callback_) | 60 if (set_owner_key_callback_) |
| 47 return false; | 61 return false; |
| 48 set_owner_key_callback_ = callback; | 62 set_owner_key_callback_ = callback; |
| 49 return chromeos::SetOwnerKey(public_key_der); | 63 CryptoBlob* key = chromeos::CreateCryptoBlob(&public_key_der[0], |
| 64 public_key_der.size()); |
| 65 bool rv = chromeos::SetOwnerKeySafe(key); |
| 66 chromeos::FreeCryptoBlob(key); |
| 67 return rv; |
| 50 } | 68 } |
| 51 | 69 |
| 52 bool StorePropertyAsync(const std::string& name, | 70 bool StorePropertyAsync(const std::string& name, |
| 53 const std::string& value, | 71 const std::string& value, |
| 54 const std::vector<uint8>& signature, | 72 const std::vector<uint8>& signature, |
| 55 Delegate* callback) { | 73 Delegate* callback) { |
| 56 DCHECK(callback) << "must provide a callback to StorePropertyAsync()"; | 74 DCHECK(callback) << "must provide a callback to StorePropertyAsync()"; |
| 57 if (property_op_callback_) | 75 if (property_op_callback_) |
| 58 return false; | 76 return false; |
| 59 property_op_callback_ = callback; | 77 property_op_callback_ = callback; |
| 60 return chromeos::StoreProperty(name.c_str(), value.c_str(), signature); | 78 Property* prop = chromeos::CreateProperty(name.c_str(), |
| 79 value.c_str(), |
| 80 &signature[0], |
| 81 signature.size()); |
| 82 bool rv = chromeos::StorePropertySafe(prop); |
| 83 chromeos::FreeProperty(prop); |
| 84 return rv; |
| 61 } | 85 } |
| 62 | 86 |
| 63 bool UnwhitelistAsync(const std::string& email, | 87 bool UnwhitelistAsync(const std::string& email, |
| 64 const std::vector<uint8>& signature, | 88 const std::vector<uint8>& signature, |
| 65 Delegate* callback) { | 89 Delegate* callback) { |
| 66 DCHECK(callback) << "must provide a callback to UnwhitelistAsync()"; | 90 DCHECK(callback) << "must provide a callback to UnwhitelistAsync()"; |
| 67 if (whitelist_op_callback_) | 91 if (whitelist_op_callback_) |
| 68 return false; | 92 return false; |
| 69 whitelist_op_callback_ = callback; | 93 whitelist_op_callback_ = callback; |
| 70 return chromeos::Unwhitelist(email.c_str(), signature); | 94 CryptoBlob* sig = chromeos::CreateCryptoBlob(&signature[0], |
| 95 signature.size()); |
| 96 bool rv = chromeos::UnwhitelistSafe(email.c_str(), sig); |
| 97 chromeos::FreeCryptoBlob(sig); |
| 98 return rv; |
| 71 } | 99 } |
| 72 | 100 |
| 73 bool WhitelistAsync(const std::string& email, | 101 bool WhitelistAsync(const std::string& email, |
| 74 const std::vector<uint8>& signature, | 102 const std::vector<uint8>& signature, |
| 75 Delegate* callback) { | 103 Delegate* callback) { |
| 76 DCHECK(callback) << "must provide a callback to WhitelistAsync()"; | 104 DCHECK(callback) << "must provide a callback to WhitelistAsync()"; |
| 77 if (whitelist_op_callback_) | 105 if (whitelist_op_callback_) |
| 78 return false; | 106 return false; |
| 79 whitelist_op_callback_ = callback; | 107 whitelist_op_callback_ = callback; |
| 80 return chromeos::Whitelist(email.c_str(), signature); | 108 CryptoBlob* sig = chromeos::CreateCryptoBlob(&signature[0], |
| 109 signature.size()); |
| 110 bool rv = chromeos::WhitelistSafe(email.c_str(), sig); |
| 111 chromeos::FreeCryptoBlob(sig); |
| 112 return rv; |
| 81 } | 113 } |
| 82 | 114 |
| 83 bool EnumerateWhitelisted(std::vector<std::string>* whitelisted) { | 115 bool EnumerateWhitelisted(std::vector<std::string>* whitelisted) { |
| 84 return chromeos::EnumerateWhitelisted(whitelisted); | 116 UserList* list = NULL; |
| 117 if (chromeos::EnumerateWhitelistedSafe(&list)) { |
| 118 for (int i = 0; i < list->num_users; i++) |
| 119 whitelisted->push_back(std::string(list->users[i])); |
| 120 chromeos::FreeUserList(list); |
| 121 return true; |
| 122 } |
| 123 return false; |
| 85 } | 124 } |
| 86 | 125 |
| 87 bool StartSession(const std::string& user_email, | 126 bool StartSession(const std::string& user_email, |
| 88 const std::string& unique_id /* unused */) { | 127 const std::string& unique_id /* unused */) { |
| 89 // only pass unique_id through once we use it for something. | 128 // only pass unique_id through once we use it for something. |
| 90 return chromeos::StartSession(user_email.c_str(), ""); | 129 return chromeos::StartSession(user_email.c_str(), ""); |
| 91 } | 130 } |
| 92 | 131 |
| 93 bool StopSession(const std::string& unique_id /* unused */) { | 132 bool StopSession(const std::string& unique_id /* unused */) { |
| 94 // only pass unique_id through once we use it for something. | 133 // only pass unique_id through once we use it for something. |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 | 268 |
| 230 // static | 269 // static |
| 231 LoginLibrary* LoginLibrary::GetImpl(bool stub) { | 270 LoginLibrary* LoginLibrary::GetImpl(bool stub) { |
| 232 if (stub) | 271 if (stub) |
| 233 return new LoginLibraryStubImpl(); | 272 return new LoginLibraryStubImpl(); |
| 234 else | 273 else |
| 235 return new LoginLibraryImpl(); | 274 return new LoginLibraryImpl(); |
| 236 } | 275 } |
| 237 | 276 |
| 238 } // namespace chromeos | 277 } // namespace chromeos |
| OLD | NEW |