OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 REMOTING_PROTOCOL_NEGOTIATING_AUTHENTICATOR_H_ | 5 #ifndef REMOTING_PROTOCOL_NEGOTIATING_AUTHENTICATOR_H_ |
6 #define REMOTING_PROTOCOL_NEGOTIATING_AUTHENTICATOR_H_ | 6 #define REMOTING_PROTOCOL_NEGOTIATING_AUTHENTICATOR_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "remoting/protocol/authenticator.h" | 13 #include "remoting/protocol/authenticator.h" |
14 #include "remoting/protocol/authentication_method.h" | 14 #include "remoting/protocol/authentication_method.h" |
15 | 15 |
16 namespace crypto { | |
17 class RSAPrivateKey; | |
18 } // namespace crypto | |
19 | |
20 namespace remoting { | 16 namespace remoting { |
21 namespace protocol { | 17 namespace protocol { |
22 | 18 |
19 class KeyPair; | |
20 | |
23 class NegotiatingAuthenticator : public Authenticator { | 21 class NegotiatingAuthenticator : public Authenticator { |
24 public: | 22 public: |
25 virtual ~NegotiatingAuthenticator(); | 23 virtual ~NegotiatingAuthenticator(); |
26 | 24 |
27 static bool IsNegotiableMessage(const buzz::XmlElement* message); | 25 static bool IsNegotiableMessage(const buzz::XmlElement* message); |
28 | 26 |
27 // Creates a client authenticator for the given methods. | |
28 // |third_party_token_fetcher| must be non-null if a ThirdPartyAuth method is | |
29 // requested, and must outlive this authenticator. | |
29 static scoped_ptr<Authenticator> CreateForClient( | 30 static scoped_ptr<Authenticator> CreateForClient( |
30 const std::string& authentication_tag, | 31 const std::string& authentication_tag, |
31 const std::string& shared_secret, | 32 const std::string& shared_secret, |
32 const std::vector<AuthenticationMethod>& methods); | 33 const std::vector<AuthenticationMethod>& methods); |
33 | 34 |
35 // Creates a host authenticator, using a fixed shared secret/PIN hash. | |
34 static scoped_ptr<Authenticator> CreateForHost( | 36 static scoped_ptr<Authenticator> CreateForHost( |
35 const std::string& local_cert, | 37 const std::string& local_cert, |
36 const crypto::RSAPrivateKey& local_private_key, | 38 scoped_ptr<KeyPair> key_pair, |
37 const std::string& shared_secret_hash, | 39 const std::string& shared_secret_hash, |
38 AuthenticationMethod::HashFunction hash_function); | 40 AuthenticationMethod::HashFunction hash_function); |
39 | 41 |
40 // Authenticator interface. | 42 // Authenticator interface. |
41 virtual State state() const OVERRIDE; | 43 virtual State state() const OVERRIDE; |
42 virtual RejectionReason rejection_reason() const OVERRIDE; | 44 virtual RejectionReason rejection_reason() const OVERRIDE; |
43 virtual void ProcessMessage(const buzz::XmlElement* message) OVERRIDE; | 45 virtual void ProcessMessage(const buzz::XmlElement* message) OVERRIDE; |
44 virtual scoped_ptr<buzz::XmlElement> GetNextMessage() OVERRIDE; | 46 virtual scoped_ptr<buzz::XmlElement> GetNextMessage() OVERRIDE; |
45 virtual scoped_ptr<ChannelAuthenticator> | 47 virtual scoped_ptr<ChannelAuthenticator> |
46 CreateChannelAuthenticator() const OVERRIDE; | 48 CreateChannelAuthenticator() const OVERRIDE; |
47 | 49 |
48 private: | 50 private: |
49 NegotiatingAuthenticator(Authenticator::State initial_state); | 51 NegotiatingAuthenticator(Authenticator::State initial_state); |
50 | 52 |
51 void AddMethod(const AuthenticationMethod& method); | 53 void AddMethod(const AuthenticationMethod& method); |
52 void CreateAuthenticator(State initial_state); | 54 void CreateAuthenticator(State initial_state); |
55 | |
53 bool is_host_side() const; | 56 bool is_host_side() const; |
54 | 57 |
55 // Used only for host authenticators. | 58 // Used only for host authenticators. |
56 std::string local_cert_; | 59 std::string local_cert_; |
57 scoped_ptr<crypto::RSAPrivateKey> local_private_key_; | 60 scoped_ptr<KeyPair> key_pair_; |
58 bool certificate_sent_; | |
rmsousa
2013/02/23 00:48:51
Unused member variable
(likely stale, certificate
| |
59 std::string shared_secret_hash_; | 61 std::string shared_secret_hash_; |
60 | 62 |
61 // Used only for client authenticators. | 63 // Used only for client authenticators. |
62 std::string remote_cert_; | |
rmsousa
2013/02/23 00:48:51
Unused member variable
| |
63 std::string authentication_tag_; | 64 std::string authentication_tag_; |
64 std::string shared_secret_; | 65 std::string shared_secret_; |
65 | 66 |
66 // Used for both host and client authenticators. | 67 // Used for both host and client authenticators. |
67 std::vector<AuthenticationMethod> methods_; | 68 std::vector<AuthenticationMethod> methods_; |
68 AuthenticationMethod current_method_; | 69 AuthenticationMethod current_method_; |
69 scoped_ptr<Authenticator> current_authenticator_; | 70 scoped_ptr<Authenticator> current_authenticator_; |
70 State state_; | 71 State state_; |
71 RejectionReason rejection_reason_; | 72 RejectionReason rejection_reason_; |
72 | 73 |
73 DISALLOW_COPY_AND_ASSIGN(NegotiatingAuthenticator); | 74 DISALLOW_COPY_AND_ASSIGN(NegotiatingAuthenticator); |
74 }; | 75 }; |
75 | 76 |
76 } // namespace protocol | 77 } // namespace protocol |
77 } // namespace remoting | 78 } // namespace remoting |
78 | 79 |
79 #endif // REMOTING_PROTOCOL_NEGOTIATING_AUTHENTICATOR_H_ | 80 #endif // REMOTING_PROTOCOL_NEGOTIATING_AUTHENTICATOR_H_ |
OLD | NEW |