OLD | NEW |
---|---|
(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 = | |
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 : token_state_(initial_state), | |
31 rejection_reason_(INVALID_CREDENTIALS) { | |
32 } | |
33 | |
34 ThirdPartyAuthenticatorBase::~ThirdPartyAuthenticatorBase() { | |
35 } | |
36 | |
37 Authenticator::State ThirdPartyAuthenticatorBase::state() const { | |
38 if (token_state_ == ACCEPTED) { | |
Wez
2013/03/22 06:17:01
nit: no need for {}
rmsousa
2013/03/22 21:19:05
Done.
| |
39 return underlying_->state(); | |
40 } | |
41 return token_state_; | |
42 } | |
43 | |
44 Authenticator::RejectionReason | |
45 ThirdPartyAuthenticatorBase::rejection_reason() const { | |
46 DCHECK_EQ(state(), REJECTED); | |
47 | |
48 if (token_state_ == REJECTED) { | |
Wez
2013/03/22 06:17:01
nit: no need for {}
rmsousa
2013/03/22 21:19:05
Done.
| |
49 return rejection_reason_; | |
50 } | |
51 return underlying_->rejection_reason(); | |
52 } | |
53 | |
54 void ThirdPartyAuthenticatorBase::ProcessMessage( | |
55 const buzz::XmlElement* message, | |
56 const base::Closure& resume_callback) { | |
57 DCHECK_EQ(state(), WAITING_MESSAGE); | |
58 | |
59 if (token_state_ == WAITING_MESSAGE) { | |
60 ProcessTokenMessage(message, resume_callback); | |
61 } else { | |
62 DCHECK(token_state_ == ACCEPTED); | |
Sergey Ulanov
2013/03/22 05:58:43
DCHECK_EQ, here and below
Wez
2013/03/22 06:17:01
nit DCHECK_EQ
rmsousa
2013/03/22 21:19:05
Done.
rmsousa
2013/03/22 21:19:05
Done.
| |
63 DCHECK(underlying_); | |
64 DCHECK(underlying_->state() == WAITING_MESSAGE); | |
Wez
2013/03/22 06:17:01
nit: DCHECK_EQ
rmsousa
2013/03/22 21:19:05
Done.
| |
65 underlying_->ProcessMessage(message, resume_callback); | |
66 } | |
67 } | |
68 | |
69 scoped_ptr<buzz::XmlElement> ThirdPartyAuthenticatorBase::GetNextMessage() { | |
70 DCHECK_EQ(state(), MESSAGE_READY); | |
71 | |
72 scoped_ptr<buzz::XmlElement> message; | |
73 if (underlying_ && underlying_->state() == MESSAGE_READY) { | |
74 message = underlying_->GetNextMessage().Pass(); | |
75 } else { | |
76 message = CreateEmptyAuthenticatorMessage(); | |
77 } | |
78 if (token_state_ == MESSAGE_READY) { | |
Wez
2013/03/22 06:17:01
nit: no need for {
Wez
2013/03/22 06:17:01
nit: blank lines before and after this if block to
rmsousa
2013/03/22 21:19:05
Done.
rmsousa
2013/03/22 21:19:05
Done.
| |
79 AddTokenElements(message.get()); | |
80 } | |
81 return message.Pass(); | |
82 } | |
83 | |
84 scoped_ptr<ChannelAuthenticator> | |
85 ThirdPartyAuthenticatorBase::CreateChannelAuthenticator() const { | |
86 DCHECK_EQ(state(), ACCEPTED); | |
87 | |
88 return underlying_->CreateChannelAuthenticator(); | |
89 } | |
90 | |
91 } // namespace protocol | |
92 } // namespace remoting | |
OLD | NEW |