summaryrefslogtreecommitdiffstats
path: root/remoting/client/jni/chromoting_jni_instance.cc
diff options
context:
space:
mode:
Diffstat (limited to 'remoting/client/jni/chromoting_jni_instance.cc')
-rw-r--r--remoting/client/jni/chromoting_jni_instance.cc74
1 files changed, 32 insertions, 42 deletions
diff --git a/remoting/client/jni/chromoting_jni_instance.cc b/remoting/client/jni/chromoting_jni_instance.cc
index 54b8588..8b63f3d2 100644
--- a/remoting/client/jni/chromoting_jni_instance.cc
+++ b/remoting/client/jni/chromoting_jni_instance.cc
@@ -23,6 +23,7 @@
#include "remoting/jingle_glue/server_log_entry.h"
#include "remoting/protocol/host_stub.h"
#include "remoting/protocol/libjingle_transport_factory.h"
+#include "remoting/protocol/negotiating_client_authenticator.h"
namespace remoting {
@@ -48,6 +49,7 @@ ChromotingJniInstance::ChromotingJniInstance(ChromotingJniRuntime* jni_runtime,
const char* pairing_secret)
: jni_runtime_(jni_runtime),
host_id_(host_id),
+ host_jid_(host_jid),
create_pairing_(false),
stats_logging_enabled_(false),
weak_factory_(this) {
@@ -61,23 +63,24 @@ ChromotingJniInstance::ChromotingJniInstance(ChromotingJniRuntime* jni_runtime,
xmpp_config_.auth_token = auth_token;
xmpp_config_.auth_service = "oauth2";
- // Initialize ClientConfig.
- client_config_.host_jid = host_jid;
- client_config_.host_public_key = host_pubkey;
-
- client_config_.fetch_secret_callback =
- base::Bind(&ChromotingJniInstance::FetchSecret, this);
- client_config_.authentication_tag = host_id_;
+ // Initialize |authenticator_|.
+ scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher>
+ token_fetcher(new TokenFetcherProxy(
+ base::Bind(&ChromotingJniInstance::FetchThirdPartyToken,
+ weak_factory_.GetWeakPtr()),
+ host_pubkey));
- client_config_.client_pairing_id = pairing_id;
- client_config_.client_paired_secret = pairing_secret;
+ std::vector<protocol::AuthenticationMethod> auth_methods;
+ auth_methods.push_back(protocol::AuthenticationMethod::Spake2Pair());
+ auth_methods.push_back(protocol::AuthenticationMethod::Spake2(
+ protocol::AuthenticationMethod::HMAC_SHA256));
+ auth_methods.push_back(protocol::AuthenticationMethod::Spake2(
+ protocol::AuthenticationMethod::NONE));
- client_config_.authentication_methods.push_back(
- protocol::AuthenticationMethod::FromString("spake2_pair"));
- client_config_.authentication_methods.push_back(
- protocol::AuthenticationMethod::FromString("spake2_hmac"));
- client_config_.authentication_methods.push_back(
- protocol::AuthenticationMethod::FromString("spake2_plain"));
+ authenticator_.reset(new protocol::NegotiatingClientAuthenticator(
+ pairing_id, pairing_secret, host_id_,
+ base::Bind(&ChromotingJniInstance::FetchSecret, this),
+ token_fetcher.Pass(), auth_methods));
// Post a task to start connection
jni_runtime_->display_task_runner()->PostTask(
@@ -193,7 +196,7 @@ void ChromotingJniInstance::SendMouseEvent(
if (button != protocol::MouseEvent::BUTTON_UNDEFINED)
event.set_button_down(button_down);
- connection_->input_stub()->InjectMouseEvent(event);
+ client_->input_stub()->InjectMouseEvent(event);
}
void ChromotingJniInstance::SendMouseWheelEvent(int delta_x, int delta_y) {
@@ -208,7 +211,7 @@ void ChromotingJniInstance::SendMouseWheelEvent(int delta_x, int delta_y) {
protocol::MouseEvent event;
event.set_wheel_delta_x(delta_x);
event.set_wheel_delta_y(delta_y);
- connection_->input_stub()->InjectMouseEvent(event);
+ client_->input_stub()->InjectMouseEvent(event);
}
bool ChromotingJniInstance::SendKeyEvent(int key_code, bool key_down) {
@@ -232,7 +235,7 @@ void ChromotingJniInstance::SendTextEvent(const std::string& text) {
protocol::TextEvent event;
event.set_text(text);
- connection_->input_stub()->InjectTextEvent(event);
+ client_->input_stub()->InjectTextEvent(event);
}
void ChromotingJniInstance::RecordPaintTime(int64 paint_time_ms) {
@@ -260,7 +263,7 @@ void ChromotingJniInstance::OnConnectionState(
protocol::PairingRequest request;
DCHECK(!device_name_.empty());
request.set_client_name(device_name_);
- connection_->host_stub()->RequestPairing(request);
+ client_->host_stub()->RequestPairing(request);
}
jni_runtime_->ui_task_runner()->PostTask(
@@ -310,15 +313,6 @@ protocol::CursorShapeStub* ChromotingJniInstance::GetCursorShapeStub() {
return this;
}
-scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher>
- ChromotingJniInstance::GetTokenFetcher(const std::string& host_public_key) {
- return scoped_ptr<protocol::ThirdPartyClientAuthenticator::TokenFetcher>(
- new TokenFetcherProxy(
- base::Bind(&ChromotingJniInstance::FetchThirdPartyToken,
- weak_factory_.GetWeakPtr()),
- host_public_key));
-}
-
void ChromotingJniInstance::InjectClipboardEvent(
const protocol::ClipboardEvent& event) {
NOTIMPLEMENTED();
@@ -360,8 +354,6 @@ void ChromotingJniInstance::ConnectToHostOnNetworkThread() {
jni_runtime_->network_task_runner().get()));
client_context_->Start();
- connection_.reset(new protocol::ConnectionToHost(true));
-
SoftwareVideoRenderer* renderer =
new SoftwareVideoRenderer(client_context_->main_task_runner(),
client_context_->decode_task_runner(),
@@ -369,10 +361,10 @@ void ChromotingJniInstance::ConnectToHostOnNetworkThread() {
view_->set_frame_producer(renderer);
video_renderer_.reset(renderer);
- client_.reset(new ChromotingClient(
- client_config_, client_context_.get(), connection_.get(),
- this, video_renderer_.get(), scoped_ptr<AudioPlayer>()));
-
+ client_.reset(new ChromotingClient(client_context_.get(),
+ this,
+ video_renderer_.get(),
+ scoped_ptr<AudioPlayer>()));
signaling_.reset(new XmppSignalStrategy(
net::ClientSocketFactory::GetDefaultFactory(),
@@ -396,7 +388,8 @@ void ChromotingJniInstance::ConnectToHostOnNetworkThread() {
port_allocator.PassAs<cricket::HttpPortAllocatorBase>(),
network_settings));
- client_->Start(signaling_.get(), transport_factory.Pass());
+ client_->Start(signaling_.get(), authenticator_.Pass(),
+ transport_factory.Pass(), host_jid_, std::string());
}
void ChromotingJniInstance::DisconnectFromHostOnNetworkThread() {
@@ -407,7 +400,7 @@ void ChromotingJniInstance::DisconnectFromHostOnNetworkThread() {
stats_logging_enabled_ = false;
// |client_| must be torn down before |signaling_|.
- connection_.reset();
+ client_.reset();
client_.reset();
client_status_logger_.reset();
}
@@ -422,11 +415,8 @@ void ChromotingJniInstance::FetchSecret(
return;
}
- if (!client_config_.client_pairing_id.empty()) {
- // We attempted to connect using an existing pairing that was rejected.
- // Unless we forget about the stale credentials, we'll continue trying them.
- jni_runtime_->CommitPairingCredentials(host_id_, "", "");
- }
+ // Delete pairing credentials if they exist.
+ jni_runtime_->CommitPairingCredentials(host_id_, "", "");
pin_callback_ = callback;
jni_runtime_->DisplayAuthenticationPrompt(pairable);
@@ -456,7 +446,7 @@ void ChromotingJniInstance::SendKeyEventInternal(int usb_key_code,
protocol::KeyEvent event;
event.set_usb_keycode(usb_key_code);
event.set_pressed(key_down);
- connection_->input_stub()->InjectKeyEvent(event);
+ client_->input_stub()->InjectKeyEvent(event);
}
void ChromotingJniInstance::EnableStatsLogging(bool enabled) {