Microsoft Azure IoTHub client AMQP transport
Dependents: sht15_remote_monitoring RobotArmDemo iothub_client_sample_amqp iothub_client_sample_amqp ... more
This library implements the AMQP transport for Microsoft Azure IoTHub client. The code is replicated from https://github.com/Azure/azure-iot-sdks
Diff: iothubtransport_amqp_cbs_auth.c
- Revision:
- 42:c2eaa912a28c
- Parent:
- 41:71c01aa3df1a
- Child:
- 50:f3a92c6c6534
--- a/iothubtransport_amqp_cbs_auth.c Mon Sep 11 09:22:16 2017 -0700 +++ b/iothubtransport_amqp_cbs_auth.c Mon Sep 25 13:37:09 2017 -0700 @@ -253,6 +253,8 @@ char* sas_token; STRING_HANDLE devices_path; + // Codes_SRS_IOTHUBTRANSPORT_AMQP_AUTH_09_053: [A STRING_HANDLE, referred to as `devices_path`, shall be created from the following parts: iothub_host_fqdn + "/devices/" + device_id] + // Codes_SRS_IOTHUBTRANSPORT_AMQP_AUTH_09_071: [A STRING_HANDLE, referred to as `devices_path`, shall be created from the following parts: iothub_host_fqdn + "/devices/" + device_id] if ((devices_path = create_devices_path(instance->iothub_host_fqdn, instance->device_id)) == NULL) { // Codes_SRS_IOTHUBTRANSPORT_AMQP_AUTH_09_054: [If `devices_path` failed to be created, authentication_do_work() shall fail and return] @@ -267,32 +269,16 @@ IOTHUB_CREDENTIAL_TYPE cred_type = IoTHubClient_Auth_Get_Credential_Type(instance->authorization_module); if (cred_type == IOTHUB_CREDENTIAL_TYPE_DEVICE_KEY || cred_type == IOTHUB_CREDENTIAL_TYPE_DEVICE_AUTH) { - double seconds_since_epoch; - // Codes_SRS_IOTHUBTRANSPORT_AMQP_AUTH_09_053: [A STRING_HANDLE, referred to as `devices_path`, shall be created from the following parts: iothub_host_fqdn + "/devices/" + device_id] - // Codes_SRS_IOTHUBTRANSPORT_AMQP_AUTH_09_071: [A STRING_HANDLE, referred to as `devices_path`, shall be created from the following parts: iothub_host_fqdn + "/devices/" + device_id] - if (get_seconds_since_epoch(&seconds_since_epoch) != RESULT_OK) + /* Codes_SRS_IOTHUBTRANSPORT_AMQP_AUTH_09_049: [authentication_do_work() shall create a SAS token using IoTHubClient_Auth_Get_SasToken, unless it has failed previously] */ + sas_token = IoTHubClient_Auth_Get_SasToken(instance->authorization_module, STRING_c_str(devices_path), instance->sas_token_lifetime_secs); + if (sas_token == NULL) { + LogError("failure getting sas token."); result = __FAILURE__; - sas_token = NULL; - LogError("Failed creating a SAS token (get_seconds_since_epoch() failed)"); } else { - // Codes_SRS_IOTHUBTRANSPORT_AMQP_AUTH_09_052: [The SAS token expiration time shall be calculated adding `instance->sas_token_lifetime_secs` to the current number of seconds since epoch time UTC] - // Codes_SRS_IOTHUBTRANSPORT_AMQP_AUTH_09_070: [The SAS token expiration time shall be calculated adding `instance->sas_token_lifetime_secs` to the current number of seconds since epoch time UTC] - size_t sas_token_expiration_time_secs = (size_t)seconds_since_epoch + instance->sas_token_lifetime_secs; - - /* Codes_SRS_IOTHUBTRANSPORT_AMQP_AUTH_09_049: [authentication_do_work() shall create a SAS token using IoTHubClient_Auth_Get_SasToken, unless it has failed previously] */ - sas_token = IoTHubClient_Auth_Get_SasToken(instance->authorization_module, STRING_c_str(devices_path), sas_token_expiration_time_secs); - if (sas_token == NULL) - { - LogError("failure getting sas token."); - result = __FAILURE__; - } - else - { - result = RESULT_OK; - } + result = RESULT_OK; } } else if (cred_type == IOTHUB_CREDENTIAL_TYPE_SAS_TOKEN)