| 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/host/token_validator_factory_impl.h" | 5 #include "remoting/host/token_validator_factory_impl.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 bool IsValidScope(const std::string& token_scope) { | 100 bool IsValidScope(const std::string& token_scope) { |
| 101 // TODO(rmsousa): Deal with reordering/subsets/supersets/aliases/etc. | 101 // TODO(rmsousa): Deal with reordering/subsets/supersets/aliases/etc. |
| 102 return token_scope == token_scope_; | 102 return token_scope == token_scope_; |
| 103 } | 103 } |
| 104 | 104 |
| 105 static std::string CreateScope(const std::string& local_jid, | 105 static std::string CreateScope(const std::string& local_jid, |
| 106 const std::string& remote_jid) { | 106 const std::string& remote_jid) { |
| 107 std::string nonce_bytes; | 107 std::string nonce_bytes; |
| 108 crypto::RandBytes(WriteInto(&nonce_bytes, kNonceLength + 1), kNonceLength); | 108 crypto::RandBytes(WriteInto(&nonce_bytes, kNonceLength + 1), kNonceLength); |
| 109 std::string nonce; | 109 std::string nonce; |
| 110 bool success = base::Base64Encode(nonce_bytes, &nonce); | 110 base::Base64Encode(nonce_bytes, &nonce); |
| 111 DCHECK(success); | |
| 112 return "client:" + remote_jid + " host:" + local_jid + " nonce:" + nonce; | 111 return "client:" + remote_jid + " host:" + local_jid + " nonce:" + nonce; |
| 113 } | 112 } |
| 114 | 113 |
| 115 std::string ProcessResponse() { | 114 std::string ProcessResponse() { |
| 116 // Verify that we got a successful response. | 115 // Verify that we got a successful response. |
| 117 net::URLRequestStatus status = request_->GetStatus(); | 116 net::URLRequestStatus status = request_->GetStatus(); |
| 118 if (!status.is_success()) { | 117 if (!status.is_success()) { |
| 119 LOG(ERROR) << "Error validating token, status=" << status.status() | 118 LOG(ERROR) << "Error validating token, status=" << status.status() |
| 120 << " err=" << status.error(); | 119 << " err=" << status.error(); |
| 121 return std::string(); | 120 return std::string(); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 TokenValidatorFactoryImpl::CreateTokenValidator( | 181 TokenValidatorFactoryImpl::CreateTokenValidator( |
| 183 const std::string& local_jid, | 182 const std::string& local_jid, |
| 184 const std::string& remote_jid) { | 183 const std::string& remote_jid) { |
| 185 return scoped_ptr<protocol::ThirdPartyHostAuthenticator::TokenValidator>( | 184 return scoped_ptr<protocol::ThirdPartyHostAuthenticator::TokenValidator>( |
| 186 new TokenValidatorImpl(token_url_, token_validation_url_, key_pair_, | 185 new TokenValidatorImpl(token_url_, token_validation_url_, key_pair_, |
| 187 local_jid, remote_jid, | 186 local_jid, remote_jid, |
| 188 request_context_getter_)); | 187 request_context_getter_)); |
| 189 } | 188 } |
| 190 | 189 |
| 191 } // namespace remoting | 190 } // namespace remoting |
| OLD | NEW |