| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef REMOTING_HOST_IT2ME_IT2ME_HOST_H_ | 5 #ifndef REMOTING_HOST_IT2ME_IT2ME_HOST_H_ |
| 6 #define REMOTING_HOST_IT2ME_IT2ME_HOST_H_ | 6 #define REMOTING_HOST_IT2ME_IT2ME_HOST_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "remoting/host/host_status_observer.h" | 14 #include "remoting/host/host_status_observer.h" |
| 15 #include "remoting/host/it2me/it2me_confirmation_dialog.h" | 15 #include "remoting/host/it2me/it2me_confirmation_dialog.h" |
| 16 #include "remoting/host/it2me/it2me_confirmation_dialog_proxy.h" | 16 #include "remoting/host/it2me/it2me_confirmation_dialog_proxy.h" |
| 17 #include "remoting/protocol/validating_authenticator.h" |
| 17 #include "remoting/signaling/xmpp_signal_strategy.h" | 18 #include "remoting/signaling/xmpp_signal_strategy.h" |
| 18 | 19 |
| 19 namespace base { | 20 namespace base { |
| 20 class DictionaryValue; | 21 class DictionaryValue; |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace policy { | 24 namespace policy { |
| 24 class PolicyService; | 25 class PolicyService; |
| 25 } // namespace policy | 26 } // namespace policy |
| 26 | 27 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 // remoting::HostStatusObserver implementation. | 86 // remoting::HostStatusObserver implementation. |
| 86 void OnAccessDenied(const std::string& jid) override; | 87 void OnAccessDenied(const std::string& jid) override; |
| 87 void OnClientConnected(const std::string& jid) override; | 88 void OnClientConnected(const std::string& jid) override; |
| 88 void OnClientDisconnected(const std::string& jid) override; | 89 void OnClientDisconnected(const std::string& jid) override; |
| 89 | 90 |
| 90 void SetStateForTesting(It2MeHostState state, | 91 void SetStateForTesting(It2MeHostState state, |
| 91 const std::string& error_message) { | 92 const std::string& error_message) { |
| 92 SetState(state, error_message); | 93 SetState(state, error_message); |
| 93 } | 94 } |
| 94 | 95 |
| 96 // Updates the current policies based on |policies|. Runs |done_callback| on |
| 97 // the calling thread once the policies have been updated. |
| 98 void SetPolicyForTesting(std::unique_ptr<base::DictionaryValue> policies, |
| 99 const base::Closure& done_callback); |
| 100 |
| 101 // Returns the callback used for validating the connection. Do not run the |
| 102 // returned callback after this object has been destroyed. |
| 103 protocol::ValidatingAuthenticator::ValidationCallback |
| 104 GetValidationCallbackForTesting(); |
| 105 |
| 95 protected: | 106 protected: |
| 96 friend class base::RefCountedThreadSafe<It2MeHost>; | 107 friend class base::RefCountedThreadSafe<It2MeHost>; |
| 97 | 108 |
| 98 ~It2MeHost() override; | 109 ~It2MeHost() override; |
| 99 | 110 |
| 100 ChromotingHostContext* host_context() { return host_context_.get(); } | 111 ChromotingHostContext* host_context() { return host_context_.get(); } |
| 101 scoped_refptr<base::SingleThreadTaskRunner> task_runner() { | 112 scoped_refptr<base::SingleThreadTaskRunner> task_runner() { |
| 102 return task_runner_; | 113 return task_runner_; |
| 103 } | 114 } |
| 104 base::WeakPtr<It2MeHost::Observer> observer() { return observer_; } | 115 base::WeakPtr<It2MeHost::Observer> observer() { return observer_; } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 134 // Called when malformed policies are detected. | 145 // Called when malformed policies are detected. |
| 135 void OnPolicyError(); | 146 void OnPolicyError(); |
| 136 | 147 |
| 137 // Handlers for NAT traversal and domain policies. | 148 // Handlers for NAT traversal and domain policies. |
| 138 void UpdateNatPolicy(bool nat_traversal_enabled); | 149 void UpdateNatPolicy(bool nat_traversal_enabled); |
| 139 void UpdateHostDomainPolicy(const std::string& host_domain); | 150 void UpdateHostDomainPolicy(const std::string& host_domain); |
| 140 void UpdateClientDomainPolicy(const std::string& client_domain); | 151 void UpdateClientDomainPolicy(const std::string& client_domain); |
| 141 | 152 |
| 142 void DisconnectOnNetworkThread(); | 153 void DisconnectOnNetworkThread(); |
| 143 | 154 |
| 155 // Uses details of the connection and current policies to determine if the |
| 156 // connection should be accepted or rejected. |
| 157 void ValidateConnectionDetails( |
| 158 const std::string& remote_jid, |
| 159 const protocol::ValidatingAuthenticator::ResultCallback& result_callback); |
| 160 |
| 144 // Caller supplied fields. | 161 // Caller supplied fields. |
| 145 std::unique_ptr<ChromotingHostContext> host_context_; | 162 std::unique_ptr<ChromotingHostContext> host_context_; |
| 146 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 163 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 147 base::WeakPtr<It2MeHost::Observer> observer_; | 164 base::WeakPtr<It2MeHost::Observer> observer_; |
| 148 XmppSignalStrategy::XmppServerConfig xmpp_server_config_; | 165 XmppSignalStrategy::XmppServerConfig xmpp_server_config_; |
| 149 std::string directory_bot_jid_; | 166 std::string directory_bot_jid_; |
| 150 | 167 |
| 151 It2MeHostState state_; | 168 It2MeHostState state_; |
| 152 | 169 |
| 153 scoped_refptr<RsaKeyPair> host_key_pair_; | 170 scoped_refptr<RsaKeyPair> host_key_pair_; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 175 // that on startup, we do not accidentally start a connection before we have | 192 // that on startup, we do not accidentally start a connection before we have |
| 176 // queried our policy restrictions. | 193 // queried our policy restrictions. |
| 177 bool policy_received_; | 194 bool policy_received_; |
| 178 | 195 |
| 179 // On startup, it is possible to have Connect() called before the policy read | 196 // On startup, it is possible to have Connect() called before the policy read |
| 180 // is completed. Rather than just failing, we thunk the connection call so | 197 // is completed. Rather than just failing, we thunk the connection call so |
| 181 // it can be executed after at least one successful policy read. This | 198 // it can be executed after at least one successful policy read. This |
| 182 // variable contains the thunk if it is necessary. | 199 // variable contains the thunk if it is necessary. |
| 183 base::Closure pending_connect_; | 200 base::Closure pending_connect_; |
| 184 | 201 |
| 202 // Called after the client machine initiates the connection process and |
| 203 // determines whether to reject the connection or allow it to continue. |
| 204 protocol::ValidatingAuthenticator::ValidationCallback validation_callback_; |
| 205 |
| 185 DISALLOW_COPY_AND_ASSIGN(It2MeHost); | 206 DISALLOW_COPY_AND_ASSIGN(It2MeHost); |
| 186 }; | 207 }; |
| 187 | 208 |
| 188 // Having a factory interface makes it possible for the test to provide a mock | 209 // Having a factory interface makes it possible for the test to provide a mock |
| 189 // implementation of the It2MeHost. | 210 // implementation of the It2MeHost. |
| 190 class It2MeHostFactory { | 211 class It2MeHostFactory { |
| 191 public: | 212 public: |
| 192 It2MeHostFactory(); | 213 It2MeHostFactory(); |
| 193 virtual ~It2MeHostFactory(); | 214 virtual ~It2MeHostFactory(); |
| 194 | 215 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 206 const std::string& directory_bot_jid); | 227 const std::string& directory_bot_jid); |
| 207 | 228 |
| 208 private: | 229 private: |
| 209 policy::PolicyService* policy_service_; | 230 policy::PolicyService* policy_service_; |
| 210 DISALLOW_COPY_AND_ASSIGN(It2MeHostFactory); | 231 DISALLOW_COPY_AND_ASSIGN(It2MeHostFactory); |
| 211 }; | 232 }; |
| 212 | 233 |
| 213 } // namespace remoting | 234 } // namespace remoting |
| 214 | 235 |
| 215 #endif // REMOTING_HOST_IT2ME_IT2ME_HOST_H_ | 236 #endif // REMOTING_HOST_IT2ME_IT2ME_HOST_H_ |
| OLD | NEW |