| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 BLIMP_NET_ENGINE_AUTHENTICATION_HANDLER_H_ | 5 #ifndef BLIMP_NET_ENGINE_AUTHENTICATION_HANDLER_H_ |
| 6 #define BLIMP_NET_ENGINE_AUTHENTICATION_HANDLER_H_ | 6 #define BLIMP_NET_ENGINE_AUTHENTICATION_HANDLER_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 9 #include <string> |
| 8 #include <vector> | 10 #include <vector> |
| 9 | 11 |
| 10 #include "base/macros.h" | 12 #include "base/macros.h" |
| 11 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 12 #include "blimp/net/blimp_net_export.h" | 14 #include "blimp/net/blimp_net_export.h" |
| 13 #include "blimp/net/connection_handler.h" | 15 #include "blimp/net/connection_handler.h" |
| 14 | 16 |
| 15 namespace blimp { | 17 namespace blimp { |
| 16 | 18 |
| 17 class BlimpConnection; | 19 class BlimpConnection; |
| 18 class BlimpMessage; | 20 class BlimpMessage; |
| 19 | 21 |
| 20 // Authenticates connections and passes successfully authenticated connections | 22 // Authenticates connections and passes successfully authenticated connections |
| 21 // to |connection_handler|. | 23 // to |connection_handler|. |
| 22 class BLIMP_NET_EXPORT EngineAuthenticationHandler : public ConnectionHandler { | 24 class BLIMP_NET_EXPORT EngineAuthenticationHandler : public ConnectionHandler { |
| 23 public: | 25 public: |
| 24 // |client_token|: used to authenticate incoming connection. | 26 // |client_auth_token|: used to authenticate incoming connection. |
| 25 // |connection_handler|: a new connection is passed on to it after the | 27 // |connection_handler|: a new connection is passed on to it after the |
| 26 // connection is authenticate this handler. | 28 // connection is authenticate this handler. |
| 27 EngineAuthenticationHandler(ConnectionHandler* connection_handler, | 29 EngineAuthenticationHandler(ConnectionHandler* connection_handler, |
| 28 const std::string& client_token); | 30 const std::string& client_auth_token); |
| 29 | 31 |
| 30 ~EngineAuthenticationHandler() override; | 32 ~EngineAuthenticationHandler() override; |
| 31 | 33 |
| 32 // ConnectionHandler implementation. | 34 // ConnectionHandler implementation. |
| 33 void HandleConnection(std::unique_ptr<BlimpConnection> connection) override; | 35 void HandleConnection(std::unique_ptr<BlimpConnection> connection) override; |
| 34 | 36 |
| 35 private: | 37 private: |
| 36 // Used to abandon pending authenticated connections if |this| is deleted. | 38 // Used to abandon pending authenticated connections if |this| is deleted. |
| 37 base::WeakPtrFactory<ConnectionHandler> connection_handler_weak_factory_; | 39 base::WeakPtrFactory<ConnectionHandler> connection_handler_weak_factory_; |
| 38 | 40 |
| 39 // Used to authenticate incoming connection. Engine is assigned to one client | 41 // Used to authenticate incoming connection. Engine is assigned to one client |
| 40 // only, and all connections from that client shall carry the same token. | 42 // only, and all connections from that client shall carry the same token. |
| 41 const std::string client_token_; | 43 const std::string client_auth_token_; |
| 42 | 44 |
| 43 DISALLOW_COPY_AND_ASSIGN(EngineAuthenticationHandler); | 45 DISALLOW_COPY_AND_ASSIGN(EngineAuthenticationHandler); |
| 44 }; | 46 }; |
| 45 | 47 |
| 46 } // namespace blimp | 48 } // namespace blimp |
| 47 | 49 |
| 48 #endif // BLIMP_NET_ENGINE_AUTHENTICATION_HANDLER_H_ | 50 #endif // BLIMP_NET_ENGINE_AUTHENTICATION_HANDLER_H_ |
| OLD | NEW |