summaryrefslogtreecommitdiffstats
path: root/remoting/protocol/channel_authenticator.h
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-23 03:58:43 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-23 03:58:43 +0000
commit8d1f875d17695b508b8ac6ada9cef468f6fd181e (patch)
tree71dd26ccb18e60b4e569c738715a3153e5e91042 /remoting/protocol/channel_authenticator.h
parent313b80bd2c5b7257d8daa2ef4aef0ee5b6e1555c (diff)
downloadchromium_src-8d1f875d17695b508b8ac6ada9cef468f6fd181e.zip
chromium_src-8d1f875d17695b508b8ac6ada9cef468f6fd181e.tar.gz
chromium_src-8d1f875d17695b508b8ac6ada9cef468f6fd181e.tar.bz2
Move SSL layer initialization into ChannelAuthenticator implementations.
Also separate client and host authenticators into separate files. Review URL: http://codereview.chromium.org/8604001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111311 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/protocol/channel_authenticator.h')
-rw-r--r--remoting/protocol/channel_authenticator.h98
1 files changed, 19 insertions, 79 deletions
diff --git a/remoting/protocol/channel_authenticator.h b/remoting/protocol/channel_authenticator.h
index c925ea9..535730a 100644
--- a/remoting/protocol/channel_authenticator.h
+++ b/remoting/protocol/channel_authenticator.h
@@ -8,93 +8,33 @@
#include <string>
#include "base/callback.h"
-#include "base/memory/ref_counted.h"
-#include "base/threading/non_thread_safe.h"
-#include "net/base/completion_callback.h"
+#include "net/base/net_errors.h"
namespace net {
-class DrainableIOBuffer;
-class GrowableIOBuffer;
-class SSLSocket;
+class StreamSocket;
} // namespace net
namespace remoting {
namespace protocol {
-class ChannelAuthenticator : public base::NonThreadSafe {
+// Interface for channel authentications that perform channel-level
+// authentication. Depending on implementation channel authenticators
+// may also establish SSL connection. Each instance of this interface
+// should be used only once for one channel.
+class ChannelAuthenticator {
public:
- enum Result {
- SUCCESS,
- FAILURE,
- };
-
- typedef base::Callback<void(Result)> DoneCallback;
-
- ChannelAuthenticator() { }
- virtual ~ChannelAuthenticator() { }
-
- // Starts authentication of the |socket|. |done_callback| is called
- // when authentication is finished. Caller retains ownership of
- // |socket|. |shared_secret| is a shared secret that we use to
- // authenticate the channel.
- virtual void Authenticate(net::SSLSocket* socket,
- const DoneCallback& done_callback) = 0;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ChannelAuthenticator);
-};
-
-class HostChannelAuthenticator : public ChannelAuthenticator {
- public:
- HostChannelAuthenticator(const std::string& shared_secret);
- virtual ~HostChannelAuthenticator();
-
- // ChannelAuthenticator overrides.
- virtual void Authenticate(net::SSLSocket* socket,
- const DoneCallback& done_callback) OVERRIDE;
-
- private:
- void DoAuthRead();
- void OnAuthBytesRead(int result);
- bool HandleAuthBytesRead(int result);
- bool VerifyAuthBytes(const std::string& received_auth_bytes);
-
- std::string shared_secret_;
- std::string auth_bytes_;
- net::SSLSocket* socket_;
- DoneCallback done_callback_;
-
- scoped_refptr<net::GrowableIOBuffer> auth_read_buf_;
-
- net::OldCompletionCallbackImpl<HostChannelAuthenticator> auth_read_callback_;
-
- DISALLOW_COPY_AND_ASSIGN(HostChannelAuthenticator);
-};
-
-class ClientChannelAuthenticator : public ChannelAuthenticator {
- public:
- ClientChannelAuthenticator(const std::string& shared_secret);
- virtual ~ClientChannelAuthenticator();
-
- // ChannelAuthenticator overrides.
- virtual void Authenticate(net::SSLSocket* socket,
- const DoneCallback& done_callback) OVERRIDE;
-
- private:
- void DoAuthWrite();
- void OnAuthBytesWritten(int result);
- bool HandleAuthBytesWritten(int result);
-
- std::string shared_secret_;
- net::SSLSocket* socket_;
- DoneCallback done_callback_;
-
- scoped_refptr<net::DrainableIOBuffer> auth_write_buf_;
-
- net::OldCompletionCallbackImpl<ClientChannelAuthenticator>
- auth_write_callback_;
-
- DISALLOW_COPY_AND_ASSIGN(ClientChannelAuthenticator);
+ typedef base::Callback<void(net::Error error, net::StreamSocket*)>
+ DoneCallback;
+
+ virtual ~ChannelAuthenticator() {}
+
+ // Start authentication of the given |socket|. Takes ownership of
+ // |socket|, and caller must not use |socket| after calling this
+ // method. |done_callback| is called when authentication is
+ // finished. Callback may be invoked before this method
+ // returns. Callback handler must take ownership of the result.
+ virtual void SecureAndAuthenticate(
+ net::StreamSocket* socket, const DoneCallback& done_callback) = 0;
};
} // namespace protocol