OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "remoting/protocol/me2me_host_authenticator_factory.h" |
| 6 |
| 7 #include "base/string_util.h" |
| 8 #include "crypto/rsa_private_key.h" |
| 9 #include "remoting/protocol/v1_authenticator.h" |
| 10 #include "remoting/protocol/v2_authenticator.h" |
| 11 |
| 12 namespace remoting { |
| 13 namespace protocol { |
| 14 |
| 15 Me2MeHostAuthenticatorFactory::Me2MeHostAuthenticatorFactory( |
| 16 const std::string& local_jid, |
| 17 const std::string& local_cert, |
| 18 const crypto::RSAPrivateKey* local_private_key, |
| 19 const std::string& shared_secret) |
| 20 : local_cert_(local_cert), |
| 21 local_private_key_(local_private_key->Copy()), |
| 22 shared_secret_(shared_secret) { |
| 23 // Verify that |local_jid| is bare. |
| 24 DCHECK_EQ(local_jid.find('/'), std::string::npos); |
| 25 local_jid_prefix_ = local_jid + '/'; |
| 26 } |
| 27 |
| 28 Me2MeHostAuthenticatorFactory::~Me2MeHostAuthenticatorFactory() { |
| 29 } |
| 30 |
| 31 Authenticator* Me2MeHostAuthenticatorFactory::CreateAuthenticator( |
| 32 const std::string& remote_jid, |
| 33 const buzz::XmlElement* first_message) { |
| 34 // Reject incoming connection if the client's jid is not an ASCII string. |
| 35 if (!IsStringASCII(remote_jid)) { |
| 36 LOG(ERROR) << "Rejecting incoming connection from " << remote_jid; |
| 37 return NULL; |
| 38 } |
| 39 |
| 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 |
| 42 // insensitive. |
| 43 if (!StartsWithASCII(remote_jid, local_jid_prefix_, false)) { |
| 44 LOG(ERROR) << "Rejecting incoming connection from " << remote_jid; |
| 45 return NULL; |
| 46 } |
| 47 |
| 48 // TODO(sergeyu): V2 authenticator is not finished it. Enable it |
| 49 // here when it is finished. crbug.com/105214 |
| 50 // |
| 51 // if (V2Authenticator::IsEkeMessage(first_message)) { |
| 52 // return V2Authenticator::CreateForHost( |
| 53 // local_cert_, local_private_key_.get(), shared_secret_); |
| 54 // } |
| 55 |
| 56 // TODO(sergeyu): Old clients still use V1 auth protocol. Remove |
| 57 // this once we are done migrating to V2. |
| 58 return new V1HostAuthenticator(local_cert_, local_private_key_.get(), |
| 59 shared_secret_, remote_jid); |
| 60 } |
| 61 |
| 62 } // namespace protocol |
| 63 } // namespace remoting |
OLD | NEW |