| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 "entd/entd.h" | 5 #include "entd/entd.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include <iostream> | 9 #include <iostream> |
| 10 | 10 |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 // Build the callbackServer object. | 389 // Build the callbackServer object. |
| 390 callback_server_.reset(new CallbackServer(this)); | 390 callback_server_.reset(new CallbackServer(this)); |
| 391 if (!callback_server_->Initialize()) { | 391 if (!callback_server_->Initialize()) { |
| 392 LOG(ERROR) << "Error initializing entd.callback_server"; | 392 LOG(ERROR) << "Error initializing entd.callback_server"; |
| 393 exit(1); | 393 exit(1); |
| 394 } | 394 } |
| 395 entd->Set(v8::String::NewSymbol("callbackServer"), | 395 entd->Set(v8::String::NewSymbol("callbackServer"), |
| 396 callback_server_->obj(), v8::ReadOnly); | 396 callback_server_->obj(), v8::ReadOnly); |
| 397 | 397 |
| 398 // Build the pkcs11 object | 398 // Build the pkcs11 object |
| 399 bool res = false; | |
| 400 pkcs11_.reset(new Pkcs11(NULL, NULL)); | 399 pkcs11_.reset(new Pkcs11(NULL, NULL)); |
| 401 if (pkcs11_mode_ == "opencryptoki") { | 400 bool res = pkcs11_->Initialize(); |
| 402 res = pkcs11_->InitializeOpenCryptoki(pkcs11_config_filename_); | 401 if (pkcs11_mode_ == "openssl") { |
| 403 } else if (pkcs11_mode_ == "glaptop") { | 402 res = res && pkcs11_->SetOpenSSLHandlers(); |
| 404 res = pkcs11_->InitializeGLaptop(); | 403 } else if (pkcs11_mode_ != "test") { |
| 405 } else if (pkcs11_mode_ == "openssl") { | 404 res = res && pkcs11_->SetOpenCryptokiHandlers(); |
| 406 res = pkcs11_->InitializeOpenSSL(); | |
| 407 } else if (!pkcs11_mode_.empty()) { | |
| 408 LOG(ERROR) << "Unrecognized pkcs11 mode: " << pkcs11_mode_; | |
| 409 } else { | |
| 410 res = pkcs11_->Initialize(); | |
| 411 } | 405 } |
| 412 if (!res) { | 406 if (!res) { |
| 413 LOG(ERROR) << "Error initializing entd.pkcs11"; | 407 LOG(ERROR) << "Error initializing entd.pkcs11"; |
| 414 exit(1); | 408 exit(1); |
| 415 } | 409 } |
| 410 |
| 416 entd->Set(v8::String::New("pkcs11"), | 411 entd->Set(v8::String::New("pkcs11"), |
| 417 pkcs11_->obj(), v8::ReadOnly); | 412 pkcs11_->obj(), v8::ReadOnly); |
| 418 | 413 |
| 419 return handle_scope.Close(entd); | 414 return handle_scope.Close(entd); |
| 420 } | 415 } |
| 421 | 416 |
| 422 bool Entd::StartScriptingEnvironment() { | 417 bool Entd::StartScriptingEnvironment() { |
| 423 v8::HandleScope handle_scope; | 418 v8::HandleScope handle_scope; |
| 424 | 419 |
| 425 // Create the global object. | 420 // Create the global object. |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 *result = script->Run(); | 865 *result = script->Run(); |
| 871 if (!result || result->IsEmpty()) { | 866 if (!result || result->IsEmpty()) { |
| 872 utils::ReportV8Exception(&try_catch); | 867 utils::ReportV8Exception(&try_catch); |
| 873 return false; | 868 return false; |
| 874 } | 869 } |
| 875 | 870 |
| 876 return true; | 871 return true; |
| 877 } | 872 } |
| 878 | 873 |
| 879 } // namespace entd | 874 } // namespace entd |
| OLD | NEW |