1 | // Copyright (c) Microsoft. All rights reserved.
|
---|
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
---|
3 |
|
---|
4 | #ifndef IOTHUB_CLIENT_AUTHORIZATION_H
|
---|
5 | #define IOTHUB_CLIENT_AUTHORIZATION_H
|
---|
6 |
|
---|
7 | #include "azure_c_shared_utility/macro_utils.h"
|
---|
8 | #include "azure_c_shared_utility/umock_c_prod.h"
|
---|
9 | #include "azure_c_shared_utility/xio.h"
|
---|
10 |
|
---|
11 | #ifdef __cplusplus
|
---|
12 | extern "C" {
|
---|
13 | #include <cstdint>
|
---|
14 | #else
|
---|
15 | #include <stdint.h>
|
---|
16 | #include <stdbool.h>
|
---|
17 | #endif /* __cplusplus */
|
---|
18 |
|
---|
19 | typedef struct IOTHUB_AUTHORIZATION_DATA_TAG* IOTHUB_AUTHORIZATION_HANDLE;
|
---|
20 |
|
---|
21 | #define IOTHUB_CREDENTIAL_TYPE_VALUES \
|
---|
22 | IOTHUB_CREDENTIAL_TYPE_UNKNOWN, \
|
---|
23 | IOTHUB_CREDENTIAL_TYPE_DEVICE_KEY, \
|
---|
24 | IOTHUB_CREDENTIAL_TYPE_X509, \
|
---|
25 | IOTHUB_CREDENTIAL_TYPE_X509_ECC, \
|
---|
26 | IOTHUB_CREDENTIAL_TYPE_SAS_TOKEN, \
|
---|
27 | IOTHUB_CREDENTIAL_TYPE_DEVICE_AUTH
|
---|
28 |
|
---|
29 |
|
---|
30 | MU_DEFINE_ENUM(IOTHUB_CREDENTIAL_TYPE, IOTHUB_CREDENTIAL_TYPE_VALUES);
|
---|
31 |
|
---|
32 | #define SAS_TOKEN_STATUS_VALUES \
|
---|
33 | SAS_TOKEN_STATUS_FAILED, \
|
---|
34 | SAS_TOKEN_STATUS_VALID, \
|
---|
35 | SAS_TOKEN_STATUS_INVALID
|
---|
36 |
|
---|
37 | MU_DEFINE_ENUM(SAS_TOKEN_STATUS, SAS_TOKEN_STATUS_VALUES);
|
---|
38 |
|
---|
39 | MOCKABLE_FUNCTION(, IOTHUB_AUTHORIZATION_HANDLE, IoTHubClient_Auth_Create, const char*, device_key, const char*, device_id, const char*, device_sas_token, const char *, module_id);
|
---|
40 | MOCKABLE_FUNCTION(, IOTHUB_AUTHORIZATION_HANDLE, IoTHubClient_Auth_CreateFromDeviceAuth, const char*, device_id, const char*, module_id);
|
---|
41 | MOCKABLE_FUNCTION(, void, IoTHubClient_Auth_Destroy, IOTHUB_AUTHORIZATION_HANDLE, handle);
|
---|
42 | MOCKABLE_FUNCTION(, IOTHUB_CREDENTIAL_TYPE, IoTHubClient_Auth_Set_x509_Type, IOTHUB_AUTHORIZATION_HANDLE, handle, bool, enable_x509);
|
---|
43 | MOCKABLE_FUNCTION(, IOTHUB_CREDENTIAL_TYPE, IoTHubClient_Auth_Get_Credential_Type, IOTHUB_AUTHORIZATION_HANDLE, handle);
|
---|
44 | MOCKABLE_FUNCTION(, char*, IoTHubClient_Auth_Get_SasToken, IOTHUB_AUTHORIZATION_HANDLE, handle, const char*, scope, size_t, expiry_time_relative_seconds, const char*, key_name);
|
---|
45 | MOCKABLE_FUNCTION(, int, IoTHubClient_Auth_Set_xio_Certificate, IOTHUB_AUTHORIZATION_HANDLE, handle, XIO_HANDLE, xio);
|
---|
46 | MOCKABLE_FUNCTION(, const char*, IoTHubClient_Auth_Get_DeviceId, IOTHUB_AUTHORIZATION_HANDLE, handle);
|
---|
47 | MOCKABLE_FUNCTION(, const char*, IoTHubClient_Auth_Get_ModuleId, IOTHUB_AUTHORIZATION_HANDLE, handle);
|
---|
48 | MOCKABLE_FUNCTION(, const char*, IoTHubClient_Auth_Get_DeviceKey, IOTHUB_AUTHORIZATION_HANDLE, handle);
|
---|
49 | MOCKABLE_FUNCTION(, SAS_TOKEN_STATUS, IoTHubClient_Auth_Is_SasToken_Valid, IOTHUB_AUTHORIZATION_HANDLE, handle);
|
---|
50 | MOCKABLE_FUNCTION(, int, IoTHubClient_Auth_Get_x509_info, IOTHUB_AUTHORIZATION_HANDLE, handle, char**, x509_cert, char**, x509_key);
|
---|
51 | MOCKABLE_FUNCTION(, int, IoTHubClient_Auth_Set_SasToken_Expiry, IOTHUB_AUTHORIZATION_HANDLE, handle, size_t, expiry_time_seconds);
|
---|
52 | MOCKABLE_FUNCTION(, size_t, IoTHubClient_Auth_Get_SasToken_Expiry, IOTHUB_AUTHORIZATION_HANDLE, handle);
|
---|
53 |
|
---|
54 |
|
---|
55 | #ifdef USE_EDGE_MODULES
|
---|
56 | MOCKABLE_FUNCTION(, char*, IoTHubClient_Auth_Get_TrustBundle, IOTHUB_AUTHORIZATION_HANDLE, handle, const char*, certificate_file_name);
|
---|
57 | #endif
|
---|
58 |
|
---|
59 |
|
---|
60 | #ifdef __cplusplus
|
---|
61 | }
|
---|
62 | #endif
|
---|
63 |
|
---|
64 | #endif /* IOTHUB_CLIENT_AUTHORIZATION_H */
|
---|