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

Side by Side Diff: remoting/protocol/protocol_test_client.cc

Issue 7008003: Wire in OAuth2 support into non-sandboxed connections in libjingle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if !defined(OS_WIN) 7 #if !defined(OS_WIN)
8 extern "C" { 8 extern "C" {
9 #include <unistd.h> 9 #include <unistd.h>
10 } 10 }
11 #endif // !defined(OS_WIN) 11 #endif // !defined(OS_WIN)
12 12
13 #include <iostream> 13 #include <iostream>
14 #include <list> 14 #include <list>
15 15
16 #include "base/at_exit.h" 16 #include "base/at_exit.h"
17 #include "base/command_line.h" 17 #include "base/command_line.h"
18 #include "base/test/mock_chrome_application_mac.h" 18 #include "base/test/mock_chrome_application_mac.h"
19 #include "base/time.h" 19 #include "base/time.h"
20 #include "crypto/nss_util.h" 20 #include "crypto/nss_util.h"
21 #include "net/base/completion_callback.h" 21 #include "net/base/completion_callback.h"
22 #include "net/base/io_buffer.h" 22 #include "net/base/io_buffer.h"
23 #include "net/base/net_errors.h" 23 #include "net/base/net_errors.h"
24 #include "net/socket/socket.h" 24 #include "net/socket/socket.h"
25 #include "remoting/base/constants.h" 25 #include "remoting/base/constants.h"
26 #include "remoting/jingle_glue/jingle_client.h" 26 #include "remoting/jingle_glue/jingle_client.h"
27 #include "remoting/jingle_glue/jingle_thread.h" 27 #include "remoting/jingle_glue/jingle_thread.h"
28 #include "remoting/protocol/jingle_session_manager.h" 28 #include "remoting/protocol/jingle_session_manager.h"
29 29
30 using remoting::kChromotingTokenServiceName;
31
32 namespace remoting { 30 namespace remoting {
33 namespace protocol { 31 namespace protocol {
34 32
35 namespace { 33 namespace {
36 const int kBufferSize = 4096; 34 const int kBufferSize = 4096;
37 const char kDummyAuthToken[] = ""; 35 const char kDummyAuthToken[] = "";
38 } // namespace 36 } // namespace
39 37
40 class ProtocolTestClient; 38 class ProtocolTestClient;
41 39
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 std::string str(reinterpret_cast<const char*>(read_buffer_->data()), 214 std::string str(reinterpret_cast<const char*>(read_buffer_->data()),
217 result); 215 result);
218 std::cout << "(" << session_->jid() << "): " << str << std::endl; 216 std::cout << "(" << session_->jid() << "): " << str << std::endl;
219 } else { 217 } else {
220 LOG(ERROR) << "Read() returned error " << result; 218 LOG(ERROR) << "Read() returned error " << result;
221 } 219 }
222 } 220 }
223 221
224 void ProtocolTestClient::Run(const std::string& username, 222 void ProtocolTestClient::Run(const std::string& username,
225 const std::string& auth_token, 223 const std::string& auth_token,
224 const std::string& auth_service,
226 const std::string& host_jid) { 225 const std::string& host_jid) {
227 remoting::JingleThread jingle_thread; 226 remoting::JingleThread jingle_thread;
228 jingle_thread.Start(); 227 jingle_thread.Start();
229 signal_strategy_.reset( 228 signal_strategy_.reset(
230 new XmppSignalStrategy(&jingle_thread, username, auth_token, 229 new XmppSignalStrategy(&jingle_thread, username, auth_token,
231 kChromotingTokenServiceName)); 230 auth_service));
232 client_ = new JingleClient(&jingle_thread, signal_strategy_.get(), 231 client_ = new JingleClient(&jingle_thread, signal_strategy_.get(),
233 NULL, NULL, NULL, this); 232 NULL, NULL, NULL, this);
234 client_->Init(); 233 client_->Init();
235 234
236 session_manager_ = new JingleSessionManager(&jingle_thread); 235 session_manager_ = new JingleSessionManager(&jingle_thread);
237 236
238 host_jid_ = host_jid; 237 host_jid_ = host_jid;
239 238
240 while (true) { 239 while (true) {
241 std::string line; 240 std::string line;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 std::string host_jid(cmd_line->GetSwitchValueASCII("host_jid")); 366 std::string host_jid(cmd_line->GetSwitchValueASCII("host_jid"));
368 367
369 if (!cmd_line->HasSwitch("username")) 368 if (!cmd_line->HasSwitch("username"))
370 usage(argv[0]); 369 usage(argv[0]);
371 std::string username(cmd_line->GetSwitchValueASCII("username")); 370 std::string username(cmd_line->GetSwitchValueASCII("username"));
372 371
373 if (!cmd_line->HasSwitch("auth_token")) 372 if (!cmd_line->HasSwitch("auth_token"))
374 usage(argv[0]); 373 usage(argv[0]);
375 std::string auth_token(cmd_line->GetSwitchValueASCII("auth_token")); 374 std::string auth_token(cmd_line->GetSwitchValueASCII("auth_token"));
376 375
376 // Default to OAuth2 for the auth token.
377 std::string auth_service("oauth2");
378 if (cmd_line->HasSwitch("auth_service"))
379 auth_service = cmd_line->GetSwitchValueASCII("auth_service");
380
377 scoped_refptr<ProtocolTestClient> client(new ProtocolTestClient()); 381 scoped_refptr<ProtocolTestClient> client(new ProtocolTestClient());
378 382
379 client->Run(username, auth_token, host_jid); 383 client->Run(username, auth_token, host_jid, auth_service);
380 384
381 return 0; 385 return 0;
382 } 386 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698