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

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

Issue 12326090: Third Party authentication protocol. (Closed) Base URL: http://git.chromium.org/chromium/src.git@host_key_pair
Patch Set: Split authenticator into base, client, host 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/third_party_authenticator_base.h"
6
7 #include "base/base64.h"
8 #include "base/bind.h"
9 #include "base/callback.h"
10 #include "base/logging.h"
11 #include "remoting/base/constants.h"
12 #include "remoting/base/rsa_key_pair.h"
13 #include "remoting/protocol/channel_authenticator.h"
14 #include "remoting/protocol/v2_authenticator.h"
15 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
16
17 namespace remoting {
18 namespace protocol {
19
20 // static
21 const buzz::StaticQName ThirdPartyAuthenticatorBase::kTokenUrlTag = {
Sergey Ulanov 2013/03/07 21:20:41 nit: it's more readable if you move { to the next
rmsousa 2013/03/20 01:30:16 Done.
22 remoting::kChromotingXmlNamespace, "third-party-token-url" };
23 const buzz::StaticQName ThirdPartyAuthenticatorBase::kTokenScopeTag = {
24 remoting::kChromotingXmlNamespace, "third-party-token-scope" };
25 const buzz::StaticQName ThirdPartyAuthenticatorBase::kTokenTag = {
26 remoting::kChromotingXmlNamespace, "third-party-token" };
27
28 ThirdPartyAuthenticatorBase::ThirdPartyAuthenticatorBase(
29 Authenticator::State initial_state)
30 : state_(initial_state),
31 rejection_reason_(INVALID_CREDENTIALS) {
32 }
33
34 ThirdPartyAuthenticatorBase::~ThirdPartyAuthenticatorBase() {
35 }
36
37 Authenticator::State ThirdPartyAuthenticatorBase::state() const {
38 if (state_ == ACCEPTED) {
39 return underlying_->state();
40 }
41 return state_;
42 }
43
44 Authenticator::RejectionReason ThirdPartyAuthenticatorBase::rejection_reason()
45 const {
Sergey Ulanov 2013/03/07 21:20:41 nit: const must be next to closing bracket. Better
rmsousa 2013/03/20 01:30:16 Done.
46 DCHECK_EQ(state(), REJECTED);
47
48 if (state_ == REJECTED) {
49 return rejection_reason_;
50 } else {
51 return underlying_->rejection_reason();
Sergey Ulanov 2013/03/07 21:20:41 Are we sure underlying_ exists here? Shouldn't thi
rmsousa 2013/03/20 01:30:16 This can only be called when state() is REJECTED.
52 }
53 }
54
55 void ThirdPartyAuthenticatorBase::ProcessMessage(
56 const buzz::XmlElement* message,
57 const base::Closure& resume_callback) {
58 DCHECK_EQ(state(), WAITING_MESSAGE);
59
60 if (state_ == WAITING_MESSAGE) {
61 ProcessMessageInternal(message, resume_callback);
62 } else {
63 DCHECK(state_ == ACCEPTED);
64 DCHECK(underlying_);
65 DCHECK(underlying_->state() == WAITING_MESSAGE);
66 underlying_->ProcessMessage(message, resume_callback);
67 }
68 }
69
70 scoped_ptr<buzz::XmlElement> ThirdPartyAuthenticatorBase::GetNextMessage() {
71 DCHECK_EQ(state(), MESSAGE_READY);
72
73 scoped_ptr<buzz::XmlElement> message;
74 if (underlying_ && underlying_->state() == MESSAGE_READY) {
75 message = underlying_->GetNextMessage().Pass();
76 } else {
77 message = CreateEmptyAuthenticatorMessage();
78 }
79 GetNextMessageInternal(message.get());
Sergey Ulanov 2013/03/07 21:20:41 Why do we need to call this for messages that we g
rmsousa 2013/03/20 01:30:16 This adds the token related fields to the message.
80 return message.Pass();
81 }
82
83 scoped_ptr<ChannelAuthenticator>
84 ThirdPartyAuthenticatorBase::CreateChannelAuthenticator() const {
85 DCHECK_EQ(state(), ACCEPTED);
86
87 return underlying_->CreateChannelAuthenticator();
88 }
89
90 } // namespace protocol
91 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698