| 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/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "remoting/base/rsa_key_pair.h" | 9 #include "remoting/base/rsa_key_pair.h" |
| 10 #include "remoting/protocol/channel_authenticator.h" | 10 #include "remoting/protocol/channel_authenticator.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } | 134 } |
| 135 remote_jid_prefix = local_jid.substr(0, slash_pos); | 135 remote_jid_prefix = local_jid.substr(0, slash_pos); |
| 136 } else { | 136 } else { |
| 137 // TODO(rmsousa): This only works for cases where the JID prefix matches | 137 // TODO(rmsousa): This only works for cases where the JID prefix matches |
| 138 // the host owner email. Figure out a way to verify the JID in other cases. | 138 // the host owner email. Figure out a way to verify the JID in other cases. |
| 139 remote_jid_prefix = host_owner_; | 139 remote_jid_prefix = host_owner_; |
| 140 } | 140 } |
| 141 | 141 |
| 142 // Verify that the client's jid is an ASCII string, and then check that the | 142 // Verify that the client's jid is an ASCII string, and then check that the |
| 143 // client JID has the expected prefix. Comparison is case insensitive. | 143 // client JID has the expected prefix. Comparison is case insensitive. |
| 144 if (!IsStringASCII(remote_jid) || | 144 if (!base::IsStringASCII(remote_jid) || |
| 145 !StartsWithASCII(remote_jid, remote_jid_prefix + '/', false)) { | 145 !StartsWithASCII(remote_jid, remote_jid_prefix + '/', false)) { |
| 146 LOG(ERROR) << "Rejecting incoming connection from " << remote_jid; | 146 LOG(ERROR) << "Rejecting incoming connection from " << remote_jid; |
| 147 return scoped_ptr<Authenticator>(new RejectingAuthenticator()); | 147 return scoped_ptr<Authenticator>(new RejectingAuthenticator()); |
| 148 } | 148 } |
| 149 | 149 |
| 150 if (!local_cert_.empty() && key_pair_.get()) { | 150 if (!local_cert_.empty() && key_pair_.get()) { |
| 151 if (token_validator_factory_) { | 151 if (token_validator_factory_) { |
| 152 return NegotiatingHostAuthenticator::CreateWithThirdPartyAuth( | 152 return NegotiatingHostAuthenticator::CreateWithThirdPartyAuth( |
| 153 local_cert_, key_pair_, | 153 local_cert_, key_pair_, |
| 154 token_validator_factory_->CreateTokenValidator( | 154 token_validator_factory_->CreateTokenValidator( |
| 155 local_jid, remote_jid)); | 155 local_jid, remote_jid)); |
| 156 } | 156 } |
| 157 | 157 |
| 158 return NegotiatingHostAuthenticator::CreateWithSharedSecret( | 158 return NegotiatingHostAuthenticator::CreateWithSharedSecret( |
| 159 local_cert_, key_pair_, shared_secret_hash_.value, | 159 local_cert_, key_pair_, shared_secret_hash_.value, |
| 160 shared_secret_hash_.hash_function, pairing_registry_); | 160 shared_secret_hash_.hash_function, pairing_registry_); |
| 161 } | 161 } |
| 162 | 162 |
| 163 return scoped_ptr<Authenticator>(new RejectingAuthenticator()); | 163 return scoped_ptr<Authenticator>(new RejectingAuthenticator()); |
| 164 } | 164 } |
| 165 | 165 |
| 166 } // namespace protocol | 166 } // namespace protocol |
| 167 } // namespace remoting | 167 } // namespace remoting |
| OLD | NEW |