Chromium Code Reviews| 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_AUTHENTICATOR_H_ | |
| 6 #define REMOTING_PROTOCOL_AUTHENTICATOR_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 namespace buzz { | |
| 11 class XmlElement; | |
| 12 } // namespace buzz | |
| 13 | |
| 14 namespace remoting { | |
| 15 namespace protocol { | |
| 16 | |
| 17 // Authenticator is an abstract interface for authentication protocol | |
| 18 // implementations. The same interface is used on both ends of the | |
| 19 // connection, but it may be implemented differently on each side of | |
| 20 // 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.
| |
| 21 // | |
| 22 // 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.
| |
| 23 // messages before session is authenticated. Each message | |
| 24 // sent/received by an Authenticator is delivered either in a session | |
| 25 // description inside session-initiate and session-accept messages or | |
| 26 // 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.
| |
| 27 class Authenticator { | |
| 28 public: | |
| 29 // Allowed state transitions: | |
| 30 // When ProcessMessage() is called: | |
| 31 // WAITING_MESSAGE -> MESSAGE_READY | |
| 32 // WAITING_MESSAGE -> ACCEPTED | |
| 33 // WAITING_MESSAGE -> REJECTED | |
| 34 // When GetNextMessage() is called: | |
| 35 // MESSAGE_READY -> WAITING_MESSAGE | |
| 36 // MESSAGE_READY -> ACCEPTED | |
| 37 // MESSAGE_READY -> REJECTED | |
| 38 enum State { | |
| 39 // Waiting for the next message from the peer. | |
| 40 WAITING_MESSAGE, | |
| 41 | |
| 42 // Next message is ready to be sent to the peer. | |
| 43 MESSAGE_READY, | |
| 44 | |
| 45 // Session is authenticated successufully. | |
| 46 ACCEPTED, | |
| 47 | |
| 48 // Session is rejected. | |
| 49 REJECTED, | |
| 50 }; | |
| 51 | |
| 52 Authenticator() {} | |
| 53 virtual ~Authenticator() {} | |
| 54 | |
| 55 // Returns current state of the authenticator. | |
| 56 virtual State state() const = 0; | |
| 57 | |
| 58 // Called in response to incoming message received from the peer. | |
| 59 // Should only be called when in WAITING_MESSAGE state. | |
| 60 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
| |
| 61 | |
| 62 // Must be called when in MESSAGE_READY state. Returns next | |
| 63 // authentication message that needs to be sent to the peer. | |
| 64 virtual talk_base::XmlElement* GetNextMessage() = 0; | |
| 65 | |
| 66 // Following methods can be called only in the ACCEPTED state. | |
| 67 | |
| 68 // Returns local SSL certificate that should be used for the | |
| 69 // session. Can return empty on the client side if client cert | |
| 70 // should not be used. | |
| 71 virtual std::string GetLocalCert() const = 0; | |
| 72 | |
| 73 // Returns remote SSL certificate that should be used for the | |
| 74 // session. Can return empty on the host side if client cert | |
| 75 // should not be used. | |
| 76 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.
| |
| 77 | |
| 78 // Returns shared secret used to verify channels. | |
| 79 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
| |
| 80 }; | |
| 81 | |
| 82 // Factory for Authenticator instances. | |
| 83 class AuthenticatorFactory { | |
| 84 // Called when session-initiate stanza is received to create | |
| 85 // 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.
| |
| 86 // authentication part of the session-initiate stanza so that | |
| 87 // 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.
| |
| 88 // (useful when multiple authenticators is supported). Returns NULL | |
| 89 // if the |first_message| is invalid and the session should be | |
| 90 // rejected. ProcessMessage() should be called with |first_message| | |
| 91 // 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.
| |
| 92 virtual Authenticator* CreateAuthenticator( | |
| 93 const talk_base::XmlElement* first_message) = 0; | |
| 94 }; | |
| 95 | |
| 96 } // namespace protocol | |
| 97 } // namespace remoting | |
| 98 | |
| 99 #endif // REMOTING_PROTOCOL_AUTHENTICATOR_H_ | |
| OLD | NEW |