| 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_client_authenticator.h" | 5 #include "remoting/protocol/third_party_client_authenticator.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "remoting/base/constants.h" | 13 #include "remoting/base/constants.h" |
| 14 #include "remoting/base/rsa_key_pair.h" | 14 #include "remoting/base/rsa_key_pair.h" |
| 15 #include "remoting/protocol/channel_authenticator.h" | 15 #include "remoting/protocol/channel_authenticator.h" |
| 16 #include "remoting/protocol/v2_authenticator.h" | |
| 17 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" | 16 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" |
| 18 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 19 | 18 |
| 20 namespace remoting { | 19 namespace remoting { |
| 21 namespace protocol { | 20 namespace protocol { |
| 22 | 21 |
| 23 ThirdPartyClientAuthenticator::ThirdPartyClientAuthenticator( | 22 ThirdPartyClientAuthenticator::ThirdPartyClientAuthenticator( |
| 23 const CreateBaseAuthenticatorCallback& create_base_authenticator_callback, |
| 24 scoped_ptr<TokenFetcher> token_fetcher) | 24 scoped_ptr<TokenFetcher> token_fetcher) |
| 25 : ThirdPartyAuthenticatorBase(WAITING_MESSAGE), | 25 : ThirdPartyAuthenticatorBase(WAITING_MESSAGE), |
| 26 token_fetcher_(std::move(token_fetcher)) { | 26 create_base_authenticator_callback_(create_base_authenticator_callback), |
| 27 } | 27 token_fetcher_(std::move(token_fetcher)) {} |
| 28 | 28 |
| 29 ThirdPartyClientAuthenticator::~ThirdPartyClientAuthenticator() { | 29 ThirdPartyClientAuthenticator::~ThirdPartyClientAuthenticator() {} |
| 30 } | |
| 31 | 30 |
| 32 void ThirdPartyClientAuthenticator::ProcessTokenMessage( | 31 void ThirdPartyClientAuthenticator::ProcessTokenMessage( |
| 33 const buzz::XmlElement* message, | 32 const buzz::XmlElement* message, |
| 34 const base::Closure& resume_callback) { | 33 const base::Closure& resume_callback) { |
| 35 std::string token_url = message->TextNamed(kTokenUrlTag); | 34 std::string token_url = message->TextNamed(kTokenUrlTag); |
| 36 std::string token_scope = message->TextNamed(kTokenScopeTag); | 35 std::string token_scope = message->TextNamed(kTokenScopeTag); |
| 37 | 36 |
| 38 if (token_url.empty() || token_scope.empty()) { | 37 if (token_url.empty() || token_scope.empty()) { |
| 39 LOG(ERROR) << "Third-party authentication protocol error: " | 38 LOG(ERROR) << "Third-party authentication protocol error: " |
| 40 "missing token verification URL or scope."; | 39 "missing token verification URL or scope."; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 67 void ThirdPartyClientAuthenticator::OnThirdPartyTokenFetched( | 66 void ThirdPartyClientAuthenticator::OnThirdPartyTokenFetched( |
| 68 const base::Closure& resume_callback, | 67 const base::Closure& resume_callback, |
| 69 const std::string& third_party_token, | 68 const std::string& third_party_token, |
| 70 const std::string& shared_secret) { | 69 const std::string& shared_secret) { |
| 71 token_ = third_party_token; | 70 token_ = third_party_token; |
| 72 if (token_.empty() || shared_secret.empty()) { | 71 if (token_.empty() || shared_secret.empty()) { |
| 73 token_state_ = REJECTED; | 72 token_state_ = REJECTED; |
| 74 rejection_reason_ = INVALID_CREDENTIALS; | 73 rejection_reason_ = INVALID_CREDENTIALS; |
| 75 } else { | 74 } else { |
| 76 token_state_ = MESSAGE_READY; | 75 token_state_ = MESSAGE_READY; |
| 77 underlying_ = V2Authenticator::CreateForClient( | 76 underlying_ = |
| 78 shared_secret, MESSAGE_READY); | 77 create_base_authenticator_callback_.Run(shared_secret, MESSAGE_READY); |
| 79 } | 78 } |
| 80 resume_callback.Run(); | 79 resume_callback.Run(); |
| 81 } | 80 } |
| 82 | 81 |
| 83 } // namespace protocol | 82 } // namespace protocol |
| 84 } // namespace remoting | 83 } // namespace remoting |
| OLD | NEW |