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