OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef REMOTING_PROTOCOL_FAKE_AUTHENTICATOR_H_ |
| 6 #define REMOTING_PROTOCOL_FAKE_AUTHENTICATOR_H_ |
| 7 |
| 8 #include "base/memory/weak_ptr.h" |
| 9 #include "remoting/protocol/authenticator.h" |
| 10 #include "remoting/protocol/channel_authenticator.h" |
| 11 |
| 12 namespace remoting { |
| 13 namespace protocol { |
| 14 |
| 15 class FakeChannelAuthenticator : public ChannelAuthenticator { |
| 16 public: |
| 17 FakeChannelAuthenticator(bool accept, bool async); |
| 18 virtual ~FakeChannelAuthenticator(); |
| 19 |
| 20 // ChannelAuthenticator interface. |
| 21 virtual void SecureAndAuthenticate( |
| 22 net::StreamSocket* socket, const DoneCallback& done_callback) OVERRIDE; |
| 23 |
| 24 private: |
| 25 void CallCallback( |
| 26 const DoneCallback& done_callback, |
| 27 net::Error error, |
| 28 net::StreamSocket* socket); |
| 29 |
| 30 bool accept_; |
| 31 bool async_; |
| 32 |
| 33 base::WeakPtrFactory<FakeChannelAuthenticator> weak_factory_; |
| 34 |
| 35 DISALLOW_COPY_AND_ASSIGN(FakeChannelAuthenticator); |
| 36 }; |
| 37 |
| 38 class FakeAuthenticator : public Authenticator { |
| 39 public: |
| 40 enum Type { |
| 41 HOST, |
| 42 CLIENT, |
| 43 }; |
| 44 |
| 45 enum Action { |
| 46 ACCEPT, |
| 47 REJECT, |
| 48 REJECT_CHANNEL |
| 49 }; |
| 50 |
| 51 FakeAuthenticator(Type type, int round_trips, Action action, bool async); |
| 52 virtual ~FakeAuthenticator(); |
| 53 |
| 54 // Authenticator interface. |
| 55 virtual State state() const OVERRIDE; |
| 56 virtual void ProcessMessage(const buzz::XmlElement* message) OVERRIDE; |
| 57 virtual buzz::XmlElement* GetNextMessage() OVERRIDE; |
| 58 virtual ChannelAuthenticator* CreateChannelAuthenticator() const OVERRIDE; |
| 59 |
| 60 protected: |
| 61 Type type_; |
| 62 int round_trips_; |
| 63 Action action_; |
| 64 bool async_; |
| 65 |
| 66 // Total number of messages that have been processed. |
| 67 int messages_; |
| 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(FakeAuthenticator); |
| 70 }; |
| 71 |
| 72 class FakeHostAuthenticatorFactory : public AuthenticatorFactory { |
| 73 public: |
| 74 FakeHostAuthenticatorFactory( |
| 75 int round_trips, FakeAuthenticator::Action action, bool async); |
| 76 virtual ~FakeHostAuthenticatorFactory(); |
| 77 |
| 78 // AuthenticatorFactory interface. |
| 79 virtual Authenticator* CreateAuthenticator( |
| 80 const std::string& remote_jid, |
| 81 const buzz::XmlElement* first_message) OVERRIDE; |
| 82 |
| 83 private: |
| 84 int round_trips_; |
| 85 FakeAuthenticator::Action action_; |
| 86 bool async_; |
| 87 |
| 88 DISALLOW_COPY_AND_ASSIGN(FakeHostAuthenticatorFactory); |
| 89 }; |
| 90 |
| 91 } // namespace protocol |
| 92 } // namespace remoting |
| 93 |
| 94 #endif // REMOTING_PROTOCOL_FAKE_AUTHENTICATOR_H_ |
OLD | NEW |