| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/protocol/third_party_authenticator_base.h" | 5 #include "remoting/protocol/third_party_authenticator_base.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 const buzz::StaticQName ThirdPartyAuthenticatorBase::kTokenUrlTag = | 21 const buzz::StaticQName ThirdPartyAuthenticatorBase::kTokenUrlTag = |
| 22 { remoting::kChromotingXmlNamespace, "third-party-token-url" }; | 22 { remoting::kChromotingXmlNamespace, "third-party-token-url" }; |
| 23 const buzz::StaticQName ThirdPartyAuthenticatorBase::kTokenScopeTag = | 23 const buzz::StaticQName ThirdPartyAuthenticatorBase::kTokenScopeTag = |
| 24 { remoting::kChromotingXmlNamespace, "third-party-token-scope" }; | 24 { remoting::kChromotingXmlNamespace, "third-party-token-scope" }; |
| 25 const buzz::StaticQName ThirdPartyAuthenticatorBase::kTokenTag = | 25 const buzz::StaticQName ThirdPartyAuthenticatorBase::kTokenTag = |
| 26 { remoting::kChromotingXmlNamespace, "third-party-token" }; | 26 { remoting::kChromotingXmlNamespace, "third-party-token" }; |
| 27 | 27 |
| 28 ThirdPartyAuthenticatorBase::ThirdPartyAuthenticatorBase( | 28 ThirdPartyAuthenticatorBase::ThirdPartyAuthenticatorBase( |
| 29 Authenticator::State initial_state) | 29 Authenticator::State initial_state) |
| 30 : token_state_(initial_state), | 30 : token_state_(initial_state), |
| 31 started_(false), |
| 31 rejection_reason_(INVALID_CREDENTIALS) { | 32 rejection_reason_(INVALID_CREDENTIALS) { |
| 32 } | 33 } |
| 33 | 34 |
| 34 ThirdPartyAuthenticatorBase::~ThirdPartyAuthenticatorBase() { | 35 ThirdPartyAuthenticatorBase::~ThirdPartyAuthenticatorBase() { |
| 35 } | 36 } |
| 36 | 37 |
| 38 bool ThirdPartyAuthenticatorBase::started() const { |
| 39 return started_; |
| 40 } |
| 41 |
| 37 Authenticator::State ThirdPartyAuthenticatorBase::state() const { | 42 Authenticator::State ThirdPartyAuthenticatorBase::state() const { |
| 38 if (token_state_ == ACCEPTED) | 43 if (token_state_ == ACCEPTED) |
| 39 return underlying_->state(); | 44 return underlying_->state(); |
| 40 return token_state_; | 45 return token_state_; |
| 41 } | 46 } |
| 42 | 47 |
| 43 Authenticator::RejectionReason | 48 Authenticator::RejectionReason |
| 44 ThirdPartyAuthenticatorBase::rejection_reason() const { | 49 ThirdPartyAuthenticatorBase::rejection_reason() const { |
| 45 DCHECK_EQ(state(), REJECTED); | 50 DCHECK_EQ(state(), REJECTED); |
| 46 | 51 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 67 scoped_ptr<buzz::XmlElement> ThirdPartyAuthenticatorBase::GetNextMessage() { | 72 scoped_ptr<buzz::XmlElement> ThirdPartyAuthenticatorBase::GetNextMessage() { |
| 68 DCHECK_EQ(state(), MESSAGE_READY); | 73 DCHECK_EQ(state(), MESSAGE_READY); |
| 69 | 74 |
| 70 scoped_ptr<buzz::XmlElement> message; | 75 scoped_ptr<buzz::XmlElement> message; |
| 71 if (underlying_ && underlying_->state() == MESSAGE_READY) { | 76 if (underlying_ && underlying_->state() == MESSAGE_READY) { |
| 72 message = underlying_->GetNextMessage().Pass(); | 77 message = underlying_->GetNextMessage().Pass(); |
| 73 } else { | 78 } else { |
| 74 message = CreateEmptyAuthenticatorMessage(); | 79 message = CreateEmptyAuthenticatorMessage(); |
| 75 } | 80 } |
| 76 | 81 |
| 77 if (token_state_ == MESSAGE_READY) | 82 if (token_state_ == MESSAGE_READY) { |
| 78 AddTokenElements(message.get()); | 83 AddTokenElements(message.get()); |
| 79 | 84 started_ = true; |
| 85 } |
| 80 return message.Pass(); | 86 return message.Pass(); |
| 81 } | 87 } |
| 82 | 88 |
| 83 scoped_ptr<ChannelAuthenticator> | 89 scoped_ptr<ChannelAuthenticator> |
| 84 ThirdPartyAuthenticatorBase::CreateChannelAuthenticator() const { | 90 ThirdPartyAuthenticatorBase::CreateChannelAuthenticator() const { |
| 85 DCHECK_EQ(state(), ACCEPTED); | 91 DCHECK_EQ(state(), ACCEPTED); |
| 86 | 92 |
| 87 return underlying_->CreateChannelAuthenticator(); | 93 return underlying_->CreateChannelAuthenticator(); |
| 88 } | 94 } |
| 89 | 95 |
| 90 } // namespace protocol | 96 } // namespace protocol |
| 91 } // namespace remoting | 97 } // namespace remoting |
| OLD | NEW |