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/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
13 #include "remoting/protocol/authenticator.h" | 14 #include "remoting/protocol/authenticator.h" |
14 #include "remoting/protocol/authentication_method.h" | 15 #include "remoting/protocol/authentication_method.h" |
15 | 16 |
16 namespace crypto { | 17 namespace remoting { |
17 class RSAPrivateKey; | |
18 } // namespace crypto | |
19 | 18 |
20 namespace remoting { | 19 class RsaKeyPair; |
| 20 |
21 namespace protocol { | 21 namespace protocol { |
22 | 22 |
23 class NegotiatingAuthenticator : public Authenticator { | 23 class NegotiatingAuthenticator : public Authenticator { |
24 public: | 24 public: |
25 virtual ~NegotiatingAuthenticator(); | 25 virtual ~NegotiatingAuthenticator(); |
26 | 26 |
27 static bool IsNegotiableMessage(const buzz::XmlElement* message); | 27 static bool IsNegotiableMessage(const buzz::XmlElement* message); |
28 | 28 |
| 29 // Creates a client authenticator for the given methods. |
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_refptr<RsaKeyPair> 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, | 45 virtual void ProcessMessage(const buzz::XmlElement* message, |
44 const base::Closure& resume_callback) OVERRIDE; | 46 const base::Closure& resume_callback) OVERRIDE; |
45 virtual scoped_ptr<buzz::XmlElement> GetNextMessage() OVERRIDE; | 47 virtual scoped_ptr<buzz::XmlElement> GetNextMessage() OVERRIDE; |
46 virtual scoped_ptr<ChannelAuthenticator> | 48 virtual scoped_ptr<ChannelAuthenticator> |
47 CreateChannelAuthenticator() const OVERRIDE; | 49 CreateChannelAuthenticator() const OVERRIDE; |
48 | 50 |
49 private: | 51 private: |
50 NegotiatingAuthenticator(Authenticator::State initial_state); | 52 NegotiatingAuthenticator(Authenticator::State initial_state); |
51 | 53 |
52 void AddMethod(const AuthenticationMethod& method); | 54 void AddMethod(const AuthenticationMethod& method); |
53 void CreateAuthenticator(State initial_state); | 55 void CreateAuthenticator(State initial_state); |
54 void UpdateState(const base::Closure& resume_callback); | 56 void UpdateState(const base::Closure& resume_callback); |
55 | 57 |
56 bool is_host_side() const; | 58 bool is_host_side() const; |
57 | 59 |
58 // Used only for host authenticators. | 60 // Used only for host authenticators. |
59 std::string local_cert_; | 61 std::string local_cert_; |
60 scoped_ptr<crypto::RSAPrivateKey> local_private_key_; | 62 scoped_refptr<RsaKeyPair> local_key_pair_; |
61 bool certificate_sent_; | |
62 std::string shared_secret_hash_; | 63 std::string shared_secret_hash_; |
63 | 64 |
64 // Used only for client authenticators. | 65 // Used only for client authenticators. |
65 std::string remote_cert_; | |
66 std::string authentication_tag_; | 66 std::string authentication_tag_; |
67 std::string shared_secret_; | 67 std::string shared_secret_; |
68 | 68 |
69 // Used for both host and client authenticators. | 69 // Used for both host and client authenticators. |
70 std::vector<AuthenticationMethod> methods_; | 70 std::vector<AuthenticationMethod> methods_; |
71 AuthenticationMethod current_method_; | 71 AuthenticationMethod current_method_; |
72 scoped_ptr<Authenticator> current_authenticator_; | 72 scoped_ptr<Authenticator> current_authenticator_; |
73 State state_; | 73 State state_; |
74 RejectionReason rejection_reason_; | 74 RejectionReason rejection_reason_; |
75 | 75 |
76 DISALLOW_COPY_AND_ASSIGN(NegotiatingAuthenticator); | 76 DISALLOW_COPY_AND_ASSIGN(NegotiatingAuthenticator); |
77 }; | 77 }; |
78 | 78 |
79 } // namespace protocol | 79 } // namespace protocol |
80 } // namespace remoting | 80 } // namespace remoting |
81 | 81 |
82 #endif // REMOTING_PROTOCOL_NEGOTIATING_AUTHENTICATOR_H_ | 82 #endif // REMOTING_PROTOCOL_NEGOTIATING_AUTHENTICATOR_H_ |
OLD | NEW |