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 <limits> | |
6 | |
5 #include "remoting/protocol/jingle_session_manager.h" | 7 #include "remoting/protocol/jingle_session_manager.h" |
wtc
2011/01/20 01:33:05
Nit: the Style Guide recommends that this header b
| |
6 | 8 |
7 #include "base/base64.h" | 9 #include "base/base64.h" |
8 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "base/rand_util.h" | |
9 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
10 #include "remoting/base/constants.h" | 13 #include "remoting/base/constants.h" |
11 #include "remoting/jingle_glue/jingle_thread.h" | 14 #include "remoting/jingle_glue/jingle_thread.h" |
12 #include "remoting/proto/auth.pb.h" | 15 #include "remoting/proto/auth.pb.h" |
13 #include "third_party/libjingle/source/talk/p2p/base/constants.h" | 16 #include "third_party/libjingle/source/talk/p2p/base/constants.h" |
14 #include "third_party/libjingle/source/talk/p2p/base/transport.h" | 17 #include "third_party/libjingle/source/talk/p2p/base/transport.h" |
15 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" | 18 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" |
16 | 19 |
17 using buzz::QName; | 20 using buzz::QName; |
18 using buzz::XmlElement; | 21 using buzz::XmlElement; |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 // Allow local connections if neccessary. | 278 // Allow local connections if neccessary. |
276 cricket_session->set_allow_local_ips(allow_local_ips_); | 279 cricket_session->set_allow_local_ips(allow_local_ips_); |
277 | 280 |
278 // If this is an outcoming session the session object is already created. | 281 // If this is an outcoming session the session object is already created. |
279 if (incoming) { | 282 if (incoming) { |
280 // Generate private key and certificate. | 283 // Generate private key and certificate. |
281 // TODO(hclam): Instead of generating we should restore them from the disk. | 284 // TODO(hclam): Instead of generating we should restore them from the disk. |
282 if (!certificate_) { | 285 if (!certificate_) { |
283 private_key_.reset(base::RSAPrivateKey::Create(1024)); | 286 private_key_.reset(base::RSAPrivateKey::Create(1024)); |
284 certificate_ = net::X509Certificate::CreateSelfSigned( | 287 certificate_ = net::X509Certificate::CreateSelfSigned( |
285 private_key_.get(), "CN=chromoting", 1, | 288 private_key_.get(), "CN=chromoting", |
289 base::RandInt(1, std::numeric_limits<int>::max()), | |
wtc
2011/01/20 01:33:05
This is correct. But it uses only half of the pos
| |
286 base::TimeDelta::FromDays(1)); | 290 base::TimeDelta::FromDays(1)); |
287 CHECK(certificate_); | 291 CHECK(certificate_); |
288 } | 292 } |
289 JingleSession* jingle_session = | 293 JingleSession* jingle_session = |
290 JingleSession::CreateServerSession(this, certificate_, | 294 JingleSession::CreateServerSession(this, certificate_, |
291 private_key_.release()); | 295 private_key_.release()); |
292 certificate_ = NULL; | 296 certificate_ = NULL; |
293 sessions_.push_back(make_scoped_refptr(jingle_session)); | 297 sessions_.push_back(make_scoped_refptr(jingle_session)); |
294 jingle_session->Init(cricket_session); | 298 jingle_session->Init(cricket_session); |
295 } | 299 } |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
545 scoped_refptr<net::X509Certificate> certificate) { | 549 scoped_refptr<net::X509Certificate> certificate) { |
546 cricket::SessionDescription* desc = new cricket::SessionDescription(); | 550 cricket::SessionDescription* desc = new cricket::SessionDescription(); |
547 desc->AddContent(JingleSession::kChromotingContentName, | 551 desc->AddContent(JingleSession::kChromotingContentName, |
548 kChromotingXmlNamespace, | 552 kChromotingXmlNamespace, |
549 new ContentDescription(config, auth_token, certificate)); | 553 new ContentDescription(config, auth_token, certificate)); |
550 return desc; | 554 return desc; |
551 } | 555 } |
552 | 556 |
553 } // namespace protocol | 557 } // namespace protocol |
554 } // namespace remoting | 558 } // namespace remoting |
OLD | NEW |