summaryrefslogtreecommitdiffstats
path: root/remoting/protocol/v1_authenticator.h
blob: aceafe652e31a24ccd80358d3b3990205bd0d378 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright (c) 2012 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_V1_AUTHENTICATOR_H_
#define REMOTING_PROTOCOL_V1_AUTHENTICATOR_H_

#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "remoting/protocol/authenticator.h"

namespace crypto {
class RSAPrivateKey;
}  // namespace base

namespace remoting {
namespace protocol {

class V1ClientAuthenticator : public Authenticator {
 public:
  V1ClientAuthenticator(const std::string& local_jid,
                        const std::string& shared_secret);
  virtual ~V1ClientAuthenticator();

  // Authenticator interface.
  virtual State state() const OVERRIDE;
  virtual RejectionReason rejection_reason() const OVERRIDE;
  virtual void ProcessMessage(const buzz::XmlElement* message) OVERRIDE;
  virtual scoped_ptr<buzz::XmlElement> GetNextMessage() OVERRIDE;
  virtual scoped_ptr<ChannelAuthenticator>
      CreateChannelAuthenticator() const OVERRIDE;

 private:
  std::string local_jid_;
  std::string shared_secret_;
  std::string remote_cert_;
  State state_;
  RejectionReason rejection_reason_;

  DISALLOW_COPY_AND_ASSIGN(V1ClientAuthenticator);
};

class V1HostAuthenticator : public Authenticator {
 public:
  // Doesn't take ownership of |local_private_key|.
  V1HostAuthenticator(const std::string& local_cert,
                      const crypto::RSAPrivateKey& local_private_key,
                      const std::string& shared_secret,
                      const std::string& remote_jid);
  virtual ~V1HostAuthenticator();

  // Authenticator interface.
  virtual State state() const OVERRIDE;
  virtual RejectionReason rejection_reason() const OVERRIDE;
  virtual void ProcessMessage(const buzz::XmlElement* message) OVERRIDE;
  virtual scoped_ptr<buzz::XmlElement> GetNextMessage() OVERRIDE;
  virtual scoped_ptr<ChannelAuthenticator>
      CreateChannelAuthenticator() const OVERRIDE;

 private:
  std::string local_cert_;
  scoped_ptr<crypto::RSAPrivateKey> local_private_key_;
  std::string shared_secret_;
  std::string remote_jid_;
  State state_;
  RejectionReason rejection_reason_;

  DISALLOW_COPY_AND_ASSIGN(V1HostAuthenticator);
};

}  // namespace protocol
}  // namespace remoting

#endif  // REMOTING_PROTOCOL_V1_AUTHENTICATOR_H_