Skip to content

Commit aa39c5f

Browse files
committed
Disabling oauth1.
1 parent fd880ca commit aa39c5f

File tree

10 files changed

+18
-86
lines changed

10 files changed

+18
-86
lines changed

Release/include/cpprest/http_client.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ namespace client
7373
{
7474

7575
// credentials and web_proxy class has been moved from web::http::client namespace to web namespace.
76-
// The below using declarations ensure we dont break existing code.
76+
// The below using declarations ensure we don't break existing code.
7777
// Please use the web::credentials and web::web_proxy class going forward.
7878
using web::credentials;
7979
using web::web_proxy;
@@ -118,7 +118,9 @@ class http_client_config
118118
/// <returns>Shared pointer to OAuth 1.0 configuration.</returns>
119119
const std::shared_ptr<oauth1::experimental::oauth1_config> oauth1() const
120120
{
121-
return m_oauth1;
121+
// CodePlex #230
122+
throw std::runtime_error("oauth1 is not implemented yet.");
123+
//return m_oauth1;
122124
}
123125

124126
/// <summary>
@@ -127,7 +129,9 @@ class http_client_config
127129
/// <param name="config">OAuth 1.0 configuration to set.</param>
128130
void set_oauth1(oauth1::experimental::oauth1_config config)
129131
{
130-
m_oauth1 = std::make_shared<oauth1::experimental::oauth1_config>(std::move(config));
132+
// CodePlex #230
133+
throw std::runtime_error("oauth1 is not implemented yet.");
134+
//m_oauth1 = std::make_shared<oauth1::experimental::oauth1_config>(std::move(config));
131135
}
132136
#endif
133137

Release/src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ elseif(WIN32)
6262
http/client/http_win7.cpp
6363
http/listener/http_windows_server.cpp
6464
http/oauth/oauth1.cpp
65+
http/oauth/oauth2.cpp
6566
streams/windows/fileio.cpp
6667
streams/windows/ioscheduler.cpp
6768
utilities/dllmain.cpp

Release/src/build/sources.proj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@
221221

222222
<!-- non-TargetXP and non-Phone8.0 files go here-->
223223
<ItemGroup Condition ="'$(TargetXP)' != 'true' and '$(PlatformToolset)' != 'v110_wp80'">
224-
<ClInclude Include="$(CasablancaIncludeDir)\cpprest\oauth1.h">
224+
<ClInclude Include="$(CasablancaIncludeDir)\cpprest\oauth1.h">
225225
<Filter>Header Files\cpprest</Filter>
226226
</ClInclude>
227227
<ClCompile Include="$(CasablancaSrcDir)\http\oauth\oauth1.cpp">

Release/src/http/oauth/oauth1.cpp

Lines changed: 9 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -59,60 +59,10 @@ namespace experimental
5959
#include <winternl.h>
6060
#include <bcrypt.h>
6161

62-
std::vector<unsigned char> oauth1_config::_hmac_sha1(const utility::string_t& key, const utility::string_t& data)
62+
std::vector<unsigned char> oauth1_config::_hmac_sha1(const utility::string_t&, const utility::string_t&)
6363
{
64-
NTSTATUS status;
65-
BCRYPT_ALG_HANDLE alg_handle = nullptr;
66-
BCRYPT_HASH_HANDLE hash_handle = nullptr;
67-
68-
std::vector<unsigned char> hash;
69-
DWORD hash_len = 0;
70-
ULONG result_len = 0;
71-
72-
auto key_c = conversions::utf16_to_utf8(key);
73-
auto data_c = conversions::utf16_to_utf8(data);
74-
75-
status = BCryptOpenAlgorithmProvider(&alg_handle, BCRYPT_SHA1_ALGORITHM, nullptr, BCRYPT_ALG_HANDLE_HMAC_FLAG);
76-
if (!NT_SUCCESS(status))
77-
{
78-
goto cleanup;
79-
}
80-
status = BCryptGetProperty(alg_handle, BCRYPT_HASH_LENGTH, (PBYTE) &hash_len, sizeof(hash_len), &result_len, 0);
81-
if (!NT_SUCCESS(status))
82-
{
83-
goto cleanup;
84-
}
85-
hash.resize(hash_len);
86-
87-
status = BCryptCreateHash(alg_handle, &hash_handle, nullptr, 0, (PBYTE) key_c.c_str(), (ULONG) key_c.length(), 0);
88-
if (!NT_SUCCESS(status))
89-
{
90-
goto cleanup;
91-
}
92-
status = BCryptHashData(hash_handle, (PBYTE) data_c.c_str(), (ULONG) data_c.length(), 0);
93-
if (!NT_SUCCESS(status))
94-
{
95-
goto cleanup;
96-
}
97-
status = BCryptFinishHash(hash_handle, hash.data(), hash_len, 0);
98-
if (!NT_SUCCESS(status))
99-
{
100-
goto cleanup;
101-
}
102-
103-
return hash;
104-
105-
cleanup:
106-
if (hash_handle)
107-
{
108-
BCryptDestroyHash(hash_handle);
109-
}
110-
if (alg_handle)
111-
{
112-
BCryptCloseAlgorithmProvider(alg_handle, 0);
113-
}
114-
115-
return hash;
64+
// CodePlex #230
65+
throw std::runtime_error("oauth1 is not implemented yet.");
11666
}
11767

11868
#elif defined(_MS_WINDOWS) && defined(__cplusplus_winrt) // Windows RT
@@ -121,37 +71,20 @@ using namespace Windows::Security::Cryptography;
12171
using namespace Windows::Security::Cryptography::Core;
12272
using namespace Windows::Storage::Streams;
12373

124-
std::vector<unsigned char> oauth1_config::_hmac_sha1(const utility::string_t& key, const utility::string_t& data)
74+
std::vector<unsigned char> oauth1_config::_hmac_sha1(const utility::string_t&, const utility::string_t&)
12575
{
126-
Platform::String^ data_str = ref new Platform::String(data.c_str());
127-
Platform::String^ key_str = ref new Platform::String(key.c_str());
128-
129-
MacAlgorithmProvider^ HMACSha1Provider = MacAlgorithmProvider::OpenAlgorithm(MacAlgorithmNames::HmacSha1);
130-
IBuffer^ content_buffer = CryptographicBuffer::ConvertStringToBinary(data_str, BinaryStringEncoding::Utf8);
131-
IBuffer^ key_buffer = CryptographicBuffer::ConvertStringToBinary(key_str, BinaryStringEncoding::Utf8);
132-
133-
auto signature_key = HMACSha1Provider->CreateKey(key_buffer);
134-
auto signed_buffer = CryptographicEngine::Sign(signature_key, content_buffer);
135-
136-
Platform::Array<unsigned char, 1>^ arr;
137-
CryptographicBuffer::CopyToByteArray(signed_buffer, &arr);
138-
return std::vector<unsigned char>(arr->Data, arr->Data + arr->Length);
76+
// CodePlex #230
77+
throw std::runtime_error("oauth1 is not implemented yet.");
13978
}
14079

14180
#else // Linux, Mac OS X
14281

14382
#include <openssl/hmac.h>
14483

145-
std::vector<unsigned char> oauth1_config::_hmac_sha1(const utility::string_t& key, const utility::string_t& data)
84+
std::vector<unsigned char> oauth1_config::_hmac_sha1(const utility::string_t&, const utility::string_t&)
14685
{
147-
unsigned char digest[HMAC_MAX_MD_CBLOCK];
148-
unsigned int digest_len = 0;
149-
150-
HMAC(EVP_sha1(), key.c_str(), static_cast<int>(key.length()),
151-
(const unsigned char*) data.c_str(), data.length(),
152-
digest, &digest_len);
153-
154-
return std::vector<unsigned char>(digest, digest + digest_len);
86+
// CodePlex #230
87+
throw std::runtime_error("oauth1 is not implemented yet.");
15588
}
15689

15790
#endif

Release/tests/Functional/http/client/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ set(SOURCES
1212
http_client_tests.cpp
1313
http_methods_tests.cpp
1414
multiple_requests.cpp
15-
oauth1_tests.cpp
1615
oauth2_tests.cpp
1716
outside_tests.cpp
1817
pipeline_stage_tests.cpp

Release/tests/Functional/http/client/VS11.winrt/HttpClient110_test.winrt.vcxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@
217217
<ClCompile Include="..\header_tests.cpp" />
218218
<ClCompile Include="..\http_client_tests.cpp" />
219219
<ClCompile Include="..\http_methods_tests.cpp" />
220-
<ClCompile Include="..\oauth1_tests.cpp" />
221220
<ClCompile Include="..\oauth2_tests.cpp" />
222221
<ClCompile Include="..\outside_tests.cpp" />
223222
<ClCompile Include="..\multiple_requests.cpp" />

Release/tests/Functional/http/client/VS11.xp/HttpClient110_test.xp.vcxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@
199199
<ClCompile Include="..\header_tests.cpp" />
200200
<ClCompile Include="..\http_client_tests.cpp" />
201201
<ClCompile Include="..\http_methods_tests.cpp" />
202-
<ClCompile Include="..\oauth1_tests.cpp" />
203202
<ClCompile Include="..\oauth2_tests.cpp" />
204203
<ClCompile Include="..\outside_tests.cpp" />
205204
<ClCompile Include="..\multiple_requests.cpp" />

Release/tests/Functional/http/client/VS11/HttpClient110_test.vcxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@
205205
<ClCompile Include="..\header_tests.cpp" />
206206
<ClCompile Include="..\http_client_tests.cpp" />
207207
<ClCompile Include="..\http_methods_tests.cpp" />
208-
<ClCompile Include="..\oauth1_tests.cpp" />
209208
<ClCompile Include="..\oauth2_tests.cpp" />
210209
<ClCompile Include="..\outside_tests.cpp" />
211210
<ClCompile Include="..\multiple_requests.cpp" />

Release/tests/Functional/http/client/VS12.winrt/HttpClient120_test.winrt.vcxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@
237237
<ClCompile Include="..\header_tests.cpp" />
238238
<ClCompile Include="..\http_client_tests.cpp" />
239239
<ClCompile Include="..\http_methods_tests.cpp" />
240-
<ClCompile Include="..\oauth1_tests.cpp" />
241240
<ClCompile Include="..\oauth2_tests.cpp" />
242241
<ClCompile Include="..\outside_tests.cpp" />
243242
<ClCompile Include="..\multiple_requests.cpp" />

Release/tests/Functional/http/client/VS12/HttpClient120_test.vcxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@
217217
<ClCompile Include="..\header_tests.cpp" />
218218
<ClCompile Include="..\http_client_tests.cpp" />
219219
<ClCompile Include="..\http_methods_tests.cpp" />
220-
<ClCompile Include="..\oauth1_tests.cpp" />
221220
<ClCompile Include="..\oauth2_tests.cpp" />
222221
<ClCompile Include="..\outside_tests.cpp" />
223222
<ClCompile Include="..\multiple_requests.cpp" />

0 commit comments

Comments
 (0)