Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(538)

Side by Side Diff: remoting/protocol/pin_client_authenticator.cc

Issue 12518027: Protocol / client plugin changes to support interactively asking for a PIN (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2013 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 #include "remoting/protocol/pin_client_authenticator.h"
6
7 #include "base/bind.h"
8 #include "base/callback.h"
9 #include "base/logging.h"
10 #include "remoting/protocol/channel_authenticator.h"
11 #include "remoting/protocol/pin_fetcher.h"
12 #include "remoting/protocol/v2_authenticator.h"
13 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
14
15 namespace remoting {
16 namespace protocol {
17
18 PinClientAuthenticator::PinClientAuthenticator(
19 AuthenticationMethod::HashFunction hash_function,
20 const std::string& authentication_tag,
21 scoped_ptr<PinFetcher> pin_fetcher,
22 Authenticator::State initial_state,
23 const base::Closure& resume_callback)
24 : hash_function_(hash_function),
25 authentication_tag_(authentication_tag),
26 pin_fetcher_(pin_fetcher.Pass()) {
27 DCHECK(pin_fetcher_);
28 pin_fetcher_->FetchPin(base::Bind(
29 &PinClientAuthenticator::OnPinFetched,
30 base::Unretained(this), initial_state, resume_callback));
31 }
32
33 PinClientAuthenticator::~PinClientAuthenticator() {
34 }
35
36 Authenticator::State PinClientAuthenticator::state() const {
37 DCHECK(underlying_);
Sergey Ulanov 2013/03/17 21:29:21 What if this method is called before PIN is fetche
rmsousa 2013/03/18 21:07:26 That's illegal (hence the DCHECK). NegotatingAuthe
38 return underlying_->state();
39 }
40
41 Authenticator::RejectionReason
42 PinClientAuthenticator::rejection_reason() const {
43 DCHECK(underlying_);
44 DCHECK_EQ(underlying_->state(), REJECTED);
45 return underlying_->rejection_reason();
46 }
47
48 void PinClientAuthenticator::ProcessMessage(
49 const buzz::XmlElement* message, const base::Closure& resume_callback) {
50 DCHECK(underlying_);
51 underlying_->ProcessMessage(message, resume_callback);
52 }
53
54 void PinClientAuthenticator::OnPinFetched(
55 Authenticator::State initial_state,
56 const base::Closure& resume_callback,
57 const std::string& shared_secret) {
58 underlying_ = V2Authenticator::CreateForClient(
59 AuthenticationMethod::ApplyHashFunction(
60 hash_function_, authentication_tag_, shared_secret),
61 initial_state);
62 resume_callback.Run();
63 }
64
65
66 scoped_ptr<buzz::XmlElement> PinClientAuthenticator::GetNextMessage() {
67 DCHECK(underlying_);
68 DCHECK_EQ(underlying_->state(), MESSAGE_READY);
69 return underlying_->GetNextMessage();
70 }
71
72 scoped_ptr<ChannelAuthenticator>
73 PinClientAuthenticator::CreateChannelAuthenticator() const {
74 DCHECK(underlying_);
75 DCHECK_EQ(underlying_->state(), ACCEPTED);
76 return underlying_->CreateChannelAuthenticator();
77 }
78
79 } // namespace protocol
80 } // namespace remoting
81
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698