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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "remoting/base/rsa_key_pair.h" | 11 #include "remoting/base/rsa_key_pair.h" |
12 #include "remoting/protocol/channel_authenticator.h" | 12 #include "remoting/protocol/channel_authenticator.h" |
13 #include "remoting/protocol/negotiating_host_authenticator.h" | 13 #include "remoting/protocol/negotiating_host_authenticator.h" |
14 #include "remoting/protocol/rejecting_authenticator.h" | 14 #include "remoting/protocol/rejecting_authenticator.h" |
15 #include "remoting/protocol/token_validator.h" | 15 #include "remoting/protocol/token_validator.h" |
16 #include "remoting/signaling/jid_util.h" | 16 #include "remoting/signaling/jid_util.h" |
17 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" | 17 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" |
18 | 18 |
19 namespace remoting { | 19 namespace remoting { |
20 namespace protocol { | 20 namespace protocol { |
21 | 21 |
22 // static | 22 // static |
23 scoped_ptr<AuthenticatorFactory> | 23 scoped_ptr<AuthenticatorFactory> Me2MeHostAuthenticatorFactory::CreateWithPin( |
24 Me2MeHostAuthenticatorFactory::CreateWithSharedSecret( | |
25 bool use_service_account, | 24 bool use_service_account, |
26 const std::string& host_owner, | 25 const std::string& host_owner, |
27 const std::string& local_cert, | 26 const std::string& local_cert, |
28 scoped_refptr<RsaKeyPair> key_pair, | 27 scoped_refptr<RsaKeyPair> key_pair, |
29 const std::string& required_client_domain, | 28 const std::string& required_client_domain, |
30 const SharedSecretHash& shared_secret_hash, | 29 const std::string& pin_hash, |
31 scoped_refptr<PairingRegistry> pairing_registry) { | 30 scoped_refptr<PairingRegistry> pairing_registry) { |
32 scoped_ptr<Me2MeHostAuthenticatorFactory> result( | 31 scoped_ptr<Me2MeHostAuthenticatorFactory> result( |
33 new Me2MeHostAuthenticatorFactory()); | 32 new Me2MeHostAuthenticatorFactory()); |
34 result->use_service_account_ = use_service_account; | 33 result->use_service_account_ = use_service_account; |
35 result->host_owner_ = host_owner; | 34 result->host_owner_ = host_owner; |
36 result->local_cert_ = local_cert; | 35 result->local_cert_ = local_cert; |
37 result->key_pair_ = key_pair; | 36 result->key_pair_ = key_pair; |
38 result->required_client_domain_ = required_client_domain; | 37 result->required_client_domain_ = required_client_domain; |
39 result->shared_secret_hash_ = shared_secret_hash; | 38 result->pin_hash_ = pin_hash; |
40 result->pairing_registry_ = pairing_registry; | 39 result->pairing_registry_ = pairing_registry; |
41 return std::move(result); | 40 return std::move(result); |
42 } | 41 } |
43 | 42 |
44 | 43 |
45 // static | 44 // static |
46 scoped_ptr<AuthenticatorFactory> | 45 scoped_ptr<AuthenticatorFactory> |
47 Me2MeHostAuthenticatorFactory::CreateWithThirdPartyAuth( | 46 Me2MeHostAuthenticatorFactory::CreateWithThirdPartyAuth( |
48 bool use_service_account, | 47 bool use_service_account, |
49 const std::string& host_owner, | 48 const std::string& host_owner, |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 } | 120 } |
122 | 121 |
123 if (!local_cert_.empty() && key_pair_.get()) { | 122 if (!local_cert_.empty() && key_pair_.get()) { |
124 if (token_validator_factory_) { | 123 if (token_validator_factory_) { |
125 return NegotiatingHostAuthenticator::CreateWithThirdPartyAuth( | 124 return NegotiatingHostAuthenticator::CreateWithThirdPartyAuth( |
126 local_cert_, key_pair_, | 125 local_cert_, key_pair_, |
127 token_validator_factory_->CreateTokenValidator( | 126 token_validator_factory_->CreateTokenValidator( |
128 local_jid, remote_jid)); | 127 local_jid, remote_jid)); |
129 } | 128 } |
130 | 129 |
131 return NegotiatingHostAuthenticator::CreateWithSharedSecret( | 130 return NegotiatingHostAuthenticator::CreateWithPin( |
132 local_cert_, key_pair_, shared_secret_hash_.value, | 131 local_cert_, key_pair_, pin_hash_, pairing_registry_); |
133 shared_secret_hash_.hash_function, pairing_registry_); | |
134 } | 132 } |
135 | 133 |
136 return make_scoped_ptr( | 134 return make_scoped_ptr( |
137 new RejectingAuthenticator(Authenticator::INVALID_CREDENTIALS)); | 135 new RejectingAuthenticator(Authenticator::INVALID_CREDENTIALS)); |
138 } | 136 } |
139 | 137 |
140 } // namespace protocol | 138 } // namespace protocol |
141 } // namespace remoting | 139 } // namespace remoting |
OLD | NEW |