cleanup: pass string as const reference from c/b/extension
[chromium-blink-merge.git] / remoting / protocol / v2_authenticator.h
blobb52a3e165303dcb0befaaeb1161ff8cf7a7351b1
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
3 // found in the LICENSE file.
5 #ifndef REMOTING_PROTOCOL_V2_AUTHENTICATOR_H_
6 #define REMOTING_PROTOCOL_V2_AUTHENTICATOR_H_
8 #include <string>
9 #include <queue>
11 #include "base/compiler_specific.h"
12 #include "base/gtest_prod_util.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "crypto/p224_spake.h"
15 #include "remoting/protocol/authenticator.h"
17 namespace remoting {
19 class RsaKeyPair;
21 namespace protocol {
23 class V2Authenticator : public Authenticator {
24 public:
25 static bool IsEkeMessage(const buzz::XmlElement* message);
27 static scoped_ptr<Authenticator> CreateForClient(
28 const std::string& shared_secret,
29 State initial_state);
31 static scoped_ptr<Authenticator> CreateForHost(
32 const std::string& local_cert,
33 scoped_refptr<RsaKeyPair> key_pair,
34 const std::string& shared_secret,
35 State initial_state);
37 virtual ~V2Authenticator();
39 // Authenticator interface.
40 virtual State state() const OVERRIDE;
41 virtual bool started() const OVERRIDE;
42 virtual RejectionReason rejection_reason() const OVERRIDE;
43 virtual void ProcessMessage(const buzz::XmlElement* message,
44 const base::Closure& resume_callback) OVERRIDE;
45 virtual scoped_ptr<buzz::XmlElement> GetNextMessage() OVERRIDE;
46 virtual scoped_ptr<ChannelAuthenticator>
47 CreateChannelAuthenticator() const OVERRIDE;
49 private:
50 FRIEND_TEST_ALL_PREFIXES(V2AuthenticatorTest, InvalidSecret);
52 V2Authenticator(crypto::P224EncryptedKeyExchange::PeerType type,
53 const std::string& shared_secret,
54 State initial_state);
56 virtual void ProcessMessageInternal(const buzz::XmlElement* message);
58 bool is_host_side() const;
60 // Used only for host authenticators.
61 std::string local_cert_;
62 scoped_refptr<RsaKeyPair> local_key_pair_;
63 bool certificate_sent_;
65 // Used only for client authenticators.
66 std::string remote_cert_;
68 // Used for both host and client authenticators.
69 crypto::P224EncryptedKeyExchange key_exchange_impl_;
70 State state_;
71 bool started_;
72 RejectionReason rejection_reason_;
73 std::queue<std::string> pending_messages_;
74 std::string auth_key_;
76 DISALLOW_COPY_AND_ASSIGN(V2Authenticator);
79 } // namespace protocol
80 } // namespace remoting
82 #endif // REMOTING_PROTOCOL_V2_AUTHENTICATOR_H_