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

Unified 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: Reviewer comments 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 side-by-side diff with in-line comments
Download patch
Index: remoting/protocol/third_party_authenticator_base.cc
diff --git a/remoting/protocol/third_party_authenticator_base.cc b/remoting/protocol/third_party_authenticator_base.cc
new file mode 100644
index 0000000000000000000000000000000000000000..83084cc50bd1e930b837133d1f5b1721b6f07261
--- /dev/null
+++ b/remoting/protocol/third_party_authenticator_base.cc
@@ -0,0 +1,92 @@
+// Copyright 2013 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.
+
+#include "remoting/protocol/third_party_authenticator_base.h"
+
+#include "base/base64.h"
+#include "base/bind.h"
+#include "base/callback.h"
+#include "base/logging.h"
+#include "remoting/base/constants.h"
+#include "remoting/base/rsa_key_pair.h"
+#include "remoting/protocol/channel_authenticator.h"
+#include "remoting/protocol/v2_authenticator.h"
+#include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
+
+namespace remoting {
+namespace protocol {
+
+// static
+const buzz::StaticQName ThirdPartyAuthenticatorBase::kTokenUrlTag =
+ { remoting::kChromotingXmlNamespace, "third-party-token-url" };
+const buzz::StaticQName ThirdPartyAuthenticatorBase::kTokenScopeTag =
+ { remoting::kChromotingXmlNamespace, "third-party-token-scope" };
+const buzz::StaticQName ThirdPartyAuthenticatorBase::kTokenTag =
+ { remoting::kChromotingXmlNamespace, "third-party-token" };
+
+ThirdPartyAuthenticatorBase::ThirdPartyAuthenticatorBase(
+ Authenticator::State initial_state)
+ : token_state_(initial_state),
+ rejection_reason_(INVALID_CREDENTIALS) {
+}
+
+ThirdPartyAuthenticatorBase::~ThirdPartyAuthenticatorBase() {
+}
+
+Authenticator::State ThirdPartyAuthenticatorBase::state() const {
+ if (token_state_ == ACCEPTED) {
Wez 2013/03/22 06:17:01 nit: no need for {}
rmsousa 2013/03/22 21:19:05 Done.
+ return underlying_->state();
+ }
+ return token_state_;
+}
+
+Authenticator::RejectionReason
+ThirdPartyAuthenticatorBase::rejection_reason() const {
+ DCHECK_EQ(state(), REJECTED);
+
+ if (token_state_ == REJECTED) {
Wez 2013/03/22 06:17:01 nit: no need for {}
rmsousa 2013/03/22 21:19:05 Done.
+ return rejection_reason_;
+ }
+ return underlying_->rejection_reason();
+}
+
+void ThirdPartyAuthenticatorBase::ProcessMessage(
+ const buzz::XmlElement* message,
+ const base::Closure& resume_callback) {
+ DCHECK_EQ(state(), WAITING_MESSAGE);
+
+ if (token_state_ == WAITING_MESSAGE) {
+ ProcessTokenMessage(message, resume_callback);
+ } else {
+ 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.
+ DCHECK(underlying_);
+ DCHECK(underlying_->state() == WAITING_MESSAGE);
Wez 2013/03/22 06:17:01 nit: DCHECK_EQ
rmsousa 2013/03/22 21:19:05 Done.
+ underlying_->ProcessMessage(message, resume_callback);
+ }
+}
+
+scoped_ptr<buzz::XmlElement> ThirdPartyAuthenticatorBase::GetNextMessage() {
+ DCHECK_EQ(state(), MESSAGE_READY);
+
+ scoped_ptr<buzz::XmlElement> message;
+ if (underlying_ && underlying_->state() == MESSAGE_READY) {
+ message = underlying_->GetNextMessage().Pass();
+ } else {
+ message = CreateEmptyAuthenticatorMessage();
+ }
+ 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.
+ AddTokenElements(message.get());
+ }
+ return message.Pass();
+}
+
+scoped_ptr<ChannelAuthenticator>
+ThirdPartyAuthenticatorBase::CreateChannelAuthenticator() const {
+ DCHECK_EQ(state(), ACCEPTED);
+
+ return underlying_->CreateChannelAuthenticator();
+}
+
+} // namespace protocol
+} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698