OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "remoting/protocol/me2me_host_authenticator_factory.h" | 5 #include "remoting/protocol/me2me_host_authenticator_factory.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "crypto/rsa_private_key.h" | 8 #include "crypto/rsa_private_key.h" |
9 #include "remoting/protocol/v1_authenticator.h" | 9 #include "remoting/protocol/v1_authenticator.h" |
10 #include "remoting/protocol/v2_authenticator.h" | 10 #include "remoting/protocol/v2_authenticator.h" |
(...skipping 10 matching lines...) Expand all Loading... | |
21 local_private_key_(local_private_key.Copy()), | 21 local_private_key_(local_private_key.Copy()), |
22 shared_secret_(shared_secret) { | 22 shared_secret_(shared_secret) { |
23 // Verify that |local_jid| is bare. | 23 // Verify that |local_jid| is bare. |
24 DCHECK_EQ(local_jid.find('/'), std::string::npos); | 24 DCHECK_EQ(local_jid.find('/'), std::string::npos); |
25 local_jid_prefix_ = local_jid + '/'; | 25 local_jid_prefix_ = local_jid + '/'; |
26 } | 26 } |
27 | 27 |
28 Me2MeHostAuthenticatorFactory::~Me2MeHostAuthenticatorFactory() { | 28 Me2MeHostAuthenticatorFactory::~Me2MeHostAuthenticatorFactory() { |
29 } | 29 } |
30 | 30 |
31 Authenticator* Me2MeHostAuthenticatorFactory::CreateAuthenticator( | 31 scoped_ptr<Authenticator> Me2MeHostAuthenticatorFactory::CreateAuthenticator( |
32 const std::string& remote_jid, | 32 const std::string& remote_jid, |
33 const buzz::XmlElement* first_message) { | 33 const buzz::XmlElement* first_message) { |
34 // Reject incoming connection if the client's jid is not an ASCII string. | 34 // Reject incoming connection if the client's jid is not an ASCII string. |
35 if (!IsStringASCII(remote_jid)) { | 35 if (!IsStringASCII(remote_jid)) { |
36 LOG(ERROR) << "Rejecting incoming connection from " << remote_jid; | 36 LOG(ERROR) << "Rejecting incoming connection from " << remote_jid; |
37 return NULL; | 37 return scoped_ptr<Authenticator>(NULL); |
38 } | 38 } |
39 | 39 |
40 // Check that the client has the same bare jid as the host, i.e. | 40 // Check that the client has the same bare jid as the host, i.e. |
41 // client's full JID starts with host's bare jid. Comparison is case | 41 // client's full JID starts with host's bare jid. Comparison is case |
42 // insensitive. | 42 // insensitive. |
43 if (!StartsWithASCII(remote_jid, local_jid_prefix_, false)) { | 43 if (!StartsWithASCII(remote_jid, local_jid_prefix_, false)) { |
44 LOG(ERROR) << "Rejecting incoming connection from " << remote_jid; | 44 LOG(ERROR) << "Rejecting incoming connection from " << remote_jid; |
45 return NULL; | 45 return scoped_ptr<Authenticator>(NULL); |
46 } | 46 } |
47 | 47 |
48 // TODO(sergeyu): V2 authenticator is not finished yet. Enable it | 48 // TODO(sergeyu): V2 authenticator is not finished yet. Enable it |
49 // here when it is finished. crbug.com/105214 | 49 // here when it is finished. crbug.com/105214 |
50 // | 50 // |
51 // if (V2Authenticator::IsEkeMessage(first_message)) { | 51 // if (V2Authenticator::IsEkeMessage(first_message)) { |
52 // return V2Authenticator::CreateForHost( | 52 // return V2Authenticator::CreateForHost( |
53 // local_cert_, local_private_key_.get(), shared_secret_); | 53 // local_cert_, local_private_key_.get(), shared_secret_); |
54 // } | 54 // } |
55 | 55 |
56 // TODO(sergeyu): Old clients still use V1 auth protocol. Remove | 56 // TODO(sergeyu): Old clients still use V1 auth protocol. Remove |
57 // this once we are done migrating to V2. | 57 // this once we are done migrating to V2. |
58 return new V1HostAuthenticator(local_cert_, *local_private_key_, | 58 return scoped_ptr<Authenticator>(new V1HostAuthenticator( |
Wez
2012/01/19 23:23:41
It feels like the scoped_ptr<> shouldn't be needed
Sergey Ulanov
2012/01/19 23:50:26
Yep, it doesn't work without scoped_ptr<>.
| |
59 shared_secret_, remote_jid); | 59 local_cert_, *local_private_key_, |
60 shared_secret_, remote_jid)); | |
60 } | 61 } |
61 | 62 |
62 } // namespace protocol | 63 } // namespace protocol |
63 } // namespace remoting | 64 } // namespace remoting |
OLD | NEW |