Index: remoting/protocol/authenticator.h |
diff --git a/remoting/protocol/authenticator.h b/remoting/protocol/authenticator.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3e06c06ecc9fe7ac654b61949715dab385ae4538 |
--- /dev/null |
+++ b/remoting/protocol/authenticator.h |
@@ -0,0 +1,99 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef REMOTING_PROTOCOL_AUTHENTICATOR_H_ |
+#define REMOTING_PROTOCOL_AUTHENTICATOR_H_ |
+ |
+#include <string> |
+ |
+namespace buzz { |
+class XmlElement; |
+} // namespace buzz |
+ |
+namespace remoting { |
+namespace protocol { |
+ |
+// Authenticator is an abstract interface for authentication protocol |
+// implementations. The same interface is used on both ends of the |
+// connection, but it may be implemented differently on each side of |
+// the connection. |
Wez
2011/11/10 02:26:59
I don't think the second sentence is necessary.
Y
Sergey Ulanov
2011/11/10 23:17:47
Done.
|
+// |
+// Authenticator instances on connection ends may exchange multiple |
Wez
2011/11/10 02:26:59
reword: Authenticators may exchange...
Sergey Ulanov
2011/11/10 23:17:47
Done.
|
+// messages before session is authenticated. Each message |
+// sent/received by an Authenticator is delivered either in a session |
+// description inside session-initiate and session-accept messages or |
+// in a session-info message. |
Wez
2011/11/10 02:26:59
Explain why it is that some of the exchange uses o
Sergey Ulanov
2011/11/10 23:17:47
Done.
|
+class Authenticator { |
+ public: |
+ // Allowed state transitions: |
+ // When ProcessMessage() is called: |
+ // WAITING_MESSAGE -> MESSAGE_READY |
+ // WAITING_MESSAGE -> ACCEPTED |
+ // WAITING_MESSAGE -> REJECTED |
+ // When GetNextMessage() is called: |
+ // MESSAGE_READY -> WAITING_MESSAGE |
+ // MESSAGE_READY -> ACCEPTED |
+ // MESSAGE_READY -> REJECTED |
+ enum State { |
+ // Waiting for the next message from the peer. |
+ WAITING_MESSAGE, |
+ |
+ // Next message is ready to be sent to the peer. |
+ MESSAGE_READY, |
+ |
+ // Session is authenticated successufully. |
+ ACCEPTED, |
+ |
+ // Session is rejected. |
+ REJECTED, |
+ }; |
+ |
+ Authenticator() {} |
+ virtual ~Authenticator() {} |
+ |
+ // Returns current state of the authenticator. |
+ virtual State state() const = 0; |
+ |
+ // Called in response to incoming message received from the peer. |
+ // Should only be called when in WAITING_MESSAGE state. |
+ virtual State ProcessMessage(talk_base::XmlElement* message) = 0; |
Wez
2011/11/11 22:12:00
For the existing IT2Me authentication scheme, we k
Sergey Ulanov
2011/11/12 00:12:49
I don't think there is a problem for the existing
Wez
2011/11/12 00:25:36
Not sure I understand the last comment; do you mea
|
+ |
+ // Must be called when in MESSAGE_READY state. Returns next |
+ // authentication message that needs to be sent to the peer. |
+ virtual talk_base::XmlElement* GetNextMessage() = 0; |
+ |
+ // Following methods can be called only in the ACCEPTED state. |
+ |
+ // Returns local SSL certificate that should be used for the |
+ // session. Can return empty on the client side if client cert |
+ // should not be used. |
+ virtual std::string GetLocalCert() const = 0; |
+ |
+ // Returns remote SSL certificate that should be used for the |
+ // session. Can return empty on the host side if client cert |
+ // should not be used. |
+ virtual std::string GetPeerCert() const = 0; |
Wez
2011/11/10 02:26:59
Do we need GetLocalCert and GetPeerCert? Isn't ce
Sergey Ulanov
2011/11/10 23:17:47
GetPeerCert() and GetLocalCert() return certs that
Wez
2011/11/11 01:17:42
Let's discuss this offline; I think it's important
Sergey Ulanov
2011/11/11 19:16:41
Removed these methods for now.
|
+ |
+ // Returns shared secret used to verify channels. |
+ virtual std::string GetSharedSecret() const = 0; |
Sergey Ulanov
2011/11/10 00:12:51
Alternatively we can return ChannelAuthenticator h
Wez
2011/11/10 02:26:59
We'll need to be able to return different kinds of
Sergey Ulanov
2011/11/10 23:17:47
Ok I've replaced it with CreateChannelAuthenticato
|
+}; |
+ |
+// Factory for Authenticator instances. |
+class AuthenticatorFactory { |
+ // Called when session-initiate stanza is received to create |
+ // authenticator for the new session. |first_message| specified |
Wez
2011/11/10 02:26:59
typo: specified -> specifies (or "provides")
Sergey Ulanov
2011/11/10 23:17:47
Done.
|
+ // authentication part of the session-initiate stanza so that |
+ // appropriate type of Authenticator can be choosed for the session |
Wez
2011/11/10 02:26:59
typo: choosed -> chosen
Sergey Ulanov
2011/11/10 23:17:47
Done.
|
+ // (useful when multiple authenticators is supported). Returns NULL |
+ // if the |first_message| is invalid and the session should be |
+ // rejected. ProcessMessage() should be called with |first_message| |
+ // for the result of this method. |
Wez
2011/11/10 02:26:59
Although the last line makes sense, it's an implem
Sergey Ulanov
2011/11/10 23:17:47
The idea is that the caller must call ProcessMessa
Wez
2011/11/11 01:17:42
Yes, making it clearer would be good! My reading
Sergey Ulanov
2011/11/11 19:16:41
It's used to determine what type of authenticator
Wez
2011/11/11 22:12:00
So is the purpose of your comment to say that even
Sergey Ulanov
2011/11/12 00:12:49
Yes.
|
+ virtual Authenticator* CreateAuthenticator( |
+ const talk_base::XmlElement* first_message) = 0; |
+}; |
+ |
+} // namespace protocol |
+} // namespace remoting |
+ |
+#endif // REMOTING_PROTOCOL_AUTHENTICATOR_H_ |