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 "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 post_body_.data(), post_body_.size())); | 92 post_body_.data(), post_body_.size())); |
93 request_->set_upload( | 93 request_->set_upload( |
94 net::ElementsUploadDataStream::CreateWithReader(reader.Pass(), 0)); | 94 net::ElementsUploadDataStream::CreateWithReader(reader.Pass(), 0)); |
95 request_->Start(); | 95 request_->Start(); |
96 } | 96 } |
97 | 97 |
98 std::string TokenValidatorImpl::CreateScope( | 98 std::string TokenValidatorImpl::CreateScope( |
99 const std::string& local_jid, | 99 const std::string& local_jid, |
100 const std::string& remote_jid) { | 100 const std::string& remote_jid) { |
101 std::string nonce_bytes; | 101 std::string nonce_bytes; |
102 crypto::RandBytes(WriteInto(&nonce_bytes, kNonceLength + 1), kNonceLength); | 102 crypto::RandBytes(base::WriteInto(&nonce_bytes, kNonceLength + 1), |
| 103 kNonceLength); |
103 std::string nonce; | 104 std::string nonce; |
104 base::Base64Encode(nonce_bytes, &nonce); | 105 base::Base64Encode(nonce_bytes, &nonce); |
105 return "client:" + remote_jid + " host:" + local_jid + " nonce:" + nonce; | 106 return "client:" + remote_jid + " host:" + local_jid + " nonce:" + nonce; |
106 } | 107 } |
107 | 108 |
108 TokenValidatorFactoryImpl::TokenValidatorFactoryImpl( | 109 TokenValidatorFactoryImpl::TokenValidatorFactoryImpl( |
109 const ThirdPartyAuthConfig& third_party_auth_config, | 110 const ThirdPartyAuthConfig& third_party_auth_config, |
110 scoped_refptr<RsaKeyPair> key_pair, | 111 scoped_refptr<RsaKeyPair> key_pair, |
111 scoped_refptr<net::URLRequestContextGetter> request_context_getter) | 112 scoped_refptr<net::URLRequestContextGetter> request_context_getter) |
112 : third_party_auth_config_(third_party_auth_config), | 113 : third_party_auth_config_(third_party_auth_config), |
113 key_pair_(key_pair), | 114 key_pair_(key_pair), |
114 request_context_getter_(request_context_getter) { | 115 request_context_getter_(request_context_getter) { |
115 } | 116 } |
116 | 117 |
117 TokenValidatorFactoryImpl::~TokenValidatorFactoryImpl() { | 118 TokenValidatorFactoryImpl::~TokenValidatorFactoryImpl() { |
118 } | 119 } |
119 | 120 |
120 scoped_ptr<protocol::TokenValidator> | 121 scoped_ptr<protocol::TokenValidator> |
121 TokenValidatorFactoryImpl::CreateTokenValidator( | 122 TokenValidatorFactoryImpl::CreateTokenValidator( |
122 const std::string& local_jid, | 123 const std::string& local_jid, |
123 const std::string& remote_jid) { | 124 const std::string& remote_jid) { |
124 return make_scoped_ptr( | 125 return make_scoped_ptr( |
125 new TokenValidatorImpl(third_party_auth_config_, | 126 new TokenValidatorImpl(third_party_auth_config_, |
126 key_pair_, local_jid, remote_jid, | 127 key_pair_, local_jid, remote_jid, |
127 request_context_getter_)); | 128 request_context_getter_)); |
128 } | 129 } |
129 | 130 |
130 } // namespace remoting | 131 } // namespace remoting |
OLD | NEW |