-
Notifications
You must be signed in to change notification settings - Fork 68
/
IotCredentialProvider.h
83 lines (61 loc) · 2.82 KB
/
IotCredentialProvider.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef __KINESIS_VIDEO_IOT_CREDENTIAL_PROVIDER_INCLUDE_I__
#define __KINESIS_VIDEO_IOT_CREDENTIAL_PROVIDER_INCLUDE_I__
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#define IOT_REQUEST_CONNECTION_TIMEOUT (3 * HUNDREDS_OF_NANOS_IN_A_SECOND)
#define IOT_REQUEST_COMPLETION_TIMEOUT (5 * HUNDREDS_OF_NANOS_IN_A_SECOND)
#define ROLE_ALIASES_PATH ((PCHAR) "/role-aliases")
#define CREDENTIAL_SERVICE ((PCHAR) "/credentials")
#define IOT_THING_NAME_HEADER "x-amzn-iot-thingname"
/**
* Service call callback functionality
*/
typedef STATUS (*BlockingServiceCallFunc)(PRequestInfo, PCallInfo);
/**
* Grace period which is added to the current time to determine whether the extracted credentials are still valid
*/
#define IOT_CREDENTIAL_FETCH_GRACE_PERIOD \
(5 * HUNDREDS_OF_NANOS_IN_A_SECOND + MIN_STREAMING_TOKEN_EXPIRATION_DURATION + STREAMING_TOKEN_EXPIRATION_GRACE_PERIOD)
typedef struct __IotCredentialProvider IotCredentialProvider;
struct __IotCredentialProvider {
// First member should be the abstract credential provider
AwsCredentialProvider credentialProvider;
// Current time functionality - optional
GetCurrentTimeFunc getCurrentTimeFn;
// Custom data supplied to time function
UINT64 customData;
// IoT credential endpoint
CHAR iotGetCredentialEndpoint[MAX_URI_CHAR_LEN + 1];
// IoT certificate file path
CHAR certPath[MAX_PATH_LEN + 1];
// IoT private key file path
CHAR privateKeyPath[MAX_PATH_LEN + 1];
// CA certificate file path
CHAR caCertPath[MAX_PATH_LEN + 1];
// IoT role alias
CHAR roleAlias[MAX_ROLE_ALIAS_LEN + 1];
// String name is used as IoT thing-name
CHAR thingName[MAX_STREAM_NAME_LEN + 1];
UINT64 connectionTimeout;
UINT64 completionTimeout;
// Static Aws Credentials structure with the pointer following the main allocation
PAwsCredentials pAwsCredentials;
// Service call functionality
BlockingServiceCallFunc serviceCallFn;
};
typedef struct __IotCredentialProvider* PIotCredentialProvider;
////////////////////////////////////////////////////////////////////////
// Callback function implementations
////////////////////////////////////////////////////////////////////////
STATUS createIotCredentialProviderWithTime(PCHAR, PCHAR, PCHAR, PCHAR, PCHAR, PCHAR, UINT64, UINT64, GetCurrentTimeFunc, UINT64,
BlockingServiceCallFunc, PAwsCredentialProvider*);
STATUS getIotCredentials(PAwsCredentialProvider, PAwsCredentials*);
// internal functions
STATUS iotCurlHandler(PIotCredentialProvider);
STATUS parseIotResponse(PIotCredentialProvider, PCallInfo);
#ifdef __cplusplus
}
#endif
#endif /* __KINESIS_VIDEO_IOT_CREDENTIAL_PROVIDER_INCLUDE_I__ */