void shared_key_authentication_handler::sign_request(web::http::http_request& request, operation_context context) const { web::http::http_headers& headers = request.headers(); headers.add(ms_header_date, utility::datetime::utc_now().to_string()); if (m_credentials.is_shared_key()) { utility::string_t string_to_sign = m_canonicalizer->canonicalize(request, context); if (core::logger::instance().should_log(context, client_log_level::log_level_verbose)) { utility::string_t with_dots(string_to_sign); std::replace(with_dots.begin(), with_dots.end(), _XPLATSTR('\n'), _XPLATSTR('.')); core::logger::instance().log(context, client_log_level::log_level_verbose, _XPLATSTR("StringToSign: ") + with_dots); } utility::string_t header_value; header_value.reserve(256); header_value.append(m_canonicalizer->authentication_scheme()); header_value.append(_XPLATSTR(" ")); header_value.append(m_credentials.account_name()); header_value.append(_XPLATSTR(":")); header_value.append(calculate_hmac_sha256_hash(string_to_sign, m_credentials)); headers.add(web::http::header_names::authorization, header_value); } }
/* Test creating paths */ void createPaths() { ::core::Path empty_path; equal(empty_path.toString(), "/"); isTrue(empty_path.absolute()); ::core::Path ordinary_path("/an/ordinary/path"); equal(ordinary_path.toString(), "/an/ordinary/path"); isTrue(ordinary_path.absolute()); ::core::Path extra_separators("/path//with///extra/separators//"); equal(extra_separators.toString(), "/path/with/extra/separators"); isTrue(extra_separators.absolute()); ::core::Path with_dot("/a/path/with/./dot"); equal(with_dot.toString(), "/a/path/with/dot"); isTrue(with_dot.absolute()); ::core::Path with_dots("/a/path/with/../dots"); equal(with_dots.toString(), "/a/path/dots"); isTrue(with_dots.absolute()); ::core::Path relative_path("relative/path"); equal(relative_path.toString(), "relative/path"); isFalse(relative_path.absolute()); relative_path.set("./new/path/"); equal(relative_path.toString(), "new/path"); isFalse(relative_path.absolute()); ::core::Path path_start_dots("../starts/with/relative"); equal(path_start_dots.toString(), "../starts/with/relative"); isFalse(path_start_dots.absolute()); ::core::Path multiple_dots("./../starts/./with/../two/dots"); equal(multiple_dots.toString(), "../starts/two/dots"); isFalse(multiple_dots.absolute()); }