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