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

Unified Diff: remoting/protocol/jingle_session.cc

Issue 8774031: Multi-step authentication support in JingleSession. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years 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
« no previous file with comments | « remoting/protocol/jingle_session.h ('k') | remoting/protocol/jingle_session_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/jingle_session.cc
diff --git a/remoting/protocol/jingle_session.cc b/remoting/protocol/jingle_session.cc
index 0d6dc4f21ecb77fa4dfa262f461652b634a2bf75..8abada22e307f6563f067522d7986d2b36ce979b 100644
--- a/remoting/protocol/jingle_session.cc
+++ b/remoting/protocol/jingle_session.cc
@@ -45,6 +45,8 @@ JingleSession::JingleSession(
jid_ = cricket_session_->remote_name();
cricket_session_->SignalState.connect(this, &JingleSession::OnSessionState);
cricket_session_->SignalError.connect(this, &JingleSession::OnSessionError);
+ cricket_session_->SignalInfoMessage.connect(
+ this, &JingleSession::OnSessionInfoMessage);
cricket_session_->SignalReceivedTerminateReason.connect(
this, &JingleSession::OnTerminateReason);
}
@@ -246,6 +248,25 @@ void JingleSession::OnSessionError(
}
}
+void JingleSession::OnSessionInfoMessage(cricket::Session* session,
+ const buzz::XmlElement* message) {
+ DCHECK_EQ(cricket_session_,session);
+
+ const buzz::XmlElement* auth_message =
+ Authenticator::FindAuthenticatorMessage(message);
+ if (auth_message) {
+ if (state_ != CONNECTED ||
+ authenticator_->state() != Authenticator::WAITING_MESSAGE) {
+ LOG(WARNING) << "Received unexpected authenticator message "
+ << auth_message->Str();
+ return;
+ }
+
+ authenticator_->ProcessMessage(auth_message);
+ ProcessAuthenticationStep();
+ }
+}
+
void JingleSession::OnTerminateReason(cricket::Session* session,
const std::string& reason) {
terminate_reason_ = reason;
@@ -294,16 +315,10 @@ bool JingleSession::InitializeConfigFromDescription(
return false;
}
- DCHECK(authenticator_->state() == Authenticator::WAITING_MESSAGE);
+ DCHECK_EQ(authenticator_->state(), Authenticator::WAITING_MESSAGE);
authenticator_->ProcessMessage(auth_message);
- // Support for more than two auth message is not implemented yet.
- DCHECK(authenticator_->state() != Authenticator::WAITING_MESSAGE &&
- authenticator_->state() != Authenticator::MESSAGE_READY);
-
- if (authenticator_->state() != Authenticator::ACCEPTED) {
- return false;
- }
+ // Initialize session configuration.
SessionConfig config;
if (!content_description->config()->GetFinalConfig(&config)) {
LOG(ERROR) << "Connection response does not specify configuration";
@@ -333,8 +348,12 @@ void JingleSession::OnAccept() {
SetState(CONNECTED);
- if (authenticator_->state() == Authenticator::ACCEPTED)
+ // Process authentication.
+ if (authenticator_->state() == Authenticator::ACCEPTED) {
SetState(AUTHENTICATED);
+ } else {
+ ProcessAuthenticationStep();
+ }
}
void JingleSession::OnTerminate() {
@@ -398,8 +417,6 @@ void JingleSession::AcceptConnection() {
DCHECK(authenticator_->state() == Authenticator::WAITING_MESSAGE);
authenticator_->ProcessMessage(auth_message);
- // Support for more than two auth message is not implemented yet.
- DCHECK(authenticator_->state() != Authenticator::WAITING_MESSAGE);
if (authenticator_->state() == Authenticator::REJECTED) {
CloseInternal(net::ERR_CONNECTION_FAILED, AUTHENTICATION_FAILED);
return;
@@ -412,11 +429,29 @@ void JingleSession::AcceptConnection() {
buzz::XmlElement* auth_reply = NULL;
if (authenticator_->state() == Authenticator::MESSAGE_READY)
auth_reply = authenticator_->GetNextMessage();
- DCHECK_EQ(authenticator_->state(), Authenticator::ACCEPTED);
+ DCHECK_NE(authenticator_->state(), Authenticator::MESSAGE_READY);
cricket_session_->Accept(
CreateSessionDescription(candidate_config, auth_reply));
}
+void JingleSession::ProcessAuthenticationStep() {
+ DCHECK_EQ(state_, CONNECTED);
+
+ if (authenticator_->state() == Authenticator::MESSAGE_READY) {
+ buzz::XmlElement* auth_message = authenticator_->GetNextMessage();
+ cricket::XmlElements message;
+ message.push_back(auth_message);
+ cricket_session_->SendInfoMessage(message);
+ }
+ DCHECK_NE(authenticator_->state(), Authenticator::MESSAGE_READY);
+
+ if (authenticator_->state() == Authenticator::ACCEPTED) {
+ SetState(AUTHENTICATED);
+ } else if (authenticator_->state() == Authenticator::REJECTED) {
+ CloseInternal(net::ERR_CONNECTION_ABORTED, AUTHENTICATION_FAILED);
+ }
+}
+
void JingleSession::AddChannelConnector(
const std::string& name, JingleChannelConnector* connector) {
DCHECK(channel_connectors_.find(name) == channel_connectors_.end());
« no previous file with comments | « remoting/protocol/jingle_session.h ('k') | remoting/protocol/jingle_session_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698