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

Side by Side Diff: remoting/protocol/v1_authenticator.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/protocol/jingle_session_unittest.cc ('k') | remoting/remoting.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/v1_authenticator.h" 5 #include "remoting/protocol/v1_authenticator.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "crypto/rsa_private_key.h" 9 #include "crypto/rsa_private_key.h"
10 #include "remoting/base/constants.h" 10 #include "remoting/base/constants.h"
11 #include "remoting/protocol/auth_util.h" 11 #include "remoting/protocol/auth_util.h"
12 #include "remoting/protocol/v1_client_channel_authenticator.h" 12 #include "remoting/protocol/v1_client_channel_authenticator.h"
13 #include "remoting/protocol/v1_host_channel_authenticator.h" 13 #include "remoting/protocol/v1_host_channel_authenticator.h"
14 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" 14 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
15 15
16 using buzz::QName; 16 using buzz::QName;
17 using buzz::XmlElement; 17 using buzz::XmlElement;
18 18
19 namespace remoting { 19 namespace remoting {
20 namespace protocol { 20 namespace protocol {
21 21
22 namespace { 22 namespace {
23 const char kAuthenticationTag[] = "authentication";
24 const char kAuthTokenTag[] = "auth-token"; 23 const char kAuthTokenTag[] = "auth-token";
25 const char kCertificateTag[] = "certificate"; 24 const char kCertificateTag[] = "certificate";
26 } // namespace 25 } // namespace
27 26
28 V1ClientAuthenticator::V1ClientAuthenticator( 27 V1ClientAuthenticator::V1ClientAuthenticator(
29 const std::string& local_jid, 28 const std::string& local_jid,
30 const std::string& shared_secret) 29 const std::string& shared_secret)
31 : local_jid_(local_jid), 30 : local_jid_(local_jid),
32 shared_secret_(shared_secret), 31 shared_secret_(shared_secret),
33 state_(MESSAGE_READY) { 32 state_(MESSAGE_READY) {
(...skipping 23 matching lines...) Expand all
57 if (remote_cert_.empty()) { 56 if (remote_cert_.empty()) {
58 state_ = REJECTED; 57 state_ = REJECTED;
59 } else { 58 } else {
60 state_ = ACCEPTED; 59 state_ = ACCEPTED;
61 } 60 }
62 } 61 }
63 62
64 XmlElement* V1ClientAuthenticator::GetNextMessage() { 63 XmlElement* V1ClientAuthenticator::GetNextMessage() {
65 DCHECK_EQ(state_, MESSAGE_READY); 64 DCHECK_EQ(state_, MESSAGE_READY);
66 65
67 XmlElement* authentication_tag = new XmlElement( 66 XmlElement* message = CreateEmptyAuthenticatorMessage();
68 QName(kChromotingXmlNamespace, kAuthenticationTag));
69
70 std::string token = 67 std::string token =
71 protocol::GenerateSupportAuthToken(local_jid_, shared_secret_); 68 protocol::GenerateSupportAuthToken(local_jid_, shared_secret_);
72
73 XmlElement* auth_token_tag = new XmlElement( 69 XmlElement* auth_token_tag = new XmlElement(
74 QName(kChromotingXmlNamespace, kAuthTokenTag)); 70 QName(kChromotingXmlNamespace, kAuthTokenTag));
75 auth_token_tag->SetBodyText(token); 71 auth_token_tag->SetBodyText(token);
76 authentication_tag->AddElement(auth_token_tag); 72 message->AddElement(auth_token_tag);
77 73
78 state_ = WAITING_MESSAGE; 74 state_ = WAITING_MESSAGE;
79 return authentication_tag; 75 return message;
80 } 76 }
81 77
82 ChannelAuthenticator* 78 ChannelAuthenticator*
83 V1ClientAuthenticator::CreateChannelAuthenticator() const { 79 V1ClientAuthenticator::CreateChannelAuthenticator() const {
84 DCHECK_EQ(state_, ACCEPTED); 80 DCHECK_EQ(state_, ACCEPTED);
85 return new V1ClientChannelAuthenticator(remote_cert_, shared_secret_); 81 return new V1ClientChannelAuthenticator(remote_cert_, shared_secret_);
86 }; 82 };
87 83
88 V1HostAuthenticator::V1HostAuthenticator( 84 V1HostAuthenticator::V1HostAuthenticator(
89 const std::string& local_cert, 85 const std::string& local_cert,
(...skipping 24 matching lines...) Expand all
114 remote_jid_, shared_secret_, auth_token)) { 110 remote_jid_, shared_secret_, auth_token)) {
115 state_ = REJECTED; 111 state_ = REJECTED;
116 } else { 112 } else {
117 state_ = MESSAGE_READY; 113 state_ = MESSAGE_READY;
118 } 114 }
119 } 115 }
120 116
121 XmlElement* V1HostAuthenticator::GetNextMessage() { 117 XmlElement* V1HostAuthenticator::GetNextMessage() {
122 DCHECK_EQ(state_, MESSAGE_READY); 118 DCHECK_EQ(state_, MESSAGE_READY);
123 119
124 XmlElement* message = new XmlElement( 120 XmlElement* message = CreateEmptyAuthenticatorMessage();
125 QName(kChromotingXmlNamespace, kAuthenticationTag));
126
127 buzz::XmlElement* certificate_tag = new XmlElement( 121 buzz::XmlElement* certificate_tag = new XmlElement(
128 buzz::QName(kChromotingXmlNamespace, kCertificateTag)); 122 buzz::QName(kChromotingXmlNamespace, kCertificateTag));
129 std::string base64_cert; 123 std::string base64_cert;
130 if (!base::Base64Encode(local_cert_, &base64_cert)) { 124 if (!base::Base64Encode(local_cert_, &base64_cert)) {
131 LOG(DFATAL) << "Cannot perform base64 encode on certificate"; 125 LOG(DFATAL) << "Cannot perform base64 encode on certificate";
132 } 126 }
133 certificate_tag->SetBodyText(base64_cert); 127 certificate_tag->SetBodyText(base64_cert);
134 message->AddElement(certificate_tag); 128 message->AddElement(certificate_tag);
135 129
136 state_ = ACCEPTED; 130 state_ = ACCEPTED;
(...skipping 22 matching lines...) Expand all
159 153
160 Authenticator* V1HostAuthenticatorFactory::CreateAuthenticator( 154 Authenticator* V1HostAuthenticatorFactory::CreateAuthenticator(
161 const std::string& remote_jid, 155 const std::string& remote_jid,
162 const buzz::XmlElement* first_message) { 156 const buzz::XmlElement* first_message) {
163 return new V1HostAuthenticator(local_cert_, local_private_key_.get(), 157 return new V1HostAuthenticator(local_cert_, local_private_key_.get(),
164 shared_secret_, remote_jid); 158 shared_secret_, remote_jid);
165 } 159 }
166 160
167 } // namespace remoting 161 } // namespace remoting
168 } // namespace protocol 162 } // namespace protocol
OLDNEW
« no previous file with comments | « remoting/protocol/jingle_session_unittest.cc ('k') | remoting/remoting.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698