HTTP processor module implementation file. More...
#include "http_processor.h"
#include "log_util.h"
#include "memory.h"
#include "http_definitions.h"
#include "json.h"
#include "json_util.h"
#include "list.h"
#include "data_types.h"
#include "time_series.h"
#include "event_list.h"
#include "file.h"
#include "custom_data.h"
#include "stream_data.h"
#include "data_source_configuration.h"
#include "definitions.h"
#include "jwt.h"
#include "storage.h"
#include "security.h"
#include "http_request.h"
#include "random.h"
#include "file_util.h"
#include "mcl/mcl_common.h"
#include "time_util.h"
Go to the source code of this file.
Macros | |
#define | SERVER_NONCE "server_nonce" |
#define | SERVER_PROOF "server_proof" |
#define | JSON_NAME_CLIENT_ID "client_id" |
#define | JSON_NAME_TOKEN_ENDPOINT_AUTH_METHOD "token_endpoint_auth_method" |
#define | JSON_NAME_GRANT_TYPES "grant_types" |
#define | JSON_NAME_CLIENT_SECRET "client_secret" |
#define | JSON_NAME_CLIENT_SECRET_EXPIRES_AT "client_secret_expires_at" |
#define | JSON_NAME_REGISTRATION_ACCESS_TOKEN "registration_access_token" |
#define | JSON_NAME_REGISTRATION_CLIENT_URI "registration_client_uri" |
#define | JSON_NAME_JWKS "jwks" |
#define | JSON_NAME_KEYS "keys" |
#define | JSON_NAME_E "e" |
#define | JSON_NAME_N "n" |
#define | JSON_NAME_KTY "kty" |
#define | JSON_NAME_KID "kid" |
#define | JSON_NAME_ACCESS_TOKEN "access_token" |
#define | REGISTER_URI_PATH "/register" |
#define | ACCESS_TOKEN_URI_PATH "/token" |
#define | MAX_STREAM_CALLBACK_CALL_COUNT 10 |
#define | MAX_RANGE_HEADER_LENGTH (100) |
#define | MAX_TOP_EVENT_PARAMETER_LENGTH (50) |
#define | EVENT_REQUEST_LIMIT (100) |
According to specification. More... | |
#define | CORRELATION_ID_BYTE_LENGTH 16 |
Enumerations | |
enum | E_ENDPOINT_TYPE { ENDPOINT_ONBOARDING, ENDPOINT_KEY_ROTATION, ENDPOINT_EXCHANGE } |
Enumeration for the Mindsphere endpoints. More... | |
enum | E_ENDPOINT_URI { ENDPOINT_URI_EXCHANGE, ENDPOINT_URI_DOWNLOAD, ENDPOINT_URI_EVENT, ENDPOINT_URI_ACK_EVENT, ENDPOINT_URI_ACCESS_TOKEN, ENDPOINT_URI_REGISTER, ENDPOINT_URI_END } |
Enumeration for URIs for different endpoints. More... | |
Variables | |
string_t | endpoint_uri [ENDPOINT_URI_END] |
HTTP processor module implementation file.
Definition in file http_processor.c.
#define ACCESS_TOKEN_URI_PATH "/token" |
Definition at line 57 of file http_processor.c.
#define CORRELATION_ID_BYTE_LENGTH 16 |
Definition at line 66 of file http_processor.c.
Referenced by _generate_correlation_id_string().
#define EVENT_REQUEST_LIMIT (100) |
According to specification.
Definition at line 64 of file http_processor.c.
#define JSON_NAME_ACCESS_TOKEN "access_token" |
Definition at line 54 of file http_processor.c.
Referenced by http_processor_get_access_token().
#define JSON_NAME_CLIENT_ID "client_id" |
Definition at line 41 of file http_processor.c.
Referenced by _compose_rsa_key_rotation_json(), _process_registration_response_rsa_3072(), and _process_registration_response_shared_secret().
#define JSON_NAME_CLIENT_SECRET "client_secret" |
Definition at line 44 of file http_processor.c.
Referenced by _process_registration_response_shared_secret().
#define JSON_NAME_CLIENT_SECRET_EXPIRES_AT "client_secret_expires_at" |
Definition at line 45 of file http_processor.c.
#define JSON_NAME_E "e" |
Definition at line 50 of file http_processor.c.
Referenced by _compose_rsa_key_rotation_json(), and _compose_rsa_onboarding_json().
#define JSON_NAME_GRANT_TYPES "grant_types" |
Definition at line 43 of file http_processor.c.
#define JSON_NAME_JWKS "jwks" |
Definition at line 48 of file http_processor.c.
Referenced by _compose_rsa_key_rotation_json(), and _compose_rsa_onboarding_json().
#define JSON_NAME_KEYS "keys" |
Definition at line 49 of file http_processor.c.
Referenced by _compose_rsa_key_rotation_json(), and _compose_rsa_onboarding_json().
#define JSON_NAME_KID "kid" |
Definition at line 53 of file http_processor.c.
Referenced by _compose_rsa_key_rotation_json(), and _compose_rsa_onboarding_json().
#define JSON_NAME_KTY "kty" |
Definition at line 52 of file http_processor.c.
Referenced by _compose_rsa_key_rotation_json(), and _compose_rsa_onboarding_json().
#define JSON_NAME_N "n" |
Definition at line 51 of file http_processor.c.
Referenced by _compose_rsa_key_rotation_json(), and _compose_rsa_onboarding_json().
#define JSON_NAME_REGISTRATION_ACCESS_TOKEN "registration_access_token" |
Definition at line 46 of file http_processor.c.
Referenced by _process_registration_response_rsa_3072(), and _process_registration_response_shared_secret().
#define JSON_NAME_REGISTRATION_CLIENT_URI "registration_client_uri" |
Definition at line 47 of file http_processor.c.
Referenced by _process_registration_response_rsa_3072(), and _process_registration_response_shared_secret().
#define JSON_NAME_TOKEN_ENDPOINT_AUTH_METHOD "token_endpoint_auth_method" |
Definition at line 42 of file http_processor.c.
#define MAX_RANGE_HEADER_LENGTH (100) |
Definition at line 62 of file http_processor.c.
Referenced by _process_registration_response_rsa_3072().
#define MAX_STREAM_CALLBACK_CALL_COUNT 10 |
Definition at line 60 of file http_processor.c.
Referenced by _get_payload_from_file().
#define MAX_TOP_EVENT_PARAMETER_LENGTH (50) |
Definition at line 63 of file http_processor.c.
#define REGISTER_URI_PATH "/register" |
Definition at line 56 of file http_processor.c.
#define SERVER_NONCE "server_nonce" |
Definition at line 38 of file http_processor.c.
#define SERVER_PROOF "server_proof" |
Definition at line 39 of file http_processor.c.
enum E_ENDPOINT_TYPE |
Enumeration for the Mindsphere endpoints.
Enumerator | |
---|---|
ENDPOINT_ONBOARDING |
Onboarding endpoint. |
ENDPOINT_KEY_ROTATION |
Key rotation endpoint. |
ENDPOINT_EXCHANGE |
Exchange endpoint. |
Definition at line 71 of file http_processor.c.
enum E_ENDPOINT_URI |
Enumeration for URIs for different endpoints.
Definition at line 81 of file http_processor.c.
|
static |
Definition at line 1777 of file http_processor.c.
References security_handler_t::access_token, ASSERT_CODE_MESSAGE, HTTP_HEADER_AUTHORIZATION, http_header_names, http_request_add_header(), MCL_HTTP_REQUEST_FINALIZE_FAILED, MCL_NULL, MCL_OK, MCL_TRUE, http_processor_t::security_handler, string_concatenate(), string_destroy(), and string_initialize_static().
Referenced by _exchange_finalize_http_request(), _exchange_initialize_http_request_headers(), and http_processor_get_access_token().
|
static |
Definition at line 2214 of file http_processor.c.
References ASSERT_CODE_MESSAGE, DEBUG_ENTRY, DEBUG_LEAVE, JSON_OBJECT, json_util_add_item_to_array(), json_util_initialize(), and MCL_OK.
Referenced by _compose_rsa_key_rotation_json(), and _compose_rsa_onboarding_json().
|
static |
Definition at line 2227 of file http_processor.c.
References DEBUG_ENTRY, DEBUG_LEAVE, file_util_fclose(), file_util_fopen(), MCL_NULL, and MCL_OK.
Referenced by http_processor_initialize().
E_MCL_ERROR_CODE _compose_access_token_request_payload | ( | http_processor_t * | http_processor, |
string_t ** | request_payload | ||
) |
Definition at line 2406 of file http_processor.c.
References http_processor_t::configuration, DEBUG_ENTRY, DEBUG_LEAVE, jwt_destroy(), jwt_get_token(), jwt_initialize(), MCL_FAIL, MCL_NULL, MCL_OK, http_processor_t::security_handler, configuration_t::security_profile, string_concatenate(), string_destroy(), string_initialize_static(), and configuration_t::tenant.
Referenced by http_processor_get_access_token().
|
static |
Definition at line 2167 of file http_processor.c.
References _add_key_to_keys_array(), string_t::buffer, security_handler_t::client_id, DEBUG_ENTRY, DEBUG_LEAVE, JSON_NAME_CLIENT_ID, JSON_NAME_E, JSON_NAME_JWKS, JSON_NAME_KEYS, JSON_NAME_KID, JSON_NAME_KTY, JSON_NAME_N, JSON_OBJECT, json_util_add_string(), json_util_destroy(), json_util_finish_object(), json_util_initialize(), json_util_start_array(), json_util_start_object(), json_util_to_string(), MCL_FREE, MCL_NULL, MCL_OK, rsa_t::private_key, rsa_t::public_key, security_handler_t::rsa, security_handler_generate_rsa_key(), security_rsa_get_modulus_and_exponent(), and string_initialize_dynamic().
Referenced by http_processor_register().
|
static |
Definition at line 2125 of file http_processor.c.
References _add_key_to_keys_array(), DEBUG_ENTRY, DEBUG_LEAVE, JSON_NAME_E, JSON_NAME_JWKS, JSON_NAME_KEYS, JSON_NAME_KID, JSON_NAME_KTY, JSON_NAME_N, JSON_OBJECT, json_util_add_string(), json_util_destroy(), json_util_finish_object(), json_util_initialize(), json_util_start_array(), json_util_start_object(), json_util_to_string(), MCL_FREE, MCL_NULL, MCL_OK, rsa_t::public_key, security_handler_t::rsa, security_rsa_get_modulus_and_exponent(), and string_initialize_dynamic().
Referenced by http_processor_register().
|
static |
Definition at line 766 of file http_processor.c.
References ASSERT_STATEMENT_CODE_MESSAGE, string_t::buffer, DEBUG_ENTRY, DEBUG_LEAVE, string_t::length, MCL_FAIL, MCL_NULL, MCL_OK, string_destroy(), string_initialize_new(), and string_util_snprintf().
Referenced by http_processor_get_access_token(), and http_processor_initialize().
|
static |
Definition at line 2243 of file http_processor.c.
References security_handler_t::client_id, security_handler_t::client_secret, http_processor_t::configuration, DEBUG_ENTRY, DEBUG_LEAVE, configuration_t::load_function, MCL_OK, MCL_SECURITY_SHARED_SECRET, rsa_t::private_key, rsa_t::public_key, security_handler_t::registration_access_token, security_handler_t::registration_client_uri, security_handler_t::rsa, mcl_load_registration_information_callback_t::rsa, http_processor_t::security_handler, configuration_t::security_profile, mcl_load_registration_information_callback_t::shared_secret, and string_initialize_dynamic().
Referenced by http_processor_initialize().
|
static |
Definition at line 2278 of file http_processor.c.
References DEBUG_ENTRY, DEBUG_LEAVE, MCL_BAD_REQUEST, MCL_CONFLICT, MCL_CREATED, MCL_FORBIDDEN, MCL_HTTP_RESULT_CODE_BAD_REQUEST, MCL_HTTP_RESULT_CODE_CONFLICT, MCL_HTTP_RESULT_CODE_CREATED, MCL_HTTP_RESULT_CODE_FORBIDDEN, MCL_HTTP_RESULT_CODE_INTERNAL_SERVER_ERR, MCL_HTTP_RESULT_CODE_NOT_FOUND, MCL_HTTP_RESULT_CODE_PARTIAL_CONTENT, MCL_HTTP_RESULT_CODE_PAYLOAD_TOO_LARGE, MCL_HTTP_RESULT_CODE_PRECONDITION_FAILED, MCL_HTTP_RESULT_CODE_SUCCESS, MCL_HTTP_RESULT_CODE_TOO_MANY_REQUESTS, MCL_HTTP_RESULT_CODE_UNAUTHORIZED, MCL_INFO, MCL_NOT_FOUND, MCL_OK, MCL_PARTIAL_CONTENT, MCL_PRECONDITION_FAIL, MCL_REQUEST_PAYLOAD_TOO_LARGE, MCL_SERVER_FAIL, MCL_TOO_MANY_REQUESTS, MCL_UNAUTHORIZED, MCL_UNEXPECTED_RESULT_CODE, and http_response_t::result_code.
Referenced by _exchange_evaluate_response(), http_processor_get_access_token(), and http_processor_register().
|
static |
Definition at line 1161 of file http_processor.c.
References _exchange_store_data_get_content_info(), _get_payload_from_buffer(), _get_payload_from_file(), ASSERT_CODE_MESSAGE, store_data_t::data, DATA_STATE_WRITTEN, DEBUG_ENTRY, DEBUG_LEAVE, file_t::descriptor, http_request_add_tuple(), MCL_DEBUG, MCL_FAIL, MCL_HTTP_REQUEST_NO_MORE_SPACE, MCL_NULL, MCL_OK, store_data_t::meta, store_data_t::payload_buffer, store_data_t::payload_size, STORE_DATA_FILE, store_data_set_state(), STORE_DATA_STREAM, and store_data_t::type.
Referenced by _exchange_fill_http_request().
|
static |
Definition at line 976 of file http_processor.c.
References _exchange_store_data_get_content_info(), _get_payload_from_buffer(), _get_payload_from_file(), ASSERT_CODE_MESSAGE, string_t::buffer, store_data_t::data, DATA_STATE_WRITTEN, DEBUG_ENTRY, DEBUG_LEAVE, file_t::descriptor, http_request_add_raw_data(), http_request_end_tuple_sub_section(), http_request_get_available_space_for_raw_data(), http_request_start_tuple(), http_request_start_tuple_sub_section(), string_t::length, MCL_DEBUG, MCL_FAIL, MCL_HTTP_REQUEST_NO_MORE_SPACE, MCL_NEW, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, store_data_t::meta, store_data_stream_info_t::meta_state, store_data_stream_info_t::meta_stream_index, store_data_t::payload_buffer, store_data_t::payload_size, store_data_stream_info_t::payload_state, store_data_stream_info_t::payload_stream_index, stream_data_t::read_callback, STORE_DATA_FILE, store_data_set_state(), STORE_DATA_STREAM, store_data_t::stream_info, store_data_stream_info_t::tuple_subboundary, store_data_t::type, and stream_data_t::user_context.
Referenced by _exchange_fill_http_request().
|
static |
Definition at line 1625 of file http_processor.c.
References mcl_list_node_t::data, DATA_STATE_SENT, DEBUG_ENTRY, DEBUG_LEAVE, store_t::high_priority_list, list_next(), store_t::low_priority_list, MCL_NULL, MCL_OK, store_data_get_state(), and store_data_remove().
Referenced by _exchange_evaluate_response().
|
static |
Definition at line 1516 of file http_processor.c.
References _evaluate_response_codes(), _exchange_clear_sent_data_from_store(), _exchange_update_store_state(), string_t::buffer, DEBUG_ENTRY, DEBUG_LEAVE, http_response_destroy(), MCL_DEBUG, MCL_ERROR, MCL_FAIL, MCL_FALSE, MCL_HTTP_RESULT_CODE_SUCCESS, MCL_INFO, MCL_NULL, MCL_OK, MCL_TRUE, and http_response_t::result_code.
Referenced by http_processor_exchange(), and http_processor_stream().
|
static |
Definition at line 1346 of file http_processor.c.
References _exchange_add_current_data_to_request(), _exchange_add_current_data_to_request_by_streaming(), _exchange_finalize_http_request(), _exchange_prepare_data(), ASSERT_CODE_MESSAGE, mcl_list_t::current, mcl_list_node_t::data, DATA_STATE_INITIAL, DATA_STATE_PREPARED, DATA_STATE_STREAMING, DEBUG_ENTRY, DEBUG_LEAVE, mcl_list_t::head, store_t::high_priority_list, MCL_DEBUG, MCL_EXCHANGE_STREAMING_IS_ACTIVE, MCL_FAIL, MCL_FALSE, MCL_HTTP_REQUEST_NO_MORE_SPACE, MCL_NULL, MCL_OK, MCL_PARTIALLY_WRITTEN, MCL_STORE_ITEM_EXCEEDS_MAX_HTTP_REQUEST_SIZE, MCL_TRUE, mcl_list_node_t::next, store_data_get_state(), store_data_set_state(), and store_t::streamable.
Referenced by _get_payload_from_file(), and http_processor_exchange().
|
static |
Definition at line 1763 of file http_processor.c.
References _add_authentication_header_to_request(), ASSERT_CODE, ASSERT_CODE_MESSAGE, DEBUG_ENTRY, DEBUG_LEAVE, http_request_finalize(), MCL_HTTP_REQUEST_FINALIZE_FAILED, and MCL_OK.
Referenced by _exchange_fill_http_request(), and _get_payload_from_file().
|
static |
Definition at line 1742 of file http_processor.c.
References _add_authentication_header_to_request(), ASSERT_CODE, ASSERT_CODE_MESSAGE, CONTENT_TYPE_APPLICATION_JSON, CONTENT_TYPE_MULTIPART_MIXED, content_type_values, DEBUG_ENTRY, DEBUG_LEAVE, HTTP_HEADER_ACCEPT, HTTP_HEADER_CONTENT_TYPE, http_header_names, http_request_add_header(), MCL_HTTP_REQUEST_FINALIZE_FAILED, and MCL_OK.
Referenced by http_processor_exchange(), and http_processor_stream().
|
static |
Definition at line 1222 of file http_processor.c.
References ASSERT_CODE_MESSAGE, stream_data_t::base, string_t::buffer, binary_payload_t::buffer, store_data_t::data, DATA_STATE_PREPARED, DEBUG_ENTRY, DEBUG_LEAVE, event_list_t::events, json_from_data_source_configuration_payload(), json_from_event_payload(), json_from_item_meta(), json_from_time_series_payload(), string_t::length, MCL_DEBUG, MCL_ERROR_RETURN, MCL_FAIL, MCL_FREE, MCL_NULL, MCL_OK, time_series_t::meta, data_source_configuration_t::meta, file_t::meta, custom_data_t::meta, event_list_t::meta, store_data_t::meta, time_series_t::payload, custom_data_t::payload, file_t::payload, data_source_configuration_t::payload, store_data_t::payload_buffer, store_data_t::payload_size, file_payload_t::size, binary_payload_t::size, STORE_DATA_CUSTOM, STORE_DATA_DATA_SOURCE_CONFIGURATION, STORE_DATA_EVENT_LIST, STORE_DATA_FILE, store_data_set_state(), STORE_DATA_STREAM, STORE_DATA_TIME_SERIES, string_destroy(), and store_data_t::type.
Referenced by _exchange_fill_http_request().
|
static |
Definition at line 1654 of file http_processor.c.
References item_meta_t::content_id, CONTENT_TYPE_APPLICATION_JSON, CONTENT_TYPE_APPLICATION_OCTET_STREAM, CONTENT_TYPE_META_JSON, content_type_values, store_data_t::data, DEBUG_ENTRY, DEBUG_LEAVE, MCL_DEBUG, MCL_FAIL, MCL_NULL, MCL_OK, time_series_t::meta, file_t::meta, custom_data_t::meta, data_source_configuration_t::meta, event_list_t::meta, STORE_DATA_CUSTOM, STORE_DATA_DATA_SOURCE_CONFIGURATION, STORE_DATA_EVENT_LIST, STORE_DATA_FILE, STORE_DATA_STREAM, STORE_DATA_TIME_SERIES, and store_data_t::type.
Referenced by _exchange_add_current_data_to_request(), and _exchange_add_current_data_to_request_by_streaming().
|
static |
Definition at line 1571 of file http_processor.c.
References DATA_STATE_PREPARED, DATA_STATE_SENT, DATA_STATE_WRITTEN, DEBUG_ENTRY, DEBUG_LEAVE, MCL_DEBUG, MCL_OK, MCL_TRUE, store_data_get_state(), and store_data_set_state().
Referenced by _exchange_update_store_state().
|
static |
Definition at line 1600 of file http_processor.c.
References _exchange_update_store_data_state(), mcl_list_node_t::data, DEBUG_ENTRY, DEBUG_LEAVE, store_t::high_priority_list, list_next(), list_reset(), store_t::low_priority_list, MCL_NULL, and MCL_OK.
Referenced by _exchange_evaluate_response().
|
static |
Definition at line 2343 of file http_processor.c.
References ASSERT_CODE, ASSERT_STATEMENT_CODE, CORRELATION_ID_BYTE_LENGTH, DEBUG_ENTRY, DEBUG_LEAVE, MCL_NULL, MCL_OK, security_generate_random_bytes(), string_destroy(), string_initialize_new(), and string_util_snprintf().
Referenced by http_processor_exchange(), http_processor_get_access_token(), http_processor_register(), and http_processor_stream().
|
static |
Definition at line 1799 of file http_processor.c.
References DEBUG_ENTRY, DEBUG_LEAVE, and string_util_memcpy().
Referenced by _exchange_add_current_data_to_request(), and _exchange_add_current_data_to_request_by_streaming().
|
static |
Definition at line 1812 of file http_processor.c.
References _exchange_fill_http_request(), _exchange_finalize_http_request(), http_processor_stream_callback_context_t::call_count, DEBUG_ENTRY, DEBUG_LEAVE, file_util_fread(), http_client_get_callback_termination_code(), http_processor_stream_callback_context_t::http_processor, MAX_STREAM_CALLBACK_CALL_COUNT, MCL_DEBUG, MCL_EXCHANGE_STREAMING_IS_ACTIVE, MCL_FAIL, MCL_FALSE, MCL_HTTP_REQUEST_FINALIZE_FAILED, MCL_NULL, MCL_OK, MCL_STORE_IS_EMPTY, MCL_STORE_ITEM_EXCEEDS_MAX_HTTP_REQUEST_SIZE, http_request_t::payload, http_request_t::payload_offset, http_request_t::payload_size, http_processor_stream_callback_context_t::previous_result, http_processor_stream_callback_context_t::request, and http_processor_stream_callback_context_t::store.
Referenced by _exchange_add_current_data_to_request(), and _exchange_add_current_data_to_request_by_streaming().
|
static |
Definition at line 1961 of file http_processor.c.
References ASSERT_CODE, ASSERT_CODE_MESSAGE, ASSERT_STATEMENT_CODE_MESSAGE, string_t::buffer, security_handler_t::client_id, DEBUG_ENTRY, DEBUG_LEAVE, file_payload_t::end_byte, HTTP_HEADER_CONTENT_RANGE, http_header_names, HTTP_HEADER_RANGE, http_request_add_header(), http_response_get_header(), http_response_get_payload(), JSON_NAME_CLIENT_ID, JSON_NAME_REGISTRATION_ACCESS_TOKEN, JSON_NAME_REGISTRATION_CLIENT_URI, json_util_destroy(), json_util_get_object_item(), json_util_get_string(), json_util_parse_with_size(), MAX_RANGE_HEADER_LENGTH, MCL_FAIL, MCL_FREE, MCL_MALLOC, MCL_NULL, MCL_NULL_CHAR, MCL_OK, MCL_OUT_OF_MEMORY, MCL_TRUE, file_t::payload, http_response_t::payload_size, security_handler_t::registration_access_token, security_handler_t::registration_client_uri, http_processor_t::security_handler, file_payload_t::start_byte, string_destroy(), string_initialize_dynamic(), string_initialize_new(), string_util_find(), string_util_snprintf(), string_util_strncpy(), and string_util_strtol().
Referenced by http_processor_register().
|
static |
Definition at line 1910 of file http_processor.c.
References ASSERT_CODE_MESSAGE, security_handler_t::client_id, security_handler_t::client_secret, DEBUG_ENTRY, DEBUG_LEAVE, http_response_get_payload(), JSON_NAME_CLIENT_ID, JSON_NAME_CLIENT_SECRET, JSON_NAME_REGISTRATION_ACCESS_TOKEN, JSON_NAME_REGISTRATION_CLIENT_URI, json_util_destroy(), json_util_get_object_item(), json_util_get_string(), json_util_parse_with_size(), MCL_FREE, MCL_NULL, MCL_OK, http_response_t::payload_size, security_handler_t::registration_access_token, security_handler_t::registration_client_uri, http_processor_t::security_handler, and string_destroy().
Referenced by http_processor_register().
E_MCL_ERROR_CODE _save_registration_information | ( | http_processor_t * | http_processor | ) |
Definition at line 2366 of file http_processor.c.
References string_t::buffer, security_handler_t::client_id, security_handler_t::client_secret, http_processor_t::configuration, DEBUG_ENTRY, DEBUG_LEAVE, configuration_t::load_function, MCL_NULL, MCL_OK, MCL_SECURITY_SHARED_SECRET, rsa_t::private_key, rsa_t::public_key, security_handler_t::registration_access_token, security_handler_t::registration_client_uri, security_handler_t::rsa, mcl_load_registration_information_callback_t::rsa, mcl_save_registration_information_callback_t::rsa, configuration_t::save_function, http_processor_t::security_handler, configuration_t::security_profile, mcl_save_registration_information_callback_t::shared_secret, storage_save_rsa_registration_information(), storage_save_shared_secret_registration_information(), and configuration_t::store_path.
Referenced by http_processor_register().
void http_processor_destroy | ( | http_processor_t ** | http_processor | ) |
To destroy the HTTP Processor Handler.
Will release the resources of HTTP Processor. After destroy operation, handler shouldn't be used.
[in] | http_processor | HTTP Processor handle to be destroyed. |
Definition at line 946 of file http_processor.c.
References DEBUG_ENTRY, DEBUG_LEAVE, http_client_destroy(), MCL_DEBUG, MCL_FREE, MCL_NULL, security_handler_destroy(), and string_destroy().
Referenced by http_processor_initialize(), and mcl_communication_destroy().
E_MCL_ERROR_CODE http_processor_exchange | ( | http_processor_t * | http_processor, |
store_t * | store, | ||
void ** | reserved | ||
) |
Exchange operation logic.
Performs exchange operation on MindSphere. After successfully sending the data from the received store object, data will be removed.
[in] | http_processor | HTTP Processor handle to be used. |
[in] | store | The data to be exchanged will be read from this store. |
[out] | reserved | Reserved for future use. |
store
has no data. Definition at line 786 of file http_processor.c.
References _exchange_evaluate_response(), _exchange_fill_http_request(), _exchange_initialize_http_request_headers(), _generate_correlation_id_string(), ASSERT_CODE_MESSAGE, http_processor_t::configuration, mcl_list_t::count, DEBUG_ENTRY, DEBUG_LEAVE, configuration_t::exchange_endpoint, store_t::high_priority_list, http_processor_t::http_client, http_client_send(), HTTP_HEADER_CORRELATION_ID, http_header_names, http_request_add_header(), http_request_destroy(), http_request_initialize(), HTTP_REQUEST_RESIZE_ENABLED, store_t::low_priority_list, configuration_t::max_http_payload_size, MCL_DEBUG, MCL_ERROR_RETURN, MCL_HTTP_POST, MCL_NULL, MCL_OK, MCL_STORE_IS_EMPTY, MCL_TRUE, store_get_data_count(), string_destroy(), and configuration_t::user_agent.
Referenced by mcl_communication_exchange().
E_MCL_ERROR_CODE http_processor_get_access_token | ( | http_processor_t * | http_processor | ) |
This function is called by mcl_communication_get_access_token()
.
[in] | http_processor | HTTP Processor handle to be used. |
Definition at line 580 of file http_processor.c.
References _add_authentication_header_to_request(), _compose_access_token_request_payload(), _concatenate_host_and_endpoint(), _evaluate_response_codes(), _generate_correlation_id_string(), security_handler_t::access_token, configuration_t::access_token_endpoint, ASSERT_CODE_MESSAGE, ASSERT_STATEMENT_CODE_MESSAGE, string_t::buffer, http_processor_t::configuration, CONTENT_TYPE_URL_ENCODED, content_type_values, DEBUG_ENTRY, DEBUG_LEAVE, ENDPOINT_URI_DOWNLOAD, file_destroy(), file_initialize(), http_processor_t::http_client, http_client_send(), HTTP_HEADER_ACCEPT, HTTP_HEADER_CONTENT_DISPOSITION, HTTP_HEADER_CONTENT_TYPE, HTTP_HEADER_CORRELATION_ID, http_header_names, HTTP_HEADER_SERVER_TIME, http_request_add_header(), http_request_destroy(), http_request_initialize(), HTTP_REQUEST_RESIZE_ENABLED, http_response_destroy(), http_response_get_header(), http_response_get_payload(), JSON_NAME_ACCESS_TOKEN, json_util_destroy(), json_util_get_object_item(), json_util_get_string(), json_util_parse_with_size(), security_handler_t::last_token_time, string_t::length, configuration_t::max_http_payload_size, MCL_BUFFER_OVERFLOW_ERROR, MCL_ERROR, MCL_ERROR_RETURN, MCL_FAIL, MCL_FREE, MCL_HTTP_GET, MCL_HTTP_POST, MCL_INFO, MCL_NULL, MCL_OK, MCL_PARTIAL_CONTENT, MCL_TRUE, configuration_t::mindsphere_hostname, http_response_t::payload, http_request_t::payload, http_response_t::payload_size, http_processor_t::security_handler, string_destroy(), string_initialize_static(), string_util_memcpy(), and configuration_t::user_agent.
Referenced by mcl_communication_get_access_token(), mcl_communication_onboard(), mcl_communication_rotate_key(), and mcl_communication_update_security_information().
E_MCL_ERROR_CODE http_processor_initialize | ( | configuration_t * | configuration, |
http_processor_t ** | http_processor | ||
) |
Http Processor Initialize function.
Performs creation and initializations of following modules :
[in] | configuration | The configuration parameters to be used for initializing itself and other modules. |
[out] | http_processor | The newly initialized HTTP processor. |
Definition at line 196 of file http_processor.c.
References _check_file_path(), _concatenate_host_and_endpoint(), _custom_load_register_info(), ASSERT_CODE_MESSAGE, ASSERT_STATEMENT_CODE_MESSAGE, DEBUG_ENTRY, DEBUG_LEAVE, ENDPOINT_URI_ACCESS_TOKEN, ENDPOINT_URI_EXCHANGE, ENDPOINT_URI_REGISTER, http_client_initialize(), http_processor_destroy(), json_util_initialize_json_library(), MCL_DEBUG, MCL_ERROR, MCL_INFO, MCL_NEW, MCL_NO_ACCESS_TOKEN_PROVIDED, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, MCL_PATH_NOT_ACCESSIBLE, MCL_REGISTRATION_INFO_IS_NOT_LOADED, MCL_SECURITY_RSA_3072, MCL_SECURITY_SHARED_SECRET, security_handler_generate_rsa_key(), security_handler_initialize(), security_initialize(), storage_load_rsa_registration_information(), and storage_load_shared_secret_registration_information().
Referenced by mcl_communication_initialize().
E_MCL_ERROR_CODE http_processor_register | ( | http_processor_t * | http_processor | ) |
This function is called by mcl_communication_onboard()
and mcl_communication_rotate_key()
.
[in] | http_processor | HTTP Processor handle to be used. |
Definition at line 323 of file http_processor.c.
References _compose_rsa_key_rotation_json(), _compose_rsa_onboarding_json(), _evaluate_response_codes(), _generate_correlation_id_string(), _process_registration_response_rsa_3072(), _process_registration_response_shared_secret(), _save_registration_information(), ASSERT_CODE_MESSAGE, ASSERT_STATEMENT_CODE_MESSAGE, string_t::buffer, security_handler_t::client_id, http_processor_t::configuration, CONTENT_TYPE_APPLICATION_JSON, content_type_values, DEBUG_ENTRY, DEBUG_LEAVE, http_processor_t::http_client, http_client_send(), HTTP_HEADER_ACCEPT, HTTP_HEADER_AUTHORIZATION, HTTP_HEADER_CONTENT_TYPE, HTTP_HEADER_CORRELATION_ID, http_header_names, http_request_add_header(), http_request_destroy(), http_request_initialize(), HTTP_REQUEST_RESIZE_ENABLED, http_response_destroy(), configuration_t::initial_access_token, string_t::length, configuration_t::max_http_payload_size, MCL_CREATED, MCL_ERROR, MCL_ERROR_RETURN, MCL_FAIL, MCL_HTTP_POST, MCL_HTTP_PUT, MCL_INFO, MCL_NULL, MCL_OK, MCL_SECURITY_RSA_3072, MCL_SECURITY_SHARED_SECRET, MCL_UNEXPECTED_RESULT_CODE, http_request_t::payload, security_handler_t::registration_access_token, security_handler_t::registration_client_uri, configuration_t::registration_endpoint, http_processor_t::security_handler, configuration_t::security_profile, string_destroy(), string_initialize_new(), string_util_memcpy(), string_util_snprintf(), and configuration_t::user_agent.
Referenced by mcl_communication_onboard(), and mcl_communication_rotate_key().
E_MCL_ERROR_CODE http_processor_stream | ( | http_processor_t * | http_processor, |
store_t * | store, | ||
void ** | reserved | ||
) |
Exchange operation logic with streaming.
Performs exchange operation on MindSphere using the http transfer-encoding method. This method directly writes the data to the request buffer while performing the send operation, this way uses less memory than normal exchange method, hence it is suitable sending large data in resource constrained systems. Also this is the only way to send unknown size data, which represented in MCL as stream_data_t.
[in] | http_processor | HTTP Processor handle to be used |
[in] | store | The data to be exchanged will be read from this store. |
[out] | reserved | Reserved for future use.
|
Definition at line 870 of file http_processor.c.
References _exchange_evaluate_response(), _exchange_initialize_http_request_headers(), _generate_correlation_id_string(), ASSERT_CODE_MESSAGE, http_processor_t::configuration, mcl_list_t::count, DEBUG_ENTRY, DEBUG_LEAVE, configuration_t::exchange_endpoint, store_t::high_priority_list, http_processor_t::http_client, http_client_send(), HTTP_HEADER_CORRELATION_ID, http_header_names, http_request_add_header(), http_request_destroy(), http_request_initialize(), HTTP_REQUEST_RESIZE_DISABLED, store_t::low_priority_list, configuration_t::max_http_payload_size, MCL_DEBUG, MCL_ERROR_RETURN, MCL_FAIL, MCL_HTTP_POST, MCL_NULL, MCL_OK, MCL_OPERATION_IS_NOT_SUPPORTED, MCL_STORE_IS_EMPTY, MCL_TRUE, http_client_send_callback_info_t::read_callback, http_processor_stream_callback_context_t::request, store_get_data_count(), string_destroy(), configuration_t::user_agent, and http_client_send_callback_info_t::user_context.
Referenced by mcl_communication_exchange().
E_MCL_ERROR_CODE http_processor_update_security_information | ( | http_processor_t * | http_processor | ) |
This function is called by mcl_communication_update_security_information()
.
[in] | http_processor | HTTP Processor handle to be used. |
Definition at line 459 of file http_processor.c.
References ASSERT_CODE_MESSAGE, string_t::buffer, security_handler_t::client_id, security_handler_t::client_secret, http_processor_t::configuration, DEBUG_ENTRY, DEBUG_LEAVE, configuration_t::load_function, MCL_FAIL, MCL_FREE, MCL_NULL, MCL_OK, MCL_SECURITY_SHARED_SECRET, MCL_SECURITY_UP_TO_DATE, MCL_TRUE, rsa_t::private_key, rsa_t::public_key, security_handler_t::registration_access_token, security_handler_t::rsa, mcl_load_registration_information_callback_t::rsa, configuration_t::save_function, http_processor_t::security_handler, configuration_t::security_profile, mcl_load_registration_information_callback_t::shared_secret, mcl_save_registration_information_callback_t::shared_secret, storage_load_rsa_registration_information(), storage_load_shared_secret_registration_information(), configuration_t::store_path, string_compare_with_cstr(), string_destroy(), string_initialize_dynamic(), string_util_strlen(), and string_util_strncmp().
Referenced by mcl_communication_update_security_information().
string_t endpoint_uri[ENDPOINT_URI_END] |
Definition at line 93 of file http_processor.c.