diff --git a/client/client-multi/client-c/CMakeLists.txt b/client/client-multi/client-c/CMakeLists.txt index e469d537a7..a7bfb7a9bb 100644 --- a/client/client-multi/client-c/CMakeLists.txt +++ b/client/client-multi/client-c/CMakeLists.txt @@ -166,7 +166,6 @@ set(KAA_SOURCE_FILES ${KAA_SRC_FOLDER}/avro_src/io.c ${KAA_SRC_FOLDER}/avro_src/encoding_binary.c ${KAA_SRC_FOLDER}/collections/kaa_list.c - ${KAA_SRC_FOLDER}/utilities/kaa_aes_rsa.c ${KAA_SRC_FOLDER}/utilities/kaa_log.c ${KAA_SRC_FOLDER}/utilities/kaa_mem.c ${KAA_SRC_FOLDER}/utilities/kaa_buffer.c @@ -178,7 +177,14 @@ set(KAA_SOURCE_FILES ${KAA_SRC_FOLDER}/kaa.c ${KAA_SRC_FOLDER}/kaa_extension.c ${KAA_SRC_FOLDER}/platform-impl/common/kaa_htonll.c - ) +) + +if(WITH_ENCRYPTION) + set(KAA_SOURCE_FILES + ${KAA_SOURCE_FILES} + ${KAA_SRC_FOLDER}/utilities/kaa_aes_rsa.c + ${KAA_SRC_FOLDER}/platform-impl/common/encryption_utils.c) +endif(WITH_ENCRYPTION) # Includes auto-generated Cmake's scripts. @@ -186,19 +192,23 @@ include(${CMAKE_CURRENT_LIST_DIR}/listfiles/CMakeGen.cmake) # Kaa include directories set(KAA_INCLUDE_DIRS - ${KAA_INCLUDE_PATHS} # Provided by platform cmake + ${KAA_INCLUDE_PATHS} ${CMAKE_CURRENT_LIST_DIR}/src - ${CMAKE_CURRENT_LIST_DIR}/thirdparty/mbedtls ${KAA_SRC_FOLDER} ${KAA_THIRDPARTY_INCLUDE_DIR}) # Build unit tests. include(${CMAKE_CURRENT_LIST_DIR}/listfiles/UnitTest.cmake) +include_directories(SYSTEM ${KAA_INCLUDE_PATHS}) + +# This already includes mbedtls +add_subdirectory(tools/kaa_encryption/rsa_key_gen) + # Build Kaa libraries. add_library(kaac ${KAA_SOURCE_FILES}) target_include_directories(kaac PUBLIC ${KAA_INCLUDE_DIRS}) -target_link_libraries(kaac PRIVATE ${KAA_THIRDPARTY_LIBRARIES}) +target_link_libraries(kaac PRIVATE ${KAA_THIRDPARTY_LIBRARIES} mbedtls) message("BOOTSTRAP ENABLED") include(${CMAKE_CURRENT_LIST_DIR}/src/extensions/bootstrap/CMakeLists.txt) @@ -281,7 +291,6 @@ if(${KAA_PLATFORM} STREQUAL "posix") if(${KAA_RUNTIME_KEY_GENERATION}) add_definitions(-DKAA_RUNTIME_KEY_GENERATION) endif() - add_subdirectory(tools/kaa_encryption/rsa_key_gen) target_link_libraries(kaac PUBLIC rsa_keygen) else() add_dependencies(kaac kaa_rsa_keygen) diff --git a/client/client-multi/client-c/listfiles/platform/esp8266/CMakeLists.txt b/client/client-multi/client-c/listfiles/platform/esp8266/CMakeLists.txt index bcea41b8f9..6e0505c928 100644 --- a/client/client-multi/client-c/listfiles/platform/esp8266/CMakeLists.txt +++ b/client/client-multi/client-c/listfiles/platform/esp8266/CMakeLists.txt @@ -28,13 +28,13 @@ set(ESP8266_SRC ${ESP8266_SRC_FOLDER}/status.c ${ESP8266_SRC_FOLDER}/tcp_utils.c ${ESP8266_SRC_FOLDER}/time.c - ${KAA_SRC_FOLDER}/platform-impl/common/key_utils.c ${ESP8266_SRC_FOLDER}/exit.c ${ESP8266_SRC_FOLDER}/snprintf.c ${KAA_SRC_FOLDER}/platform-impl/common/sha.c ${KAA_SRC_FOLDER}/platform-impl/common/kaa_failover_strategy.c ${KAA_SRC_FOLDER}/platform-impl/common/ext_log_storage_memory.c ${KAA_SRC_FOLDER}/platform-impl/common/ext_log_upload_strategies.c + ${KAA_SRC_FOLDER}/platform-impl/common/key_utils.c ${KAA_SRC_FOLDER}/platform-impl/common/kaa_tcp_channel.c ${KAA_SRC_FOLDER}/kaa_protocols/kaa_tcp/kaatcp_parser.c ${KAA_SRC_FOLDER}/kaa_protocols/kaa_tcp/kaatcp_request.c diff --git a/client/client-multi/client-c/listfiles/platform/posix/CMakeLists.txt b/client/client-multi/client-c/listfiles/platform/posix/CMakeLists.txt index 2651ab962c..354341a0e5 100644 --- a/client/client-multi/client-c/listfiles/platform/posix/CMakeLists.txt +++ b/client/client-multi/client-c/listfiles/platform/posix/CMakeLists.txt @@ -17,7 +17,6 @@ set(KAA_SOURCE_FILES ${KAA_SOURCE_FILES} ${KAA_SRC_FOLDER}/platform-impl/posix/kaa_client.c - ${KAA_SRC_FOLDER}/platform-impl/posix/key_utils.c ${KAA_SRC_FOLDER}/platform-impl/posix/logger.c ${KAA_SRC_FOLDER}/platform-impl/posix/file_utils.c ${KAA_SRC_FOLDER}/platform-impl/posix/status.c @@ -26,6 +25,7 @@ set(KAA_SOURCE_FILES ${KAA_SRC_FOLDER}/platform-impl/common/kaa_failover_strategy.c ${KAA_SRC_FOLDER}/platform-impl/common/ext_log_storage_memory.c ${KAA_SRC_FOLDER}/platform-impl/common/ext_log_upload_strategies.c + ${KAA_SRC_FOLDER}/platform-impl/common/key_utils.c ) if(NOT KAA_WITHOUT_TCP_CHANNEL) diff --git a/client/client-multi/client-c/src/extensions/logging/kaa_logging.c b/client/client-multi/client-c/src/extensions/logging/kaa_logging.c index 020b8e4f92..e323164d10 100644 --- a/client/client-multi/client-c/src/extensions/logging/kaa_logging.c +++ b/client/client-multi/client-c/src/extensions/logging/kaa_logging.c @@ -22,7 +22,6 @@ #include #include #include -#include #include "platform/stdio.h" #include "platform/sock.h" #include "platform/time.h" diff --git a/client/client-multi/client-c/src/extensions/profile/kaa_profile.c b/client/client-multi/client-c/src/extensions/profile/kaa_profile.c index cc49682688..9bb4d27015 100644 --- a/client/client-multi/client-c/src/extensions/profile/kaa_profile.c +++ b/client/client-multi/client-c/src/extensions/profile/kaa_profile.c @@ -251,7 +251,7 @@ kaa_error_t kaa_profile_request_get_size(kaa_profile_manager_t *self, size_t *ex if (!self->status->is_registered) { if (!self->extension_data->public_key.buffer) { - ext_get_endpoint_public_key((uint8_t **)&self->extension_data->public_key.buffer, + ext_get_endpoint_public_key((const uint8_t **)&self->extension_data->public_key.buffer, (size_t *)&self->extension_data->public_key.size); } diff --git a/client/client-multi/client-c/src/kaa/kaa.c b/client/client-multi/client-c/src/kaa/kaa.c index ff5be43f6c..a2e498a1cb 100644 --- a/client/client-multi/client-c/src/kaa/kaa.c +++ b/client/client-multi/client-c/src/kaa/kaa.c @@ -30,6 +30,10 @@ #include "kaa_defaults.h" #include "platform/ext_key_utils.h" +#ifdef KAA_ENCRYPTION +#include "platform/ext_encryption_utils.h" +#endif + #include #ifndef KAA_DISABLE_FEATURE_PROFILE @@ -111,6 +115,26 @@ static kaa_error_t kaa_context_destroy(kaa_context_t *context) return KAA_ERR_NONE; } +static kaa_error_t kaa_init_keys(void) +{ + kaa_error_t error = kaa_init_rsa_keypair(); + if (error) { + return error; + } +#ifdef KAA_ENCRYPTION + error = kaa_init_session_key(); + if (error) { + return error; + } +#endif + return error; +} + +static void kaa_deinit_keys(void) +{ + kaa_deinit_rsa_keypair(); +} + kaa_error_t kaa_init(kaa_context_t **kaa_context_p) { KAA_RETURN_IF_NIL(kaa_context_p, KAA_ERR_BADPARAM); diff --git a/client/client-multi/client-c/src/kaa/platform-impl/common/encryption_utils.c b/client/client-multi/client-c/src/kaa/platform-impl/common/encryption_utils.c new file mode 100644 index 0000000000..21da7280cf --- /dev/null +++ b/client/client-multi/client-c/src/kaa/platform-impl/common/encryption_utils.c @@ -0,0 +1,155 @@ +/* + * Copyright 2014-2016 CyberVision, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "platform/ext_encryption_utils.h" +#include "platform/ext_key_utils.h" + +#include +#include + +#include + +#include +#include +#include +#include + +#define ENCRYPTED_SESSION_KEY_LENGTH 256 +#define KAA_SIGNATURE_LENGTH 256 +#define AES_ECB_ENCRYPTION_CHUNK_SIZE 16 + +extern mbedtls_pk_context kaa_pk_context_; + +/** + * Contains Endpoint keys. + * + * The main purpose of the structure is + * caching calculated keys. + */ +static struct { + uint8_t session_key[KAA_SESSION_KEY_LENGTH]; + uint8_t encrypted_session_key[ENCRYPTED_SESSION_KEY_LENGTH]; + uint8_t signature[KAA_SIGNATURE_LENGTH]; + size_t session_key_length; +} keys; + +kaa_error_t kaa_init_session_key(void) +{ + /* Initialization should be performed only once */ + static bool initialized = false; + if (!initialized) { + /* Generate session key */ + if (init_aes_key(keys.session_key, KAA_SESSION_KEY_LENGTH)) { + return KAA_ERR_BADDATA; + } + + keys.session_key_length = KAA_SESSION_KEY_LENGTH; + initialized = true; + } + + return KAA_ERR_NONE; +} + +void ext_get_endpoint_session_key(const uint8_t **buffer, size_t *buffer_size) +{ + if (buffer == NULL || buffer_size == 0) { + return; + } + *buffer = keys.session_key; + *buffer_size = keys.session_key_length; +} + +/* Get encrypted session key (enctypted with remote key) */ +kaa_error_t ext_get_encrypted_session_key(uint8_t **buffer, size_t *buffer_size, + const uint8_t *remote_key, size_t remote_key_size) +{ + if (buffer == NULL || buffer_size == NULL || remote_key == NULL || remote_key_size == 0) { + return KAA_ERR_BADPARAM; + } + + kaa_error_t err = rsa_encrypt(remote_key, remote_key_size, keys.session_key, + KAA_SESSION_KEY_LENGTH, keys.encrypted_session_key); + if (err) { + return err; + } + + *buffer = keys.encrypted_session_key; + *buffer_size = ENCRYPTED_SESSION_KEY_LENGTH; + + return err; +} +size_t ext_get_encrypted_data_size(size_t input_size) +{ + if (input_size == 0) { + return 0; + } + + return input_size + AES_ECB_ENCRYPTION_CHUNK_SIZE - + (input_size % AES_ECB_ENCRYPTION_CHUNK_SIZE); +} + +kaa_error_t ext_encrypt_data(const uint8_t *input, size_t payload_size, uint8_t *output) +{ + if (input == NULL || payload_size == 0 || output == NULL) { + return KAA_ERR_BADPARAM; + } + + /* Adding PKCS7 padding */ + size_t enc_data_size = ext_get_encrypted_data_size(payload_size); + uint8_t padding = enc_data_size - payload_size; + memset(output + payload_size, padding, padding); + + return aes_encrypt_decrypt(MBEDTLS_AES_ENCRYPT, input, enc_data_size, + output, keys.session_key); +} + +kaa_error_t ext_decrypt_data(const uint8_t *input, size_t input_size, + uint8_t *output, size_t *output_size) +{ + if (input == NULL || input_size == 0 || output == NULL || output_size == 0) { + return KAA_ERR_BADPARAM; + } + + if (aes_encrypt_decrypt(MBEDTLS_AES_DECRYPT, input, input_size, + output, keys.session_key)) { + return KAA_ERR_BADPARAM; + } + + /* Reduce PKCS7 padding */ + uint8_t padding_length = *(output+input_size - 1); + *output_size = input_size - padding_length; + + return KAA_ERR_NONE; +} + +kaa_error_t ext_get_signature(const uint8_t *input, size_t input_size, + uint8_t **output, size_t *output_size) +{ + if (!input || !input_size || !output || !output_size) { + return KAA_ERR_BADPARAM; + } + + kaa_error_t error = rsa_sign(&kaa_pk_context_, input, input_size, keys.signature, output_size); + + if (error) { + return KAA_ERR_BADDATA; + } + *output = keys.signature; + *output_size = KAA_SIGNATURE_LENGTH; + + return KAA_ERR_NONE; +} + diff --git a/client/client-multi/client-c/src/kaa/platform-impl/common/kaa_tcp_channel.c b/client/client-multi/client-c/src/kaa/platform-impl/common/kaa_tcp_channel.c index 20c295c260..9b01911277 100644 --- a/client/client-multi/client-c/src/kaa/platform-impl/common/kaa_tcp_channel.c +++ b/client/client-multi/client-c/src/kaa/platform-impl/common/kaa_tcp_channel.c @@ -33,7 +33,7 @@ #include "platform/ext_system_logger.h" #include #include "kaa_platform_common.h" -#include "platform/ext_key_utils.h" +#include "platform/ext_encryption_utils.h" #include "kaa_tcp_channel.h" #include "kaa_context.h" #include "kaa_channel_manager.h" diff --git a/client/client-multi/client-c/src/kaa/platform-impl/common/key_utils.c b/client/client-multi/client-c/src/kaa/platform-impl/common/key_utils.c index de3eb443f0..b3fa05cb6c 100644 --- a/client/client-multi/client-c/src/kaa/platform-impl/common/key_utils.c +++ b/client/client-multi/client-c/src/kaa/platform-impl/common/key_utils.c @@ -24,247 +24,158 @@ #include #include #include + #include + +#ifdef KAA_RUNTIME_KEY_GENERATION #include #include #include -#include +#include +#define KAA_PRIVATE_KEY_STORAGE "private.key" +#define KAA_PUBLIC_KEY_STORAGE "public.key" -#define KAA_SESSION_KEY_LENGTH 16 -#define ENC_SESSION_KEY_LENGTH 256 -#define KAA_SIGNATURE_LENGTH 256 -#define AES_ECB_ENCRYPTION_CHUNCK_SIZE 16 +static mbedtls_pk_context pk_pub_context; +#else +#include +#endif /* KAA_RUNTIME_KEY_GENERATION */ -/** - * Contains Endpoint keys. - * - * The main purpose of the structure is - * caching calculated keys. - */ -typedef struct { - uint8_t session_key[KAA_SESSION_KEY_LENGTH]; - uint8_t encrypted_session_key[ENC_SESSION_KEY_LENGTH]; - uint8_t signature[KAA_SIGNATURE_LENGTH]; - size_t encrypted_session_key_length; - size_t session_key_length; -} endpoint_keys_t; +#define KAA_RSA_PUBLIC_KEY_LENGTH_MAX 294 +#define KAA_SHA1_PUB_LEN 20 +#define KAA_SHA1_PUB_BASE64_LEN 28 -/* Endpoint's RSA Keys */ -static endpoint_keys_t keys; -static mbedtls_pk_context pk_context_; -/* Some forward declarations of helpers */ -static kaa_error_t set_rsa_public_key(mbedtls_pk_context *pk, const uint8_t *key, size_t key_size); -static int rsa_encrypt(mbedtls_pk_context *pk, const uint8_t *input, - size_t input_len, uint8_t *output); +mbedtls_pk_context kaa_pk_context_; -/* Performs initialization of the keys */ -kaa_error_t kaa_init_keys(void) +kaa_error_t kaa_init_rsa_keypair(void) { +#ifdef KAA_RUNTIME_KEY_GENERATION /* Initialization should be performed only once */ static bool initialized = false; if (!initialized) { - /* Generate session key */ - if (init_aes_key(keys.session_key, KAA_SESSION_KEY_LENGTH)) { - return KAA_ERR_BADDATA; + if (mbedtls_pk_parse_keyfile(&kaa_pk_context_, KAA_PRIVATE_KEY_STORAGE, NULL)) { + if (rsa_genkey(&kaa_pk_context_)) { + mbedtls_pk_free(&kaa_pk_context_); + return KAA_ERR_BADDATA; + } + if (write_rsa_key(&kaa_pk_context_, KAA_PRIVATE_KEY_STORAGE, PRIVATE_KEY)) { + mbedtls_pk_free(&kaa_pk_context_); + return KAA_ERR_BADDATA; + } + if (write_rsa_key(&kaa_pk_context_, KAA_PUBLIC_KEY_STORAGE, PUBLIC_KEY)) { + mbedtls_pk_free(&kaa_pk_context_); + return KAA_ERR_BADDATA; + } } - - keys.session_key_length = KAA_SESSION_KEY_LENGTH; - if (mbedtls_pk_parse_key(&pk_context_, KAA_RSA_PRIVATE_KEY, - KAA_RSA_PRIVATE_KEY_LENGTH, NULL, 0)) { - return KAA_ERR_BADDATA; + if (mbedtls_pk_parse_public_keyfile(&pk_pub_context, KAA_PUBLIC_KEY_STORAGE)) { + pk_pub_context = kaa_pk_context_; } initialized = true; } - - return KAA_ERR_NONE; -} - -void kaa_deinit_keys(void) -{ - mbedtls_pk_free(&pk_context_); -} - -void ext_get_endpoint_session_key(uint8_t **buffer, size_t *buffer_size) -{ - if (!buffer || !buffer_size) { - return; +#else + if (mbedtls_pk_parse_key(&kaa_pk_context_, KAA_RSA_PRIVATE_KEY, + KAA_RSA_PRIVATE_KEY_LENGTH, NULL, 0)) { + return KAA_ERR_BADDATA; } - *buffer = keys.session_key; - *buffer_size = keys.session_key_length; +#endif /* KAA_RUNTIME_KEY_GENERATION */ + return KAA_ERR_NONE; } -/* Get encrypted session key (enctypted with remote key) */ -kaa_error_t ext_get_encrypted_session_key(uint8_t **buffer, size_t *buffer_size, - const uint8_t *remote_key, size_t remote_key_size) +void kaa_deinit_rsa_keypair(void) { - if (!buffer || !buffer_size || !remote_key || !remote_key_size) { - return KAA_ERR_BADPARAM; - } - - mbedtls_pk_context local_ctx; - mbedtls_pk_init(&local_ctx); - int err = set_rsa_public_key(&local_ctx, remote_key, remote_key_size); - if (err) { - goto exit; - } - err = rsa_encrypt(&local_ctx, keys.session_key, - KAA_SESSION_KEY_LENGTH, keys.encrypted_session_key); - if (err) { - goto exit; - } - - keys.encrypted_session_key_length = ENC_SESSION_KEY_LENGTH; - - *buffer = keys.encrypted_session_key; - *buffer_size = keys.encrypted_session_key_length; - -exit: - mbedtls_pk_free(&local_ctx); - return err ? KAA_ERR_BADDATA : KAA_ERR_NONE; + mbedtls_pk_free(&kaa_pk_context_); } +#ifdef KAA_RUNTIME_KEY_GENERATION /* TODO(KAA-1089) */ __attribute__((weak)) -void ext_get_endpoint_public_key(uint8_t **buffer, size_t *buffer_size) +void ext_get_endpoint_public_key(const uint8_t **buffer, size_t *buffer_size) { - if (!buffer || !buffer_size) { + if (buffer == NULL || buffer_size == 0) { return; } - - *buffer = KAA_RSA_PUBLIC_KEY; - *buffer_size = KAA_RSA_PUBLIC_KEY_LENGTH; -} - -size_t ext_get_encrypted_data_size(size_t input_size) -{ - if (!input_size) { - return 0; - } - - if (input_size % AES_ECB_ENCRYPTION_CHUNCK_SIZE != 0) { - return AES_ECB_ENCRYPTION_CHUNCK_SIZE - - (input_size % AES_ECB_ENCRYPTION_CHUNCK_SIZE) + input_size; + static int key_length; + static int initialized = false; + static uint8_t buff[KAA_RSA_PUBLIC_KEY_LENGTH_MAX]; + if (!initialized) { + key_length = mbedtls_pk_write_pubkey_der(&pk_pub_context, buff, sizeof(buff)); + if (key_length < 0) { + *buffer = NULL; + *buffer_size = 0; + return; + } + initialized = true; } - - return input_size + AES_ECB_ENCRYPTION_CHUNCK_SIZE; + *buffer = buff; + *buffer_size = key_length; } -kaa_error_t ext_encrypt_data(const uint8_t *input, size_t payload_size, uint8_t *output) +void ext_get_sha1_public(uint8_t **sha1, size_t *length) { - if (!input || !payload_size || !output) { - return KAA_ERR_BADPARAM; + if (sha1 == NULL || length == NULL) { + return; } - - /* Adding PKCS7 padding */ - size_t enc_data_size = ext_get_encrypted_data_size(payload_size); - uint8_t padding = enc_data_size - payload_size; - memset(output + payload_size, padding, padding); - - /* Process the buffer chunk by chunk */ - while (enc_data_size >= KAA_SESSION_KEY_LENGTH) { - if (aes_encrypt_decrypt(MBEDTLS_AES_ENCRYPT, input, - KAA_SESSION_KEY_LENGTH, - output, keys.session_key) < 0) { - return KAA_ERR_BADDATA; + static uint8_t sha1_public[KAA_SHA1_PUB_LEN]; + static int initialized = false; + if (!initialized) { + uint8_t pub_key[KAA_RSA_PUBLIC_KEY_LENGTH_MAX]; + int key_length = mbedtls_pk_write_pubkey_der(&pk_pub_context, pub_key, KAA_RSA_PUBLIC_KEY_LENGTH_MAX); + if (key_length < 0) { + *sha1 = NULL; + *length = 0; + return; } - - enc_data_size -= KAA_SESSION_KEY_LENGTH; - - input += KAA_SESSION_KEY_LENGTH; - output += KAA_SESSION_KEY_LENGTH; + sha1_from_public_key(pub_key, key_length, sha1_public); + initialized = true; } - - return KAA_ERR_NONE; + *length = KAA_SHA1_PUB_LEN; + *sha1 = sha1_public; } -kaa_error_t ext_decrypt_data(const uint8_t *input, size_t input_size, - uint8_t *output, size_t *output_payload_size) +kaa_error_t ext_get_sha1_base64_public(const uint8_t **sha1, size_t *length) { - if (!input || !input_size || !output || !output_payload_size) { + if (sha1 == NULL || length == NULL) { return KAA_ERR_BADPARAM; } - - size_t tmp_in_size = input_size; - while (input_size >= KAA_SESSION_KEY_LENGTH) { - if (aes_encrypt_decrypt(MBEDTLS_AES_DECRYPT, input, - KAA_SESSION_KEY_LENGTH, output, - keys.session_key) < 0) { + static size_t sha1_base64_len = 0; + static uint8_t sha1_base64_buffer[KAA_SHA1_PUB_BASE64_LEN]; + static int initialized = false; + if (!initialized) { + uint8_t pub_key[KAA_RSA_PUBLIC_KEY_LENGTH_MAX]; + uint8_t sha1_public[KAA_SHA1_PUB_LEN]; + int key_length = mbedtls_pk_write_pubkey_der(&pk_pub_context, pub_key, KAA_RSA_PUBLIC_KEY_LENGTH_MAX); + if (key_length < 0) { return KAA_ERR_BADDATA; } - input_size -= KAA_SESSION_KEY_LENGTH; - - input += KAA_SESSION_KEY_LENGTH; - output += KAA_SESSION_KEY_LENGTH; - } - - /* Reduce PKCS7 padding */ - uint8_t padding_length = *(output - 1); - *output_payload_size = tmp_in_size - padding_length; - - return KAA_ERR_NONE; -} - -kaa_error_t ext_get_signature(const uint8_t *input, size_t input_size, - uint8_t **output, size_t *output_size) -{ - if (!input || !input_size || !output || !output_size) { - return KAA_ERR_BADPARAM; - } - - kaa_error_t error = rsa_sign(&pk_context_, input, input_size, keys.signature, output_size); - - if (error) { - return KAA_ERR_BADDATA; + sha1_from_public_key(pub_key, key_length, sha1_public); + int error = sha1_to_base64(sha1_public, sizeof(sha1_public), sha1_base64_buffer, sizeof(sha1_base64_buffer), &sha1_base64_len); + if (error) { + return KAA_ERR_BADDATA; + } + initialized = true; } - *output = keys.signature; - *output_size = KAA_SIGNATURE_LENGTH; - + *sha1 = sha1_base64_buffer; + *length = sha1_base64_len; return KAA_ERR_NONE; } - -static kaa_error_t set_rsa_public_key(mbedtls_pk_context *pk, const uint8_t *key, size_t key_size) -{ - if (!pk || !key || !key_size) { - return KAA_ERR_BADPARAM; - } - - if (mbedtls_pk_parse_public_key(pk, key, key_size)!= 0) { - return KAA_ERR_INVALID_PUB_KEY; - } - - return KAA_ERR_NONE; -} - -static int rsa_encrypt(mbedtls_pk_context *pk, const uint8_t *input, size_t input_len, uint8_t *output) +#else +/* TODO(KAA-1089) */ +__attribute__((weak)) +void ext_get_endpoint_public_key(const uint8_t **buffer, size_t *buffer_size) { - int ret = 0; - - mbedtls_entropy_context entropy; - mbedtls_ctr_drbg_context ctr_drbg; - const uint8_t pers[] = "key_gen"; - - mbedtls_ctr_drbg_init(&ctr_drbg); - mbedtls_entropy_init(&entropy); - - ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, - pers, sizeof(pers) - 1); - if (!ret) { - ret = mbedtls_rsa_rsaes_pkcs1_v15_encrypt(mbedtls_pk_rsa(*pk), mbedtls_ctr_drbg_random, &ctr_drbg, - MBEDTLS_RSA_PUBLIC, input_len, input, output); + if (buffer == NULL || buffer_size == NULL) { + return; } - mbedtls_ctr_drbg_free(&ctr_drbg); - mbedtls_entropy_free(&entropy); - - return ret; + *buffer = KAA_RSA_PUBLIC_KEY; + *buffer_size = KAA_RSA_PUBLIC_KEY_LENGTH; } void ext_get_sha1_public(uint8_t **sha1, size_t *length) { - if (!sha1 || !length) { + if (sha1 == NULL || length == NULL) { return; } *sha1 = (uint8_t *)KAA_SHA1_PUB; @@ -273,10 +184,11 @@ void ext_get_sha1_public(uint8_t **sha1, size_t *length) kaa_error_t ext_get_sha1_base64_public(const uint8_t **sha1, size_t *length) { - if (!sha1 || !length) { + if (sha1 == NULL || length == NULL) { return KAA_ERR_BADPARAM; } *sha1 = (uint8_t *)KAA_SHA1_PUB_BASE64; *length = KAA_SHA1_PUB_BASE64_LEN; return KAA_ERR_NONE; } +#endif /* KAA_RUNTIME_KEY_GENERATION */ diff --git a/client/client-multi/client-c/src/kaa/platform-impl/esp8266/key_utils.c b/client/client-multi/client-c/src/kaa/platform-impl/esp8266/key_utils.c deleted file mode 100644 index d8155cf2fe..0000000000 --- a/client/client-multi/client-c/src/kaa/platform-impl/esp8266/key_utils.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2014-2016 CyberVision, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "rsa.h" - - -void ext_get_endpoint_public_key(char **buffer, size_t *buffer_size, - bool *needs_deallocation) -{ - *buffer = (char*)KAA_PUBLIC_KEY_DATA; - *buffer_size = KAA_PUBLIC_KEY_LENGTH; - *needs_deallocation = false; -} diff --git a/client/client-multi/client-c/src/kaa/platform-impl/posix/key_utils.c b/client/client-multi/client-c/src/kaa/platform-impl/posix/key_utils.c deleted file mode 100644 index b8c2744875..0000000000 --- a/client/client-multi/client-c/src/kaa/platform-impl/posix/key_utils.c +++ /dev/null @@ -1,343 +0,0 @@ -/* - * Copyright 2014-2016 CyberVision, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#define ENC_SESSION_KEY_LENGTH 256 -#define KAA_SIGNATURE_LENGTH 256 -#define AES_ECB_ENCRYPTION_CHUNCK_SIZE 16 -#define KAA_RSA_PUBLIC_KEY_LENGTH_MAX 294 -#define KAA_SHA1_PUB_LEN 20 -#define KAA_SHA1_PUB_BASE64_LEN 28 - -#define KAA_PRIVATE_KEY_STORAGE "private.key" -#define KAA_PUBLIC_KEY_STORAGE "public.key" - -/** - * Contains Endpoint keys. - * - * The main purpose of the structure is - * caching calculated keys. - */ - -typedef struct { - uint8_t session_key[KAA_SESSION_KEY_LENGTH]; - uint8_t encrypted_session_key[ENC_SESSION_KEY_LENGTH]; - uint8_t signature[KAA_SIGNATURE_LENGTH]; - size_t encrypted_session_key_length; - size_t session_key_length; -} endpoint_key_utils_t; - -/* Endpoint's RSA Keys */ -static endpoint_key_utils_t keys; -static mbedtls_pk_context pk_context_; -static mbedtls_pk_context pk_pub_context; - -/* TODO(KAA-1089) */ -__attribute__((weak)) -void ext_get_endpoint_public_key(uint8_t **buffer, size_t *buffer_size) -{ - if (!buffer || !buffer_size) { - return; - } - static int key_length; - static int initialized = false; - static uint8_t buff[KAA_RSA_PUBLIC_KEY_LENGTH_MAX]; - if (!initialized) { - key_length = mbedtls_pk_write_pubkey_der(&pk_pub_context, buff, sizeof(buff)); - if (key_length < 0) { - *buffer = NULL; - *buffer_size = 0; - return; - } - initialized = true; - } - *buffer = buff; - *buffer_size = key_length; -} - -static int rsa_encrypt(mbedtls_pk_context *pk, const uint8_t *input, size_t input_len, uint8_t *output) -{ - int ret = 0; - - mbedtls_entropy_context entropy; - mbedtls_ctr_drbg_context ctr_drbg; - const uint8_t pers[] = "key_gen"; - - mbedtls_ctr_drbg_init(&ctr_drbg); - mbedtls_entropy_init(&entropy); - - ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, - pers, sizeof(pers) - 1); - if (!ret) { - ret = mbedtls_rsa_rsaes_pkcs1_v15_encrypt(mbedtls_pk_rsa(*pk), mbedtls_ctr_drbg_random, &ctr_drbg, - MBEDTLS_RSA_PUBLIC, input_len, input, output); - } - - mbedtls_ctr_drbg_free(&ctr_drbg); - mbedtls_entropy_free(&entropy); - - return ret ? KAA_ERR_BADDATA : KAA_ERR_NONE; -} - -static kaa_error_t set_rsa_public_key(mbedtls_pk_context *pk, const uint8_t *key, size_t key_size) -{ - if (!pk || !key || !key_size) { - return KAA_ERR_BADPARAM; - } - - if (mbedtls_pk_parse_public_key(pk, key, key_size) != 0) { - return KAA_ERR_INVALID_PUB_KEY; - } - - return KAA_ERR_NONE; -} - -/* Performs initialization of the keys */ -kaa_error_t kaa_init_keys(void) -{ - /* Initialization should be performed only once */ - static bool initialized = false; - if (!initialized) { - /* Generate session key */ - if (init_aes_key(keys.session_key, KAA_SESSION_KEY_LENGTH)) { - return KAA_ERR_BADDATA; - } - keys.session_key_length = KAA_SESSION_KEY_LENGTH; - if (mbedtls_pk_parse_keyfile(&pk_context_, KAA_PRIVATE_KEY_STORAGE, NULL)) { -#ifdef KAA_RUNTIME_KEY_GENERATION - if (rsa_genkey(&pk_context_)) { - return KAA_ERR_BADDATA; - } - if (write_rsa_key(&pk_context_, KAA_PRIVATE_KEY_STORAGE, PRIVATE_KEY)) { - return KAA_ERR_BADPARAM; - } - if (write_rsa_key(&pk_context_, KAA_PUBLIC_KEY_STORAGE, PUBLIC_KEY)) { - return KAA_ERR_BADPARAM; - } -#else - return KAA_ERR_BADDATA; -#endif - } - if (mbedtls_pk_parse_public_keyfile(&pk_pub_context, KAA_PUBLIC_KEY_STORAGE)) { -#ifdef KAA_RUNTIME_KEY_GENERATION - pk_pub_context = pk_context_; -#else - return KAA_ERR_BADDATA; -#endif - } - initialized = true; - } - - return KAA_ERR_NONE; -} - -void kaa_deinit_keys(void) -{ - mbedtls_pk_free(&pk_context_); -#ifndef KAA_RUNTIME_KEY_GENERATION - mbedtls_pk_free(&pk_pub_context); -#endif -} - -void ext_get_endpoint_session_key(uint8_t **buffer, size_t *buffer_size) -{ - if (!buffer || !buffer_size) { - return; - } - *buffer = keys.session_key; - *buffer_size = keys.session_key_length; -} - -kaa_error_t ext_encrypt_data(const uint8_t *input, size_t payload_size, uint8_t *output) -{ - if (!input || !payload_size || !output) { - return KAA_ERR_BADPARAM; - } - - /* Adding PKCS7 padding */ - size_t enc_data_size = ext_get_encrypted_data_size(payload_size); - assert(enc_data_size >= payload_size); - uint8_t padding = enc_data_size - payload_size; - memset(output + payload_size, padding, padding); - - /* Process the buffer chunk by chunk */ - while (enc_data_size >= KAA_SESSION_KEY_LENGTH) { - if (aes_encrypt_decrypt(MBEDTLS_AES_ENCRYPT, input, - KAA_SESSION_KEY_LENGTH, - output, keys.session_key) != KAA_ERR_NONE) { - return KAA_ERR_BADPARAM; - } - - enc_data_size -= KAA_SESSION_KEY_LENGTH; - - input += KAA_SESSION_KEY_LENGTH; - output += KAA_SESSION_KEY_LENGTH; - } - - return KAA_ERR_NONE; -} - -kaa_error_t ext_decrypt_data(const uint8_t *input, size_t input_size, - uint8_t *output, size_t *output_payload_size) -{ - if (!input || !input_size || !output || !output_payload_size) { - return KAA_ERR_BADPARAM; - } - - size_t tmp_in_size = input_size; - while (input_size >= KAA_SESSION_KEY_LENGTH) { - if (aes_encrypt_decrypt(MBEDTLS_AES_DECRYPT, input, - KAA_SESSION_KEY_LENGTH, output, - keys.session_key) < 0) { - return KAA_ERR_BADDATA; - } - input_size -= KAA_SESSION_KEY_LENGTH; - - input += KAA_SESSION_KEY_LENGTH; - output += KAA_SESSION_KEY_LENGTH; - } - - /* Reduce PKCS7 padding */ - uint8_t padding_length = *(output - 1); - *output_payload_size = tmp_in_size - padding_length; - - return KAA_ERR_NONE; -} - -/* Get encrypted session key (enctypted with remote key) */ -kaa_error_t ext_get_encrypted_session_key(uint8_t **buffer, size_t *buffer_size, - const uint8_t *remote_key, size_t remote_key_size) -{ - if (!buffer || !buffer_size || !remote_key || !remote_key_size) { - return KAA_ERR_BADPARAM; - } - - mbedtls_pk_context local_ctx; - mbedtls_pk_init(&local_ctx); - kaa_error_t err = set_rsa_public_key(&local_ctx, remote_key, remote_key_size); - if (err) { - goto exit; - } - err = rsa_encrypt(&local_ctx, keys.session_key, - KAA_SESSION_KEY_LENGTH, keys.encrypted_session_key); - if (err) { - goto exit; - } - - keys.encrypted_session_key_length = ENC_SESSION_KEY_LENGTH; - - *buffer = keys.encrypted_session_key; - *buffer_size = keys.encrypted_session_key_length; - -exit: - mbedtls_pk_free(&local_ctx); - return err ? KAA_ERR_BADDATA : KAA_ERR_NONE; -} - -size_t ext_get_encrypted_data_size(size_t input_size) -{ - if (!input_size) { - return 0; - } - - if (input_size % AES_ECB_ENCRYPTION_CHUNCK_SIZE != 0) { - return AES_ECB_ENCRYPTION_CHUNCK_SIZE - - (input_size % AES_ECB_ENCRYPTION_CHUNCK_SIZE) + input_size; - } - - return input_size + AES_ECB_ENCRYPTION_CHUNCK_SIZE; -} - -kaa_error_t ext_get_signature(const uint8_t *input, size_t input_size, - uint8_t **output, size_t *output_size) -{ - if (!input || !input_size || !output || !output_size) { - return KAA_ERR_BADPARAM; - } - - kaa_error_t error = rsa_sign(&pk_context_, input, input_size, keys.signature, output_size); - if (error) { - return KAA_ERR_BADDATA; - } - *output = keys.signature; - *output_size = KAA_SIGNATURE_LENGTH; - - return KAA_ERR_NONE; -} - -void ext_get_sha1_public(uint8_t **sha1, size_t *length) -{ - if (!sha1 || !length) { - return; - } - static uint8_t sha1_public[KAA_SHA1_PUB_LEN]; - static int initialized = false; - if (!initialized) { - uint8_t pub_key[KAA_RSA_PUBLIC_KEY_LENGTH_MAX]; - int key_length = mbedtls_pk_write_pubkey_der(&pk_pub_context, pub_key, KAA_RSA_PUBLIC_KEY_LENGTH_MAX); - if (key_length < 0) { - *sha1 = NULL; - *length = 0; - return; - } - sha1_from_public_key(pub_key, key_length, sha1_public); - initialized = true; - } - *length = KAA_SHA1_PUB_LEN; - *sha1 = sha1_public; -} - -kaa_error_t ext_get_sha1_base64_public(const uint8_t **sha1, size_t *length) -{ - if (!sha1 || !length) { - return KAA_ERR_BADPARAM; - } - static size_t sha1_base64_len = 0; - static uint8_t sha1_base64_buffer[1024]; - static int initialized = false; - if (!initialized) { - uint8_t pub_key[KAA_RSA_PUBLIC_KEY_LENGTH_MAX]; - uint8_t sha1_public[SHA1_LENGTH]; - int key_length = mbedtls_pk_write_pubkey_der(&pk_pub_context, pub_key, KAA_RSA_PUBLIC_KEY_LENGTH_MAX); - if (key_length < 0) { - return KAA_ERR_BADDATA; - } - sha1_from_public_key(pub_key, key_length, sha1_public); - int error = sha1_to_base64(sha1_public, sizeof(sha1_public), sha1_base64_buffer, sizeof(sha1_base64_buffer), &sha1_base64_len); - if (error) { - return KAA_ERR_BADDATA; - } - initialized = true; - } - *sha1 = (uint8_t *)sha1_base64_buffer; - *length = sha1_base64_len; - return KAA_ERR_NONE; -} diff --git a/client/client-multi/client-c/src/kaa/platform/ext_encryption_utils.h b/client/client-multi/client-c/src/kaa/platform/ext_encryption_utils.h new file mode 100644 index 0000000000..47956399ac --- /dev/null +++ b/client/client-multi/client-c/src/kaa/platform/ext_encryption_utils.h @@ -0,0 +1,117 @@ +/* + * You may obtain a copy of the License at + * Copyright 2014-2016 CyberVision, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * @brief External interface for encryption. + */ + +#ifndef EXT_ENCRYPTION_UTILS_H_ +#define EXT_ENCRYPTION_UTILS_H_ + +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Performs initialization of the AES session key. + * + * This key is required in case encryption is enabled. + * + */ +kaa_error_t kaa_init_session_key(void); + +/** + * Performs deinitialization of the AES session key. + * + */ +void kaa_deinit_session_key(void); + +/** + * Returns endpoint session key. + * + * @param[out] buffer Pointer to buffer which should be filled with session key. + * @param[out] buffer_size Pointer to buffer size, which will be initialized with key size. + */ +void ext_get_endpoint_session_key(const uint8_t **buffer, size_t *buffer_size); + +/** + * Perform encryption. + * + * @param[in] input The pointer to data to be encrypted. + * @param[in] input_size The size of the input buffer. + * @param[out] output The pointer which will be initialized with buffer containing + * enctypted data. + */ +kaa_error_t ext_encrypt_data(const uint8_t *input, size_t input_size, uint8_t *output); + +/** + * Calculates the size of the encrypted data. + * + * @param[in] input_size The size of the plaintext. + * + */ +size_t ext_get_encrypted_data_size(size_t input_size); + +/** + * Perform decryption. + * + * @param[in] input The pointer to data to be decrypted. + * @param[in] input_size The size of the input buffer. + * @param[out] output_payload_size The size of the payload data. + * @param[out] output The buffer which contains decrypted data will be filled in. + * + * @note The output buffer is assumed to be at least as long as @p input_size. + * + */ +kaa_error_t ext_decrypt_data(const uint8_t *input, size_t input_size, + uint8_t *output, size_t *output_payload_size); + +/** + * Returns encrypted endpoint session key. + * + * @param[out] buffer Pointer to buffer which should be filled with encrypted session key. + * @param[out] buffer_size Pointer to buffer's size. + * @param[in] remote_key Remote public key which will be used to encrypt session key. + * @param[in] remote_key_size Remote public key's size. + * + */ +kaa_error_t ext_get_encrypted_session_key(uint8_t **buffer, size_t *buffer_size, + const uint8_t *remote_key, size_t remote_key_size); + +/** + * Signs the encrypted session key. + * + * @param [in] input The input data to be signed. + * @param [in] input_size The size of the input data. + * @param [out] output The pointer which will be initialized with signed key. + * @param [out] output_size The length of signed key. + * + */ +kaa_error_t ext_get_signature(const uint8_t *input, size_t input_size, + uint8_t **output, size_t *output_size); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* EXT_ENCRYPTION_UTILS_H_ */ diff --git a/client/client-multi/client-c/src/kaa/platform/ext_key_utils.h b/client/client-multi/client-c/src/kaa/platform/ext_key_utils.h index b83c4a4f7a..1d0de9f2fb 100644 --- a/client/client-multi/client-c/src/kaa/platform/ext_key_utils.h +++ b/client/client-multi/client-c/src/kaa/platform/ext_key_utils.h @@ -15,7 +15,7 @@ */ /** - * @file ext_key_utils.h + * @file * @brief External interface for client keys manipulations. */ @@ -29,96 +29,28 @@ extern "C" { #endif /** - * Returns the endpoint public key. - * - * @param[out] buffer Pointer to buffer which should be filled with public key. - * @param[out] buffer_size Pointer to buffer's size. + * Performs initialization of the RSA keypair (if required). * */ -void ext_get_endpoint_public_key(uint8_t **buffer, size_t *buffer_size); +kaa_error_t kaa_init_rsa_keypair(void); /** - * @brief Performs initialization of the keys. - * - * In case if kaa channel has encryption, this function has to be - * called to perform keys initialization. - * - */ -kaa_error_t kaa_init_keys(void); - -/** - * Performs deinitialization of hte keys. - * - * In case if kaa channel has encryption, this function has to be - * called to perform keys deinitialization. + * Performs deinitialization of the RSA keypair. * */ -void kaa_deinit_keys(void); +void kaa_deinit_rsa_keypair(void); /** - * Returns endpoint session key. - * - * @param[out] buffer Pointer to buffer which should be filled encrypted session key. - * @param[out] buffer_size Pointer to buffer's size. - */ -void ext_get_endpoint_session_key(uint8_t **buffer, size_t *buffer_size); - -/** - * Perform encryption. - * - * @param[in] input The pointer to data to be encrypted. - * @param[in] input_size The size of the input buffer. - * @param[out] output The pointer which will initialized with buffer containing - * enctypted data. - */ -kaa_error_t ext_encrypt_data(const uint8_t *input, size_t input_size, uint8_t *output); - -/** - * Perform decryption. - * - * @param[in] input The pointer to data to be decrypted. - * @param[in] input_size The size of the input buffer. - * @param[out] output_payload_size The size of the payload data. - * @param[out] output The buffer which contains dectypted data will be filled in. - * - */ -kaa_error_t ext_decrypt_data(const uint8_t *input, size_t input_size, - uint8_t *output, size_t *output_payload_size); - -/** - * Returns encrypted endpoint session key. + * Returns the endpoint public key. * - * @param[out] buffer Pointer to buffer which should be filled with encrypted session key. + * @param[out] buffer Pointer which will be set to internal buffer containing the key. * @param[out] buffer_size Pointer to buffer's size. - * @param[in] remote_key Remote public key which will be used to encrypt session key. - * @param[in] remote_key_size Remote public key's size. - * - */ -kaa_error_t ext_get_encrypted_session_key(uint8_t **buffer, size_t *buffer_size, - const uint8_t *remote_key, size_t remote_key_size); -/** - * Calculates the size of the encrypted data. - * - * @param[in] input_size The size of the plain text. - * - * @return The size of the encrypted data. - */ -size_t ext_get_encrypted_data_size(size_t input_size); - -/** - * Signes the encrypted session key. - * - * @param [in] input The input data to be signed. - * @param [in] input_size The size of the input data. - * @param [out] output The pointer which will be initialized with signed key. - * @param [out] output_size The length of signed key. * */ -kaa_error_t ext_get_signature(const uint8_t *input, size_t input_size, - uint8_t **output, size_t *output_size); +void ext_get_endpoint_public_key(const uint8_t **buffer, size_t *buffer_size); /** - * Return sha1 of the RSA public key. + * Return sha1 of the endpoint public key. * * @param [out] sha1 The pointer *sha1 will be initialized with SHA1 address * of the RSA public key. @@ -127,13 +59,14 @@ kaa_error_t ext_get_signature(const uint8_t *input, size_t input_size, void ext_get_sha1_public(uint8_t **sha1, size_t *length); /** - * Return sha1 of the RSA public key in base64 format. + * Return sha1 of the endpoint public key in base64 format. * * @param [out] sha1 The pointer *sha1 will be initialized with SHA1 address * of the RSA public key in base64 encoding * @param [out] length The length of the SHA1. */ kaa_error_t ext_get_sha1_base64_public(const uint8_t **sha1, size_t *length); + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/client/client-multi/client-c/src/kaa/utilities/kaa_aes_rsa.c b/client/client-multi/client-c/src/kaa/utilities/kaa_aes_rsa.c index 699b62f6a7..9d8969a3b4 100644 --- a/client/client-multi/client-c/src/kaa/utilities/kaa_aes_rsa.c +++ b/client/client-multi/client-c/src/kaa/utilities/kaa_aes_rsa.c @@ -41,7 +41,30 @@ int init_aes_key(unsigned char *key, size_t bytes) kaa_error_t aes_encrypt_decrypt(int mode, const uint8_t *input, size_t input_size, uint8_t *output, const uint8_t *key) { - if ((input_size % 16) != 0 || !input || !input_size) { + if ((input_size % 16) != 0 || input == NULL || input_size == 0) { + return KAA_ERR_BADPARAM; + } + + while (input_size >= KAA_SESSION_KEY_LENGTH) { + + if (aes_encrypt_decrypt_block(mode, input, output, key)) { + return KAA_ERR_BADPARAM; + } + + input_size -= KAA_SESSION_KEY_LENGTH; + + input += KAA_SESSION_KEY_LENGTH; + output += KAA_SESSION_KEY_LENGTH; + } + + return KAA_ERR_NONE; + +} + +kaa_error_t aes_encrypt_decrypt_block(int mode, const uint8_t *input, + uint8_t *output, const uint8_t *key) +{ + if (input == NULL) { return KAA_ERR_BADPARAM; } @@ -57,15 +80,13 @@ kaa_error_t aes_encrypt_decrypt(int mode, const uint8_t *input, size_t input_siz initialized = true; } + /* KAA_SESSION_KEY_LENGTH * 8 - size in bits */ if (mode == MBEDTLS_AES_ENCRYPT) { - /* KAA_SESSION_KEY_LENGTH * 8 - size in bits */ mbedtls_aes_setkey_enc(&aes_ctx, key, KAA_SESSION_KEY_LENGTH * 8); - mbedtls_aes_crypt_ecb(&aes_ctx, MBEDTLS_AES_ENCRYPT, input, output); } else { - /* KAA_SESSION_KEY_LENGTH * 8 - size in bits */ mbedtls_aes_setkey_dec(&aes_ctx, key, KAA_SESSION_KEY_LENGTH * 8); - mbedtls_aes_crypt_ecb(&aes_ctx, MBEDTLS_AES_DECRYPT, input, output); } + mbedtls_aes_crypt_ecb(&aes_ctx, mode, input, output); return KAA_ERR_NONE; } @@ -106,3 +127,43 @@ int rsa_sign(mbedtls_pk_context *pk, const uint8_t *input, return ret ? KAA_ERR_BADDATA : KAA_ERR_NONE; } + +kaa_error_t rsa_encrypt(const uint8_t *key, size_t key_size, const uint8_t *input, + size_t input_len, uint8_t *output) +{ + if (key == NULL || key_size == 0) { + return KAA_ERR_BADPARAM; + } + + mbedtls_pk_context pk; + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; + const uint8_t pers[] = "key_gen"; + + mbedtls_pk_init(&pk); + + if (mbedtls_pk_parse_public_key(&pk, key, key_size) != 0) { + return KAA_ERR_INVALID_PUB_KEY; + } + + mbedtls_ctr_drbg_init(&ctr_drbg); + mbedtls_entropy_init(&entropy); + + int ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, + pers, sizeof(pers) - 1); + + if (!ret) { + ret = mbedtls_rsa_rsaes_pkcs1_v15_encrypt(mbedtls_pk_rsa(pk), mbedtls_ctr_drbg_random, &ctr_drbg, + MBEDTLS_RSA_PUBLIC, input_len, input, output); + } + + mbedtls_ctr_drbg_free(&ctr_drbg); + mbedtls_entropy_free(&entropy); + mbedtls_pk_free(&pk); + + if (ret) { + return KAA_ERR_GENERIC; + } + + return KAA_ERR_NONE; +} diff --git a/client/client-multi/client-c/src/kaa/utilities/kaa_aes_rsa.h b/client/client-multi/client-c/src/kaa/utilities/kaa_aes_rsa.h index 448c1ff0ab..d9fd22a55e 100644 --- a/client/client-multi/client-c/src/kaa/utilities/kaa_aes_rsa.h +++ b/client/client-multi/client-c/src/kaa/utilities/kaa_aes_rsa.h @@ -14,6 +14,11 @@ * limitations under the License. */ +#ifndef KAA_AES_RSA_H_ +#define KAA_AES_RSA_H_ + +#include + #include #include #include @@ -23,21 +28,21 @@ #include #include -#ifndef KAA_AES_RSA_H_ -#define KAA_AES_RSA_H_ - -#define KAA_SESSION_KEY_LENGTH 16 +#define KAA_SESSION_KEY_LENGTH 16 /** - * @brief generate AES key + * Generate AES key * * @param[out] key Generated AES key * @param[in] bytes Size of the AES key + * + * @return The error code. + * @retval 0 Success. */ int init_aes_key(unsigned char *key, size_t bytes); /** - * @brief encrypt or decrypt with AES key + * Encrypt or decrypt with AES key * * @param[in] mode Mode of encryption * @param[in] input Pointer to input data @@ -49,7 +54,19 @@ kaa_error_t aes_encrypt_decrypt(int mode, const uint8_t *input, size_t input_siz uint8_t *output, const uint8_t *key); /** - * @brief create RSA signature + * Encrypt or decrypt block of size @c KAA_SESSION_KEY_LENGTH with AES key. + * + * @param[in] mode Mode of encryption. MBEDTLS_AES_ENCRYPT + * to encryption and MBEDTLS_AES_DECTYPT to decryption. + * @param[in] input Pointer to input data (of size KAA_SESSION_KEY_LENGTH) + * @param[out] output Pointer to output data + * @param[in] key Pointer to AES key + */ +kaa_error_t aes_encrypt_decrypt_block(int mode, const uint8_t *input, uint8_t *output, + const uint8_t *key); + +/** + * Create RSA signature * * @param[in] pk Pointer to a pk structure * @param[in] input Pointer to input data @@ -60,4 +77,21 @@ kaa_error_t aes_encrypt_decrypt(int mode, const uint8_t *input, size_t input_siz int rsa_sign(mbedtls_pk_context *pk, const uint8_t *input, size_t input_size, uint8_t *output, size_t *output_size); -#endif /* KAA_AES_RSA_H */ +/** + * Encrypt data with pubcic RSA key. + * + * @param[in] key Public RSA key. + * @param[in] key_size Size of public RSA key. + * @param[in] input Input data. + * @param[in] input_len Size of input_data. + * @param[out] output Pointer to buffer where the encrypted data will be stored. + * + * @return The error code. + * @retval KAA_ERR_NONE Success + * @retval KAA_ERR_INVALID_PUBKEY The key is invalid. + * @retval KAA_ERR_GENERIC Encryption has failed. + */ +kaa_error_t rsa_encrypt(const uint8_t *key, size_t key_size, const uint8_t *input, + size_t input_len, uint8_t *output); + +#endif /* KAA_AES_RSA_H_ */ diff --git a/client/client-multi/client-c/test/kaa_tcp_channel/test_kaa_tcp_channel_bootstrap.c b/client/client-multi/client-c/test/kaa_tcp_channel/test_kaa_tcp_channel_bootstrap.c index 61fc76d4f3..e4b45309b0 100644 --- a/client/client-multi/client-c/test/kaa_tcp_channel/test_kaa_tcp_channel_bootstrap.c +++ b/client/client-multi/client-c/test/kaa_tcp_channel/test_kaa_tcp_channel_bootstrap.c @@ -38,6 +38,7 @@ #include "platform-impl/common/kaa_tcp_channel.h" #include "kaa_protocols/kaa_tcp/kaatcp_request.h" #include "platform/ext_key_utils.h" +#include "platform/ext_encryption_utils.h" #include diff --git a/client/client-multi/client-c/test/kaa_test_external.c b/client/client-multi/client-c/test/kaa_test_external.c index dcaaa4b521..7cacf11f17 100644 --- a/client/client-multi/client-c/test/kaa_test_external.c +++ b/client/client-multi/client-c/test/kaa_test_external.c @@ -25,7 +25,7 @@ #include "utilities/kaa_mem.h" #include "kaa_common.h" -static const char test_ep_key[20] = {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0x10, 0x11, 0x12, 0x13, 0x14}; +static const uint8_t test_ep_key[] = {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0x10, 0x11, 0x12, 0x13, 0x14}; void ext_status_read(char **buffer, size_t *buffer_size, bool *needs_deallocation) { @@ -40,15 +40,10 @@ void ext_status_store(const char *buffer, size_t buffer_size) (void)buffer_size; } -void ext_get_endpoint_public_key(uint8_t **buffer, size_t *buffer_size) +void ext_get_endpoint_public_key(const uint8_t **buffer, size_t *buffer_size) { - *buffer = KAA_MALLOC(SHA_1_DIGEST_LENGTH * sizeof(uint8_t)); - if (*buffer != NULL) { - memcpy(*buffer, test_ep_key, SHA_1_DIGEST_LENGTH); - *buffer_size = SHA_1_DIGEST_LENGTH; - } else { - *buffer_size = 0; - } + *buffer = test_ep_key; + *buffer_size = sizeof(test_ep_key); } void ext_configuration_read(char **buffer, size_t *buffer_size, bool *needs_deallocation) diff --git a/client/client-multi/client-c/test/test_kaa_status.c b/client/client-multi/client-c/test/test_kaa_status.c index 76e0c71f6e..cd57c2d1d8 100644 --- a/client/client-multi/client-c/test/test_kaa_status.c +++ b/client/client-multi/client-c/test/test_kaa_status.c @@ -78,7 +78,7 @@ void ext_status_store(const char *buffer, size_t buffer_size) } } -void ext_get_endpoint_public_key(uint8_t **buffer, size_t *buffer_size) +void ext_get_endpoint_public_key(const uint8_t **buffer, size_t *buffer_size) { *buffer = NULL; *buffer_size = 0; diff --git a/client/client-multi/client-c/thirdparty/mbedtls/CMakeLists.txt b/client/client-multi/client-c/thirdparty/mbedtls/CMakeLists.txt index c6c1eb22df..ab472bb804 100644 --- a/client/client-multi/client-c/thirdparty/mbedtls/CMakeLists.txt +++ b/client/client-multi/client-c/thirdparty/mbedtls/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 2.8.12) -project(kaa_mbedtls C) +project(mbedtls C) set(KAA_MBEDTLS_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/aes.c @@ -24,5 +24,5 @@ set(KAA_MBEDTLS_SOURCE_FILES ) -add_library(kaa_mbedtls ${KAA_MBEDTLS_SOURCE_FILES}) -target_include_directories(kaa_mbedtls PUBLIC ${CMAKE_CURRENT_LIST_DIR}/mbedtls ${CMAKE_CURRENT_LIST_DIR}) +add_library(mbedtls ${KAA_MBEDTLS_SOURCE_FILES}) +target_include_directories(mbedtls PUBLIC ${CMAKE_CURRENT_LIST_DIR}/mbedtls ${CMAKE_CURRENT_LIST_DIR}) diff --git a/client/client-multi/client-c/tools/kaa_encryption/rsa_key_gen/CMakeLists.txt b/client/client-multi/client-c/tools/kaa_encryption/rsa_key_gen/CMakeLists.txt index 9632f33a43..64ebf9740c 100644 --- a/client/client-multi/client-c/tools/kaa_encryption/rsa_key_gen/CMakeLists.txt +++ b/client/client-multi/client-c/tools/kaa_encryption/rsa_key_gen/CMakeLists.txt @@ -20,5 +20,5 @@ project(kaa_rsa_keygen C) add_library(rsa_keygen kaa_rsa_key_gen.c) target_include_directories(rsa_keygen PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include) -add_subdirectory(${KAA_SDK_DIR}/thirdparty/mbedtls kaa_mbedtls) -target_link_libraries(rsa_keygen kaa_mbedtls) +add_subdirectory(${KAA_SDK_DIR}/thirdparty/mbedtls mbedtls) +target_link_libraries(rsa_keygen mbedtls) diff --git a/client/client-multi/client-c/tools/kaa_encryption/rsa_key_gen/kaa_rsa_key_gen.c b/client/client-multi/client-c/tools/kaa_encryption/rsa_key_gen/kaa_rsa_key_gen.c index fa3083fec6..18d3635ee1 100644 --- a/client/client-multi/client-c/tools/kaa_encryption/rsa_key_gen/kaa_rsa_key_gen.c +++ b/client/client-multi/client-c/tools/kaa_encryption/rsa_key_gen/kaa_rsa_key_gen.c @@ -44,6 +44,7 @@ static int fwrite_check(int n, int count) static size_t snprintf_check(int buffer_size, int written) { + (void)buffer_size; assert(buffer_size >= written); return written; } diff --git a/client/client-multi/client-cpp/.gitignore b/client/client-multi/client-cpp/.gitignore new file mode 100644 index 0000000000..0ea3df478c --- /dev/null +++ b/client/client-multi/client-cpp/.gitignore @@ -0,0 +1,6 @@ +#C++ SDK autogenerated files +kaa/profile/gen/ProfileGen.hpp +kaa/notification/gen/NotificationGen.hpp +kaa/log/gen/LogGen.hpp +kaa/gen/EndpointGen.hpp +kaa/configuration/gen/ConfigurationGen.hpp diff --git a/client/client-multi/client-cpp/avro/configuration.avsc b/client/client-multi/client-cpp/avro/configuration.avsc new file mode 100644 index 0000000000..9aba4aca9e --- /dev/null +++ b/client/client-multi/client-cpp/avro/configuration.avsc @@ -0,0 +1 @@ +{"type":"record","name":"ConfigurationRootRecord","namespace":"org.kaaproject.kaa.schema.system","fields":[{"name":"data","type":{"type":"string","avro.java.string":"String"}}],"version":1,"displayName":"RootRecord"} \ No newline at end of file diff --git a/client/client-multi/client-cpp/avro/endpoint.avsc b/client/client-multi/client-cpp/avro/endpoint.avsc new file mode 100644 index 0000000000..c5c7f28ca4 --- /dev/null +++ b/client/client-multi/client-cpp/avro/endpoint.avsc @@ -0,0 +1,488 @@ +[ + +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "TopicState", + "direction": "out", + "fields": [ + {"name": "topicId", "type": "long"}, + {"name": "seqNumber", "type": "int"} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "enum", + "name": "SyncResponseStatus", + "symbols" : ["NO_DELTA", "DELTA", "RESYNC"] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "enum", + "name": "NotificationType", + "symbols" : ["SYSTEM", "CUSTOM"] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "enum", + "name": "SubscriptionType", + "symbols" : ["MANDATORY_SUBSCRIPTION", "OPTIONAL_SUBSCRIPTION"] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "enum", + "name": "SubscriptionCommandType", + "symbols" : ["ADD", "REMOVE"] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "enum", + "name": "SyncResponseResultType", + "symbols" : ["SUCCESS", "FAILURE", "PROFILE_RESYNC", "REDIRECT"] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "enum", + "name": "LogDeliveryErrorCode", + "direction": "in", + "symbols" : ["NO_APPENDERS_CONFIGURED", "APPENDER_INTERNAL_ERROR", "REMOTE_CONNECTION_ERROR", "REMOTE_INTERNAL_ERROR"] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "enum", + "name": "UserAttachErrorCode", + "symbols" : ["NO_VERIFIER_CONFIGURED", "TOKEN_INVALID", "TOKEN_EXPIRED", "INTERNAL_ERROR", "CONNECTION_ERROR", "REMOTE_ERROR", "OTHER"] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "direction": "out", + "name": "SubscriptionCommand", + "fields": [ + {"name": "topicId", "type": "long"}, + {"name": "command", "type": "org.kaaproject.kaa.common.endpoint.gen.SubscriptionCommandType"} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "direction": "out", + "name": "UserAttachRequest", + "fields": [ + {"name": "userVerifierId", "type": "string"}, + {"name": "userExternalId", "type": "string"}, + {"name": "userAccessToken", "type": "string"} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "UserAttachResponse", + "direction": "in", + "fields": [ + {"name": "result", "type": "org.kaaproject.kaa.common.endpoint.gen.SyncResponseResultType"}, + {"name": "errorCode", "type": ["org.kaaproject.kaa.common.endpoint.gen.UserAttachErrorCode", "null"]}, + {"name": "errorReason", "type": ["string", "null"]} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "UserAttachNotification", + "direction": "in", + "fields": [ + {"name": "userExternalId", "type": "string"}, + {"name": "endpointAccessToken", "type": "string"} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "UserDetachNotification", + "direction": "in", + "fields": [ + {"name": "endpointAccessToken", "type": "string"} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "EndpointAttachRequest", + "direction": "out", + "fields": [ + {"name": "requestId", "type": "int"}, + {"name": "endpointAccessToken", "type": "string"} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "EndpointAttachResponse", + "direction": "in", + "fields": [ + {"name": "requestId", "type": "int"}, + {"name": "endpointKeyHash", "type": ["string", "null"]}, + {"name": "result", "type": "org.kaaproject.kaa.common.endpoint.gen.SyncResponseResultType"} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "EndpointDetachRequest", + "direction": "out", + "fields": [ + {"name": "requestId", "type": "int"}, + {"name": "endpointKeyHash", "type": "string"} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "EndpointDetachResponse", + "direction": "in", + "fields": [ + {"name": "requestId", "type": "int"}, + {"name": "result", "type": "org.kaaproject.kaa.common.endpoint.gen.SyncResponseResultType"} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "Event", + "fields": [ + {"name": "seqNum", "type": "int"}, + {"name": "eventClassFQN", "type": "string"}, + {"name": "eventData", "type": "bytes"}, + {"name": "source", "type": ["string", "null"]}, + {"name": "target", "type": ["string", "null"]} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "EventListenersRequest", + "direction": "out", + "fields": [ + {"name": "requestId", "type": "int"}, + {"name": "eventClassFQNs", "type": {"type": "array", "items":"string"}} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "EventListenersResponse", + "direction": "in", + "fields": [ + {"name": "requestId", "type": "int"}, + {"name": "listeners", "type": [{"type": "array", "items":"string"}, "null"]}, + {"name": "result", "type": "org.kaaproject.kaa.common.endpoint.gen.SyncResponseResultType"} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "EventSequenceNumberRequest", + "direction": "out", + "fields": [] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "EventSequenceNumberResponse", + "direction": "in", + "fields": [ + {"name": "seqNum", "type": "int"} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "Notification", + "direction": "in", + "fields": [ + {"name": "topicId", "type": "long"}, + {"name": "type", "type": "org.kaaproject.kaa.common.endpoint.gen.NotificationType"}, + {"name": "uid", "type": ["string", "null"]}, + {"name": "seqNumber", "type": ["int", "null"]}, + {"name": "body", "type": "bytes"} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "Topic", + "direction": "in", + "fields": [ + {"name": "id", "type": "long"}, + {"name": "name", "type": "string"}, + {"name": "subscriptionType", "type": "org.kaaproject.kaa.common.endpoint.gen.SubscriptionType"} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "LogEntry", + "direction": "out", + "fields": [ + {"name": "data", "type": "bytes"} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "SyncRequestMetaData", + "direction": "out", + "fields": [ + {"name": "sdkToken", "type": "string"}, + {"name": "endpointPublicKeyHash", "type": ["bytes", "null"]}, + {"name": "profileHash", "type": ["bytes", "null"]}, + {"name": "timeout", "type": ["long", "null"]} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "ProfileSyncRequest", + "direction": "out", + "fields": [ + {"name": "endpointPublicKey", "type": ["bytes", "null"]}, + {"name": "profileBody", "type": "bytes"}, + {"name": "endpointAccessToken", "type": ["string", "null"]} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "ProtocolVersionPair", + "fields": [ + {"name": "id", "type": "int"}, + {"name": "version", "type": "int"} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "BootstrapSyncRequest", + "direction": "out", + "fields": [ + {"name": "requestId", "type": "int"}, + {"name": "supportedProtocols", "type": {"type": "array", "items":"org.kaaproject.kaa.common.endpoint.gen.ProtocolVersionPair"}} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "ConfigurationSyncRequest", + "direction": "out", + "fields": [ + {"name": "configurationHash", "type": "bytes"}, + {"name": "resyncOnly", "type": ["boolean", "null"]} + ] +}, + +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "NotificationSyncRequest", + "direction": "out", + "fields": [ + {"name": "topicListHash", "type": "int"}, + {"name": "topicStates", "type": [{"type": "array", "items":"org.kaaproject.kaa.common.endpoint.gen.TopicState"}, "null"]}, + {"name": "acceptedUnicastNotifications", "type": [{"type": "array", "items":"string"}, "null"]}, + {"name": "subscriptionCommands", "type": [{"type": "array", "items":"org.kaaproject.kaa.common.endpoint.gen.SubscriptionCommand"}, "null"]} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "UserSyncRequest", + "direction": "out", + "fields": [ + {"name": "userAttachRequest", "type": ["org.kaaproject.kaa.common.endpoint.gen.UserAttachRequest", "null"]}, + {"name": "endpointAttachRequests", "type": [{"type": "array", "items":"org.kaaproject.kaa.common.endpoint.gen.EndpointAttachRequest"}, "null"]}, + {"name": "endpointDetachRequests", "type": [{"type": "array", "items":"org.kaaproject.kaa.common.endpoint.gen.EndpointDetachRequest"}, "null"]} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "EventSyncRequest", + "direction": "out", + "fields": [ + {"name": "eventSequenceNumberRequest", "type": ["org.kaaproject.kaa.common.endpoint.gen.EventSequenceNumberRequest", "null"]}, + {"name": "eventListenersRequests", "type": [{"type": "array", "items":"org.kaaproject.kaa.common.endpoint.gen.EventListenersRequest"}, "null"]}, + {"name": "events", "type": [{"type": "array", "items":"org.kaaproject.kaa.common.endpoint.gen.Event"}, "null"]} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "LogSyncRequest", + "direction": "out", + "fields": [ + {"name": "requestId", "type": "int"}, + {"name": "logEntries", "type": [{ "type": "array", "items": "org.kaaproject.kaa.common.endpoint.gen.LogEntry"}, "null"] } + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "ProtocolMetaData", + "direction": "in", + "fields": [ + {"name": "accessPointId", "type": "int"}, + {"name": "protocolVersionInfo", "type": "org.kaaproject.kaa.common.endpoint.gen.ProtocolVersionPair"}, + {"name": "connectionInfo", "type": "bytes"} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "BootstrapSyncResponse", + "direction": "in", + "fields": [ + {"name": "requestId", "type": "int"}, + {"name": "supportedProtocols", "type": {"type": "array", "items":"org.kaaproject.kaa.common.endpoint.gen.ProtocolMetaData"}} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "ProfileSyncResponse", + "direction": "in", + "fields": [ + {"name": "responseStatus", "type": "org.kaaproject.kaa.common.endpoint.gen.SyncResponseStatus"} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "ConfigurationSyncResponse", + "direction": "in", + "fields": [ + {"name": "responseStatus", "type": "org.kaaproject.kaa.common.endpoint.gen.SyncResponseStatus"}, + {"name": "confSchemaBody", "type": ["bytes", "null"]}, + {"name": "confDeltaBody", "type": ["bytes", "null"]} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "NotificationSyncResponse", + "direction": "in", + "fields": [ + {"name": "responseStatus", "type": "org.kaaproject.kaa.common.endpoint.gen.SyncResponseStatus"}, + {"name": "notifications", "type": [{"type": "array", "items":"org.kaaproject.kaa.common.endpoint.gen.Notification"}, "null"]}, + {"name": "availableTopics", "type": [{"type": "array", "items":"org.kaaproject.kaa.common.endpoint.gen.Topic"}, "null"]} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "UserSyncResponse", + "direction": "in", + "fields": [ + {"name": "userAttachResponse", "type": ["org.kaaproject.kaa.common.endpoint.gen.UserAttachResponse", "null"]}, + {"name": "userAttachNotification", "type": ["org.kaaproject.kaa.common.endpoint.gen.UserAttachNotification", "null"]}, + {"name": "userDetachNotification", "type": ["org.kaaproject.kaa.common.endpoint.gen.UserDetachNotification", "null"]}, + {"name": "endpointAttachResponses", "type": [{"type": "array", "items":"org.kaaproject.kaa.common.endpoint.gen.EndpointAttachResponse"}, "null"]}, + {"name": "endpointDetachResponses", "type": [{"type": "array", "items":"org.kaaproject.kaa.common.endpoint.gen.EndpointDetachResponse"}, "null"]} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "EventSyncResponse", + "direction": "in", + "fields": [ + {"name": "eventSequenceNumberResponse", "type": ["org.kaaproject.kaa.common.endpoint.gen.EventSequenceNumberResponse", "null"]}, + {"name": "eventListenersResponses", "type": [{"type": "array", "items":"org.kaaproject.kaa.common.endpoint.gen.EventListenersResponse"}, "null"]}, + {"name": "events", "type": [{"type": "array", "items":"org.kaaproject.kaa.common.endpoint.gen.Event"}, "null"]} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "LogDeliveryStatus", + "direction": "in", + "fields": [ + {"name": "requestId", "type": "int"}, + {"name": "result", "type": "org.kaaproject.kaa.common.endpoint.gen.SyncResponseResultType"}, + {"name": "errorCode", "type": ["org.kaaproject.kaa.common.endpoint.gen.LogDeliveryErrorCode", "null"]} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "LogSyncResponse", + "direction": "in", + "fields": [ + {"name": "deliveryStatuses", "type": [{"type": "array", "items":"org.kaaproject.kaa.common.endpoint.gen.LogDeliveryStatus"}, "null"]} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "RedirectSyncResponse", + "direction": "in", + "fields": [ + {"name": "accessPointId", "type": "int"} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "ExtensionSync", + "fields": [ + {"name": "extensionId", "type": "int"}, + {"name": "payload", "type": "bytes"} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "SyncRequest", + "direction": "out", + "fields": [ + {"name": "requestId", "type": "int"}, + {"name": "syncRequestMetaData", "type": ["org.kaaproject.kaa.common.endpoint.gen.SyncRequestMetaData", "null"]}, + {"name": "bootstrapSyncRequest", "type": ["org.kaaproject.kaa.common.endpoint.gen.BootstrapSyncRequest", "null"]}, + {"name": "profileSyncRequest", "type": ["org.kaaproject.kaa.common.endpoint.gen.ProfileSyncRequest", "null"]}, + {"name": "configurationSyncRequest", "type": ["org.kaaproject.kaa.common.endpoint.gen.ConfigurationSyncRequest", "null"]}, + {"name": "notificationSyncRequest", "type": ["org.kaaproject.kaa.common.endpoint.gen.NotificationSyncRequest", "null"]}, + {"name": "userSyncRequest", "type": ["org.kaaproject.kaa.common.endpoint.gen.UserSyncRequest", "null"]}, + {"name": "eventSyncRequest", "type": ["org.kaaproject.kaa.common.endpoint.gen.EventSyncRequest", "null"]}, + {"name": "logSyncRequest", "type": ["org.kaaproject.kaa.common.endpoint.gen.LogSyncRequest", "null"]}, + {"name": "extensionSyncRequests", "type": [{"type": "array", "items":"org.kaaproject.kaa.common.endpoint.gen.ExtensionSync"}, "null"]} + ] +}, +{ + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "type": "record", + "name": "SyncResponse", + "direction": "in", + "fields": [ + {"name": "requestId", "type": "int"}, + {"name": "status", "type": "org.kaaproject.kaa.common.endpoint.gen.SyncResponseResultType"}, + {"name": "bootstrapSyncResponse", "type": ["org.kaaproject.kaa.common.endpoint.gen.BootstrapSyncResponse", "null"]}, + {"name": "profileSyncResponse", "type": ["org.kaaproject.kaa.common.endpoint.gen.ProfileSyncResponse", "null"]}, + {"name": "configurationSyncResponse", "type": ["org.kaaproject.kaa.common.endpoint.gen.ConfigurationSyncResponse", "null"]}, + {"name": "notificationSyncResponse", "type": ["org.kaaproject.kaa.common.endpoint.gen.NotificationSyncResponse", "null"]}, + {"name": "userSyncResponse", "type": ["org.kaaproject.kaa.common.endpoint.gen.UserSyncResponse", "null"]}, + {"name": "eventSyncResponse", "type": ["org.kaaproject.kaa.common.endpoint.gen.EventSyncResponse", "null"]}, + {"name": "redirectSyncResponse", "type": ["org.kaaproject.kaa.common.endpoint.gen.RedirectSyncResponse", "null"]}, + {"name": "logSyncResponse", "type": ["org.kaaproject.kaa.common.endpoint.gen.LogSyncResponse", "null"]}, + {"name": "extensionSyncResponses", "type": [{"type": "array", "items":"org.kaaproject.kaa.common.endpoint.gen.ExtensionSync"}, "null"]} + ] +}, +{ + "type": "record", + "name": "TopicSubscriptionInfo", + "namespace": "org.kaaproject.kaa.common.endpoint.gen", + "direction": "in", + "fields": [ + {"name": "topicInfo", "type":"org.kaaproject.kaa.common.endpoint.gen.Topic"}, + {"name": "seqNumber", "type": "int"} + ] +} +] diff --git a/client/client-multi/client-cpp/avro/log.avsc b/client/client-multi/client-cpp/avro/log.avsc new file mode 100644 index 0000000000..0a29509e3a --- /dev/null +++ b/client/client-multi/client-cpp/avro/log.avsc @@ -0,0 +1 @@ +{"type":"record","name":"SuperRecord","namespace":"org.kaaproject.kaa.scheme.sample","fields":[{"name":"logdata","type":{"type":"string","avro.java.string":"String"}}],"version":1,"displayName":"Data"} \ No newline at end of file diff --git a/client/client-multi/client-cpp/avro/notification.avsc b/client/client-multi/client-cpp/avro/notification.avsc new file mode 100644 index 0000000000..504a96698e --- /dev/null +++ b/client/client-multi/client-cpp/avro/notification.avsc @@ -0,0 +1 @@ +{"type":"record","name":"EmptyData","namespace":"org.kaaproject.kaa.schema.system","fields":[],"version":1,"displayName":"Empty Data","description":"Auto generated"} \ No newline at end of file diff --git a/client/client-multi/client-cpp/avro/profile.avsc b/client/client-multi/client-cpp/avro/profile.avsc new file mode 100644 index 0000000000..504a96698e --- /dev/null +++ b/client/client-multi/client-cpp/avro/profile.avsc @@ -0,0 +1 @@ +{"type":"record","name":"EmptyData","namespace":"org.kaaproject.kaa.schema.system","fields":[],"version":1,"displayName":"Empty Data","description":"Auto generated"} \ No newline at end of file diff --git a/client/client-multi/client-cpp/avrogen.sh b/client/client-multi/client-cpp/avrogen.sh index efc8920bf8..0b2a7fce37 100755 --- a/client/client-multi/client-cpp/avrogen.sh +++ b/client/client-multi/client-cpp/avrogen.sh @@ -22,6 +22,7 @@ fi echo "Generating necessary files according to Avro schemas" mkdir -p avro/event +mkdir -p kaa/gen avrogencpp -i avro/endpoint.avsc -o kaa/gen/EndpointGen.hpp -n kaa avrogencpp -i avro/profile.avsc -o kaa/profile/gen/ProfileGen.hpp -n kaa_profile diff --git a/client/client-multi/client-cpp/impl/ClientStatus.cpp b/client/client-multi/client-cpp/impl/ClientStatus.cpp index a5d7a483bd..3fe61f71b2 100644 --- a/client/client-multi/client-cpp/impl/ClientStatus.cpp +++ b/client/client-multi/client-cpp/impl/ClientStatus.cpp @@ -302,7 +302,8 @@ void ClientParameter::read(const std::string &strValue) ClientStatus::ClientStatus(IKaaClientContext& context) : filename_(context.getProperties().getStateFileName()), - isSDKPropertiesForUpdated_(false), hasUpdate_(false), + isSDKPropertiesForUpdated_(false), + hasUpdate_(false), context_(context) { auto eventSeqNumberTokenParamToken = parameterToToken_.left.find(ClientParameterT::EVENT_SEQUENCE_NUMBER); @@ -359,14 +360,12 @@ void ClientParameter::read(const std::string &strValue) endpointKeyHashParamToken->second, endpointKeyHashDefault_)); parameters_.insert(std::make_pair(ClientParameterT::EP_KEY_HASH, endpointKeyHashParam)); } - auto propertiesHashParamToken = parameterToToken_.left.find(ClientParameterT::PROPERTIES_HASH); if (propertiesHashParamToken != parameterToToken_.left.end()) { std::shared_ptr propertiesHashParam(new ClientParameter( propertiesHashParamToken->second, endpointHashDefault_/*It's OK*/)); parameters_.insert(std::make_pair(ClientParameterT::PROPERTIES_HASH, propertiesHashParam)); } - auto isProfileResyncNeededParamToken = parameterToToken_.left.find(ClientParameterT::IS_PROFILE_RESYNC_NEEDED); if (isProfileResyncNeededParamToken != parameterToToken_.left.end()) { std::shared_ptr isProfileResyncNeededParam(new ClientParameter( @@ -381,25 +380,27 @@ void ClientParameter::read(const std::string &strValue) void ClientStatus::checkSDKPropertiesForUpdates() { - HashDigest truePropertiesHash = getPropertiesHash(); - HashDigest storedPropertiesHash; + HashDigest currentPropertiesHash = getPropertiesHash(); auto parameter_it = parameters_.find(ClientParameterT::PROPERTIES_HASH); - if (parameter_it != parameters_.end()) { - storedPropertiesHash = boost::any_cast(parameter_it->second->getValue()); - } - if (truePropertiesHash != storedPropertiesHash) { - setRegistered(false); - auto it = parameters_.find(ClientParameterT::PROPERTIES_HASH); - if (it != parameters_.end()) { - it->second->setValue(truePropertiesHash); - } + auto storedPropertiesHash = boost::any_cast(parameter_it->second->getValue()); - isSDKPropertiesForUpdated_ = true; - KAA_LOG_INFO("SDK properties were updated"); - } else { + if (storedPropertiesHash == endpointHashDefault_) { + parameter_it->second->setValue(currentPropertiesHash); + hasUpdate_ = true; KAA_LOG_INFO("SDK properties are up to date"); + } else { + if (currentPropertiesHash != storedPropertiesHash) { + parameter_it->second->setValue(currentPropertiesHash); + + setRegistered(false); + isSDKPropertiesForUpdated_ = true; + hasUpdate_ = true; + KAA_LOG_INFO("SDK properties were updated"); + } else { + KAA_LOG_INFO("SDK properties are up to date"); + } } } diff --git a/client/client-multi/client-cpp/impl/KaaDefaults.cpp b/client/client-multi/client-cpp/impl/KaaDefaults.cpp index 867e5371e9..1273566a68 100644 --- a/client/client-multi/client-cpp/impl/KaaDefaults.cpp +++ b/client/client-multi/client-cpp/impl/KaaDefaults.cpp @@ -28,11 +28,11 @@ namespace kaa { -const char * const BUILD_VERSION = "0.7.1-SNAPSHOT"; +const char * const BUILD_VERSION = "0.10.0-SNAPSHOT"; const char * const BUILD_COMMIT_HASH = ""; -const char * const SDK_TOKEN = "48461193020513321075"; +const char * const SDK_TOKEN = "malzQyIMLTt3O6NMP4eBDKMQqek"; const std::uint32_t POLLING_PERIOD_SECONDS = 5; @@ -59,21 +59,21 @@ ITransportConnectionInfoPtr createTransportInfo(const std::int32_t& accessPointI return connectionInfo; } -const BootstrapServers& getBootstrapServers() +const BootstrapServers& getBootstrapServers() { static BootstrapServers listOfServers; if (listOfServers.empty()) { - listOfServers.push_back(createTransportInfo(0x95f7e40f, 0xfb9a3cf0, 1, "AAABJjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAInAdYDtJzx02MWRJmAzyhcsOpGZv55tQ5gmNfRM/9LyJpy9vkuSsxn7bTzks9bkptBsV05i0ms0eaOeMdSElUMAuUQL5lfWgG/StUKBtBaxWZclNlkPkvHKwrMKUWSGEjuaBme4Qk23WrpRVmFMerR62DJ557pXZfIicJ8n3Fety0ox4Qs2WwgbudAY3qfs5Md7d7lXoWNq9hxL92SHNluTEtmgFkb/PQGrWYnGy73kyUSrz4iZURF47cPt0cazHySxHl/3gxcOk1SuXKu2Jv6HGaH+AjHwKYNFiW6hLWU0Q3vUkmlPaEDJsGdRfQ7b1SZM31+ivF1Q2xfgADTBiVsCAwEAAQAAAAkxMC4yLjMuOTMAACah")); -listOfServers.push_back(createTransportInfo(0x95f7e40f, 0x56c8ff92, 1, "AAABJjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAInAdYDtJzx02MWRJmAzyhcsOpGZv55tQ5gmNfRM/9LyJpy9vkuSsxn7bTzks9bkptBsV05i0ms0eaOeMdSElUMAuUQL5lfWgG/StUKBtBaxWZclNlkPkvHKwrMKUWSGEjuaBme4Qk23WrpRVmFMerR62DJ557pXZfIicJ8n3Fety0ox4Qs2WwgbudAY3qfs5Md7d7lXoWNq9hxL92SHNluTEtmgFkb/PQGrWYnGy73kyUSrz4iZURF47cPt0cazHySxHl/3gxcOk1SuXKu2Jv6HGaH+AjHwKYNFiW6hLWU0Q3vUkmlPaEDJsGdRfQ7b1SZM31+ivF1Q2xfgADTBiVsCAwEAAQAAAAkxMC4yLjMuOTMAACag")); + listOfServers.push_back(createTransportInfo(0x929a2016, 0xfb9a3cf0, 1, "AAABJjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALPFnHKu3C/sPCp14y+LDR9pZky19eu4az9SuuvPXrb140akP6dkCstA8MBak9FoihYKf6oIAlmV+kh1We8uvpcMqHPWRSMZfn/1lQxE3wy/gtXwAP1GiMCgIS5UDW/sYRzPEpxKO6kN1hfF9AUaWu5mB7yCR+KTmTVY96WeXMiDbYkd0sBdPDUbT30JHZ4OSf9ZiPiGd8D2SEAe2vPyPdOT6p/w1Gx2HcWZ9CwE/qWSWQcgDGXQ+c8jTW/bPtcQK+UzWiRZAyvRM+WipCXBmqCNzDFLmuRiGFk+Tx+tqeVvI9XdjhicPRuF4GSqdUmmhRxpIWx8IfZbzoZhzILMisMCAwEAAQAAAAlsb2NhbGhvc3QAACah")); +listOfServers.push_back(createTransportInfo(0x929a2016, 0x56c8ff92, 1, "AAABJjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALPFnHKu3C/sPCp14y+LDR9pZky19eu4az9SuuvPXrb140akP6dkCstA8MBak9FoihYKf6oIAlmV+kh1We8uvpcMqHPWRSMZfn/1lQxE3wy/gtXwAP1GiMCgIS5UDW/sYRzPEpxKO6kN1hfF9AUaWu5mB7yCR+KTmTVY96WeXMiDbYkd0sBdPDUbT30JHZ4OSf9ZiPiGd8D2SEAe2vPyPdOT6p/w1Gx2HcWZ9CwE/qWSWQcgDGXQ+c8jTW/bPtcQK+UzWiRZAyvRM+WipCXBmqCNzDFLmuRiGFk+Tx+tqeVvI9XdjhicPRuF4GSqdUmmhRxpIWx8IfZbzoZhzILMisMCAwEAAQAAAAlsb2NhbGhvc3QAACag")); ; std::random_shuffle(listOfServers.begin(), listOfServers.end()); } return listOfServers; } -const Botan::secure_vector& getDefaultConfigData() +const Botan::secure_vector& getDefaultConfigData() { - static const Botan::secure_vector configData = Botan::base64_decode("JENPTkZJR1VSQVRJT04gREFUQQIAAQIDBAUGBwgJCgsMDQ4P"); + static const Botan::secure_vector configData = Botan::base64_decode("AA=="); return configData; } diff --git a/client/client-multi/client-cpp/kaa/configuration/gen/ConfigurationGen.hpp b/client/client-multi/client-cpp/kaa/configuration/gen/ConfigurationGen.hpp deleted file mode 100644 index e3895bf5bc..0000000000 --- a/client/client-multi/client-cpp/kaa/configuration/gen/ConfigurationGen.hpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2014-2016 CyberVision, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef CONFIGURATIONGEN_HPP_437739726__H_ -#define CONFIGURATIONGEN_HPP_437739726__H_ - - -#include -#include "boost/any.hpp" -#include "avro/Specific.hh" -#include "avro/Encoder.hh" -#include "avro/Decoder.hh" - -namespace kaa_configuration { -struct _configuration_avsc_Union__0__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - bool is_null() const { - return (idx_ == 0); - } - void set_null() { - idx_ = 0; - value_ = boost::any(); - } - boost::array get_uuidT() const; - void set_uuidT(const boost::array& v); - _configuration_avsc_Union__0__(); -}; - -struct ConfigurationRootRecord { - typedef _configuration_avsc_Union__0__ __uuid_t; - std::string data; - __uuid_t __uuid; - ConfigurationRootRecord() : - data(std::string()), - __uuid(__uuid_t()) - { } -}; - -inline -boost::array _configuration_avsc_Union__0__::get_uuidT() const { - if (idx_ != 1) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast >(value_); -} - -inline -void _configuration_avsc_Union__0__::set_uuidT(const boost::array& v) { - idx_ = 1; - value_ = v; -} - -inline _configuration_avsc_Union__0__::_configuration_avsc_Union__0__() : idx_(0) { } -} -namespace avro { -template<> struct codec_traits { - static void encode(Encoder& e, kaa_configuration::_configuration_avsc_Union__0__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - e.encodeNull(); - break; - case 1: - avro::encode(e, v.get_uuidT()); - break; - } - } - static void decode(Decoder& d, kaa_configuration::_configuration_avsc_Union__0__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - d.decodeNull(); - v.set_null(); - break; - case 1: - { - boost::array vv; - avro::decode(d, vv); - v.set_uuidT(vv); - } - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa_configuration::ConfigurationRootRecord& v) { - avro::encode(e, v.data); - avro::encode(e, v.__uuid); - } - static void decode(Decoder& d, kaa_configuration::ConfigurationRootRecord& v) { - avro::decode(d, v.data); - avro::decode(d, v.__uuid); - } -}; - -} -#endif diff --git a/client/client-multi/client-cpp/kaa/gen/EndpointGen.hpp b/client/client-multi/client-cpp/kaa/gen/EndpointGen.hpp deleted file mode 100644 index fb26d98be1..0000000000 --- a/client/client-multi/client-cpp/kaa/gen/EndpointGen.hpp +++ /dev/null @@ -1,6103 +0,0 @@ -/* - * Copyright 2014-2016 CyberVision, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef KAA_GEN_ENDPOINTGEN_HPP_3437118903__H_ -#define KAA_GEN_ENDPOINTGEN_HPP_3437118903__H_ - - -#include -#include "boost/any.hpp" -#include "avro/Specific.hh" -#include "avro/Encoder.hh" -#include "avro/Decoder.hh" - -namespace kaa { -struct TopicState { - int64_t topicId; - int32_t seqNumber; - TopicState() : - topicId(int64_t()), - seqNumber(int32_t()) - { } -}; - -enum SyncResponseStatus { - NO_DELTA, - DELTA, - RESYNC, -}; - -enum NotificationType { - SYSTEM, - CUSTOM, -}; - -enum SubscriptionType { - MANDATORY_SUBSCRIPTION, - OPTIONAL_SUBSCRIPTION, -}; - -enum SubscriptionCommandType { - ADD, - REMOVE, -}; - -enum SyncResponseResultType { - SUCCESS, - FAILURE, - PROFILE_RESYNC, - REDIRECT, -}; - -enum LogDeliveryErrorCode { - NO_APPENDERS_CONFIGURED, - APPENDER_INTERNAL_ERROR, - REMOTE_CONNECTION_ERROR, - REMOTE_INTERNAL_ERROR, -}; - -enum UserAttachErrorCode { - NO_VERIFIER_CONFIGURED, - TOKEN_INVALID, - TOKEN_EXPIRED, - INTERNAL_ERROR, - CONNECTION_ERROR, - REMOTE_ERROR, - OTHER, -}; - -struct SubscriptionCommand { - int64_t topicId; - SubscriptionCommandType command; - SubscriptionCommand() : - topicId(int64_t()), - command(SubscriptionCommandType()) - { } -}; - -struct UserAttachRequest { - std::string userVerifierId; - std::string userExternalId; - std::string userAccessToken; - UserAttachRequest() : - userVerifierId(std::string()), - userExternalId(std::string()), - userAccessToken(std::string()) - { } -}; - -struct _endpoint_avsc_Union__0__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - UserAttachErrorCode get_UserAttachErrorCode() const; - void set_UserAttachErrorCode(const UserAttachErrorCode& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__0__(); -}; - -struct _endpoint_avsc_Union__1__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - std::string get_string() const; - void set_string(const std::string& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__1__(); -}; - -struct UserAttachResponse { - typedef _endpoint_avsc_Union__0__ errorCode_t; - typedef _endpoint_avsc_Union__1__ errorReason_t; - SyncResponseResultType result; - errorCode_t errorCode; - errorReason_t errorReason; - UserAttachResponse() : - result(SyncResponseResultType()), - errorCode(errorCode_t()), - errorReason(errorReason_t()) - { } -}; - -struct UserAttachNotification { - std::string userExternalId; - std::string endpointAccessToken; - UserAttachNotification() : - userExternalId(std::string()), - endpointAccessToken(std::string()) - { } -}; - -struct UserDetachNotification { - std::string endpointAccessToken; - UserDetachNotification() : - endpointAccessToken(std::string()) - { } -}; - -struct EndpointAttachRequest { - int32_t requestId; - std::string endpointAccessToken; - EndpointAttachRequest() : - requestId(int32_t()), - endpointAccessToken(std::string()) - { } -}; - -struct _endpoint_avsc_Union__2__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - std::string get_string() const; - void set_string(const std::string& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__2__(); -}; - -struct EndpointAttachResponse { - typedef _endpoint_avsc_Union__2__ endpointKeyHash_t; - int32_t requestId; - endpointKeyHash_t endpointKeyHash; - SyncResponseResultType result; - EndpointAttachResponse() : - requestId(int32_t()), - endpointKeyHash(endpointKeyHash_t()), - result(SyncResponseResultType()) - { } -}; - -struct EndpointDetachRequest { - int32_t requestId; - std::string endpointKeyHash; - EndpointDetachRequest() : - requestId(int32_t()), - endpointKeyHash(std::string()) - { } -}; - -struct EndpointDetachResponse { - int32_t requestId; - SyncResponseResultType result; - EndpointDetachResponse() : - requestId(int32_t()), - result(SyncResponseResultType()) - { } -}; - -struct _endpoint_avsc_Union__3__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - std::string get_string() const; - void set_string(const std::string& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__3__(); -}; - -struct _endpoint_avsc_Union__4__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - std::string get_string() const; - void set_string(const std::string& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__4__(); -}; - -struct Event { - typedef _endpoint_avsc_Union__3__ source_t; - typedef _endpoint_avsc_Union__4__ target_t; - int32_t seqNum; - std::string eventClassFQN; - std::vector eventData; - source_t source; - target_t target; - Event() : - seqNum(int32_t()), - eventClassFQN(std::string()), - eventData(std::vector()), - source(source_t()), - target(target_t()) - { } -}; - -struct EventListenersRequest { - int32_t requestId; - std::vector eventClassFQNs; - EventListenersRequest() : - requestId(int32_t()), - eventClassFQNs(std::vector()) - { } -}; - -struct _endpoint_avsc_Union__5__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - std::vector get_array() const; - void set_array(const std::vector& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__5__(); -}; - -struct EventListenersResponse { - typedef _endpoint_avsc_Union__5__ listeners_t; - int32_t requestId; - listeners_t listeners; - SyncResponseResultType result; - EventListenersResponse() : - requestId(int32_t()), - listeners(listeners_t()), - result(SyncResponseResultType()) - { } -}; - -struct EventSequenceNumberRequest { - EventSequenceNumberRequest() - { } -}; - -struct EventSequenceNumberResponse { - int32_t seqNum; - EventSequenceNumberResponse() : - seqNum(int32_t()) - { } -}; - -struct _endpoint_avsc_Union__6__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - std::string get_string() const; - void set_string(const std::string& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__6__(); -}; - -struct _endpoint_avsc_Union__7__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - int32_t get_int() const; - void set_int(const int32_t& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__7__(); -}; - -struct Notification { - typedef _endpoint_avsc_Union__6__ uid_t; - typedef _endpoint_avsc_Union__7__ seqNumber_t; - int64_t topicId; - NotificationType type; - uid_t uid; - seqNumber_t seqNumber; - std::vector body; - Notification() : - topicId(int64_t()), - type(NotificationType()), - uid(uid_t()), - seqNumber(seqNumber_t()), - body(std::vector()) - { } -}; - -struct Topic { - int64_t id; - std::string name; - SubscriptionType subscriptionType; - Topic() : - id(int64_t()), - name(std::string()), - subscriptionType(SubscriptionType()) - { } -}; - -struct LogEntry { - std::vector data; - LogEntry() : - data(std::vector()) - { } -}; - -struct _endpoint_avsc_Union__8__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - std::vector get_bytes() const; - void set_bytes(const std::vector& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__8__(); -}; - -struct _endpoint_avsc_Union__9__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - std::vector get_bytes() const; - void set_bytes(const std::vector& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__9__(); -}; - -struct _endpoint_avsc_Union__10__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - int64_t get_long() const; - void set_long(const int64_t& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__10__(); -}; - -struct SyncRequestMetaData { - typedef _endpoint_avsc_Union__8__ endpointPublicKeyHash_t; - typedef _endpoint_avsc_Union__9__ profileHash_t; - typedef _endpoint_avsc_Union__10__ timeout_t; - std::string sdkToken; - endpointPublicKeyHash_t endpointPublicKeyHash; - profileHash_t profileHash; - timeout_t timeout; - SyncRequestMetaData() : - sdkToken(std::string()), - endpointPublicKeyHash(endpointPublicKeyHash_t()), - profileHash(profileHash_t()), - timeout(timeout_t()) - { } -}; - -struct _endpoint_avsc_Union__11__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - std::vector get_bytes() const; - void set_bytes(const std::vector& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__11__(); -}; - -struct _endpoint_avsc_Union__12__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - std::string get_string() const; - void set_string(const std::string& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__12__(); -}; - -struct ProfileSyncRequest { - typedef _endpoint_avsc_Union__11__ endpointPublicKey_t; - typedef _endpoint_avsc_Union__12__ endpointAccessToken_t; - endpointPublicKey_t endpointPublicKey; - std::vector profileBody; - endpointAccessToken_t endpointAccessToken; - ProfileSyncRequest() : - endpointPublicKey(endpointPublicKey_t()), - profileBody(std::vector()), - endpointAccessToken(endpointAccessToken_t()) - { } -}; - -struct ProtocolVersionPair { - int32_t id; - int32_t version; - ProtocolVersionPair() : - id(int32_t()), - version(int32_t()) - { } -}; - -struct BootstrapSyncRequest { - int32_t requestId; - std::vector supportedProtocols; - BootstrapSyncRequest() : - requestId(int32_t()), - supportedProtocols(std::vector()) - { } -}; - -struct _endpoint_avsc_Union__13__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - bool get_bool() const; - void set_bool(const bool& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__13__(); -}; - -struct ConfigurationSyncRequest { - typedef _endpoint_avsc_Union__13__ resyncOnly_t; - std::vector configurationHash; - resyncOnly_t resyncOnly; - ConfigurationSyncRequest() : - configurationHash(std::vector()), - resyncOnly(resyncOnly_t()) - { } -}; - -struct _endpoint_avsc_Union__14__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - std::vector get_array() const; - void set_array(const std::vector& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__14__(); -}; - -struct _endpoint_avsc_Union__15__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - std::vector get_array() const; - void set_array(const std::vector& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__15__(); -}; - -struct _endpoint_avsc_Union__16__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - std::vector get_array() const; - void set_array(const std::vector& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__16__(); -}; - -struct NotificationSyncRequest { - typedef _endpoint_avsc_Union__14__ topicStates_t; - typedef _endpoint_avsc_Union__15__ acceptedUnicastNotifications_t; - typedef _endpoint_avsc_Union__16__ subscriptionCommands_t; - int32_t topicListHash; - topicStates_t topicStates; - acceptedUnicastNotifications_t acceptedUnicastNotifications; - subscriptionCommands_t subscriptionCommands; - NotificationSyncRequest() : - topicListHash(int32_t()), - topicStates(topicStates_t()), - acceptedUnicastNotifications(acceptedUnicastNotifications_t()), - subscriptionCommands(subscriptionCommands_t()) - { } -}; - -struct _endpoint_avsc_Union__17__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - UserAttachRequest get_UserAttachRequest() const; - void set_UserAttachRequest(const UserAttachRequest& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__17__(); -}; - -struct _endpoint_avsc_Union__18__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - std::vector get_array() const; - void set_array(const std::vector& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__18__(); -}; - -struct _endpoint_avsc_Union__19__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - std::vector get_array() const; - void set_array(const std::vector& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__19__(); -}; - -struct UserSyncRequest { - typedef _endpoint_avsc_Union__17__ userAttachRequest_t; - typedef _endpoint_avsc_Union__18__ endpointAttachRequests_t; - typedef _endpoint_avsc_Union__19__ endpointDetachRequests_t; - userAttachRequest_t userAttachRequest; - endpointAttachRequests_t endpointAttachRequests; - endpointDetachRequests_t endpointDetachRequests; - UserSyncRequest() : - userAttachRequest(userAttachRequest_t()), - endpointAttachRequests(endpointAttachRequests_t()), - endpointDetachRequests(endpointDetachRequests_t()) - { } -}; - -struct _endpoint_avsc_Union__20__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - EventSequenceNumberRequest get_EventSequenceNumberRequest() const; - void set_EventSequenceNumberRequest(const EventSequenceNumberRequest& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__20__(); -}; - -struct _endpoint_avsc_Union__21__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - std::vector get_array() const; - void set_array(const std::vector& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__21__(); -}; - -struct _endpoint_avsc_Union__22__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - std::vector get_array() const; - void set_array(const std::vector& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__22__(); -}; - -struct EventSyncRequest { - typedef _endpoint_avsc_Union__20__ eventSequenceNumberRequest_t; - typedef _endpoint_avsc_Union__21__ eventListenersRequests_t; - typedef _endpoint_avsc_Union__22__ events_t; - eventSequenceNumberRequest_t eventSequenceNumberRequest; - eventListenersRequests_t eventListenersRequests; - events_t events; - EventSyncRequest() : - eventSequenceNumberRequest(eventSequenceNumberRequest_t()), - eventListenersRequests(eventListenersRequests_t()), - events(events_t()) - { } -}; - -struct _endpoint_avsc_Union__23__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - std::vector get_array() const; - void set_array(const std::vector& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__23__(); -}; - -struct LogSyncRequest { - typedef _endpoint_avsc_Union__23__ logEntries_t; - int32_t requestId; - logEntries_t logEntries; - LogSyncRequest() : - requestId(int32_t()), - logEntries(logEntries_t()) - { } -}; - -struct ProtocolMetaData { - int32_t accessPointId; - ProtocolVersionPair protocolVersionInfo; - std::vector connectionInfo; - ProtocolMetaData() : - accessPointId(int32_t()), - protocolVersionInfo(ProtocolVersionPair()), - connectionInfo(std::vector()) - { } -}; - -struct BootstrapSyncResponse { - int32_t requestId; - std::vector supportedProtocols; - BootstrapSyncResponse() : - requestId(int32_t()), - supportedProtocols(std::vector()) - { } -}; - -struct ProfileSyncResponse { - SyncResponseStatus responseStatus; - ProfileSyncResponse() : - responseStatus(SyncResponseStatus()) - { } -}; - -struct _endpoint_avsc_Union__24__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - std::vector get_bytes() const; - void set_bytes(const std::vector& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__24__(); -}; - -struct _endpoint_avsc_Union__25__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - std::vector get_bytes() const; - void set_bytes(const std::vector& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__25__(); -}; - -struct ConfigurationSyncResponse { - typedef _endpoint_avsc_Union__24__ confSchemaBody_t; - typedef _endpoint_avsc_Union__25__ confDeltaBody_t; - SyncResponseStatus responseStatus; - confSchemaBody_t confSchemaBody; - confDeltaBody_t confDeltaBody; - ConfigurationSyncResponse() : - responseStatus(SyncResponseStatus()), - confSchemaBody(confSchemaBody_t()), - confDeltaBody(confDeltaBody_t()) - { } -}; - -struct _endpoint_avsc_Union__26__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - std::vector get_array() const; - void set_array(const std::vector& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__26__(); -}; - -struct _endpoint_avsc_Union__27__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - std::vector get_array() const; - void set_array(const std::vector& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__27__(); -}; - -struct NotificationSyncResponse { - typedef _endpoint_avsc_Union__26__ notifications_t; - typedef _endpoint_avsc_Union__27__ availableTopics_t; - SyncResponseStatus responseStatus; - notifications_t notifications; - availableTopics_t availableTopics; - NotificationSyncResponse() : - responseStatus(SyncResponseStatus()), - notifications(notifications_t()), - availableTopics(availableTopics_t()) - { } -}; - -struct _endpoint_avsc_Union__28__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - UserAttachResponse get_UserAttachResponse() const; - void set_UserAttachResponse(const UserAttachResponse& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__28__(); -}; - -struct _endpoint_avsc_Union__29__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - UserAttachNotification get_UserAttachNotification() const; - void set_UserAttachNotification(const UserAttachNotification& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__29__(); -}; - -struct _endpoint_avsc_Union__30__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - UserDetachNotification get_UserDetachNotification() const; - void set_UserDetachNotification(const UserDetachNotification& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__30__(); -}; - -struct _endpoint_avsc_Union__31__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - std::vector get_array() const; - void set_array(const std::vector& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__31__(); -}; - -struct _endpoint_avsc_Union__32__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - std::vector get_array() const; - void set_array(const std::vector& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__32__(); -}; - -struct UserSyncResponse { - typedef _endpoint_avsc_Union__28__ userAttachResponse_t; - typedef _endpoint_avsc_Union__29__ userAttachNotification_t; - typedef _endpoint_avsc_Union__30__ userDetachNotification_t; - typedef _endpoint_avsc_Union__31__ endpointAttachResponses_t; - typedef _endpoint_avsc_Union__32__ endpointDetachResponses_t; - userAttachResponse_t userAttachResponse; - userAttachNotification_t userAttachNotification; - userDetachNotification_t userDetachNotification; - endpointAttachResponses_t endpointAttachResponses; - endpointDetachResponses_t endpointDetachResponses; - UserSyncResponse() : - userAttachResponse(userAttachResponse_t()), - userAttachNotification(userAttachNotification_t()), - userDetachNotification(userDetachNotification_t()), - endpointAttachResponses(endpointAttachResponses_t()), - endpointDetachResponses(endpointDetachResponses_t()) - { } -}; - -struct _endpoint_avsc_Union__33__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - EventSequenceNumberResponse get_EventSequenceNumberResponse() const; - void set_EventSequenceNumberResponse(const EventSequenceNumberResponse& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__33__(); -}; - -struct _endpoint_avsc_Union__34__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - std::vector get_array() const; - void set_array(const std::vector& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__34__(); -}; - -struct _endpoint_avsc_Union__35__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - std::vector get_array() const; - void set_array(const std::vector& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__35__(); -}; - -struct EventSyncResponse { - typedef _endpoint_avsc_Union__33__ eventSequenceNumberResponse_t; - typedef _endpoint_avsc_Union__34__ eventListenersResponses_t; - typedef _endpoint_avsc_Union__35__ events_t; - eventSequenceNumberResponse_t eventSequenceNumberResponse; - eventListenersResponses_t eventListenersResponses; - events_t events; - EventSyncResponse() : - eventSequenceNumberResponse(eventSequenceNumberResponse_t()), - eventListenersResponses(eventListenersResponses_t()), - events(events_t()) - { } -}; - -struct _endpoint_avsc_Union__36__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - LogDeliveryErrorCode get_LogDeliveryErrorCode() const; - void set_LogDeliveryErrorCode(const LogDeliveryErrorCode& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__36__(); -}; - -struct LogDeliveryStatus { - typedef _endpoint_avsc_Union__36__ errorCode_t; - int32_t requestId; - SyncResponseResultType result; - errorCode_t errorCode; - LogDeliveryStatus() : - requestId(int32_t()), - result(SyncResponseResultType()), - errorCode(errorCode_t()) - { } -}; - -struct _endpoint_avsc_Union__37__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - std::vector get_array() const; - void set_array(const std::vector& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__37__(); -}; - -struct LogSyncResponse { - typedef _endpoint_avsc_Union__37__ deliveryStatuses_t; - deliveryStatuses_t deliveryStatuses; - LogSyncResponse() : - deliveryStatuses(deliveryStatuses_t()) - { } -}; - -struct RedirectSyncResponse { - int32_t accessPointId; - RedirectSyncResponse() : - accessPointId(int32_t()) - { } -}; - -struct ExtensionSync { - int32_t extensionId; - std::vector payload; - ExtensionSync() : - extensionId(int32_t()), - payload(std::vector()) - { } -}; - -struct _endpoint_avsc_Union__38__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - SyncRequestMetaData get_SyncRequestMetaData() const; - void set_SyncRequestMetaData(const SyncRequestMetaData& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__38__(); -}; - -struct _endpoint_avsc_Union__39__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - BootstrapSyncRequest get_BootstrapSyncRequest() const; - void set_BootstrapSyncRequest(const BootstrapSyncRequest& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__39__(); -}; - -struct _endpoint_avsc_Union__40__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - ProfileSyncRequest get_ProfileSyncRequest() const; - void set_ProfileSyncRequest(const ProfileSyncRequest& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__40__(); -}; - -struct _endpoint_avsc_Union__41__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - ConfigurationSyncRequest get_ConfigurationSyncRequest() const; - void set_ConfigurationSyncRequest(const ConfigurationSyncRequest& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__41__(); -}; - -struct _endpoint_avsc_Union__42__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - NotificationSyncRequest get_NotificationSyncRequest() const; - void set_NotificationSyncRequest(const NotificationSyncRequest& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__42__(); -}; - -struct _endpoint_avsc_Union__43__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - UserSyncRequest get_UserSyncRequest() const; - void set_UserSyncRequest(const UserSyncRequest& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__43__(); -}; - -struct _endpoint_avsc_Union__44__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - EventSyncRequest get_EventSyncRequest() const; - void set_EventSyncRequest(const EventSyncRequest& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__44__(); -}; - -struct _endpoint_avsc_Union__45__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - LogSyncRequest get_LogSyncRequest() const; - void set_LogSyncRequest(const LogSyncRequest& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__45__(); -}; - -struct _endpoint_avsc_Union__46__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - std::vector get_array() const; - void set_array(const std::vector& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__46__(); -}; - -struct SyncRequest { - typedef _endpoint_avsc_Union__38__ syncRequestMetaData_t; - typedef _endpoint_avsc_Union__39__ bootstrapSyncRequest_t; - typedef _endpoint_avsc_Union__40__ profileSyncRequest_t; - typedef _endpoint_avsc_Union__41__ configurationSyncRequest_t; - typedef _endpoint_avsc_Union__42__ notificationSyncRequest_t; - typedef _endpoint_avsc_Union__43__ userSyncRequest_t; - typedef _endpoint_avsc_Union__44__ eventSyncRequest_t; - typedef _endpoint_avsc_Union__45__ logSyncRequest_t; - typedef _endpoint_avsc_Union__46__ extensionSyncRequests_t; - int32_t requestId; - syncRequestMetaData_t syncRequestMetaData; - bootstrapSyncRequest_t bootstrapSyncRequest; - profileSyncRequest_t profileSyncRequest; - configurationSyncRequest_t configurationSyncRequest; - notificationSyncRequest_t notificationSyncRequest; - userSyncRequest_t userSyncRequest; - eventSyncRequest_t eventSyncRequest; - logSyncRequest_t logSyncRequest; - extensionSyncRequests_t extensionSyncRequests; - SyncRequest() : - requestId(int32_t()), - syncRequestMetaData(syncRequestMetaData_t()), - bootstrapSyncRequest(bootstrapSyncRequest_t()), - profileSyncRequest(profileSyncRequest_t()), - configurationSyncRequest(configurationSyncRequest_t()), - notificationSyncRequest(notificationSyncRequest_t()), - userSyncRequest(userSyncRequest_t()), - eventSyncRequest(eventSyncRequest_t()), - logSyncRequest(logSyncRequest_t()), - extensionSyncRequests(extensionSyncRequests_t()) - { } -}; - -struct _endpoint_avsc_Union__47__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - BootstrapSyncResponse get_BootstrapSyncResponse() const; - void set_BootstrapSyncResponse(const BootstrapSyncResponse& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__47__(); -}; - -struct _endpoint_avsc_Union__48__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - ProfileSyncResponse get_ProfileSyncResponse() const; - void set_ProfileSyncResponse(const ProfileSyncResponse& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__48__(); -}; - -struct _endpoint_avsc_Union__49__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - ConfigurationSyncResponse get_ConfigurationSyncResponse() const; - void set_ConfigurationSyncResponse(const ConfigurationSyncResponse& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__49__(); -}; - -struct _endpoint_avsc_Union__50__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - NotificationSyncResponse get_NotificationSyncResponse() const; - void set_NotificationSyncResponse(const NotificationSyncResponse& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__50__(); -}; - -struct _endpoint_avsc_Union__51__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - UserSyncResponse get_UserSyncResponse() const; - void set_UserSyncResponse(const UserSyncResponse& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__51__(); -}; - -struct _endpoint_avsc_Union__52__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - EventSyncResponse get_EventSyncResponse() const; - void set_EventSyncResponse(const EventSyncResponse& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__52__(); -}; - -struct _endpoint_avsc_Union__53__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - RedirectSyncResponse get_RedirectSyncResponse() const; - void set_RedirectSyncResponse(const RedirectSyncResponse& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__53__(); -}; - -struct _endpoint_avsc_Union__54__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - LogSyncResponse get_LogSyncResponse() const; - void set_LogSyncResponse(const LogSyncResponse& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__54__(); -}; - -struct _endpoint_avsc_Union__55__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - std::vector get_array() const; - void set_array(const std::vector& v); - bool is_null() const { - return (idx_ == 1); - } - void set_null() { - idx_ = 1; - value_ = boost::any(); - } - _endpoint_avsc_Union__55__(); -}; - -struct SyncResponse { - typedef _endpoint_avsc_Union__47__ bootstrapSyncResponse_t; - typedef _endpoint_avsc_Union__48__ profileSyncResponse_t; - typedef _endpoint_avsc_Union__49__ configurationSyncResponse_t; - typedef _endpoint_avsc_Union__50__ notificationSyncResponse_t; - typedef _endpoint_avsc_Union__51__ userSyncResponse_t; - typedef _endpoint_avsc_Union__52__ eventSyncResponse_t; - typedef _endpoint_avsc_Union__53__ redirectSyncResponse_t; - typedef _endpoint_avsc_Union__54__ logSyncResponse_t; - typedef _endpoint_avsc_Union__55__ extensionSyncResponses_t; - int32_t requestId; - SyncResponseResultType status; - bootstrapSyncResponse_t bootstrapSyncResponse; - profileSyncResponse_t profileSyncResponse; - configurationSyncResponse_t configurationSyncResponse; - notificationSyncResponse_t notificationSyncResponse; - userSyncResponse_t userSyncResponse; - eventSyncResponse_t eventSyncResponse; - redirectSyncResponse_t redirectSyncResponse; - logSyncResponse_t logSyncResponse; - extensionSyncResponses_t extensionSyncResponses; - SyncResponse() : - requestId(int32_t()), - status(SyncResponseResultType()), - bootstrapSyncResponse(bootstrapSyncResponse_t()), - profileSyncResponse(profileSyncResponse_t()), - configurationSyncResponse(configurationSyncResponse_t()), - notificationSyncResponse(notificationSyncResponse_t()), - userSyncResponse(userSyncResponse_t()), - eventSyncResponse(eventSyncResponse_t()), - redirectSyncResponse(redirectSyncResponse_t()), - logSyncResponse(logSyncResponse_t()), - extensionSyncResponses(extensionSyncResponses_t()) - { } -}; - -struct TopicSubscriptionInfo { - Topic topicInfo; - int32_t seqNumber; - TopicSubscriptionInfo() : - topicInfo(Topic()), - seqNumber(int32_t()) - { } -}; - -struct _endpoint_avsc_Union__56__ { -private: - size_t idx_; - boost::any value_; -public: - size_t idx() const { return idx_; } - TopicState get_TopicState() const; - void set_TopicState(const TopicState& v); - SyncResponseStatus get_SyncResponseStatus() const; - void set_SyncResponseStatus(const SyncResponseStatus& v); - NotificationType get_NotificationType() const; - void set_NotificationType(const NotificationType& v); - SubscriptionType get_SubscriptionType() const; - void set_SubscriptionType(const SubscriptionType& v); - SubscriptionCommandType get_SubscriptionCommandType() const; - void set_SubscriptionCommandType(const SubscriptionCommandType& v); - SyncResponseResultType get_SyncResponseResultType() const; - void set_SyncResponseResultType(const SyncResponseResultType& v); - LogDeliveryErrorCode get_LogDeliveryErrorCode() const; - void set_LogDeliveryErrorCode(const LogDeliveryErrorCode& v); - UserAttachErrorCode get_UserAttachErrorCode() const; - void set_UserAttachErrorCode(const UserAttachErrorCode& v); - SubscriptionCommand get_SubscriptionCommand() const; - void set_SubscriptionCommand(const SubscriptionCommand& v); - UserAttachRequest get_UserAttachRequest() const; - void set_UserAttachRequest(const UserAttachRequest& v); - UserAttachResponse get_UserAttachResponse() const; - void set_UserAttachResponse(const UserAttachResponse& v); - UserAttachNotification get_UserAttachNotification() const; - void set_UserAttachNotification(const UserAttachNotification& v); - UserDetachNotification get_UserDetachNotification() const; - void set_UserDetachNotification(const UserDetachNotification& v); - EndpointAttachRequest get_EndpointAttachRequest() const; - void set_EndpointAttachRequest(const EndpointAttachRequest& v); - EndpointAttachResponse get_EndpointAttachResponse() const; - void set_EndpointAttachResponse(const EndpointAttachResponse& v); - EndpointDetachRequest get_EndpointDetachRequest() const; - void set_EndpointDetachRequest(const EndpointDetachRequest& v); - EndpointDetachResponse get_EndpointDetachResponse() const; - void set_EndpointDetachResponse(const EndpointDetachResponse& v); - Event get_Event() const; - void set_Event(const Event& v); - EventListenersRequest get_EventListenersRequest() const; - void set_EventListenersRequest(const EventListenersRequest& v); - EventListenersResponse get_EventListenersResponse() const; - void set_EventListenersResponse(const EventListenersResponse& v); - EventSequenceNumberRequest get_EventSequenceNumberRequest() const; - void set_EventSequenceNumberRequest(const EventSequenceNumberRequest& v); - EventSequenceNumberResponse get_EventSequenceNumberResponse() const; - void set_EventSequenceNumberResponse(const EventSequenceNumberResponse& v); - Notification get_Notification() const; - void set_Notification(const Notification& v); - Topic get_Topic() const; - void set_Topic(const Topic& v); - LogEntry get_LogEntry() const; - void set_LogEntry(const LogEntry& v); - SyncRequestMetaData get_SyncRequestMetaData() const; - void set_SyncRequestMetaData(const SyncRequestMetaData& v); - ProfileSyncRequest get_ProfileSyncRequest() const; - void set_ProfileSyncRequest(const ProfileSyncRequest& v); - ProtocolVersionPair get_ProtocolVersionPair() const; - void set_ProtocolVersionPair(const ProtocolVersionPair& v); - BootstrapSyncRequest get_BootstrapSyncRequest() const; - void set_BootstrapSyncRequest(const BootstrapSyncRequest& v); - ConfigurationSyncRequest get_ConfigurationSyncRequest() const; - void set_ConfigurationSyncRequest(const ConfigurationSyncRequest& v); - NotificationSyncRequest get_NotificationSyncRequest() const; - void set_NotificationSyncRequest(const NotificationSyncRequest& v); - UserSyncRequest get_UserSyncRequest() const; - void set_UserSyncRequest(const UserSyncRequest& v); - EventSyncRequest get_EventSyncRequest() const; - void set_EventSyncRequest(const EventSyncRequest& v); - LogSyncRequest get_LogSyncRequest() const; - void set_LogSyncRequest(const LogSyncRequest& v); - ProtocolMetaData get_ProtocolMetaData() const; - void set_ProtocolMetaData(const ProtocolMetaData& v); - BootstrapSyncResponse get_BootstrapSyncResponse() const; - void set_BootstrapSyncResponse(const BootstrapSyncResponse& v); - ProfileSyncResponse get_ProfileSyncResponse() const; - void set_ProfileSyncResponse(const ProfileSyncResponse& v); - ConfigurationSyncResponse get_ConfigurationSyncResponse() const; - void set_ConfigurationSyncResponse(const ConfigurationSyncResponse& v); - NotificationSyncResponse get_NotificationSyncResponse() const; - void set_NotificationSyncResponse(const NotificationSyncResponse& v); - UserSyncResponse get_UserSyncResponse() const; - void set_UserSyncResponse(const UserSyncResponse& v); - EventSyncResponse get_EventSyncResponse() const; - void set_EventSyncResponse(const EventSyncResponse& v); - LogDeliveryStatus get_LogDeliveryStatus() const; - void set_LogDeliveryStatus(const LogDeliveryStatus& v); - LogSyncResponse get_LogSyncResponse() const; - void set_LogSyncResponse(const LogSyncResponse& v); - RedirectSyncResponse get_RedirectSyncResponse() const; - void set_RedirectSyncResponse(const RedirectSyncResponse& v); - ExtensionSync get_ExtensionSync() const; - void set_ExtensionSync(const ExtensionSync& v); - SyncRequest get_SyncRequest() const; - void set_SyncRequest(const SyncRequest& v); - SyncResponse get_SyncResponse() const; - void set_SyncResponse(const SyncResponse& v); - TopicSubscriptionInfo get_TopicSubscriptionInfo() const; - void set_TopicSubscriptionInfo(const TopicSubscriptionInfo& v); - _endpoint_avsc_Union__56__(); -}; - -inline -UserAttachErrorCode _endpoint_avsc_Union__0__::get_UserAttachErrorCode() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__0__::set_UserAttachErrorCode(const UserAttachErrorCode& v) { - idx_ = 0; - value_ = v; -} - -inline -std::string _endpoint_avsc_Union__1__::get_string() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__1__::set_string(const std::string& v) { - idx_ = 0; - value_ = v; -} - -inline -std::string _endpoint_avsc_Union__2__::get_string() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__2__::set_string(const std::string& v) { - idx_ = 0; - value_ = v; -} - -inline -std::string _endpoint_avsc_Union__3__::get_string() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__3__::set_string(const std::string& v) { - idx_ = 0; - value_ = v; -} - -inline -std::string _endpoint_avsc_Union__4__::get_string() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__4__::set_string(const std::string& v) { - idx_ = 0; - value_ = v; -} - -inline -std::vector _endpoint_avsc_Union__5__::get_array() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast >(value_); -} - -inline -void _endpoint_avsc_Union__5__::set_array(const std::vector& v) { - idx_ = 0; - value_ = v; -} - -inline -std::string _endpoint_avsc_Union__6__::get_string() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__6__::set_string(const std::string& v) { - idx_ = 0; - value_ = v; -} - -inline -int32_t _endpoint_avsc_Union__7__::get_int() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__7__::set_int(const int32_t& v) { - idx_ = 0; - value_ = v; -} - -inline -std::vector _endpoint_avsc_Union__8__::get_bytes() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast >(value_); -} - -inline -void _endpoint_avsc_Union__8__::set_bytes(const std::vector& v) { - idx_ = 0; - value_ = v; -} - -inline -std::vector _endpoint_avsc_Union__9__::get_bytes() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast >(value_); -} - -inline -void _endpoint_avsc_Union__9__::set_bytes(const std::vector& v) { - idx_ = 0; - value_ = v; -} - -inline -int64_t _endpoint_avsc_Union__10__::get_long() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__10__::set_long(const int64_t& v) { - idx_ = 0; - value_ = v; -} - -inline -std::vector _endpoint_avsc_Union__11__::get_bytes() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast >(value_); -} - -inline -void _endpoint_avsc_Union__11__::set_bytes(const std::vector& v) { - idx_ = 0; - value_ = v; -} - -inline -std::string _endpoint_avsc_Union__12__::get_string() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__12__::set_string(const std::string& v) { - idx_ = 0; - value_ = v; -} - -inline -bool _endpoint_avsc_Union__13__::get_bool() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__13__::set_bool(const bool& v) { - idx_ = 0; - value_ = v; -} - -inline -std::vector _endpoint_avsc_Union__14__::get_array() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast >(value_); -} - -inline -void _endpoint_avsc_Union__14__::set_array(const std::vector& v) { - idx_ = 0; - value_ = v; -} - -inline -std::vector _endpoint_avsc_Union__15__::get_array() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast >(value_); -} - -inline -void _endpoint_avsc_Union__15__::set_array(const std::vector& v) { - idx_ = 0; - value_ = v; -} - -inline -std::vector _endpoint_avsc_Union__16__::get_array() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast >(value_); -} - -inline -void _endpoint_avsc_Union__16__::set_array(const std::vector& v) { - idx_ = 0; - value_ = v; -} - -inline -UserAttachRequest _endpoint_avsc_Union__17__::get_UserAttachRequest() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__17__::set_UserAttachRequest(const UserAttachRequest& v) { - idx_ = 0; - value_ = v; -} - -inline -std::vector _endpoint_avsc_Union__18__::get_array() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast >(value_); -} - -inline -void _endpoint_avsc_Union__18__::set_array(const std::vector& v) { - idx_ = 0; - value_ = v; -} - -inline -std::vector _endpoint_avsc_Union__19__::get_array() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast >(value_); -} - -inline -void _endpoint_avsc_Union__19__::set_array(const std::vector& v) { - idx_ = 0; - value_ = v; -} - -inline -EventSequenceNumberRequest _endpoint_avsc_Union__20__::get_EventSequenceNumberRequest() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__20__::set_EventSequenceNumberRequest(const EventSequenceNumberRequest& v) { - idx_ = 0; - value_ = v; -} - -inline -std::vector _endpoint_avsc_Union__21__::get_array() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast >(value_); -} - -inline -void _endpoint_avsc_Union__21__::set_array(const std::vector& v) { - idx_ = 0; - value_ = v; -} - -inline -std::vector _endpoint_avsc_Union__22__::get_array() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast >(value_); -} - -inline -void _endpoint_avsc_Union__22__::set_array(const std::vector& v) { - idx_ = 0; - value_ = v; -} - -inline -std::vector _endpoint_avsc_Union__23__::get_array() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast >(value_); -} - -inline -void _endpoint_avsc_Union__23__::set_array(const std::vector& v) { - idx_ = 0; - value_ = v; -} - -inline -std::vector _endpoint_avsc_Union__24__::get_bytes() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast >(value_); -} - -inline -void _endpoint_avsc_Union__24__::set_bytes(const std::vector& v) { - idx_ = 0; - value_ = v; -} - -inline -std::vector _endpoint_avsc_Union__25__::get_bytes() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast >(value_); -} - -inline -void _endpoint_avsc_Union__25__::set_bytes(const std::vector& v) { - idx_ = 0; - value_ = v; -} - -inline -std::vector _endpoint_avsc_Union__26__::get_array() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast >(value_); -} - -inline -void _endpoint_avsc_Union__26__::set_array(const std::vector& v) { - idx_ = 0; - value_ = v; -} - -inline -std::vector _endpoint_avsc_Union__27__::get_array() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast >(value_); -} - -inline -void _endpoint_avsc_Union__27__::set_array(const std::vector& v) { - idx_ = 0; - value_ = v; -} - -inline -UserAttachResponse _endpoint_avsc_Union__28__::get_UserAttachResponse() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__28__::set_UserAttachResponse(const UserAttachResponse& v) { - idx_ = 0; - value_ = v; -} - -inline -UserAttachNotification _endpoint_avsc_Union__29__::get_UserAttachNotification() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__29__::set_UserAttachNotification(const UserAttachNotification& v) { - idx_ = 0; - value_ = v; -} - -inline -UserDetachNotification _endpoint_avsc_Union__30__::get_UserDetachNotification() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__30__::set_UserDetachNotification(const UserDetachNotification& v) { - idx_ = 0; - value_ = v; -} - -inline -std::vector _endpoint_avsc_Union__31__::get_array() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast >(value_); -} - -inline -void _endpoint_avsc_Union__31__::set_array(const std::vector& v) { - idx_ = 0; - value_ = v; -} - -inline -std::vector _endpoint_avsc_Union__32__::get_array() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast >(value_); -} - -inline -void _endpoint_avsc_Union__32__::set_array(const std::vector& v) { - idx_ = 0; - value_ = v; -} - -inline -EventSequenceNumberResponse _endpoint_avsc_Union__33__::get_EventSequenceNumberResponse() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__33__::set_EventSequenceNumberResponse(const EventSequenceNumberResponse& v) { - idx_ = 0; - value_ = v; -} - -inline -std::vector _endpoint_avsc_Union__34__::get_array() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast >(value_); -} - -inline -void _endpoint_avsc_Union__34__::set_array(const std::vector& v) { - idx_ = 0; - value_ = v; -} - -inline -std::vector _endpoint_avsc_Union__35__::get_array() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast >(value_); -} - -inline -void _endpoint_avsc_Union__35__::set_array(const std::vector& v) { - idx_ = 0; - value_ = v; -} - -inline -LogDeliveryErrorCode _endpoint_avsc_Union__36__::get_LogDeliveryErrorCode() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__36__::set_LogDeliveryErrorCode(const LogDeliveryErrorCode& v) { - idx_ = 0; - value_ = v; -} - -inline -std::vector _endpoint_avsc_Union__37__::get_array() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast >(value_); -} - -inline -void _endpoint_avsc_Union__37__::set_array(const std::vector& v) { - idx_ = 0; - value_ = v; -} - -inline -SyncRequestMetaData _endpoint_avsc_Union__38__::get_SyncRequestMetaData() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__38__::set_SyncRequestMetaData(const SyncRequestMetaData& v) { - idx_ = 0; - value_ = v; -} - -inline -BootstrapSyncRequest _endpoint_avsc_Union__39__::get_BootstrapSyncRequest() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__39__::set_BootstrapSyncRequest(const BootstrapSyncRequest& v) { - idx_ = 0; - value_ = v; -} - -inline -ProfileSyncRequest _endpoint_avsc_Union__40__::get_ProfileSyncRequest() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__40__::set_ProfileSyncRequest(const ProfileSyncRequest& v) { - idx_ = 0; - value_ = v; -} - -inline -ConfigurationSyncRequest _endpoint_avsc_Union__41__::get_ConfigurationSyncRequest() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__41__::set_ConfigurationSyncRequest(const ConfigurationSyncRequest& v) { - idx_ = 0; - value_ = v; -} - -inline -NotificationSyncRequest _endpoint_avsc_Union__42__::get_NotificationSyncRequest() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__42__::set_NotificationSyncRequest(const NotificationSyncRequest& v) { - idx_ = 0; - value_ = v; -} - -inline -UserSyncRequest _endpoint_avsc_Union__43__::get_UserSyncRequest() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__43__::set_UserSyncRequest(const UserSyncRequest& v) { - idx_ = 0; - value_ = v; -} - -inline -EventSyncRequest _endpoint_avsc_Union__44__::get_EventSyncRequest() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__44__::set_EventSyncRequest(const EventSyncRequest& v) { - idx_ = 0; - value_ = v; -} - -inline -LogSyncRequest _endpoint_avsc_Union__45__::get_LogSyncRequest() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__45__::set_LogSyncRequest(const LogSyncRequest& v) { - idx_ = 0; - value_ = v; -} - -inline -std::vector _endpoint_avsc_Union__46__::get_array() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast >(value_); -} - -inline -void _endpoint_avsc_Union__46__::set_array(const std::vector& v) { - idx_ = 0; - value_ = v; -} - -inline -BootstrapSyncResponse _endpoint_avsc_Union__47__::get_BootstrapSyncResponse() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__47__::set_BootstrapSyncResponse(const BootstrapSyncResponse& v) { - idx_ = 0; - value_ = v; -} - -inline -ProfileSyncResponse _endpoint_avsc_Union__48__::get_ProfileSyncResponse() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__48__::set_ProfileSyncResponse(const ProfileSyncResponse& v) { - idx_ = 0; - value_ = v; -} - -inline -ConfigurationSyncResponse _endpoint_avsc_Union__49__::get_ConfigurationSyncResponse() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__49__::set_ConfigurationSyncResponse(const ConfigurationSyncResponse& v) { - idx_ = 0; - value_ = v; -} - -inline -NotificationSyncResponse _endpoint_avsc_Union__50__::get_NotificationSyncResponse() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__50__::set_NotificationSyncResponse(const NotificationSyncResponse& v) { - idx_ = 0; - value_ = v; -} - -inline -UserSyncResponse _endpoint_avsc_Union__51__::get_UserSyncResponse() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__51__::set_UserSyncResponse(const UserSyncResponse& v) { - idx_ = 0; - value_ = v; -} - -inline -EventSyncResponse _endpoint_avsc_Union__52__::get_EventSyncResponse() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__52__::set_EventSyncResponse(const EventSyncResponse& v) { - idx_ = 0; - value_ = v; -} - -inline -RedirectSyncResponse _endpoint_avsc_Union__53__::get_RedirectSyncResponse() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__53__::set_RedirectSyncResponse(const RedirectSyncResponse& v) { - idx_ = 0; - value_ = v; -} - -inline -LogSyncResponse _endpoint_avsc_Union__54__::get_LogSyncResponse() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__54__::set_LogSyncResponse(const LogSyncResponse& v) { - idx_ = 0; - value_ = v; -} - -inline -std::vector _endpoint_avsc_Union__55__::get_array() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast >(value_); -} - -inline -void _endpoint_avsc_Union__55__::set_array(const std::vector& v) { - idx_ = 0; - value_ = v; -} - -inline -TopicState _endpoint_avsc_Union__56__::get_TopicState() const { - if (idx_ != 0) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_TopicState(const TopicState& v) { - idx_ = 0; - value_ = v; -} - -inline -SyncResponseStatus _endpoint_avsc_Union__56__::get_SyncResponseStatus() const { - if (idx_ != 1) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_SyncResponseStatus(const SyncResponseStatus& v) { - idx_ = 1; - value_ = v; -} - -inline -NotificationType _endpoint_avsc_Union__56__::get_NotificationType() const { - if (idx_ != 2) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_NotificationType(const NotificationType& v) { - idx_ = 2; - value_ = v; -} - -inline -SubscriptionType _endpoint_avsc_Union__56__::get_SubscriptionType() const { - if (idx_ != 3) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_SubscriptionType(const SubscriptionType& v) { - idx_ = 3; - value_ = v; -} - -inline -SubscriptionCommandType _endpoint_avsc_Union__56__::get_SubscriptionCommandType() const { - if (idx_ != 4) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_SubscriptionCommandType(const SubscriptionCommandType& v) { - idx_ = 4; - value_ = v; -} - -inline -SyncResponseResultType _endpoint_avsc_Union__56__::get_SyncResponseResultType() const { - if (idx_ != 5) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_SyncResponseResultType(const SyncResponseResultType& v) { - idx_ = 5; - value_ = v; -} - -inline -LogDeliveryErrorCode _endpoint_avsc_Union__56__::get_LogDeliveryErrorCode() const { - if (idx_ != 6) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_LogDeliveryErrorCode(const LogDeliveryErrorCode& v) { - idx_ = 6; - value_ = v; -} - -inline -UserAttachErrorCode _endpoint_avsc_Union__56__::get_UserAttachErrorCode() const { - if (idx_ != 7) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_UserAttachErrorCode(const UserAttachErrorCode& v) { - idx_ = 7; - value_ = v; -} - -inline -SubscriptionCommand _endpoint_avsc_Union__56__::get_SubscriptionCommand() const { - if (idx_ != 8) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_SubscriptionCommand(const SubscriptionCommand& v) { - idx_ = 8; - value_ = v; -} - -inline -UserAttachRequest _endpoint_avsc_Union__56__::get_UserAttachRequest() const { - if (idx_ != 9) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_UserAttachRequest(const UserAttachRequest& v) { - idx_ = 9; - value_ = v; -} - -inline -UserAttachResponse _endpoint_avsc_Union__56__::get_UserAttachResponse() const { - if (idx_ != 10) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_UserAttachResponse(const UserAttachResponse& v) { - idx_ = 10; - value_ = v; -} - -inline -UserAttachNotification _endpoint_avsc_Union__56__::get_UserAttachNotification() const { - if (idx_ != 11) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_UserAttachNotification(const UserAttachNotification& v) { - idx_ = 11; - value_ = v; -} - -inline -UserDetachNotification _endpoint_avsc_Union__56__::get_UserDetachNotification() const { - if (idx_ != 12) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_UserDetachNotification(const UserDetachNotification& v) { - idx_ = 12; - value_ = v; -} - -inline -EndpointAttachRequest _endpoint_avsc_Union__56__::get_EndpointAttachRequest() const { - if (idx_ != 13) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_EndpointAttachRequest(const EndpointAttachRequest& v) { - idx_ = 13; - value_ = v; -} - -inline -EndpointAttachResponse _endpoint_avsc_Union__56__::get_EndpointAttachResponse() const { - if (idx_ != 14) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_EndpointAttachResponse(const EndpointAttachResponse& v) { - idx_ = 14; - value_ = v; -} - -inline -EndpointDetachRequest _endpoint_avsc_Union__56__::get_EndpointDetachRequest() const { - if (idx_ != 15) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_EndpointDetachRequest(const EndpointDetachRequest& v) { - idx_ = 15; - value_ = v; -} - -inline -EndpointDetachResponse _endpoint_avsc_Union__56__::get_EndpointDetachResponse() const { - if (idx_ != 16) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_EndpointDetachResponse(const EndpointDetachResponse& v) { - idx_ = 16; - value_ = v; -} - -inline -Event _endpoint_avsc_Union__56__::get_Event() const { - if (idx_ != 17) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_Event(const Event& v) { - idx_ = 17; - value_ = v; -} - -inline -EventListenersRequest _endpoint_avsc_Union__56__::get_EventListenersRequest() const { - if (idx_ != 18) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_EventListenersRequest(const EventListenersRequest& v) { - idx_ = 18; - value_ = v; -} - -inline -EventListenersResponse _endpoint_avsc_Union__56__::get_EventListenersResponse() const { - if (idx_ != 19) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_EventListenersResponse(const EventListenersResponse& v) { - idx_ = 19; - value_ = v; -} - -inline -EventSequenceNumberRequest _endpoint_avsc_Union__56__::get_EventSequenceNumberRequest() const { - if (idx_ != 20) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_EventSequenceNumberRequest(const EventSequenceNumberRequest& v) { - idx_ = 20; - value_ = v; -} - -inline -EventSequenceNumberResponse _endpoint_avsc_Union__56__::get_EventSequenceNumberResponse() const { - if (idx_ != 21) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_EventSequenceNumberResponse(const EventSequenceNumberResponse& v) { - idx_ = 21; - value_ = v; -} - -inline -Notification _endpoint_avsc_Union__56__::get_Notification() const { - if (idx_ != 22) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_Notification(const Notification& v) { - idx_ = 22; - value_ = v; -} - -inline -Topic _endpoint_avsc_Union__56__::get_Topic() const { - if (idx_ != 23) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_Topic(const Topic& v) { - idx_ = 23; - value_ = v; -} - -inline -LogEntry _endpoint_avsc_Union__56__::get_LogEntry() const { - if (idx_ != 24) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_LogEntry(const LogEntry& v) { - idx_ = 24; - value_ = v; -} - -inline -SyncRequestMetaData _endpoint_avsc_Union__56__::get_SyncRequestMetaData() const { - if (idx_ != 25) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_SyncRequestMetaData(const SyncRequestMetaData& v) { - idx_ = 25; - value_ = v; -} - -inline -ProfileSyncRequest _endpoint_avsc_Union__56__::get_ProfileSyncRequest() const { - if (idx_ != 26) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_ProfileSyncRequest(const ProfileSyncRequest& v) { - idx_ = 26; - value_ = v; -} - -inline -ProtocolVersionPair _endpoint_avsc_Union__56__::get_ProtocolVersionPair() const { - if (idx_ != 27) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_ProtocolVersionPair(const ProtocolVersionPair& v) { - idx_ = 27; - value_ = v; -} - -inline -BootstrapSyncRequest _endpoint_avsc_Union__56__::get_BootstrapSyncRequest() const { - if (idx_ != 28) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_BootstrapSyncRequest(const BootstrapSyncRequest& v) { - idx_ = 28; - value_ = v; -} - -inline -ConfigurationSyncRequest _endpoint_avsc_Union__56__::get_ConfigurationSyncRequest() const { - if (idx_ != 29) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_ConfigurationSyncRequest(const ConfigurationSyncRequest& v) { - idx_ = 29; - value_ = v; -} - -inline -NotificationSyncRequest _endpoint_avsc_Union__56__::get_NotificationSyncRequest() const { - if (idx_ != 30) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_NotificationSyncRequest(const NotificationSyncRequest& v) { - idx_ = 30; - value_ = v; -} - -inline -UserSyncRequest _endpoint_avsc_Union__56__::get_UserSyncRequest() const { - if (idx_ != 31) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_UserSyncRequest(const UserSyncRequest& v) { - idx_ = 31; - value_ = v; -} - -inline -EventSyncRequest _endpoint_avsc_Union__56__::get_EventSyncRequest() const { - if (idx_ != 32) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_EventSyncRequest(const EventSyncRequest& v) { - idx_ = 32; - value_ = v; -} - -inline -LogSyncRequest _endpoint_avsc_Union__56__::get_LogSyncRequest() const { - if (idx_ != 33) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_LogSyncRequest(const LogSyncRequest& v) { - idx_ = 33; - value_ = v; -} - -inline -ProtocolMetaData _endpoint_avsc_Union__56__::get_ProtocolMetaData() const { - if (idx_ != 34) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_ProtocolMetaData(const ProtocolMetaData& v) { - idx_ = 34; - value_ = v; -} - -inline -BootstrapSyncResponse _endpoint_avsc_Union__56__::get_BootstrapSyncResponse() const { - if (idx_ != 35) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_BootstrapSyncResponse(const BootstrapSyncResponse& v) { - idx_ = 35; - value_ = v; -} - -inline -ProfileSyncResponse _endpoint_avsc_Union__56__::get_ProfileSyncResponse() const { - if (idx_ != 36) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_ProfileSyncResponse(const ProfileSyncResponse& v) { - idx_ = 36; - value_ = v; -} - -inline -ConfigurationSyncResponse _endpoint_avsc_Union__56__::get_ConfigurationSyncResponse() const { - if (idx_ != 37) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_ConfigurationSyncResponse(const ConfigurationSyncResponse& v) { - idx_ = 37; - value_ = v; -} - -inline -NotificationSyncResponse _endpoint_avsc_Union__56__::get_NotificationSyncResponse() const { - if (idx_ != 38) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_NotificationSyncResponse(const NotificationSyncResponse& v) { - idx_ = 38; - value_ = v; -} - -inline -UserSyncResponse _endpoint_avsc_Union__56__::get_UserSyncResponse() const { - if (idx_ != 39) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_UserSyncResponse(const UserSyncResponse& v) { - idx_ = 39; - value_ = v; -} - -inline -EventSyncResponse _endpoint_avsc_Union__56__::get_EventSyncResponse() const { - if (idx_ != 40) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_EventSyncResponse(const EventSyncResponse& v) { - idx_ = 40; - value_ = v; -} - -inline -LogDeliveryStatus _endpoint_avsc_Union__56__::get_LogDeliveryStatus() const { - if (idx_ != 41) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_LogDeliveryStatus(const LogDeliveryStatus& v) { - idx_ = 41; - value_ = v; -} - -inline -LogSyncResponse _endpoint_avsc_Union__56__::get_LogSyncResponse() const { - if (idx_ != 42) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_LogSyncResponse(const LogSyncResponse& v) { - idx_ = 42; - value_ = v; -} - -inline -RedirectSyncResponse _endpoint_avsc_Union__56__::get_RedirectSyncResponse() const { - if (idx_ != 43) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_RedirectSyncResponse(const RedirectSyncResponse& v) { - idx_ = 43; - value_ = v; -} - -inline -ExtensionSync _endpoint_avsc_Union__56__::get_ExtensionSync() const { - if (idx_ != 44) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_ExtensionSync(const ExtensionSync& v) { - idx_ = 44; - value_ = v; -} - -inline -SyncRequest _endpoint_avsc_Union__56__::get_SyncRequest() const { - if (idx_ != 45) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_SyncRequest(const SyncRequest& v) { - idx_ = 45; - value_ = v; -} - -inline -SyncResponse _endpoint_avsc_Union__56__::get_SyncResponse() const { - if (idx_ != 46) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_SyncResponse(const SyncResponse& v) { - idx_ = 46; - value_ = v; -} - -inline -TopicSubscriptionInfo _endpoint_avsc_Union__56__::get_TopicSubscriptionInfo() const { - if (idx_ != 47) { - throw avro::Exception("Invalid type for union"); - } - return boost::any_cast(value_); -} - -inline -void _endpoint_avsc_Union__56__::set_TopicSubscriptionInfo(const TopicSubscriptionInfo& v) { - idx_ = 47; - value_ = v; -} - -inline _endpoint_avsc_Union__0__::_endpoint_avsc_Union__0__() : idx_(0), value_(UserAttachErrorCode()) { } -inline _endpoint_avsc_Union__1__::_endpoint_avsc_Union__1__() : idx_(0), value_(std::string()) { } -inline _endpoint_avsc_Union__2__::_endpoint_avsc_Union__2__() : idx_(0), value_(std::string()) { } -inline _endpoint_avsc_Union__3__::_endpoint_avsc_Union__3__() : idx_(0), value_(std::string()) { } -inline _endpoint_avsc_Union__4__::_endpoint_avsc_Union__4__() : idx_(0), value_(std::string()) { } -inline _endpoint_avsc_Union__5__::_endpoint_avsc_Union__5__() : idx_(0), value_(std::vector()) { } -inline _endpoint_avsc_Union__6__::_endpoint_avsc_Union__6__() : idx_(0), value_(std::string()) { } -inline _endpoint_avsc_Union__7__::_endpoint_avsc_Union__7__() : idx_(0), value_(int32_t()) { } -inline _endpoint_avsc_Union__8__::_endpoint_avsc_Union__8__() : idx_(0), value_(std::vector()) { } -inline _endpoint_avsc_Union__9__::_endpoint_avsc_Union__9__() : idx_(0), value_(std::vector()) { } -inline _endpoint_avsc_Union__10__::_endpoint_avsc_Union__10__() : idx_(0), value_(int64_t()) { } -inline _endpoint_avsc_Union__11__::_endpoint_avsc_Union__11__() : idx_(0), value_(std::vector()) { } -inline _endpoint_avsc_Union__12__::_endpoint_avsc_Union__12__() : idx_(0), value_(std::string()) { } -inline _endpoint_avsc_Union__13__::_endpoint_avsc_Union__13__() : idx_(0), value_(bool()) { } -inline _endpoint_avsc_Union__14__::_endpoint_avsc_Union__14__() : idx_(0), value_(std::vector()) { } -inline _endpoint_avsc_Union__15__::_endpoint_avsc_Union__15__() : idx_(0), value_(std::vector()) { } -inline _endpoint_avsc_Union__16__::_endpoint_avsc_Union__16__() : idx_(0), value_(std::vector()) { } -inline _endpoint_avsc_Union__17__::_endpoint_avsc_Union__17__() : idx_(0), value_(UserAttachRequest()) { } -inline _endpoint_avsc_Union__18__::_endpoint_avsc_Union__18__() : idx_(0), value_(std::vector()) { } -inline _endpoint_avsc_Union__19__::_endpoint_avsc_Union__19__() : idx_(0), value_(std::vector()) { } -inline _endpoint_avsc_Union__20__::_endpoint_avsc_Union__20__() : idx_(0), value_(EventSequenceNumberRequest()) { } -inline _endpoint_avsc_Union__21__::_endpoint_avsc_Union__21__() : idx_(0), value_(std::vector()) { } -inline _endpoint_avsc_Union__22__::_endpoint_avsc_Union__22__() : idx_(0), value_(std::vector()) { } -inline _endpoint_avsc_Union__23__::_endpoint_avsc_Union__23__() : idx_(0), value_(std::vector()) { } -inline _endpoint_avsc_Union__24__::_endpoint_avsc_Union__24__() : idx_(0), value_(std::vector()) { } -inline _endpoint_avsc_Union__25__::_endpoint_avsc_Union__25__() : idx_(0), value_(std::vector()) { } -inline _endpoint_avsc_Union__26__::_endpoint_avsc_Union__26__() : idx_(0), value_(std::vector()) { } -inline _endpoint_avsc_Union__27__::_endpoint_avsc_Union__27__() : idx_(0), value_(std::vector()) { } -inline _endpoint_avsc_Union__28__::_endpoint_avsc_Union__28__() : idx_(0), value_(UserAttachResponse()) { } -inline _endpoint_avsc_Union__29__::_endpoint_avsc_Union__29__() : idx_(0), value_(UserAttachNotification()) { } -inline _endpoint_avsc_Union__30__::_endpoint_avsc_Union__30__() : idx_(0), value_(UserDetachNotification()) { } -inline _endpoint_avsc_Union__31__::_endpoint_avsc_Union__31__() : idx_(0), value_(std::vector()) { } -inline _endpoint_avsc_Union__32__::_endpoint_avsc_Union__32__() : idx_(0), value_(std::vector()) { } -inline _endpoint_avsc_Union__33__::_endpoint_avsc_Union__33__() : idx_(0), value_(EventSequenceNumberResponse()) { } -inline _endpoint_avsc_Union__34__::_endpoint_avsc_Union__34__() : idx_(0), value_(std::vector()) { } -inline _endpoint_avsc_Union__35__::_endpoint_avsc_Union__35__() : idx_(0), value_(std::vector()) { } -inline _endpoint_avsc_Union__36__::_endpoint_avsc_Union__36__() : idx_(0), value_(LogDeliveryErrorCode()) { } -inline _endpoint_avsc_Union__37__::_endpoint_avsc_Union__37__() : idx_(0), value_(std::vector()) { } -inline _endpoint_avsc_Union__38__::_endpoint_avsc_Union__38__() : idx_(0), value_(SyncRequestMetaData()) { } -inline _endpoint_avsc_Union__39__::_endpoint_avsc_Union__39__() : idx_(0), value_(BootstrapSyncRequest()) { } -inline _endpoint_avsc_Union__40__::_endpoint_avsc_Union__40__() : idx_(0), value_(ProfileSyncRequest()) { } -inline _endpoint_avsc_Union__41__::_endpoint_avsc_Union__41__() : idx_(0), value_(ConfigurationSyncRequest()) { } -inline _endpoint_avsc_Union__42__::_endpoint_avsc_Union__42__() : idx_(0), value_(NotificationSyncRequest()) { } -inline _endpoint_avsc_Union__43__::_endpoint_avsc_Union__43__() : idx_(0), value_(UserSyncRequest()) { } -inline _endpoint_avsc_Union__44__::_endpoint_avsc_Union__44__() : idx_(0), value_(EventSyncRequest()) { } -inline _endpoint_avsc_Union__45__::_endpoint_avsc_Union__45__() : idx_(0), value_(LogSyncRequest()) { } -inline _endpoint_avsc_Union__46__::_endpoint_avsc_Union__46__() : idx_(0), value_(std::vector()) { } -inline _endpoint_avsc_Union__47__::_endpoint_avsc_Union__47__() : idx_(0), value_(BootstrapSyncResponse()) { } -inline _endpoint_avsc_Union__48__::_endpoint_avsc_Union__48__() : idx_(0), value_(ProfileSyncResponse()) { } -inline _endpoint_avsc_Union__49__::_endpoint_avsc_Union__49__() : idx_(0), value_(ConfigurationSyncResponse()) { } -inline _endpoint_avsc_Union__50__::_endpoint_avsc_Union__50__() : idx_(0), value_(NotificationSyncResponse()) { } -inline _endpoint_avsc_Union__51__::_endpoint_avsc_Union__51__() : idx_(0), value_(UserSyncResponse()) { } -inline _endpoint_avsc_Union__52__::_endpoint_avsc_Union__52__() : idx_(0), value_(EventSyncResponse()) { } -inline _endpoint_avsc_Union__53__::_endpoint_avsc_Union__53__() : idx_(0), value_(RedirectSyncResponse()) { } -inline _endpoint_avsc_Union__54__::_endpoint_avsc_Union__54__() : idx_(0), value_(LogSyncResponse()) { } -inline _endpoint_avsc_Union__55__::_endpoint_avsc_Union__55__() : idx_(0), value_(std::vector()) { } -inline _endpoint_avsc_Union__56__::_endpoint_avsc_Union__56__() : idx_(0), value_(TopicState()) { } -} -namespace avro { -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::TopicState& v) { - avro::encode(e, v.topicId); - avro::encode(e, v.seqNumber); - } - static void decode(Decoder& d, kaa::TopicState& v) { - avro::decode(d, v.topicId); - avro::decode(d, v.seqNumber); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::SyncResponseStatus v) { - if (v < kaa::NO_DELTA || v > kaa::RESYNC) - { - std::ostringstream error; - error << "enum value " << v << " is out of bound for kaa::SyncResponseStatus and cannot be encoded"; - throw avro::Exception(error.str()); - } - e.encodeEnum(v); - } - static void decode(Decoder& d, kaa::SyncResponseStatus& v) { - size_t index = d.decodeEnum(); - if (index < kaa::NO_DELTA || index > kaa::RESYNC) - { - std::ostringstream error; - error << "enum value " << index << " is out of bound for kaa::SyncResponseStatus and cannot be decoded"; - throw avro::Exception(error.str()); - } - v = static_cast(index); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::NotificationType v) { - if (v < kaa::SYSTEM || v > kaa::CUSTOM) - { - std::ostringstream error; - error << "enum value " << v << " is out of bound for kaa::NotificationType and cannot be encoded"; - throw avro::Exception(error.str()); - } - e.encodeEnum(v); - } - static void decode(Decoder& d, kaa::NotificationType& v) { - size_t index = d.decodeEnum(); - if (index < kaa::SYSTEM || index > kaa::CUSTOM) - { - std::ostringstream error; - error << "enum value " << index << " is out of bound for kaa::NotificationType and cannot be decoded"; - throw avro::Exception(error.str()); - } - v = static_cast(index); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::SubscriptionType v) { - if (v < kaa::MANDATORY_SUBSCRIPTION || v > kaa::OPTIONAL_SUBSCRIPTION) - { - std::ostringstream error; - error << "enum value " << v << " is out of bound for kaa::SubscriptionType and cannot be encoded"; - throw avro::Exception(error.str()); - } - e.encodeEnum(v); - } - static void decode(Decoder& d, kaa::SubscriptionType& v) { - size_t index = d.decodeEnum(); - if (index < kaa::MANDATORY_SUBSCRIPTION || index > kaa::OPTIONAL_SUBSCRIPTION) - { - std::ostringstream error; - error << "enum value " << index << " is out of bound for kaa::SubscriptionType and cannot be decoded"; - throw avro::Exception(error.str()); - } - v = static_cast(index); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::SubscriptionCommandType v) { - if (v < kaa::ADD || v > kaa::REMOVE) - { - std::ostringstream error; - error << "enum value " << v << " is out of bound for kaa::SubscriptionCommandType and cannot be encoded"; - throw avro::Exception(error.str()); - } - e.encodeEnum(v); - } - static void decode(Decoder& d, kaa::SubscriptionCommandType& v) { - size_t index = d.decodeEnum(); - if (index < kaa::ADD || index > kaa::REMOVE) - { - std::ostringstream error; - error << "enum value " << index << " is out of bound for kaa::SubscriptionCommandType and cannot be decoded"; - throw avro::Exception(error.str()); - } - v = static_cast(index); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::SyncResponseResultType v) { - if (v < kaa::SUCCESS || v > kaa::REDIRECT) - { - std::ostringstream error; - error << "enum value " << v << " is out of bound for kaa::SyncResponseResultType and cannot be encoded"; - throw avro::Exception(error.str()); - } - e.encodeEnum(v); - } - static void decode(Decoder& d, kaa::SyncResponseResultType& v) { - size_t index = d.decodeEnum(); - if (index < kaa::SUCCESS || index > kaa::REDIRECT) - { - std::ostringstream error; - error << "enum value " << index << " is out of bound for kaa::SyncResponseResultType and cannot be decoded"; - throw avro::Exception(error.str()); - } - v = static_cast(index); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::LogDeliveryErrorCode v) { - if (v < kaa::NO_APPENDERS_CONFIGURED || v > kaa::REMOTE_INTERNAL_ERROR) - { - std::ostringstream error; - error << "enum value " << v << " is out of bound for kaa::LogDeliveryErrorCode and cannot be encoded"; - throw avro::Exception(error.str()); - } - e.encodeEnum(v); - } - static void decode(Decoder& d, kaa::LogDeliveryErrorCode& v) { - size_t index = d.decodeEnum(); - if (index < kaa::NO_APPENDERS_CONFIGURED || index > kaa::REMOTE_INTERNAL_ERROR) - { - std::ostringstream error; - error << "enum value " << index << " is out of bound for kaa::LogDeliveryErrorCode and cannot be decoded"; - throw avro::Exception(error.str()); - } - v = static_cast(index); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::UserAttachErrorCode v) { - if (v < kaa::NO_VERIFIER_CONFIGURED || v > kaa::OTHER) - { - std::ostringstream error; - error << "enum value " << v << " is out of bound for kaa::UserAttachErrorCode and cannot be encoded"; - throw avro::Exception(error.str()); - } - e.encodeEnum(v); - } - static void decode(Decoder& d, kaa::UserAttachErrorCode& v) { - size_t index = d.decodeEnum(); - if (index < kaa::NO_VERIFIER_CONFIGURED || index > kaa::OTHER) - { - std::ostringstream error; - error << "enum value " << index << " is out of bound for kaa::UserAttachErrorCode and cannot be decoded"; - throw avro::Exception(error.str()); - } - v = static_cast(index); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::SubscriptionCommand& v) { - avro::encode(e, v.topicId); - avro::encode(e, v.command); - } - static void decode(Decoder& d, kaa::SubscriptionCommand& v) { - avro::decode(d, v.topicId); - avro::decode(d, v.command); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::UserAttachRequest& v) { - avro::encode(e, v.userVerifierId); - avro::encode(e, v.userExternalId); - avro::encode(e, v.userAccessToken); - } - static void decode(Decoder& d, kaa::UserAttachRequest& v) { - avro::decode(d, v.userVerifierId); - avro::decode(d, v.userExternalId); - avro::decode(d, v.userAccessToken); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__0__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_UserAttachErrorCode()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__0__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - kaa::UserAttachErrorCode vv; - avro::decode(d, vv); - v.set_UserAttachErrorCode(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__1__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_string()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__1__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - std::string vv; - avro::decode(d, vv); - v.set_string(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::UserAttachResponse& v) { - avro::encode(e, v.result); - avro::encode(e, v.errorCode); - avro::encode(e, v.errorReason); - } - static void decode(Decoder& d, kaa::UserAttachResponse& v) { - avro::decode(d, v.result); - avro::decode(d, v.errorCode); - avro::decode(d, v.errorReason); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::UserAttachNotification& v) { - avro::encode(e, v.userExternalId); - avro::encode(e, v.endpointAccessToken); - } - static void decode(Decoder& d, kaa::UserAttachNotification& v) { - avro::decode(d, v.userExternalId); - avro::decode(d, v.endpointAccessToken); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::UserDetachNotification& v) { - avro::encode(e, v.endpointAccessToken); - } - static void decode(Decoder& d, kaa::UserDetachNotification& v) { - avro::decode(d, v.endpointAccessToken); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::EndpointAttachRequest& v) { - avro::encode(e, v.requestId); - avro::encode(e, v.endpointAccessToken); - } - static void decode(Decoder& d, kaa::EndpointAttachRequest& v) { - avro::decode(d, v.requestId); - avro::decode(d, v.endpointAccessToken); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__2__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_string()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__2__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - std::string vv; - avro::decode(d, vv); - v.set_string(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::EndpointAttachResponse& v) { - avro::encode(e, v.requestId); - avro::encode(e, v.endpointKeyHash); - avro::encode(e, v.result); - } - static void decode(Decoder& d, kaa::EndpointAttachResponse& v) { - avro::decode(d, v.requestId); - avro::decode(d, v.endpointKeyHash); - avro::decode(d, v.result); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::EndpointDetachRequest& v) { - avro::encode(e, v.requestId); - avro::encode(e, v.endpointKeyHash); - } - static void decode(Decoder& d, kaa::EndpointDetachRequest& v) { - avro::decode(d, v.requestId); - avro::decode(d, v.endpointKeyHash); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::EndpointDetachResponse& v) { - avro::encode(e, v.requestId); - avro::encode(e, v.result); - } - static void decode(Decoder& d, kaa::EndpointDetachResponse& v) { - avro::decode(d, v.requestId); - avro::decode(d, v.result); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__3__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_string()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__3__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - std::string vv; - avro::decode(d, vv); - v.set_string(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__4__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_string()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__4__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - std::string vv; - avro::decode(d, vv); - v.set_string(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::Event& v) { - avro::encode(e, v.seqNum); - avro::encode(e, v.eventClassFQN); - avro::encode(e, v.eventData); - avro::encode(e, v.source); - avro::encode(e, v.target); - } - static void decode(Decoder& d, kaa::Event& v) { - avro::decode(d, v.seqNum); - avro::decode(d, v.eventClassFQN); - avro::decode(d, v.eventData); - avro::decode(d, v.source); - avro::decode(d, v.target); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::EventListenersRequest& v) { - avro::encode(e, v.requestId); - avro::encode(e, v.eventClassFQNs); - } - static void decode(Decoder& d, kaa::EventListenersRequest& v) { - avro::decode(d, v.requestId); - avro::decode(d, v.eventClassFQNs); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__5__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_array()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__5__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - std::vector vv; - avro::decode(d, vv); - v.set_array(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::EventListenersResponse& v) { - avro::encode(e, v.requestId); - avro::encode(e, v.listeners); - avro::encode(e, v.result); - } - static void decode(Decoder& d, kaa::EventListenersResponse& v) { - avro::decode(d, v.requestId); - avro::decode(d, v.listeners); - avro::decode(d, v.result); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::EventSequenceNumberRequest& v) { - } - static void decode(Decoder& d, kaa::EventSequenceNumberRequest& v) { - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::EventSequenceNumberResponse& v) { - avro::encode(e, v.seqNum); - } - static void decode(Decoder& d, kaa::EventSequenceNumberResponse& v) { - avro::decode(d, v.seqNum); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__6__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_string()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__6__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - std::string vv; - avro::decode(d, vv); - v.set_string(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__7__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_int()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__7__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - int32_t vv; - avro::decode(d, vv); - v.set_int(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::Notification& v) { - avro::encode(e, v.topicId); - avro::encode(e, v.type); - avro::encode(e, v.uid); - avro::encode(e, v.seqNumber); - avro::encode(e, v.body); - } - static void decode(Decoder& d, kaa::Notification& v) { - avro::decode(d, v.topicId); - avro::decode(d, v.type); - avro::decode(d, v.uid); - avro::decode(d, v.seqNumber); - avro::decode(d, v.body); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::Topic& v) { - avro::encode(e, v.id); - avro::encode(e, v.name); - avro::encode(e, v.subscriptionType); - } - static void decode(Decoder& d, kaa::Topic& v) { - avro::decode(d, v.id); - avro::decode(d, v.name); - avro::decode(d, v.subscriptionType); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::LogEntry& v) { - avro::encode(e, v.data); - } - static void decode(Decoder& d, kaa::LogEntry& v) { - avro::decode(d, v.data); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__8__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_bytes()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__8__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - std::vector vv; - avro::decode(d, vv); - v.set_bytes(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__9__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_bytes()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__9__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - std::vector vv; - avro::decode(d, vv); - v.set_bytes(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__10__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_long()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__10__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - int64_t vv; - avro::decode(d, vv); - v.set_long(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::SyncRequestMetaData& v) { - avro::encode(e, v.sdkToken); - avro::encode(e, v.endpointPublicKeyHash); - avro::encode(e, v.profileHash); - avro::encode(e, v.timeout); - } - static void decode(Decoder& d, kaa::SyncRequestMetaData& v) { - avro::decode(d, v.sdkToken); - avro::decode(d, v.endpointPublicKeyHash); - avro::decode(d, v.profileHash); - avro::decode(d, v.timeout); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__11__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_bytes()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__11__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - std::vector vv; - avro::decode(d, vv); - v.set_bytes(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__12__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_string()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__12__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - std::string vv; - avro::decode(d, vv); - v.set_string(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::ProfileSyncRequest& v) { - avro::encode(e, v.endpointPublicKey); - avro::encode(e, v.profileBody); - avro::encode(e, v.endpointAccessToken); - } - static void decode(Decoder& d, kaa::ProfileSyncRequest& v) { - avro::decode(d, v.endpointPublicKey); - avro::decode(d, v.profileBody); - avro::decode(d, v.endpointAccessToken); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::ProtocolVersionPair& v) { - avro::encode(e, v.id); - avro::encode(e, v.version); - } - static void decode(Decoder& d, kaa::ProtocolVersionPair& v) { - avro::decode(d, v.id); - avro::decode(d, v.version); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::BootstrapSyncRequest& v) { - avro::encode(e, v.requestId); - avro::encode(e, v.supportedProtocols); - } - static void decode(Decoder& d, kaa::BootstrapSyncRequest& v) { - avro::decode(d, v.requestId); - avro::decode(d, v.supportedProtocols); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__13__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_bool()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__13__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - bool vv; - avro::decode(d, vv); - v.set_bool(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::ConfigurationSyncRequest& v) { - avro::encode(e, v.configurationHash); - avro::encode(e, v.resyncOnly); - } - static void decode(Decoder& d, kaa::ConfigurationSyncRequest& v) { - avro::decode(d, v.configurationHash); - avro::decode(d, v.resyncOnly); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__14__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_array()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__14__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - std::vector vv; - avro::decode(d, vv); - v.set_array(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__15__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_array()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__15__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - std::vector vv; - avro::decode(d, vv); - v.set_array(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__16__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_array()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__16__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - std::vector vv; - avro::decode(d, vv); - v.set_array(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::NotificationSyncRequest& v) { - avro::encode(e, v.topicListHash); - avro::encode(e, v.topicStates); - avro::encode(e, v.acceptedUnicastNotifications); - avro::encode(e, v.subscriptionCommands); - } - static void decode(Decoder& d, kaa::NotificationSyncRequest& v) { - avro::decode(d, v.topicListHash); - avro::decode(d, v.topicStates); - avro::decode(d, v.acceptedUnicastNotifications); - avro::decode(d, v.subscriptionCommands); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__17__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_UserAttachRequest()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__17__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - kaa::UserAttachRequest vv; - avro::decode(d, vv); - v.set_UserAttachRequest(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__18__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_array()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__18__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - std::vector vv; - avro::decode(d, vv); - v.set_array(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__19__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_array()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__19__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - std::vector vv; - avro::decode(d, vv); - v.set_array(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::UserSyncRequest& v) { - avro::encode(e, v.userAttachRequest); - avro::encode(e, v.endpointAttachRequests); - avro::encode(e, v.endpointDetachRequests); - } - static void decode(Decoder& d, kaa::UserSyncRequest& v) { - avro::decode(d, v.userAttachRequest); - avro::decode(d, v.endpointAttachRequests); - avro::decode(d, v.endpointDetachRequests); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__20__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_EventSequenceNumberRequest()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__20__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - kaa::EventSequenceNumberRequest vv; - avro::decode(d, vv); - v.set_EventSequenceNumberRequest(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__21__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_array()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__21__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - std::vector vv; - avro::decode(d, vv); - v.set_array(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__22__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_array()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__22__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - std::vector vv; - avro::decode(d, vv); - v.set_array(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::EventSyncRequest& v) { - avro::encode(e, v.eventSequenceNumberRequest); - avro::encode(e, v.eventListenersRequests); - avro::encode(e, v.events); - } - static void decode(Decoder& d, kaa::EventSyncRequest& v) { - avro::decode(d, v.eventSequenceNumberRequest); - avro::decode(d, v.eventListenersRequests); - avro::decode(d, v.events); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__23__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_array()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__23__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - std::vector vv; - avro::decode(d, vv); - v.set_array(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::LogSyncRequest& v) { - avro::encode(e, v.requestId); - avro::encode(e, v.logEntries); - } - static void decode(Decoder& d, kaa::LogSyncRequest& v) { - avro::decode(d, v.requestId); - avro::decode(d, v.logEntries); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::ProtocolMetaData& v) { - avro::encode(e, v.accessPointId); - avro::encode(e, v.protocolVersionInfo); - avro::encode(e, v.connectionInfo); - } - static void decode(Decoder& d, kaa::ProtocolMetaData& v) { - avro::decode(d, v.accessPointId); - avro::decode(d, v.protocolVersionInfo); - avro::decode(d, v.connectionInfo); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::BootstrapSyncResponse& v) { - avro::encode(e, v.requestId); - avro::encode(e, v.supportedProtocols); - } - static void decode(Decoder& d, kaa::BootstrapSyncResponse& v) { - avro::decode(d, v.requestId); - avro::decode(d, v.supportedProtocols); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::ProfileSyncResponse& v) { - avro::encode(e, v.responseStatus); - } - static void decode(Decoder& d, kaa::ProfileSyncResponse& v) { - avro::decode(d, v.responseStatus); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__24__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_bytes()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__24__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - std::vector vv; - avro::decode(d, vv); - v.set_bytes(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__25__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_bytes()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__25__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - std::vector vv; - avro::decode(d, vv); - v.set_bytes(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::ConfigurationSyncResponse& v) { - avro::encode(e, v.responseStatus); - avro::encode(e, v.confSchemaBody); - avro::encode(e, v.confDeltaBody); - } - static void decode(Decoder& d, kaa::ConfigurationSyncResponse& v) { - avro::decode(d, v.responseStatus); - avro::decode(d, v.confSchemaBody); - avro::decode(d, v.confDeltaBody); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__26__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_array()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__26__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - std::vector vv; - avro::decode(d, vv); - v.set_array(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__27__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_array()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__27__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - std::vector vv; - avro::decode(d, vv); - v.set_array(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::NotificationSyncResponse& v) { - avro::encode(e, v.responseStatus); - avro::encode(e, v.notifications); - avro::encode(e, v.availableTopics); - } - static void decode(Decoder& d, kaa::NotificationSyncResponse& v) { - avro::decode(d, v.responseStatus); - avro::decode(d, v.notifications); - avro::decode(d, v.availableTopics); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__28__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_UserAttachResponse()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__28__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - kaa::UserAttachResponse vv; - avro::decode(d, vv); - v.set_UserAttachResponse(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__29__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_UserAttachNotification()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__29__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - kaa::UserAttachNotification vv; - avro::decode(d, vv); - v.set_UserAttachNotification(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__30__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_UserDetachNotification()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__30__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - kaa::UserDetachNotification vv; - avro::decode(d, vv); - v.set_UserDetachNotification(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__31__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_array()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__31__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - std::vector vv; - avro::decode(d, vv); - v.set_array(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__32__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_array()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__32__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - std::vector vv; - avro::decode(d, vv); - v.set_array(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::UserSyncResponse& v) { - avro::encode(e, v.userAttachResponse); - avro::encode(e, v.userAttachNotification); - avro::encode(e, v.userDetachNotification); - avro::encode(e, v.endpointAttachResponses); - avro::encode(e, v.endpointDetachResponses); - } - static void decode(Decoder& d, kaa::UserSyncResponse& v) { - avro::decode(d, v.userAttachResponse); - avro::decode(d, v.userAttachNotification); - avro::decode(d, v.userDetachNotification); - avro::decode(d, v.endpointAttachResponses); - avro::decode(d, v.endpointDetachResponses); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__33__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_EventSequenceNumberResponse()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__33__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - kaa::EventSequenceNumberResponse vv; - avro::decode(d, vv); - v.set_EventSequenceNumberResponse(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__34__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_array()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__34__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - std::vector vv; - avro::decode(d, vv); - v.set_array(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__35__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_array()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__35__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - std::vector vv; - avro::decode(d, vv); - v.set_array(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::EventSyncResponse& v) { - avro::encode(e, v.eventSequenceNumberResponse); - avro::encode(e, v.eventListenersResponses); - avro::encode(e, v.events); - } - static void decode(Decoder& d, kaa::EventSyncResponse& v) { - avro::decode(d, v.eventSequenceNumberResponse); - avro::decode(d, v.eventListenersResponses); - avro::decode(d, v.events); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__36__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_LogDeliveryErrorCode()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__36__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - kaa::LogDeliveryErrorCode vv; - avro::decode(d, vv); - v.set_LogDeliveryErrorCode(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::LogDeliveryStatus& v) { - avro::encode(e, v.requestId); - avro::encode(e, v.result); - avro::encode(e, v.errorCode); - } - static void decode(Decoder& d, kaa::LogDeliveryStatus& v) { - avro::decode(d, v.requestId); - avro::decode(d, v.result); - avro::decode(d, v.errorCode); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__37__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_array()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__37__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - std::vector vv; - avro::decode(d, vv); - v.set_array(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::LogSyncResponse& v) { - avro::encode(e, v.deliveryStatuses); - } - static void decode(Decoder& d, kaa::LogSyncResponse& v) { - avro::decode(d, v.deliveryStatuses); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::RedirectSyncResponse& v) { - avro::encode(e, v.accessPointId); - } - static void decode(Decoder& d, kaa::RedirectSyncResponse& v) { - avro::decode(d, v.accessPointId); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::ExtensionSync& v) { - avro::encode(e, v.extensionId); - avro::encode(e, v.payload); - } - static void decode(Decoder& d, kaa::ExtensionSync& v) { - avro::decode(d, v.extensionId); - avro::decode(d, v.payload); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__38__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_SyncRequestMetaData()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__38__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - kaa::SyncRequestMetaData vv; - avro::decode(d, vv); - v.set_SyncRequestMetaData(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__39__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_BootstrapSyncRequest()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__39__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - kaa::BootstrapSyncRequest vv; - avro::decode(d, vv); - v.set_BootstrapSyncRequest(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__40__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_ProfileSyncRequest()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__40__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - kaa::ProfileSyncRequest vv; - avro::decode(d, vv); - v.set_ProfileSyncRequest(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__41__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_ConfigurationSyncRequest()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__41__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - kaa::ConfigurationSyncRequest vv; - avro::decode(d, vv); - v.set_ConfigurationSyncRequest(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__42__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_NotificationSyncRequest()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__42__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - kaa::NotificationSyncRequest vv; - avro::decode(d, vv); - v.set_NotificationSyncRequest(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__43__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_UserSyncRequest()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__43__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - kaa::UserSyncRequest vv; - avro::decode(d, vv); - v.set_UserSyncRequest(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__44__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_EventSyncRequest()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__44__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - kaa::EventSyncRequest vv; - avro::decode(d, vv); - v.set_EventSyncRequest(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__45__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_LogSyncRequest()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__45__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - kaa::LogSyncRequest vv; - avro::decode(d, vv); - v.set_LogSyncRequest(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__46__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_array()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__46__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - std::vector vv; - avro::decode(d, vv); - v.set_array(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::SyncRequest& v) { - avro::encode(e, v.requestId); - avro::encode(e, v.syncRequestMetaData); - avro::encode(e, v.bootstrapSyncRequest); - avro::encode(e, v.profileSyncRequest); - avro::encode(e, v.configurationSyncRequest); - avro::encode(e, v.notificationSyncRequest); - avro::encode(e, v.userSyncRequest); - avro::encode(e, v.eventSyncRequest); - avro::encode(e, v.logSyncRequest); - avro::encode(e, v.extensionSyncRequests); - } - static void decode(Decoder& d, kaa::SyncRequest& v) { - avro::decode(d, v.requestId); - avro::decode(d, v.syncRequestMetaData); - avro::decode(d, v.bootstrapSyncRequest); - avro::decode(d, v.profileSyncRequest); - avro::decode(d, v.configurationSyncRequest); - avro::decode(d, v.notificationSyncRequest); - avro::decode(d, v.userSyncRequest); - avro::decode(d, v.eventSyncRequest); - avro::decode(d, v.logSyncRequest); - avro::decode(d, v.extensionSyncRequests); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__47__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_BootstrapSyncResponse()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__47__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - kaa::BootstrapSyncResponse vv; - avro::decode(d, vv); - v.set_BootstrapSyncResponse(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__48__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_ProfileSyncResponse()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__48__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - kaa::ProfileSyncResponse vv; - avro::decode(d, vv); - v.set_ProfileSyncResponse(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__49__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_ConfigurationSyncResponse()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__49__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - kaa::ConfigurationSyncResponse vv; - avro::decode(d, vv); - v.set_ConfigurationSyncResponse(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__50__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_NotificationSyncResponse()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__50__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - kaa::NotificationSyncResponse vv; - avro::decode(d, vv); - v.set_NotificationSyncResponse(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__51__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_UserSyncResponse()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__51__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - kaa::UserSyncResponse vv; - avro::decode(d, vv); - v.set_UserSyncResponse(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__52__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_EventSyncResponse()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__52__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - kaa::EventSyncResponse vv; - avro::decode(d, vv); - v.set_EventSyncResponse(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__53__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_RedirectSyncResponse()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__53__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - kaa::RedirectSyncResponse vv; - avro::decode(d, vv); - v.set_RedirectSyncResponse(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__54__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_LogSyncResponse()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__54__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - kaa::LogSyncResponse vv; - avro::decode(d, vv); - v.set_LogSyncResponse(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__55__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_array()); - break; - case 1: - e.encodeNull(); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__55__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 2) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - std::vector vv; - avro::decode(d, vv); - v.set_array(vv); - } - break; - case 1: - d.decodeNull(); - v.set_null(); - break; - } - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::SyncResponse& v) { - avro::encode(e, v.requestId); - avro::encode(e, v.status); - avro::encode(e, v.bootstrapSyncResponse); - avro::encode(e, v.profileSyncResponse); - avro::encode(e, v.configurationSyncResponse); - avro::encode(e, v.notificationSyncResponse); - avro::encode(e, v.userSyncResponse); - avro::encode(e, v.eventSyncResponse); - avro::encode(e, v.redirectSyncResponse); - avro::encode(e, v.logSyncResponse); - avro::encode(e, v.extensionSyncResponses); - } - static void decode(Decoder& d, kaa::SyncResponse& v) { - avro::decode(d, v.requestId); - avro::decode(d, v.status); - avro::decode(d, v.bootstrapSyncResponse); - avro::decode(d, v.profileSyncResponse); - avro::decode(d, v.configurationSyncResponse); - avro::decode(d, v.notificationSyncResponse); - avro::decode(d, v.userSyncResponse); - avro::decode(d, v.eventSyncResponse); - avro::decode(d, v.redirectSyncResponse); - avro::decode(d, v.logSyncResponse); - avro::decode(d, v.extensionSyncResponses); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, const kaa::TopicSubscriptionInfo& v) { - avro::encode(e, v.topicInfo); - avro::encode(e, v.seqNumber); - } - static void decode(Decoder& d, kaa::TopicSubscriptionInfo& v) { - avro::decode(d, v.topicInfo); - avro::decode(d, v.seqNumber); - } -}; - -template<> struct codec_traits { - static void encode(Encoder& e, kaa::_endpoint_avsc_Union__56__ v) { - e.encodeUnionIndex(v.idx()); - switch (v.idx()) { - case 0: - avro::encode(e, v.get_TopicState()); - break; - case 1: - avro::encode(e, v.get_SyncResponseStatus()); - break; - case 2: - avro::encode(e, v.get_NotificationType()); - break; - case 3: - avro::encode(e, v.get_SubscriptionType()); - break; - case 4: - avro::encode(e, v.get_SubscriptionCommandType()); - break; - case 5: - avro::encode(e, v.get_SyncResponseResultType()); - break; - case 6: - avro::encode(e, v.get_LogDeliveryErrorCode()); - break; - case 7: - avro::encode(e, v.get_UserAttachErrorCode()); - break; - case 8: - avro::encode(e, v.get_SubscriptionCommand()); - break; - case 9: - avro::encode(e, v.get_UserAttachRequest()); - break; - case 10: - avro::encode(e, v.get_UserAttachResponse()); - break; - case 11: - avro::encode(e, v.get_UserAttachNotification()); - break; - case 12: - avro::encode(e, v.get_UserDetachNotification()); - break; - case 13: - avro::encode(e, v.get_EndpointAttachRequest()); - break; - case 14: - avro::encode(e, v.get_EndpointAttachResponse()); - break; - case 15: - avro::encode(e, v.get_EndpointDetachRequest()); - break; - case 16: - avro::encode(e, v.get_EndpointDetachResponse()); - break; - case 17: - avro::encode(e, v.get_Event()); - break; - case 18: - avro::encode(e, v.get_EventListenersRequest()); - break; - case 19: - avro::encode(e, v.get_EventListenersResponse()); - break; - case 20: - avro::encode(e, v.get_EventSequenceNumberRequest()); - break; - case 21: - avro::encode(e, v.get_EventSequenceNumberResponse()); - break; - case 22: - avro::encode(e, v.get_Notification()); - break; - case 23: - avro::encode(e, v.get_Topic()); - break; - case 24: - avro::encode(e, v.get_LogEntry()); - break; - case 25: - avro::encode(e, v.get_SyncRequestMetaData()); - break; - case 26: - avro::encode(e, v.get_ProfileSyncRequest()); - break; - case 27: - avro::encode(e, v.get_ProtocolVersionPair()); - break; - case 28: - avro::encode(e, v.get_BootstrapSyncRequest()); - break; - case 29: - avro::encode(e, v.get_ConfigurationSyncRequest()); - break; - case 30: - avro::encode(e, v.get_NotificationSyncRequest()); - break; - case 31: - avro::encode(e, v.get_UserSyncRequest()); - break; - case 32: - avro::encode(e, v.get_EventSyncRequest()); - break; - case 33: - avro::encode(e, v.get_LogSyncRequest()); - break; - case 34: - avro::encode(e, v.get_ProtocolMetaData()); - break; - case 35: - avro::encode(e, v.get_BootstrapSyncResponse()); - break; - case 36: - avro::encode(e, v.get_ProfileSyncResponse()); - break; - case 37: - avro::encode(e, v.get_ConfigurationSyncResponse()); - break; - case 38: - avro::encode(e, v.get_NotificationSyncResponse()); - break; - case 39: - avro::encode(e, v.get_UserSyncResponse()); - break; - case 40: - avro::encode(e, v.get_EventSyncResponse()); - break; - case 41: - avro::encode(e, v.get_LogDeliveryStatus()); - break; - case 42: - avro::encode(e, v.get_LogSyncResponse()); - break; - case 43: - avro::encode(e, v.get_RedirectSyncResponse()); - break; - case 44: - avro::encode(e, v.get_ExtensionSync()); - break; - case 45: - avro::encode(e, v.get_SyncRequest()); - break; - case 46: - avro::encode(e, v.get_SyncResponse()); - break; - case 47: - avro::encode(e, v.get_TopicSubscriptionInfo()); - break; - } - } - static void decode(Decoder& d, kaa::_endpoint_avsc_Union__56__& v) { - size_t n = d.decodeUnionIndex(); - if (n >= 48) { throw avro::Exception("Union index too big"); } - switch (n) { - case 0: - { - kaa::TopicState vv; - avro::decode(d, vv); - v.set_TopicState(vv); - } - break; - case 1: - { - kaa::SyncResponseStatus vv; - avro::decode(d, vv); - v.set_SyncResponseStatus(vv); - } - break; - case 2: - { - kaa::NotificationType vv; - avro::decode(d, vv); - v.set_NotificationType(vv); - } - break; - case 3: - { - kaa::SubscriptionType vv; - avro::decode(d, vv); - v.set_SubscriptionType(vv); - } - break; - case 4: - { - kaa::SubscriptionCommandType vv; - avro::decode(d, vv); - v.set_SubscriptionCommandType(vv); - } - break; - case 5: - { - kaa::SyncResponseResultType vv; - avro::decode(d, vv); - v.set_SyncResponseResultType(vv); - } - break; - case 6: - { - kaa::LogDeliveryErrorCode vv; - avro::decode(d, vv); - v.set_LogDeliveryErrorCode(vv); - } - break; - case 7: - { - kaa::UserAttachErrorCode vv; - avro::decode(d, vv); - v.set_UserAttachErrorCode(vv); - } - break; - case 8: - { - kaa::SubscriptionCommand vv; - avro::decode(d, vv); - v.set_SubscriptionCommand(vv); - } - break; - case 9: - { - kaa::UserAttachRequest vv; - avro::decode(d, vv); - v.set_UserAttachRequest(vv); - } - break; - case 10: - { - kaa::UserAttachResponse vv; - avro::decode(d, vv); - v.set_UserAttachResponse(vv); - } - break; - case 11: - { - kaa::UserAttachNotification vv; - avro::decode(d, vv); - v.set_UserAttachNotification(vv); - } - break; - case 12: - { - kaa::UserDetachNotification vv; - avro::decode(d, vv); - v.set_UserDetachNotification(vv); - } - break; - case 13: - { - kaa::EndpointAttachRequest vv; - avro::decode(d, vv); - v.set_EndpointAttachRequest(vv); - } - break; - case 14: - { - kaa::EndpointAttachResponse vv; - avro::decode(d, vv); - v.set_EndpointAttachResponse(vv); - } - break; - case 15: - { - kaa::EndpointDetachRequest vv; - avro::decode(d, vv); - v.set_EndpointDetachRequest(vv); - } - break; - case 16: - { - kaa::EndpointDetachResponse vv; - avro::decode(d, vv); - v.set_EndpointDetachResponse(vv); - } - break; - case 17: - { - kaa::Event vv; - avro::decode(d, vv); - v.set_Event(vv); - } - break; - case 18: - { - kaa::EventListenersRequest vv; - avro::decode(d, vv); - v.set_EventListenersRequest(vv); - } - break; - case 19: - { - kaa::EventListenersResponse vv; - avro::decode(d, vv); - v.set_EventListenersResponse(vv); - } - break; - case 20: - { - kaa::EventSequenceNumberRequest vv; - avro::decode(d, vv); - v.set_EventSequenceNumberRequest(vv); - } - break; - case 21: - { - kaa::EventSequenceNumberResponse vv; - avro::decode(d, vv); - v.set_EventSequenceNumberResponse(vv); - } - break; - case 22: - { - kaa::Notification vv; - avro::decode(d, vv); - v.set_Notification(vv); - } - break; - case 23: - { - kaa::Topic vv; - avro::decode(d, vv); - v.set_Topic(vv); - } - break; - case 24: - { - kaa::LogEntry vv; - avro::decode(d, vv); - v.set_LogEntry(vv); - } - break; - case 25: - { - kaa::SyncRequestMetaData vv; - avro::decode(d, vv); - v.set_SyncRequestMetaData(vv); - } - break; - case 26: - { - kaa::ProfileSyncRequest vv; - avro::decode(d, vv); - v.set_ProfileSyncRequest(vv); - } - break; - case 27: - { - kaa::ProtocolVersionPair vv; - avro::decode(d, vv); - v.set_ProtocolVersionPair(vv); - } - break; - case 28: - { - kaa::BootstrapSyncRequest vv; - avro::decode(d, vv); - v.set_BootstrapSyncRequest(vv); - } - break; - case 29: - { - kaa::ConfigurationSyncRequest vv; - avro::decode(d, vv); - v.set_ConfigurationSyncRequest(vv); - } - break; - case 30: - { - kaa::NotificationSyncRequest vv; - avro::decode(d, vv); - v.set_NotificationSyncRequest(vv); - } - break; - case 31: - { - kaa::UserSyncRequest vv; - avro::decode(d, vv); - v.set_UserSyncRequest(vv); - } - break; - case 32: - { - kaa::EventSyncRequest vv; - avro::decode(d, vv); - v.set_EventSyncRequest(vv); - } - break; - case 33: - { - kaa::LogSyncRequest vv; - avro::decode(d, vv); - v.set_LogSyncRequest(vv); - } - break; - case 34: - { - kaa::ProtocolMetaData vv; - avro::decode(d, vv); - v.set_ProtocolMetaData(vv); - } - break; - case 35: - { - kaa::BootstrapSyncResponse vv; - avro::decode(d, vv); - v.set_BootstrapSyncResponse(vv); - } - break; - case 36: - { - kaa::ProfileSyncResponse vv; - avro::decode(d, vv); - v.set_ProfileSyncResponse(vv); - } - break; - case 37: - { - kaa::ConfigurationSyncResponse vv; - avro::decode(d, vv); - v.set_ConfigurationSyncResponse(vv); - } - break; - case 38: - { - kaa::NotificationSyncResponse vv; - avro::decode(d, vv); - v.set_NotificationSyncResponse(vv); - } - break; - case 39: - { - kaa::UserSyncResponse vv; - avro::decode(d, vv); - v.set_UserSyncResponse(vv); - } - break; - case 40: - { - kaa::EventSyncResponse vv; - avro::decode(d, vv); - v.set_EventSyncResponse(vv); - } - break; - case 41: - { - kaa::LogDeliveryStatus vv; - avro::decode(d, vv); - v.set_LogDeliveryStatus(vv); - } - break; - case 42: - { - kaa::LogSyncResponse vv; - avro::decode(d, vv); - v.set_LogSyncResponse(vv); - } - break; - case 43: - { - kaa::RedirectSyncResponse vv; - avro::decode(d, vv); - v.set_RedirectSyncResponse(vv); - } - break; - case 44: - { - kaa::ExtensionSync vv; - avro::decode(d, vv); - v.set_ExtensionSync(vv); - } - break; - case 45: - { - kaa::SyncRequest vv; - avro::decode(d, vv); - v.set_SyncRequest(vv); - } - break; - case 46: - { - kaa::SyncResponse vv; - avro::decode(d, vv); - v.set_SyncResponse(vv); - } - break; - case 47: - { - kaa::TopicSubscriptionInfo vv; - avro::decode(d, vv); - v.set_TopicSubscriptionInfo(vv); - } - break; - } - } -}; - -} -#endif diff --git a/client/client-multi/client-cpp/kaa/log/gen/LogGen.hpp b/client/client-multi/client-cpp/kaa/log/gen/LogGen.hpp deleted file mode 100644 index 8a586c1a98..0000000000 --- a/client/client-multi/client-cpp/kaa/log/gen/LogGen.hpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2014-2016 CyberVision, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef KAA_GEN_LOGGEN_HPP_392481303__H_ -#define KAA_GEN_LOGGEN_HPP_392481303__H_ - - -#include -#include "boost/any.hpp" -#include "avro/Specific.hh" -#include "avro/Encoder.hh" -#include "avro/Decoder.hh" - -namespace kaa_log { -struct SuperRecord { - std::string logdata; - SuperRecord() : - logdata(std::string()) - { } -}; - -} -namespace avro { -template<> struct codec_traits { - static void encode(Encoder& e, const kaa_log::SuperRecord& v) { - avro::encode(e, v.logdata); - } - static void decode(Decoder& d, kaa_log::SuperRecord& v) { - avro::decode(d, v.logdata); - } -}; - -} -#endif diff --git a/client/client-multi/client-cpp/kaa/notification/gen/NotificationDefinitions.hpp b/client/client-multi/client-cpp/kaa/notification/gen/NotificationDefinitions.hpp index e838503c90..4d46b556d2 100644 --- a/client/client-multi/client-cpp/kaa/notification/gen/NotificationDefinitions.hpp +++ b/client/client-multi/client-cpp/kaa/notification/gen/NotificationDefinitions.hpp @@ -31,7 +31,7 @@ namespace kaa { /** * @typedef The user-defined notification structure. */ -typedef kaa_notification::BasicNotification KaaNotification; +typedef kaa_notification::EmptyData KaaNotification; typedef std::vector Topics; typedef std::vector Notifications; diff --git a/client/client-multi/client-cpp/kaa/notification/gen/NotificationGen.hpp b/client/client-multi/client-cpp/kaa/notification/gen/NotificationGen.hpp deleted file mode 100644 index 1b1fdbea13..0000000000 --- a/client/client-multi/client-cpp/kaa/notification/gen/NotificationGen.hpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2014-2016 CyberVision, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef CLIENT_CLIENT_MULTI_CLIENT_CPP_KAA_GEN_NOTIFICATIONGEN_HPP_3229282092__H_ -#define CLIENT_CLIENT_MULTI_CLIENT_CPP_KAA_GEN_NOTIFICATIONGEN_HPP_3229282092__H_ - - -#include -#include "boost/any.hpp" -#include "avro/Specific.hh" -#include "avro/Encoder.hh" -#include "avro/Decoder.hh" - -namespace kaa_notification { -struct BasicNotification { - std::string data; - BasicNotification() : - data(std::string()) - { } -}; - -} -namespace avro { -template<> struct codec_traits { - static void encode(Encoder& e, const kaa_notification::BasicNotification& v) { - avro::encode(e, v.data); - } - static void decode(Decoder& d, kaa_notification::BasicNotification& v) { - avro::decode(d, v.data); - } -}; - -} -#endif diff --git a/client/client-multi/client-cpp/kaa/profile/gen/ProfileDefinitions.hpp b/client/client-multi/client-cpp/kaa/profile/gen/ProfileDefinitions.hpp index 7bd52314f4..9038c299b3 100644 --- a/client/client-multi/client-cpp/kaa/profile/gen/ProfileDefinitions.hpp +++ b/client/client-multi/client-cpp/kaa/profile/gen/ProfileDefinitions.hpp @@ -32,7 +32,7 @@ namespace kaa { /** * @typedef The user-defined profile structure. */ -typedef kaa_profile::Profile KaaProfile; +typedef kaa_profile::EmptyData KaaProfile; } diff --git a/client/client-multi/client-cpp/kaa/profile/gen/ProfileGen.hpp b/client/client-multi/client-cpp/kaa/profile/gen/ProfileGen.hpp deleted file mode 100644 index 6dda23ce81..0000000000 --- a/client/client-multi/client-cpp/kaa/profile/gen/ProfileGen.hpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2014-2016 CyberVision, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#ifndef KAA_GEN_PROFILEGEN_HPP_419439815__H_ -#define KAA_GEN_PROFILEGEN_HPP_419439815__H_ - - -#include -#include "boost/any.hpp" -#include "avro/Specific.hh" -#include "avro/Encoder.hh" -#include "avro/Decoder.hh" - -namespace kaa_profile { -struct Profile { - Profile() - { } -}; - -} -namespace avro { -template<> struct codec_traits { - static void encode(Encoder& e, const kaa_profile::Profile& v) { - } - static void decode(Decoder& d, kaa_profile::Profile& v) { - } -}; - -} -#endif diff --git a/client/client-multi/client-cpp/pom.xml b/client/client-multi/client-cpp/pom.xml index 852ea87720..7bcfe3113b 100644 --- a/client/client-multi/client-cpp/pom.xml +++ b/client/client-multi/client-cpp/pom.xml @@ -78,7 +78,12 @@ Modules/FindSqlite3.cmake tools/avro-cpp-disable-tests.patch toolchains/*.cmake - + avro/configuration.avsc + avro/endpoint.avsc + avro/log.avsc + avro/notification.avsc + avro/profile.avsc + diff --git a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/channel/impl/transports/DefaultUserTransport.java b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/channel/impl/transports/DefaultUserTransport.java index e896940735..95e41e8da2 100644 --- a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/channel/impl/transports/DefaultUserTransport.java +++ b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/channel/impl/transports/DefaultUserTransport.java @@ -43,7 +43,7 @@ public class DefaultUserTransport extends AbstractKaaTransport implements private static final Logger LOG = LoggerFactory.getLogger(DefaultUserTransport.class); private EndpointRegistrationProcessor processor; - private final Map attachedEndpoints = new HashMap(); + private Map attachedEndpoints = new HashMap(); @Override public UserSyncRequest createUserRequest() { @@ -74,16 +74,23 @@ public UserSyncRequest createUserRequest() { public void onUserResponse(UserSyncResponse response) throws IOException { if (processor != null) { boolean hasChanges = false; + if (clientState != null) { + attachedEndpoints = clientState.getAttachedEndpointsList(); + } Map attachEndpointRequests = processor.getAttachEndpointRequests(); if (response.getEndpointAttachResponses() != null && !response.getEndpointAttachResponses().isEmpty()) { for (EndpointAttachResponse attached : response.getEndpointAttachResponses()) { EndpointAccessToken attachedToken = attachEndpointRequests.remove(attached.getRequestId()); if (attached.getResult() == SyncResponseResultType.SUCCESS) { - LOG.info("Token {}", attachedToken); - attachedEndpoints.put(attachedToken, new EndpointKeyHash(attached.getEndpointKeyHash())); - hasChanges = true; + if (attachedToken != null) { + LOG.info("Token {}", attachedToken); + attachedEndpoints.put(attachedToken, new EndpointKeyHash(attached.getEndpointKeyHash())); + hasChanges = true; + } else { + LOG.warn("Endpoint {} is already attached!", attached.getEndpointKeyHash()); + } } else { - LOG.error("Failed to attach endpoint. Attach endpoint request id: {}", attached.getRequestId()); + LOG.error("Failed to attach endpoint {}. Attach endpoint request id: {}", attached.getEndpointKeyHash(), attached.getRequestId()); } } } diff --git a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/logging/AbstractLogCollector.java b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/logging/AbstractLogCollector.java index 7ca699ff4c..90846a6fc5 100644 --- a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/logging/AbstractLogCollector.java +++ b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/logging/AbstractLogCollector.java @@ -145,6 +145,7 @@ public void onLogResponse(LogSyncResponse logSyncResponse) throws IOException { for (LogDeliveryStatus response : logSyncResponse.getDeliveryStatuses()) { final int requestId = response.getRequestId(); final BucketInfo bucketInfo = bucketInfoMap.get(requestId); + final long arriveTime = System.currentTimeMillis(); if (bucketInfo != null) { bucketInfoMap.remove(requestId); if (response.getResult() == SyncResponseResultType.SUCCESS) { @@ -162,7 +163,7 @@ public void run() { executorContext.getCallbackExecutor().execute(new Runnable() { @Override public void run() { - notifyDeliveryFuturesOnSuccess(bucketInfo); + notifyDeliveryFuturesOnSuccess(bucketInfo, arriveTime); } }); } else { @@ -345,13 +346,13 @@ protected void addDeliveryFuture(BucketInfo info, RecordFuture future) { } } - protected void notifyDeliveryFuturesOnSuccess(BucketInfo info) { + protected void notifyDeliveryFuturesOnSuccess(BucketInfo info, Long arriveTime) { synchronized (deliveryFuturesMap) { List deliveryFutures = deliveryFuturesMap.get(info.getBucketId()); if (deliveryFutures != null) { for (RecordFuture future : deliveryFutures) { RecordInfo recordInfo = new RecordInfo(info); - future.setValue(recordInfo); + future.setValue(recordInfo, arriveTime); } deliveryFuturesMap.remove(info.getBucketId()); diff --git a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/logging/future/RecordFuture.java b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/logging/future/RecordFuture.java index cb0d68db38..c7bba350a2 100644 --- a/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/logging/future/RecordFuture.java +++ b/client/client-multi/client-java-core/src/main/java/org/kaaproject/kaa/client/logging/future/RecordFuture.java @@ -89,10 +89,10 @@ public boolean equals(Object obj) { return true; } - public void setValue(RecordInfo value) { + public void setValue(RecordInfo value, Long arriveTime) { try { value.setRecordAddedTimestampMs(recordAddedTimestampMs); - value.setRecordDeliveryTimeMs(System.currentTimeMillis() - recordAddedTimestampMs); + value.setRecordDeliveryTimeMs(arriveTime - recordAddedTimestampMs); this.queue.put(new ExecutionResult<>(value, null)); } catch (InterruptedException e) { LOG.warn("Failed to push value", e); diff --git a/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/channel/DefaultUserTransportTest.java b/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/channel/DefaultUserTransportTest.java index 8b9bb30109..9e7e93652a 100644 --- a/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/channel/DefaultUserTransportTest.java +++ b/client/client-multi/client-java-core/src/test/java/org/kaaproject/kaa/client/channel/DefaultUserTransportTest.java @@ -103,6 +103,7 @@ public void onUserResponse() throws Exception { dettachingEPs.put(REQUEST_ID_2, new EndpointKeyHash("keyhash2")); KaaClientState clientState = Mockito.mock(KaaClientState.class); + EndpointRegistrationProcessor processor = Mockito.mock(EndpointRegistrationProcessor.class); Mockito.when(processor.getAttachEndpointRequests()).thenReturn(attachingEPs); @@ -120,20 +121,43 @@ public void onUserResponse() throws Exception { new EndpointDetachResponse(REQUEST_ID_1, SyncResponseResultType.SUCCESS), new EndpointDetachResponse(REQUEST_ID_1 + 2, SyncResponseResultType.FAILURE))); - transport.onUserResponse(response1); transport.setEndpointRegistrationProcessor(processor); transport.setClientState(clientState); transport.onUserResponse(response1); Mockito.verify(processor, Mockito.times(1)).onUpdate(Mockito.anyListOf(EndpointAttachResponse.class), Mockito.anyListOf(EndpointDetachResponse.class), Mockito.any(UserAttachResponse.class), Mockito.any(UserAttachNotification.class), Mockito.any(UserDetachNotification.class)); - UserSyncResponse response2 = new UserSyncResponse(); + Mockito.verify(clientState, Mockito.times(1)).setAttachedEndpointsList(Mockito.anyMap()); + } + + @Test + public void onDuplicateUserAttachResponse() throws Exception { + KaaClientState clientState = Mockito.mock(KaaClientState.class); + EndpointRegistrationProcessor processor = Mockito.mock(EndpointRegistrationProcessor.class); + + Map attachingEPs = new HashMap<>(); + attachingEPs.put(REQUEST_ID_1, new EndpointAccessToken("token1")); + + + Mockito.when(processor.getAttachEndpointRequests()).thenReturn(attachingEPs); + + UserTransport transport = new DefaultUserTransport(); + UserSyncResponse response1 = new UserSyncResponse(); + + response1.setEndpointAttachResponses(Arrays.asList( + new EndpointAttachResponse(REQUEST_ID_1, "keyhash1", SyncResponseResultType.SUCCESS))); - response2.setEndpointDetachResponses(Arrays.asList( - new EndpointDetachResponse(REQUEST_ID_2, SyncResponseResultType.SUCCESS))); + transport.setClientState(clientState); + transport.setEndpointRegistrationProcessor(processor); + + Map map = new HashMap<>(); + map.put(new EndpointAccessToken("token1"), new EndpointKeyHash("keyhash1")); - transport.onUserResponse(response2); + transport.onUserResponse(response1); + Mockito.verify(clientState, Mockito.times(1)).setAttachedEndpointsList(map); - Mockito.verify(clientState, Mockito.times(2)).setAttachedEndpointsList(Mockito.anyMap()); + transport.onUserResponse(response1); + Mockito.verify(clientState, Mockito.times(1)).setAttachedEndpointsList(map); } + } diff --git a/client/client-multi/client-objective-c/Kaa.podspec b/client/client-multi/client-objective-c/Kaa.podspec new file mode 100644 index 0000000000..eabf566a42 --- /dev/null +++ b/client/client-multi/client-objective-c/Kaa.podspec @@ -0,0 +1,80 @@ + +Pod::Spec.new do |s| + + + s.name = "Kaa" + s.version = "0.9.0" + s.summary = "Kaa iOS SDk" + + + s.description = <<-DESC + +Kaa is a production-ready, multi-purpose middleware platform for building complete end-to-end IoT solutions, connected applications, and smart products. + DESC + + s.homepage = "http://www.kaaproject.org" + + + # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + +s.license = { + :type => 'Apache License, Version 2.0', + :text => ' + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ' + } + + s.author = { "Anton Vilimets" => "avilimets@cybervisiontech.com" } + + + + s.platform = :ios + s.ios.deployment_target = "8.0" + + s.source = { :path => "./Kaa"} + + + # ――― Source Code + + s.source_files = "Kaa/**/*", "Kaa/**/**/*" + + s.private_header_files = "Kaa/security/NSData+CommonCrypto.h" + + + # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + + + # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + + s.frameworks = "Security", "SystemConfiguration" + + + # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + + s.dependency "CocoaLumberjack", "2.3" + s.dependency "AFNetworking", "~> 3.x" + s.dependency "sqlite3" + + s.prefix_header_contents = %( +#import + +#ifndef Kaa_prefix_pch +#define Kaa_prefix_pch + +#ifdef __OBJC__ + #import "CocoaLumberjack.h" +#endif + +#endif) + + + +end diff --git a/client/client-multi/client-objective-c/Kaa.xcodeproj/project.pbxproj b/client/client-multi/client-objective-c/Kaa.xcodeproj/project.pbxproj index 89869be8c9..48fae324c5 100644 --- a/client/client-multi/client-objective-c/Kaa.xcodeproj/project.pbxproj +++ b/client/client-multi/client-objective-c/Kaa.xcodeproj/project.pbxproj @@ -9,6 +9,8 @@ /* Begin PBXBuildFile section */ 2751A21FD925C7B97408EDB2 /* libPods-Kaa.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 236E19905FF92899F3DD4D05 /* libPods-Kaa.a */; }; 391A91A31BBE604C00DBA851 /* EndPointObjectHashTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 391A91A21BBE604C00DBA851 /* EndPointObjectHashTest.m */; }; + 7B9A9A021D8BEFD40090D528 /* NSData+CommonCrypto.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B9A9A001D8BEFD40090D528 /* NSData+CommonCrypto.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 7B9A9A031D8BEFD40090D528 /* NSData+CommonCrypto.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B9A9A011D8BEFD40090D528 /* NSData+CommonCrypto.m */; }; B843B49E1BE67F950060519D /* TestsHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = B843B49D1BE67F950060519D /* TestsHelper.m */; }; B85B18F51C92E9CA002467B1 /* AbstractLogCollectorTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B85B18F41C92E9CA002467B1 /* AbstractLogCollectorTests.m */; }; B8C10A151BC2BBBF001A2236 /* KaaClientPropertiesTest.m in Sources */ = {isa = PBXBuildFile; fileRef = B8C10A131BC2BBBF001A2236 /* KaaClientPropertiesTest.m */; }; @@ -197,7 +199,6 @@ C5AAD9191CB7DE700046AA91 /* KeyPair.h in Headers */ = {isa = PBXBuildFile; fileRef = B8CCBF421C46799D00C26F0B /* KeyPair.h */; settings = {ATTRIBUTES = (Public, ); }; }; C5AAD91A1CB7DE700046AA91 /* KeyUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = B8CCBF441C46799D00C26F0B /* KeyUtils.h */; settings = {ATTRIBUTES = (Public, ); }; }; C5AAD91B1CB7DE700046AA91 /* MessageEncoderDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = B8CCBF461C46799D00C26F0B /* MessageEncoderDecoder.h */; settings = {ATTRIBUTES = (Public, ); }; }; - C5AAD91C1CB7DE700046AA91 /* NSData+CommonCrypto.h in Headers */ = {isa = PBXBuildFile; fileRef = B8CCBF481C46799D00C26F0B /* NSData+CommonCrypto.h */; settings = {ATTRIBUTES = (Public, ); }; }; C5AAD91D1CB7DE700046AA91 /* Transactable.h in Headers */ = {isa = PBXBuildFile; fileRef = B8CCBF571C4679BE00C26F0B /* Transactable.h */; settings = {ATTRIBUTES = (Public, ); }; }; C5AAD91E1CB7DE700046AA91 /* TransactionId.h in Headers */ = {isa = PBXBuildFile; fileRef = B8CCBF581C4679BE00C26F0B /* TransactionId.h */; settings = {ATTRIBUTES = (Public, ); }; }; C5AAD91F1CB7DE700046AA91 /* BlockingQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = B8CCBF671C467B2E00C26F0B /* BlockingQueue.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -321,7 +322,6 @@ C5AAD9A51CB7E1B20046AA91 /* KeyPair.m in Sources */ = {isa = PBXBuildFile; fileRef = B8CCBF431C46799D00C26F0B /* KeyPair.m */; }; C5AAD9A61CB7E1B20046AA91 /* KeyUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = B8CCBF451C46799D00C26F0B /* KeyUtils.m */; }; C5AAD9A71CB7E1B20046AA91 /* MessageEncoderDecoder.m in Sources */ = {isa = PBXBuildFile; fileRef = B8CCBF471C46799D00C26F0B /* MessageEncoderDecoder.m */; }; - C5AAD9A81CB7E1B20046AA91 /* NSData+CommonCrypto.m in Sources */ = {isa = PBXBuildFile; fileRef = B8CCBF491C46799D00C26F0B /* NSData+CommonCrypto.m */; }; C5AAD9A91CB7E1B20046AA91 /* TransactionId.m in Sources */ = {isa = PBXBuildFile; fileRef = B8CCBF591C4679BE00C26F0B /* TransactionId.m */; }; C5AAD9AA1CB7E1B20046AA91 /* BlockingQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = B8CCBF681C467B2E00C26F0B /* BlockingQueue.m */; }; C5AAD9AB1CB7E1B20046AA91 /* KAABase64.m in Sources */ = {isa = PBXBuildFile; fileRef = B8CCBF6A1C467B2E00C26F0B /* KAABase64.m */; }; @@ -360,6 +360,8 @@ 392356A81C56647800BCA885 /* TopicListHashCalculator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopicListHashCalculator.h; sourceTree = ""; }; 392356A91C56647800BCA885 /* TopicListHashCalculator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopicListHashCalculator.m; sourceTree = ""; }; 4CAC4D1133C2E2FBC990B5AC /* Pods-libKaa.a.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-libKaa.a.debug.xcconfig"; path = "Pods/Target Support Files/Pods-libKaa.a/Pods-libKaa.a.debug.xcconfig"; sourceTree = ""; }; + 7B9A9A001D8BEFD40090D528 /* NSData+CommonCrypto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+CommonCrypto.h"; sourceTree = ""; }; + 7B9A9A011D8BEFD40090D528 /* NSData+CommonCrypto.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+CommonCrypto.m"; sourceTree = ""; }; 82D20E3FF13591EBE78EEF11 /* Pods-Kaa.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Kaa.release.xcconfig"; path = "Pods/Target Support Files/Pods-Kaa/Pods-Kaa.release.xcconfig"; sourceTree = ""; }; ACAA02F0BC14427987EC4DE4 /* Pods-Kaa.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Kaa.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Kaa/Pods-Kaa.debug.xcconfig"; sourceTree = ""; }; B0EF18F15697D1F651B3AED4 /* libPods-KaaTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-KaaTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -623,8 +625,6 @@ B8CCBF451C46799D00C26F0B /* KeyUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KeyUtils.m; sourceTree = ""; }; B8CCBF461C46799D00C26F0B /* MessageEncoderDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageEncoderDecoder.h; sourceTree = ""; }; B8CCBF471C46799D00C26F0B /* MessageEncoderDecoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MessageEncoderDecoder.m; sourceTree = ""; }; - B8CCBF481C46799D00C26F0B /* NSData+CommonCrypto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+CommonCrypto.h"; sourceTree = ""; }; - B8CCBF491C46799D00C26F0B /* NSData+CommonCrypto.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+CommonCrypto.m"; sourceTree = ""; }; B8CCBF571C4679BE00C26F0B /* Transactable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Transactable.h; sourceTree = ""; }; B8CCBF581C4679BE00C26F0B /* TransactionId.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TransactionId.h; sourceTree = ""; }; B8CCBF591C4679BE00C26F0B /* TransactionId.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TransactionId.m; sourceTree = ""; }; @@ -1286,8 +1286,8 @@ B8CCBF451C46799D00C26F0B /* KeyUtils.m */, B8CCBF461C46799D00C26F0B /* MessageEncoderDecoder.h */, B8CCBF471C46799D00C26F0B /* MessageEncoderDecoder.m */, - B8CCBF481C46799D00C26F0B /* NSData+CommonCrypto.h */, - B8CCBF491C46799D00C26F0B /* NSData+CommonCrypto.m */, + 7B9A9A001D8BEFD40090D528 /* NSData+CommonCrypto.h */, + 7B9A9A011D8BEFD40090D528 /* NSData+CommonCrypto.m */, ); path = security; sourceTree = ""; @@ -1684,7 +1684,6 @@ C5AAD9191CB7DE700046AA91 /* KeyPair.h in Headers */, C5AAD91A1CB7DE700046AA91 /* KeyUtils.h in Headers */, C5AAD91B1CB7DE700046AA91 /* MessageEncoderDecoder.h in Headers */, - C5AAD91C1CB7DE700046AA91 /* NSData+CommonCrypto.h in Headers */, C5AAD91D1CB7DE700046AA91 /* Transactable.h in Headers */, C5AAD91E1CB7DE700046AA91 /* TransactionId.h in Headers */, C5AAD91F1CB7DE700046AA91 /* BlockingQueue.h in Headers */, @@ -1695,6 +1694,7 @@ C5AAD9241CB7DE700046AA91 /* SHAMessageDigest.h in Headers */, C5AAD9251CB7DE700046AA91 /* TimeCommons.h in Headers */, C5AAD9261CB7DE700046AA91 /* UUID.h in Headers */, + 7B9A9A021D8BEFD40090D528 /* NSData+CommonCrypto.h in Headers */, C5AAD9271CB7DE700046AA91 /* KaaClientFactory.h in Headers */, C5AAD9281CB7DE700046AA91 /* BaseKaaClient.h in Headers */, C5AAD9291CB7DE700046AA91 /* GenericKaaClient.h in Headers */, @@ -1727,12 +1727,12 @@ isa = PBXNativeTarget; buildConfigurationList = B824A2021B1452C50076C753 /* Build configuration list for PBXNativeTarget "KaaTests" */; buildPhases = ( - B66933FD8935E5B3BC6153B6 /* Check Pods Manifest.lock */, + B66933FD8935E5B3BC6153B6 /* [CP] Check Pods Manifest.lock */, B824A1F21B1452C50076C753 /* Sources */, B824A1F31B1452C50076C753 /* Frameworks */, B824A1F41B1452C50076C753 /* Resources */, - 187C1CBC80866C0AFDD68769 /* Copy Pods Resources */, - ED6792EF2E814A4017A759DC /* Embed Pods Frameworks */, + 187C1CBC80866C0AFDD68769 /* [CP] Copy Pods Resources */, + ED6792EF2E814A4017A759DC /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -1747,11 +1747,11 @@ isa = PBXNativeTarget; buildConfigurationList = C5AAD8901CB7DC710046AA91 /* Build configuration list for PBXNativeTarget "Kaa" */; buildPhases = ( - 4836AC55C9524E366A3B1311 /* Check Pods Manifest.lock */, + 4836AC55C9524E366A3B1311 /* [CP] Check Pods Manifest.lock */, C5AAD8841CB7DC710046AA91 /* Sources */, C5AAD8851CB7DC710046AA91 /* Frameworks */, C5AAD8861CB7DC710046AA91 /* Headers */, - 9D7EDA889FB49B43974032B7 /* Copy Pods Resources */, + 9D7EDA889FB49B43974032B7 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -1808,14 +1808,14 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 187C1CBC80866C0AFDD68769 /* Copy Pods Resources */ = { + 187C1CBC80866C0AFDD68769 /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Copy Pods Resources"; + name = "[CP] Copy Pods Resources"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -1823,14 +1823,14 @@ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-KaaTests/Pods-KaaTests-resources.sh\"\n"; showEnvVarsInLog = 0; }; - 4836AC55C9524E366A3B1311 /* Check Pods Manifest.lock */ = { + 4836AC55C9524E366A3B1311 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Check Pods Manifest.lock"; + name = "[CP] Check Pods Manifest.lock"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -1838,14 +1838,14 @@ shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; - 9D7EDA889FB49B43974032B7 /* Copy Pods Resources */ = { + 9D7EDA889FB49B43974032B7 /* [CP] Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Copy Pods Resources"; + name = "[CP] Copy Pods Resources"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -1853,14 +1853,14 @@ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Kaa/Pods-Kaa-resources.sh\"\n"; showEnvVarsInLog = 0; }; - B66933FD8935E5B3BC6153B6 /* Check Pods Manifest.lock */ = { + B66933FD8935E5B3BC6153B6 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Check Pods Manifest.lock"; + name = "[CP] Check Pods Manifest.lock"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -1868,14 +1868,14 @@ shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; - ED6792EF2E814A4017A759DC /* Embed Pods Frameworks */ = { + ED6792EF2E814A4017A759DC /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Embed Pods Frameworks"; + name = "[CP] Embed Pods Frameworks"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -2007,6 +2007,7 @@ C5AAD9851CB7E1B10046AA91 /* ConfigurationDeserializer.m in Sources */, C5AAD9861CB7E1B10046AA91 /* ResyncConfigurationManager.m in Sources */, C5AAD9871CB7E1B10046AA91 /* AbstractExecutorContext.m in Sources */, + 7B9A9A031D8BEFD40090D528 /* NSData+CommonCrypto.m in Sources */, C5AAD9881CB7E1B10046AA91 /* SimpleExecutorContext.m in Sources */, C5AAD9891CB7E1B10046AA91 /* SingleThreadExecutorContext.m in Sources */, C5AAD98A1CB7E1B10046AA91 /* TransportContext.m in Sources */, @@ -2040,7 +2041,6 @@ C5AAD9A51CB7E1B20046AA91 /* KeyPair.m in Sources */, C5AAD9A61CB7E1B20046AA91 /* KeyUtils.m in Sources */, C5AAD9A71CB7E1B20046AA91 /* MessageEncoderDecoder.m in Sources */, - C5AAD9A81CB7E1B20046AA91 /* NSData+CommonCrypto.m in Sources */, C5AAD9A91CB7E1B20046AA91 /* TransactionId.m in Sources */, C5AAD9AA1CB7E1B20046AA91 /* BlockingQueue.m in Sources */, C5AAD9AB1CB7E1B20046AA91 /* KAABase64.m in Sources */, diff --git a/client/client-multi/client-objective-c/Kaa/AbstractKaaClient.h b/client/client-multi/client-objective-c/Kaa/AbstractKaaClient.h index 6744efccae..2ba63d1573 100644 --- a/client/client-multi/client-objective-c/Kaa/AbstractKaaClient.h +++ b/client/client-multi/client-objective-c/Kaa/AbstractKaaClient.h @@ -68,6 +68,10 @@ typedef enum { - (instancetype)initWithPlatformContext:(id)context delegate:(id)delegate; +- (instancetype)initWithPlatformContext:(id)context + delegate:(id)delegate + autoGeneratedKeys:(BOOL)isAutogeneratedKeys; + - (TransportContext *)buildTransportContextWithProperties:(KaaClientProperties *)properties clientState:(id)state; diff --git a/client/client-multi/client-objective-c/Kaa/AbstractKaaClient.m b/client/client-multi/client-objective-c/Kaa/AbstractKaaClient.m index 3e083cab02..662b8f6e06 100644 --- a/client/client-multi/client-objective-c/Kaa/AbstractKaaClient.m +++ b/client/client-multi/client-objective-c/Kaa/AbstractKaaClient.m @@ -65,6 +65,10 @@ - (void)checkReadiness; @implementation AbstractKaaClient - (instancetype)initWithPlatformContext:(id)context delegate:(id)delegate { + return [self initWithPlatformContext:context delegate:delegate autoGeneratedKeys:YES]; +} + +- (instancetype)initWithPlatformContext:(id)context delegate:(id)delegate autoGeneratedKeys:(BOOL)isAutogeneratedKeys { self = [super init]; if (self) { self.context = context; @@ -85,7 +89,7 @@ - (instancetype)initWithPlatformContext:(id)context de [serverList shuffle]; } - self.clientState = [[KaaClientPropertiesState alloc] initWithBase64:[context getBase64] clientProperties:self.properties]; + self.clientState = [[KaaClientPropertiesState alloc] initWithBase64:[context getBase64] clientProperties:self.properties autogeneratedKeys:isAutogeneratedKeys]; TransportContext *transportContext = [self buildTransportContextWithProperties:self.properties clientState:self.clientState]; diff --git a/client/client-multi/client-objective-c/Kaa/BaseKaaClient.h b/client/client-multi/client-objective-c/Kaa/BaseKaaClient.h index 2f210491f2..2c42b55786 100644 --- a/client/client-multi/client-objective-c/Kaa/BaseKaaClient.h +++ b/client/client-multi/client-objective-c/Kaa/BaseKaaClient.h @@ -24,4 +24,6 @@ */ @interface BaseKaaClient : AbstractKaaClient +- (instancetype)initWithPlatformContext:(id)context delegate:(id)delegate; + @end diff --git a/client/client-multi/client-objective-c/Kaa/BaseKaaClient.m b/client/client-multi/client-objective-c/Kaa/BaseKaaClient.m index 9fb6165a85..bd4ab2a0cb 100644 --- a/client/client-multi/client-objective-c/Kaa/BaseKaaClient.m +++ b/client/client-multi/client-objective-c/Kaa/BaseKaaClient.m @@ -20,6 +20,10 @@ @implementation BaseKaaClient +- (instancetype)initWithPlatformContext:(id)context delegate:(id)delegate { + return [super initWithPlatformContext:context delegate:delegate autoGeneratedKeys:YES]; +} + - (BucketRunner *)addLogRecord:(KAADummyLog *)record { [self checkLifecycleState:CLIENT_LIFECYCLE_STATE_STARTED withErrorMessage:@"Kaa client isn't started"]; return [self.logCollector addLogRecord:record]; diff --git a/client/client-multi/client-objective-c/Kaa/Kaa.h b/client/client-multi/client-objective-c/Kaa/Kaa.h index 21a0eb21f1..76e735011c 100644 --- a/client/client-multi/client-objective-c/Kaa/Kaa.h +++ b/client/client-multi/client-objective-c/Kaa/Kaa.h @@ -136,7 +136,6 @@ FOUNDATION_EXPORT const unsigned char KaaVersionString[]; #import #import #import -#import #import #import #import diff --git a/client/client-multi/client-objective-c/Kaa/KaaClientFactory.h b/client/client-multi/client-objective-c/Kaa/KaaClientFactory.h index 4259fdf4e4..6ab5feb7ab 100644 --- a/client/client-multi/client-objective-c/Kaa/KaaClientFactory.h +++ b/client/client-multi/client-objective-c/Kaa/KaaClientFactory.h @@ -23,9 +23,17 @@ /** * Creates new Kaa client with specified platform context and state delegate. + * + * @param context Kaa platform specific context for client init + * @param delegate notifier for changing client state + * @param isAutogeneratedKeys check whether to generate public/private key pair automatically. + * 'NO' - use existing pre-generated public/private key pair. + * 'YES' - generate public/private key pair if necessary (default behaviour). */ + (id)clientWithContext:(id)context stateDelegate:(id)delegate; ++ (id)clientWithContext:(id)context stateDelegate:(id)delegate autoGeneratedKeys:(BOOL)isAutogeneratedKeys; + /** * Creates new Kaa client with specified platform context. */ diff --git a/client/client-multi/client-objective-c/Kaa/KaaClientFactory.m b/client/client-multi/client-objective-c/Kaa/KaaClientFactory.m index 7a9656039e..43a62adcba 100644 --- a/client/client-multi/client-objective-c/Kaa/KaaClientFactory.m +++ b/client/client-multi/client-objective-c/Kaa/KaaClientFactory.m @@ -23,12 +23,16 @@ @implementation KaaClientFactory + (id)clientWithContext:(id)context stateDelegate:(id)delegate { + return [self clientWithContext:context stateDelegate:delegate autoGeneratedKeys:YES]; +} + ++ (id)clientWithContext:(id)context stateDelegate:(id)delegate autoGeneratedKeys:(BOOL)isAutogeneratedKeys { [DDLog addLogger:[DDTTYLogger sharedInstance]]; // TTY = Xcode console [DDLog addLogger:[DDASLLogger sharedInstance]]; // ASL = Apple System Logs @try { - return [[BaseKaaClient alloc] initWithPlatformContext:context delegate:delegate]; + return [[BaseKaaClient alloc] initWithPlatformContext:context delegate:delegate autoGeneratedKeys:isAutogeneratedKeys]; } @catch (NSException *exception) { DDLogError(@"%@ Failed to create Kaa client: %@. Reason: %@", TAG, exception.name, exception.reason); @@ -37,11 +41,11 @@ @implementation KaaClientFactory } + (id)clientWithContext:(id)context { - return [self clientWithContext:context stateDelegate:nil]; + return [self clientWithContext:context stateDelegate:nil autoGeneratedKeys:YES]; } + (id)clientWithStateDelegate:(id)delegate { - return [self clientWithContext:[[DefaultKaaPlatformContext alloc] init] stateDelegate:delegate]; + return [self clientWithContext:[[DefaultKaaPlatformContext alloc] init] stateDelegate:delegate autoGeneratedKeys:YES]; } + (id)client { diff --git a/client/client-multi/client-objective-c/Kaa/avro/avro_src/avro_private.h b/client/client-multi/client-objective-c/Kaa/avro/avro_src/avro_private.h index 4b62695f4e..1eb020f849 100644 --- a/client/client-multi/client-objective-c/Kaa/avro/avro_src/avro_private.h +++ b/client/client-multi/client-objective-c/Kaa/avro/avro_src/avro_private.h @@ -22,7 +22,7 @@ extern "C" { #include -#include "avro/platform.h" +#include "platform.h" #ifdef HAVE_CONFIG_H /* This is only true for now in the autotools build */ diff --git a/client/client-multi/client-objective-c/Kaa/persistance/KaaClientPropertiesState.h b/client/client-multi/client-objective-c/Kaa/persistance/KaaClientPropertiesState.h index ab45d6eb89..4378cccf3b 100644 --- a/client/client-multi/client-objective-c/Kaa/persistance/KaaClientPropertiesState.h +++ b/client/client-multi/client-objective-c/Kaa/persistance/KaaClientPropertiesState.h @@ -29,5 +29,6 @@ @interface KaaClientPropertiesState : NSObject - (instancetype)initWithBase64:(id)base64 clientProperties:(KaaClientProperties *)properties; +- (instancetype)initWithBase64:(id)base64 clientProperties:(KaaClientProperties *)properties autogeneratedKeys:(BOOL)isKeyPairAutogenerated; @end diff --git a/client/client-multi/client-objective-c/Kaa/persistance/KaaClientPropertiesState.m b/client/client-multi/client-objective-c/Kaa/persistance/KaaClientPropertiesState.m index 4587af0c0e..81937d86d8 100644 --- a/client/client-multi/client-objective-c/Kaa/persistance/KaaClientPropertiesState.m +++ b/client/client-multi/client-objective-c/Kaa/persistance/KaaClientPropertiesState.m @@ -24,6 +24,7 @@ #import "UUID.h" #import "KeyUtils.h" #import "KaaLogging.h" +#import "KaaExceptions.h" #import "TopicListHashCalculator.h" #define TAG @"KaaClientPropertiesState >>>" @@ -52,6 +53,7 @@ @interface KaaClientPropertiesState () @property (nonatomic, strong) KeyPair *keyPair; @property (nonatomic) BOOL isConfigVersionUpdated; @property (nonatomic) BOOL hasUpdate; +@property (nonatomic) BOOL isKeyPairAutogenerated; - (void)setPropertiesHash:(NSData *)hash; - (BOOL)isSDKProperyListUpdated:(KaaClientProperties *)sdkProperties; @@ -81,6 +83,10 @@ @implementation KaaClientPropertiesState @synthesize needProfileResync = _needProfileResync; - (instancetype)initWithBase64:(id)base64 clientProperties:(KaaClientProperties *)properties { + return [self initWithBase64:base64 clientProperties:properties autogeneratedKeys:YES]; +} + +- (instancetype)initWithBase64:(id)base64 clientProperties:(KaaClientProperties *)properties autogeneratedKeys:(BOOL)isKeyPairAutogenerated { self = [super init]; if (self) { self.base64 = base64; @@ -88,6 +94,7 @@ - (instancetype)initWithBase64:(id)base64 clientProperties:(KaaClient self.topicDictionary = [NSMutableDictionary dictionary]; self.attachedEndpoints = [NSMutableDictionary dictionary]; self.isConfigVersionUpdated = NO; + self.isKeyPairAutogenerated = isKeyPairAutogenerated; NSString *storage = [NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) firstObject]; NSString *stateFileName = [properties stringForKey:STATE_FILE_LOCATION_KEY]; @@ -474,9 +481,15 @@ - (KeyPair *)getOrGenerateKeyPair { return self.keyPair; } - DDLogDebug(@"%@ Generating new key pair", TAG); - self.keyPair = [KeyUtils generateKeyPair]; - return self.keyPair; + if (self.isKeyPairAutogenerated) { + DDLogDebug(@"%@ Generating new key pair", TAG); + self.keyPair = [KeyUtils generateKeyPair]; + return self.keyPair; + } else { + DDLogDebug(@"%@ Error loading key pair! Key pair is not found and key strategy is default", TAG); + [NSException raise:KaaRuntimeException format:@"Key pair is not found and your key strategy is default"]; + } + return nil; } - (void)deleteFileAtPath:(NSString *)path { diff --git a/client/client-multi/client-objective-c/Kaa/utils/SHAMessageDigest.h b/client/client-multi/client-objective-c/Kaa/utils/SHAMessageDigest.h index 2f0d2d9b39..484901fa57 100644 --- a/client/client-multi/client-objective-c/Kaa/utils/SHAMessageDigest.h +++ b/client/client-multi/client-objective-c/Kaa/utils/SHAMessageDigest.h @@ -15,7 +15,6 @@ */ #import -#import /** * Class holds secure one-way hash functions that take arbitrary-sized diff --git a/client/client-multi/client-objective-c/Kaa/utils/SHAMessageDigest.m b/client/client-multi/client-objective-c/Kaa/utils/SHAMessageDigest.m index b1a91d991f..95d883b171 100644 --- a/client/client-multi/client-objective-c/Kaa/utils/SHAMessageDigest.m +++ b/client/client-multi/client-objective-c/Kaa/utils/SHAMessageDigest.m @@ -16,6 +16,8 @@ #import "SHAMessageDigest.h" #import "NSString+Commons.h" +#import + @interface SHAMessageDigest () diff --git a/client/client-multi/client-objective-c/KaaTests/KaaClientPropertiesStateTest.m b/client/client-multi/client-objective-c/KaaTests/KaaClientPropertiesStateTest.m index 52e2e02bf1..8ac3b11743 100644 --- a/client/client-multi/client-objective-c/KaaTests/KaaClientPropertiesStateTest.m +++ b/client/client-multi/client-objective-c/KaaTests/KaaClientPropertiesStateTest.m @@ -38,14 +38,37 @@ - (void)setUp { NSLog(@"Can't remove Application Support directory!"); } - self.state = [[KaaClientPropertiesState alloc] initWithBase64:[CommonBase64 new] clientProperties:[TestsHelper getProperties]]; + self.state = [[KaaClientPropertiesState alloc] initWithBase64:[CommonBase64 new] clientProperties:[TestsHelper getProperties] autogeneratedKeys:YES]; } - (void)tearDown { [self.state clean]; } -- (void)testKeys { +- (void)testDefaultKeyStrategy { + [KeyUtils deleteExistingKeyPair]; + + self.state = [[KaaClientPropertiesState alloc] initWithBase64:[CommonBase64 new] clientProperties:[TestsHelper getProperties]]; + + SecKeyRef privateKey = [self.state privateKey]; + SecKeyRef publicKey = [self.state publicKey]; + XCTAssertTrue(privateKey != NULL); + XCTAssertTrue(publicKey != NULL); +} + +- (void)testDefaultKeyStrategyPreloadedKeys { + [KeyUtils deleteExistingKeyPair]; + + [KeyUtils generateKeyPair]; + self.state = [[KaaClientPropertiesState alloc] initWithBase64:[CommonBase64 new] clientProperties:[TestsHelper getProperties]]; + + SecKeyRef privateKey = [self.state privateKey]; + SecKeyRef publicKey = [self.state publicKey]; + XCTAssertTrue(privateKey != NULL); + XCTAssertTrue(publicKey != NULL); +} + +- (void)testGenerateKeys { SecKeyRef privateKey = [self.state privateKey]; SecKeyRef publicKey = [self.state publicKey]; XCTAssertTrue(privateKey != NULL); diff --git a/client/client-multi/client-objective-c/KaaTests/KaaClientTest.m b/client/client-multi/client-objective-c/KaaTests/KaaClientTest.m index b8c53dae0b..a4eabf3814 100644 --- a/client/client-multi/client-objective-c/KaaTests/KaaClientTest.m +++ b/client/client-multi/client-objective-c/KaaTests/KaaClientTest.m @@ -58,7 +58,7 @@ - (instancetype)initWithPlatformContext:(id)context de @implementation AbstractKaaClient (BootstrapManager) - (instancetype)initWithPlatformContext:(id)context delegate:(id)delegate bootstrapManager:(id)bsManager { - self = [self initWithPlatformContext:context delegate:delegate]; + self = [self initWithPlatformContext:context delegate:delegate autoGeneratedKeys:YES]; [self setValue:bsManager forKey:@"bootstrapManager"]; return self; } @@ -95,6 +95,23 @@ - (void)setUp { [self.client setProfileContainer:[[TestClientProfileContainer alloc] init]]; } +- (void)testDefaultKeyGenerationStrategy { + [KeyUtils deleteExistingKeyPair]; + + self.client = [KaaClientFactory clientWithContext:self.context stateDelegate:self.delegate]; +} + +- (void)testUserKeyGenerationStrategy { + [KeyUtils deleteExistingKeyPair]; + + @try { + self.client = [KaaClientFactory clientWithContext:self.context stateDelegate:self.delegate autoGeneratedKeys:NO]; + XCTFail(@"testDefaultKeyGenerationStrategy failed"); + } @catch (NSException *exception) { + NSLog(@"testDefaultKeyGenerationStrategy succeeded"); + } +} + - (void)testBasicLifeCycle { [self.client start]; @@ -166,7 +183,7 @@ - (void)testOnPauseFailure { [verifyCount(self.delegate, times(1)) onPauseFailureWithException:anything()]; } -- (void)testFailureOnResume { +- (void)testFailureOnResume { [self.client start]; [NSThread sleepForTimeInterval:1]; [verifyCount(self.delegate, times(1)) onStarted]; diff --git a/client/client-multi/client-objective-c/Podfile b/client/client-multi/client-objective-c/Podfile index f3732b77d1..12eba3a6d5 100644 --- a/client/client-multi/client-objective-c/Podfile +++ b/client/client-multi/client-objective-c/Podfile @@ -2,9 +2,10 @@ # platform :ios, '6.0' target 'Kaa' do - pod 'CocoaLumberjack' + pod 'CocoaLumberjack', '2.3' pod 'AFNetworking', '~> 3.x' pod 'sqlite3', :inhibit_warnings => true + pod 'CommonCrypto', '~> 1.1' end target :KaaTests do diff --git a/common/core/src/main/java/org/kaaproject/kaa/server/common/core/algorithms/AvroUtils.java b/common/core/src/main/java/org/kaaproject/kaa/server/common/core/algorithms/AvroUtils.java index 109675c16b..351ab1168e 100644 --- a/common/core/src/main/java/org/kaaproject/kaa/server/common/core/algorithms/AvroUtils.java +++ b/common/core/src/main/java/org/kaaproject/kaa/server/common/core/algorithms/AvroUtils.java @@ -16,6 +16,7 @@ package org.kaaproject.kaa.server.common.core.algorithms; +import java.io.IOException; import java.nio.ByteBuffer; import java.util.List; import java.util.Map; @@ -26,7 +27,7 @@ import org.apache.avro.Schema.Type; import org.apache.avro.generic.GenericData; import org.codehaus.jackson.JsonNode; -import org.codehaus.jackson.node.ArrayNode; +import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.node.ObjectNode; import static org.kaaproject.kaa.server.common.core.algorithms.CommonConstants.*; @@ -92,20 +93,49 @@ public static void copyJsonProperties(JsonProperties src, JsonProperties dst) { } } + public static String injectUuids(String json, Schema schema) throws IOException { + return injectUuids(json.getBytes(), schema); + } - public static void injectUuids(JsonNode json) { - boolean containerWithoutId = json.isContainerNode() && !json.has(UUID_FIELD); - boolean notArray = !json.isArray(); - boolean childIsNotArray = !(json.size() == 1 && json.getElements().next() instanceof ArrayNode); + public static String injectUuids(byte[] content, Schema schema) throws IOException { + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode root = objectMapper.readTree(content); + injectUuidsFromJsonNodes(root, schema); + return root.toString(); + } - if (containerWithoutId && notArray && childIsNotArray) { - ((ObjectNode)json).put(UUID_FIELD, (Integer)null); + public static String injectUuids(JsonNode root, Schema schema) { + return injectUuidsFromJsonNodes(root, schema).toString(); + } + + private static JsonNode injectUuidsFromJsonNodes(JsonNode json, Schema schema) { + if (json == null) { + return json; } - for (JsonNode node : json) { - if (node.isContainerNode()) - injectUuids(node); + switch (schema.getType()) { + case RECORD: + schema.getFields().stream() + .filter(f -> !f.name().equals(UUID_FIELD)) + .forEach(f -> injectUuidsFromJsonNodes(json.get(f.name()), f.schema())); + + boolean addressable = schema.getFields().stream().filter(f -> f.name().equals(UUID_FIELD)).findFirst().isPresent(); + if (addressable) { + ((ObjectNode) json).put(UUID_FIELD, (Integer) null); + } + break; + case UNION: + schema.getTypes() + .forEach(s -> injectUuidsFromJsonNodes(json.get(s.getName()), s)); + break; + case ARRAY: + json.getElements().forEachRemaining((e) -> injectUuids(e, schema.getElementType())); + break; + default: + return json; } + + return json; } public static void removeUuids(JsonNode json) { diff --git a/common/core/src/test/java/org/kaaproject/kaa/server/common/core/algorithms/AvroUtilsTest.java b/common/core/src/test/java/org/kaaproject/kaa/server/common/core/algorithms/AvroUtilsTest.java index 13cc8b91b1..55fdccff1e 100644 --- a/common/core/src/test/java/org/kaaproject/kaa/server/common/core/algorithms/AvroUtilsTest.java +++ b/common/core/src/test/java/org/kaaproject/kaa/server/common/core/algorithms/AvroUtilsTest.java @@ -17,6 +17,7 @@ package org.kaaproject.kaa.server.common.core.algorithms; +import org.apache.avro.Schema; import org.codehaus.jackson.JsonNode; import org.codehaus.jackson.map.ObjectMapper; import org.junit.Assert; @@ -28,17 +29,18 @@ public class AvroUtilsTest { private JsonNode data; private JsonNode dataWithUUIDs; + private Schema avroSchema; @Before public void setUp() throws IOException { data = new ObjectMapper().readTree(AvroUtilsTest.class.getClassLoader().getResourceAsStream("uuids/data.json")); dataWithUUIDs = new ObjectMapper().readTree(AvroUtilsTest.class.getClassLoader().getResourceAsStream("uuids/data_with_uuids.json")); + avroSchema = new Schema.Parser().parse(AvroUtilsTest.class.getClassLoader().getResourceAsStream("uuids/schema.json")); } @Test public void testInjectUuids() throws IOException { - AvroUtils.injectUuids(data); - String jsonWithUUIds = data.toString(); + String jsonWithUUIds = AvroUtils.injectUuids(data, avroSchema); Assert.assertTrue("Generated json is not equal json with UUIDs", jsonWithUUIds.equals(dataWithUUIDs.toString())); } diff --git a/common/core/src/test/resources/uuids/data.json b/common/core/src/test/resources/uuids/data.json index f87702917d..9e41d5303d 100644 --- a/common/core/src/test/resources/uuids/data.json +++ b/common/core/src/test/resources/uuids/data.json @@ -1,22 +1,3 @@ { - "AddressList": { - "array": [ - { - "label": "Kaa website", - "url": "http://www.kaaproject.org" - }, - { - "label": "Kaa GitHub repository", - "url": "https://github.com/kaaproject/kaa" - }, - { - "label": "Kaa docs", - "url": "http://docs.kaaproject.org/display/KAA/Kaa+IoT+Platform+Home" - }, - { - "label": "Kaa configuration design reference", - "url": "http://docs.kaaproject.org/display/KAA/Configuration" - } - ] - } + "label": "a" } \ No newline at end of file diff --git a/common/core/src/test/resources/uuids/data_with_uuids.json b/common/core/src/test/resources/uuids/data_with_uuids.json index 3187830fdd..c71dd469e9 100644 --- a/common/core/src/test/resources/uuids/data_with_uuids.json +++ b/common/core/src/test/resources/uuids/data_with_uuids.json @@ -1,27 +1,4 @@ { - "AddressList": { - "array": [ - { - "label": "Kaa website", - "url": "http://www.kaaproject.org", - "__uuid":null - }, - { - "label": "Kaa GitHub repository", - "url": "https://github.com/kaaproject/kaa", - "__uuid":null - }, - { - "label": "Kaa docs", - "url": "http://docs.kaaproject.org/display/KAA/Kaa+IoT+Platform+Home", - "__uuid":null - }, - { - "label": "Kaa configuration design reference", - "url": "http://docs.kaaproject.org/display/KAA/Configuration", - "__uuid":null - } - ] - }, + "label": "a", "__uuid":null } \ No newline at end of file diff --git a/common/core/src/test/resources/uuids/schema.json b/common/core/src/test/resources/uuids/schema.json new file mode 100644 index 0000000000..a26eba3e3e --- /dev/null +++ b/common/core/src/test/resources/uuids/schema.json @@ -0,0 +1,8 @@ +{ + "type":"record", + "name": "someFields", + "fields":[ + {"name":"label", "type":"string"}, + {"name":"__uuid", "type":"string"} + ] +} \ No newline at end of file diff --git a/doc/Administration-guide/Data-migration/index.md b/doc/Administration-guide/Data-migration/index.md deleted file mode 100644 index 017148a9b4..0000000000 --- a/doc/Administration-guide/Data-migration/index.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -layout: page -title: Data migration -permalink: /:path/ -sort_idx: 70 ---- -How to migrate Kaa configuration and data across clusters. diff --git a/doc/Administration-guide/System-Configuration/General-configuration/index.md b/doc/Administration-guide/System-Configuration/General-configuration/index.md index efb7d1bd18..614d0cdc80 100644 --- a/doc/Administration-guide/System-Configuration/General-configuration/index.md +++ b/doc/Administration-guide/System-Configuration/General-configuration/index.md @@ -111,8 +111,7 @@ to change it for development or debug process.
Interface that will be reported by all transports. * *metrics_enabled*
Default: _true_ -
Specify if metrics collections are enabled. See -[performance monitoring]({{root_url}}Administration-guide/System-installation/Planning-your-deployment/#performance-monitoring) for details. +
Specify if metrics collections are enabled. * *logs_root_dir*
Default: _/kaa_log_uploads_
Path to logs root directory. @@ -130,6 +129,9 @@ to change it for development or debug process.
Specify additional package to scan kaa plugins configuration. For details look at [Log appender provisioning]({{root_url}}Customization-guide/Customizable-system-components/Log-appenders#log-appender-provisioning) or [Owner verifier provisioning]({{root_url}}Customization-guide/Customizable-system-components/Owner-verifiers/#owner-verifier-provisioning). +* *default_ttl* +
Default: 7 days +
Defines the live time of the notification ## Public host/ports configuration diff --git a/doc/Administration-guide/System-installation/Cluster-setup/index.md b/doc/Administration-guide/System-installation/Cluster-setup/index.md index 233f631086..a0bd0342c1 100644 --- a/doc/Administration-guide/System-installation/Cluster-setup/index.md +++ b/doc/Administration-guide/System-installation/Cluster-setup/index.md @@ -44,7 +44,7 @@ In order to set up Kaa cluster you need to have at least 3 Linux nodes with ```k Also ```kaa-node``` service requires some third party dependencies like SQL and NoSQL databases and Apache Zookeeper service, more details you can find in [Architecture overview]({{root_url}}Architecture-overview/). You can find detailed instructions on how to install and configure Zookeeper service and one of supported SQL and NoSQL databases in [Single node installation]({{root_url}}Administration-guide/System-installation/Single-node-installation/#installation-steps) guide. -A set of databases (for example MongoDB + PostgreSQL) depends on your particular use case and some useful recommendations you can find in [Planning your deployment]({{root_url}}Administration-guide/System-installation/Planning-your-deployment/) guide. +A set of databases (for example MongoDB + PostgreSQL) depends on your particular use case. In this guide we assume that you had already set up your SQL and NoSQL database clusters, so this tutorial doesn't cover such themes like setting up ones for Cassandra, MongoDB or PostgreSQL. Refer to official [Cassandra](http://docs.datastax.com/en/landing_page/doc/landing_page/current.html), [MongoDB](https://docs.mongodb.com/manual/) and [PostgreSQL](https://www.postgresql.org/docs/) documentation in order to setup corresponding database cluster. diff --git a/doc/Administration-guide/System-installation/Managing-system-plug-ins/index.md b/doc/Administration-guide/System-installation/Managing-system-plug-ins/index.md deleted file mode 100644 index 01345823d0..0000000000 --- a/doc/Administration-guide/System-installation/Managing-system-plug-ins/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -layout: page -title: Managing system plug-ins -permalink: /:path/ -sort_idx: 30 ---- - -Guide for the platform administrators. \ No newline at end of file diff --git a/doc/Administration-guide/System-installation/Planning-your-deployment/index.md b/doc/Administration-guide/System-installation/Planning-your-deployment/index.md deleted file mode 100644 index dce603fc4a..0000000000 --- a/doc/Administration-guide/System-installation/Planning-your-deployment/index.md +++ /dev/null @@ -1,205 +0,0 @@ ---- -layout: page -title: Planning your deployment -permalink: /:path/ -sort_idx: 10 ---- - -* [Introduction](#introduction) -* [Building Kaa from source](#building-kaa-from-source) - * [Fetching source code](#fetching-source-code) - * [Build artifacts](#build-artifacts) -* [Installing Kaa](#installing-kaa) -* [AWS deployment preparation](#aws-deployment-preparation) -* [Performance monitoring](#performance-monitoring) - * [Accessing performance information](#accessing-performance-information) - * [Performance metrics description](#performance-metrics-description) - * [OS information](#os-information) - * [Memory usage](#memory-usage) - * [Thread system](#thread-system) - * [Remote connections](#remote-connections) - * [Third-party component metrics](#third-party-component-metrics) -* [Storing custom schemas](#storing-custom-schemas) -* [Troubleshooting](#troubleshooting) - -## Introduction - -This page describes common ways to setup and deploy your kaa instance and its environment and also some best practices. - -## Building Kaa from source - -This paragraph describes how to build the Kaa server from the source code available on [GitHub](https://github.com/kaaproject/kaa). -Before building the Kaa server from source, ensure that [Oracle JDK 8](http://www.oracle.com/technetwork/java/javase/downloads/index.html) and [Apache Maven](https://maven.apache.org/) are installed on your machine. - -### Fetching source code - -It is allowed to use any Git client to fetch the Kaa source code from the repository. - -[Set up your Git configuration](https://git-scm.com/book/tr/v2/Customizing-Git-Git-Configuration) (at least the username and email) and download Kaa repository as follows: - -```bash - $ git clone https://github.com/kaaproject/kaa.git -``` - -To build Kaa node Debian/RPM packages, execute the following command. - - -
-

- -```bash - $ mvn -P compile-gwt,mongo-dao clean install verify -``` - -

- -```bash - $ mvn -P compile-gwt,mongo-dao,build-rpm clean install verify -``` - -

- -**NOTE** - -The Debian build will work correctly on both Linux and Windows operation systems, while the RPM build will work only on Linux operated machines with the RPM tool installed. - -**NOTE** - -For the mvn command, the build number and git commit variables are set to emulate Jenkins build variables that are substituted automatically on the build machine. - -**NOTE** - -Please add "-DskipTests" suffix to the mvn command in order to skip execution of tests and speed up build process. - -## Build artifacts - -The following command can be used to browse the Kaa node build artifacts in case of successful build. - - $ ls server/node/target/kaa-node.deb - - $ ls server/node/target/rpm/kaa-node/RPMS/noarch/kaa-node*.rpm - -## Installing Kaa - -You can deploy Kaa server as a single node or as multi node cluster, for more details refer to corresponding pages: - -* [Single node installation](../Single-node-installation) -* [Node cluster setup](../Cluster-setup) - -## AWS deployment preparation - -To launch the Kaa sandbox on Amazon Elastic Compute Cloud (Amazon EC2), go through the following steps. - -1. Launch the AMI using the links in the following table: - - Amazon EC2 offers a number of [geographic regions](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html) for launching the AMI. Factors for choosing a region include: reduce latency, cost, or regulatory requirements. - - To launch an AMI for a specific region, please use the [download](http://www.kaaproject.org/download-kaa/) page. - -2. On**Choose an Instance Type** step, choose the appropriate instance type. For optimal performance we recommended that you use at least _m3.large_ instance type, or more powerful. - -3. On **Configure Instance Details** step, change values in the fields as appropriate or leave default values. - -4. On **Add Storage** step, add additional volumes as appropriate. The number of instance store devices available on the machine depends on the instance type. EBS volumes are not recommended for the database storage. - -5. On **Tag Instance** step, give a name to your instance, for example, kaa-sandbox-0.8.0 - -6. On **Configure Security Group** step, select one of the following options. - - 1. Create a new security group with the inbound open ports: - - | Protocol | Port | RangeSource | - | -------- | ---- | ----------- | - | TCP | 22 | 0.0.0.0/0 | - | TCP | 8080 | 0.0.0.0/0 | - | TCP | 9999 | 0.0.0.0/0 | - | TCP | 9998 | 0.0.0.0/0 | - | TCP | 9997 | 0.0.0.0/0 | - | TCP | 9889 | 0.0.0.0/0 | - | TCP | 9888 | 0.0.0.0/0 | - | TCP | 9887 | 0.0.0.0/0 | - | TCP | 9080 | 0.0.0.0/0 | - - 2. Select the created security group. - -7. On **Review Instance Launch** step, make any changes as appropriate. - -8. Click **Launch** and then in the **Select an existing key pair** or **Create a new key pair** dialog, do one of the following: - - * Select an existing key pair from the **Select a key pair** drop list. - * If you need to create a new key pair, click **Create a new key pair**. Then create the new key pair as described in [Creating a key pair](http://docs.aws.amazon.com/gettingstarted/latest/wah/getting-started-prereq.html). - -9. Click **Launch Instances**. The **Launch Status** page will be displayed. - -10. Click **View Instances**. - -11. After launching Kaa Sandbox instance, go to <**your\_instance\_public\_dns\>:9080/sandbox** or **:9080/sandbox** URL. Public DNS or IP of your instance are available from your instance description. - -12. For more information about Kaa Sandbox please visit this [page](https://docs.kaaproject.org/display/KAA/Sandbox). - -## Performance monitoring - -### Accessing performance information - -Each Kaa node exposes a number of system performance metrics through the [JMX](https://docs.oracle.com/javase/tutorial/jmx/overview/index.html) technology. The easiest way to access the metrics information is by using [JConsole](https://docs.oracle.com/javase/8/docs/technotes/guides/management/jconsole.html), a JMX-compliant tool that comes as a part of the JDK. - -> The default JMX port for Kaa is 7091. - -### Performance metrics description - -The metrics described in this section are available in the org.kaaproject.kaa.metrics domain. - -![alt text](jmx.png) - - -#### OS information - -| Metric name | Description | -| ------------------- | ---------------------------------------------------------------------------------------------- | -| system-load-average | The [system load](https://en.wikipedia.org/wiki/Load_(computing)) average for the last minute. | - - -#### Memory usage - -| Metric name | Description | -| ------------------------ | ---------------------------------------------------------------------------------- | -|heap-memory-usage.mb | The current memory usage of the heap memory that used for object allocation, in MB.| -| non-heap-memory-usage.mb | The current memory usage of non-heap memory, in MB. | - - -#### Thread system - -| Metric name | Description | -| ------------ | ---------------------------------------------------------------------------- | -| thread-count | The current number of live threads (including both daemons and non-daemons). | - - -#### Remote connections - -| Metric name | Description | -| -------------------- | ----------------------------------------------------------------- | -| sessionInitMeter | The current number of session initialization requests processed. | -| sessionRequestMeter | The current number of session messages processed. | -| sessionResponseMeter | The current number of session message responses. | -| redirectMeter | The current number of session messages redirected to other nodes. | -| errorMeter | The current number of errors during message processing. | - -> Each thread that handles a remote connection has a set of metrics sharing the names above, followed by the thread name. For example, a thread named foo manages a set of metrics called sessionRequestMeter.foo, sessionResponseMeter.foo, and so on. - - -### Third-party component metrics - -The JMX metrics for the third-party components used by Kaa, such as the Java MongoDB driver or Ehcache, can be observed in their respective domains. - -## Storing custom schemas - -Our best practices is to provide all schemas next to source code, covered by some version control system (VCS). -Also if you need to compile some of your schemas or you need to serialize data by some schema you can refer to [Apache Avro](https://avro.apache.org/docs/1.7.7/index.html) documentation. - -## Troubleshooting - -Common issues covered in this [guide](../Troubleshooting). - diff --git a/doc/Administration-guide/System-installation/Planning-your-deployment/jmx.png b/doc/Administration-guide/System-installation/Planning-your-deployment/jmx.png deleted file mode 100644 index 18c26e73de..0000000000 Binary files a/doc/Administration-guide/System-installation/Planning-your-deployment/jmx.png and /dev/null differ diff --git a/doc/Administration-guide/System-installation/Single-node-installation/index.md b/doc/Administration-guide/System-installation/Single-node-installation/index.md index a2545ecbcf..7dbf87e214 100644 --- a/doc/Administration-guide/System-installation/Single-node-installation/index.md +++ b/doc/Administration-guide/System-installation/Single-node-installation/index.md @@ -866,7 +866,7 @@ cqlsh> ### Kaa server components -To install Kaa you will need to [download](http://www.kaaproject.org/download-kaa/) pre-built packages or [build](../Planning-your-deployment#building-kaa-from-source) them from the [source code](https://github.com/kaaproject/kaa). We will use pre-built packages in this guide. +To install Kaa you will need to [download](http://www.kaaproject.org/download-kaa/) pre-built packages or build them from the [source code](https://github.com/kaaproject/kaa). We will use pre-built packages in this guide.
    diff --git a/doc/Administration-guide/System-installation/index.md b/doc/Administration-guide/System-installation/index.md index eee602ab9f..85d31f673a 100644 --- a/doc/Administration-guide/System-installation/index.md +++ b/doc/Administration-guide/System-installation/index.md @@ -97,14 +97,6 @@ If you need to install and configure Kaa components on a single Linux node refer To learn how to create kaa-node cluster refer to [Node cluster setup](Cluster-setup) documentation page. -### AWS deployment. - -You can either install Kaa server as described on this page or run it on [Amazon EC2](Planning-your-deployment/#aws-deployment-preparation). - -### Planning your deployment - -For more information about environment setup please refer to [Planning your deployment](Planning-your-deployment/) documentation page. - ## Troubleshooting Common issues covered in this [guide](../Troubleshooting). \ No newline at end of file diff --git a/doc/Administration-guide/index.md b/doc/Administration-guide/index.md index 77cc404c36..0688ac3d71 100644 --- a/doc/Administration-guide/index.md +++ b/doc/Administration-guide/index.md @@ -12,7 +12,7 @@ The intention of this guide is to cover Kaa platform administrative tasks. # Sections overview This guide provide the overview of [key system components]({{root_url}}Administration-guide/System-components-overview/) from the administration point of -view. Helps with [planning your deployment]({{root_url}}Administration-guide/System-installation/Planning-your-deployment/), provides an overview of +view. Helps with planning your deployment, provides an overview of [Kaa platform installation]({{root_url}}Administration-guide/System-installation/) on a [single Linux node]({{root_url}}Administration-guide/System-installation/Single-node-installation/) or [cluster of Linux nodes]({{root_url}}Administration-guide/System-installation/Cluster-setup/). After installation @@ -20,6 +20,6 @@ view. Helps with [planning your deployment]({{root_url}}Administration-guide/Sys [Tenants and applications management]({{root_url}}Administration-guide/Tenants-and-applications-management/) with [Users management]({{root_url}}Administration-guide/Users-management/) guides explains how to manage tenants, applications and users in Kaa Admin UI. [Upgrading your instance]({{root_url}}Administration-guide/Upgrading-your-instance/) helps migrate to the new Kaa platform version. -[Data migration]({{root_url}}Administration-guide/Data-migration/) show how to migrate Kaa configuration and data across clusters. [Troubleshooting]({{root_url}}Administration-guide/Troubleshooting/) explains how to resolve some common issues while using Kaa as well as how to report issues to the Kaa Crew for getting help. + diff --git a/doc/Customization-guide/Customizable-system-components/Active-load-balancing-and-EP-failover/index.md b/doc/Customization-guide/Customizable-system-components/Active-load-balancing-and-EP-failover/index.md deleted file mode 100644 index 39a6a40e4e..0000000000 --- a/doc/Customization-guide/Customizable-system-components/Active-load-balancing-and-EP-failover/index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -layout: page -title: Active load balancing and EP failover -permalink: /:path/ -sort_idx: 20 ---- diff --git a/doc/Customization-guide/Endpoint-SDKs/C++-SDK/Architecture-overview/index.md b/doc/Customization-guide/Endpoint-SDKs/C++-SDK/Architecture-overview/index.md deleted file mode 100644 index 46adb86cc5..0000000000 --- a/doc/Customization-guide/Endpoint-SDKs/C++-SDK/Architecture-overview/index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -layout: page -title: Architecture overview -permalink: /:path/ -sort_idx: 10 ---- diff --git a/doc/Customization-guide/Endpoint-SDKs/C++-SDK/Compatibility-and-dependencies/index.md b/doc/Customization-guide/Endpoint-SDKs/C++-SDK/Compatibility-and-dependencies/index.md deleted file mode 100644 index 2ba9e0a831..0000000000 --- a/doc/Customization-guide/Endpoint-SDKs/C++-SDK/Compatibility-and-dependencies/index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -layout: page -title: Compatibility and dependencies -permalink: /:path/ -sort_idx: 30 ---- diff --git a/doc/Customization-guide/Endpoint-SDKs/C++-SDK/Environment-setup/index.md b/doc/Customization-guide/Endpoint-SDKs/C++-SDK/Environment-setup/index.md deleted file mode 100644 index be4dceaf14..0000000000 --- a/doc/Customization-guide/Endpoint-SDKs/C++-SDK/Environment-setup/index.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -layout: page -title: Environment setup -permalink: /:path/ -sort_idx: 20 ---- -How to setup development environment diff --git a/doc/Customization-guide/Endpoint-SDKs/C++-SDK/index.md b/doc/Customization-guide/Endpoint-SDKs/C++-SDK/index.md deleted file mode 100644 index 8d260b82d1..0000000000 --- a/doc/Customization-guide/Endpoint-SDKs/C++-SDK/index.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -layout: page -title: C++ -permalink: /:path/ -sort_idx: 20 ---- -Directory structure, templates structure, other specific to SDK type things. diff --git a/doc/Customization-guide/Endpoint-SDKs/C-SDK/Architecture-overview/index.md b/doc/Customization-guide/Endpoint-SDKs/C-SDK/Architecture-overview/index.md deleted file mode 100644 index 46adb86cc5..0000000000 --- a/doc/Customization-guide/Endpoint-SDKs/C-SDK/Architecture-overview/index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -layout: page -title: Architecture overview -permalink: /:path/ -sort_idx: 10 ---- diff --git a/doc/Customization-guide/Endpoint-SDKs/C-SDK/Compatibility-and-dependencies/index.md b/doc/Customization-guide/Endpoint-SDKs/C-SDK/Compatibility-and-dependencies/index.md deleted file mode 100644 index 8d5a5755a2..0000000000 --- a/doc/Customization-guide/Endpoint-SDKs/C-SDK/Compatibility-and-dependencies/index.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -layout: page -title: Compatibility and dependencies -permalink: /:path/ -sort_idx: 60 ---- -List of major 3-rd party dependencies, their versions and licenses. diff --git a/doc/Customization-guide/Endpoint-SDKs/C-SDK/Environment-setup/Nix-guide/index.md b/doc/Customization-guide/Endpoint-SDKs/C-SDK/Environment-setup/Nix-guide/index.md deleted file mode 100644 index e4739e1b9f..0000000000 --- a/doc/Customization-guide/Endpoint-SDKs/C-SDK/Environment-setup/Nix-guide/index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -layout: page -title: Development environment setup -permalink: /:path/ -sort_idx: 10 ---- diff --git a/doc/Customization-guide/Endpoint-SDKs/C-SDK/Environment-setup/index.md b/doc/Customization-guide/Endpoint-SDKs/C-SDK/Environment-setup/index.md deleted file mode 100644 index 8b5cc6e777..0000000000 --- a/doc/Customization-guide/Endpoint-SDKs/C-SDK/Environment-setup/index.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -layout: page -title: Environment-setup -permalink: /:path/ -sort_idx: 20 ---- -How to setup development environment diff --git a/doc/Customization-guide/Endpoint-SDKs/C-SDK/Other-guides/index.md b/doc/Customization-guide/Endpoint-SDKs/C-SDK/Other-guides/index.md deleted file mode 100644 index ad537cb15a..0000000000 --- a/doc/Customization-guide/Endpoint-SDKs/C-SDK/Other-guides/index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -layout: page -title: Other guides -permalink: /:path/ -sort_idx: 50 ---- diff --git a/doc/Customization-guide/Endpoint-SDKs/C-SDK/Porting-guide/index.md b/doc/Customization-guide/Endpoint-SDKs/C-SDK/Porting-guide/index.md deleted file mode 100644 index 41f685e7f8..0000000000 --- a/doc/Customization-guide/Endpoint-SDKs/C-SDK/Porting-guide/index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -layout: page -title: Porting guide -permalink: /:path/ -sort_idx: 40 ---- diff --git a/doc/Customization-guide/Endpoint-SDKs/C-SDK/Testing-guide/index.md b/doc/Customization-guide/Endpoint-SDKs/C-SDK/Testing-guide/index.md deleted file mode 100644 index 8ca05d02a4..0000000000 --- a/doc/Customization-guide/Endpoint-SDKs/C-SDK/Testing-guide/index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -layout: page -title: Testing guide -permalink: /:path/ -sort_idx: 30 ---- diff --git a/doc/Customization-guide/Endpoint-SDKs/C-SDK/index.md b/doc/Customization-guide/Endpoint-SDKs/C-SDK/index.md deleted file mode 100644 index 7e2ca3bcb7..0000000000 --- a/doc/Customization-guide/Endpoint-SDKs/C-SDK/index.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -layout: page -title: C -permalink: /:path/ -sort_idx: 10 ---- -Directory structure, templates structure, other specific to SDK type things. diff --git a/doc/Customization-guide/Endpoint-SDKs/Java-SDK/Architecture-overview/index.md b/doc/Customization-guide/Endpoint-SDKs/Java-SDK/Architecture-overview/index.md deleted file mode 100644 index 46adb86cc5..0000000000 --- a/doc/Customization-guide/Endpoint-SDKs/Java-SDK/Architecture-overview/index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -layout: page -title: Architecture overview -permalink: /:path/ -sort_idx: 10 ---- diff --git a/doc/Customization-guide/Endpoint-SDKs/Java-SDK/Compatibility-and-dependencies/index.md b/doc/Customization-guide/Endpoint-SDKs/Java-SDK/Compatibility-and-dependencies/index.md deleted file mode 100644 index 2ba9e0a831..0000000000 --- a/doc/Customization-guide/Endpoint-SDKs/Java-SDK/Compatibility-and-dependencies/index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -layout: page -title: Compatibility and dependencies -permalink: /:path/ -sort_idx: 30 ---- diff --git a/doc/Customization-guide/Endpoint-SDKs/Java-SDK/Environment-setup/index.md b/doc/Customization-guide/Endpoint-SDKs/Java-SDK/Environment-setup/index.md deleted file mode 100644 index 8b5cc6e777..0000000000 --- a/doc/Customization-guide/Endpoint-SDKs/Java-SDK/Environment-setup/index.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -layout: page -title: Environment-setup -permalink: /:path/ -sort_idx: 20 ---- -How to setup development environment diff --git a/doc/Customization-guide/Endpoint-SDKs/Java-SDK/index.md b/doc/Customization-guide/Endpoint-SDKs/Java-SDK/index.md deleted file mode 100644 index aff241fde3..0000000000 --- a/doc/Customization-guide/Endpoint-SDKs/Java-SDK/index.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -layout: page -title: Java -permalink: /:path/ -sort_idx: 30 ---- -## Architecture overview - -### Lifecycle of client -Diagram below describe lifecycle of Kaa client – allowed transitions between states. - -![lifecycle](img/lifecycle.png) - -### High level overview of Kaa client structure -All calls of Kaa client APIs go through several layers those can be presented by the next scheme: - -![layers](img/layers.png) - -When we call some method on client for example `start()` Kaa client delegate responsibility for processing call to appropriate _manager_, -in our case – `BootstrapManager`. The manager calls corresponding method of _BootstrapTransport_ in turn. Next, the transport address to -`KaaChannelManager` that creates `SyncTask` and put it in queue from which `SyncWorker` will take **task** and call `sync()` -on `KaaDataChannel` (`DefaultBootstrapChannell`). And finally, channel makes request to server. - - -![sequence](img/sequence.png) - ->**NOTE:** `SyncWorker` – class that extends `Thread` and responsible for serving ongoing tasks from client to channels. -ChannelManager creates for each channel new instance of this class. \ No newline at end of file diff --git a/doc/Customization-guide/Endpoint-SDKs/Objective-C-SDK/Architecture-overview/index.md b/doc/Customization-guide/Endpoint-SDKs/Objective-C-SDK/Architecture-overview/index.md deleted file mode 100644 index 46adb86cc5..0000000000 --- a/doc/Customization-guide/Endpoint-SDKs/Objective-C-SDK/Architecture-overview/index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -layout: page -title: Architecture overview -permalink: /:path/ -sort_idx: 10 ---- diff --git a/doc/Customization-guide/Endpoint-SDKs/Objective-C-SDK/Compatibility-and-dependencies/index.md b/doc/Customization-guide/Endpoint-SDKs/Objective-C-SDK/Compatibility-and-dependencies/index.md deleted file mode 100644 index 2ba9e0a831..0000000000 --- a/doc/Customization-guide/Endpoint-SDKs/Objective-C-SDK/Compatibility-and-dependencies/index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -layout: page -title: Compatibility and dependencies -permalink: /:path/ -sort_idx: 30 ---- diff --git a/doc/Customization-guide/Endpoint-SDKs/Objective-C-SDK/Environment-setup/index.md b/doc/Customization-guide/Endpoint-SDKs/Objective-C-SDK/Environment-setup/index.md deleted file mode 100644 index be4dceaf14..0000000000 --- a/doc/Customization-guide/Endpoint-SDKs/Objective-C-SDK/Environment-setup/index.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -layout: page -title: Environment setup -permalink: /:path/ -sort_idx: 20 ---- -How to setup development environment diff --git a/doc/Customization-guide/Endpoint-SDKs/Objective-C-SDK/index.md b/doc/Customization-guide/Endpoint-SDKs/Objective-C-SDK/index.md deleted file mode 100644 index aeaf90e5c3..0000000000 --- a/doc/Customization-guide/Endpoint-SDKs/Objective-C-SDK/index.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -layout: page -title: Objective-C -permalink: /:path/ -sort_idx: 40 ---- -Directory structure, templates structure, other specific to SDK type things. diff --git a/doc/Customization-guide/Endpoint-SDKs/index.md b/doc/Customization-guide/Endpoint-SDKs/index.md deleted file mode 100644 index b98df85371..0000000000 --- a/doc/Customization-guide/Endpoint-SDKs/index.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -layout: page -title: Endpoint-SDKs -permalink: /:path/ -sort_idx: 30 ---- -Explain basic concepts of how SDKs are generated. Templates, bootstrap information. diff --git a/doc/Customization-guide/How-to-contribute/Git-flow/index.md b/doc/Customization-guide/How-to-contribute/Git-flow/index.md index 5bd9854341..43369ef3b2 100644 --- a/doc/Customization-guide/How-to-contribute/Git-flow/index.md +++ b/doc/Customization-guide/How-to-contribute/Git-flow/index.md @@ -7,15 +7,15 @@ sort_idx: 10 {% include variables.md %} -We use a [GitHub flow](https://guides.github.com/introduction/flow/). That means, you should branch from the main repository and contribute back via pull requests. That's de facto standard workflow on GitHub with a couple of additional rules. +We use a [GitHub flow](https://guides.github.com/introduction/flow/). That means, you should branch from the main repository and contribute back via pull requests. That's de facto standard workflow on GitHub. -## Main branches +## Branches -We have two main long-running branches: `master` and `develop`. `master` always points to the latest released version—**no pull requests are accepted to master**. `develop` is a main development branch; it reflects the latest development status. Usually, new changes should go there. +The `master` branch represents latest development version of Kaa. Most changes should go there. -There may be a number of short-living branches; most of them are used for specific jira tickets. However, `release-xxx` branches are special. They are pre-release branches which are used to test and stabilize everything before actual release. (Actual releases are tagged.) **Only bugfixes are accepted to release branches.** +There are also `release-x.x` branches, which are stabilizing branches used for releasing maintenance releases. (All actual releases are tagged.) -There may be develop branches for releases following after the next one; they took a form of `develop-xxx` (e.g., `develop-1.0.0`). Usually, you should avoid committing to them and use branches for specific features. +If you want to backport a bug fix, open your pull request against the appropriate release branch. ## Clonning @@ -36,32 +36,6 @@ The rest of the guide assumes the above command was executed, so `upstream` poin ## Merge requirements -### Branch off from appropriate branch - -First of all, you should decide what branch you will base your changes on. Generally, that's the `develop` branch. - -The rules are the following: - -- `release-xxx` if your change is a **bugfix** that should go to the release *xxx* and there is such branch. That's either updates to patch releases or pre-release hotfixes. -- `develop` if you want your change in the next minor version bump. (Minor is a second version component. e.g. 0.8.1 -> 0.9.0 is a minor bump. Note also that 0.9.1 -> 1.0.0 is a minor bump as well.) -- `develop-xxx` if your change shouldn't go to the next release. Usually, you know that; if you don't, that's a wrong branch. -- `master` -- never. - -Consult fix version field in Jira to see release version for your change. - -Note also that that's is a branch you will open pull request against later. - -It's always a good idea to fetch newest changes from the branch before starting: - -```sh -git checkout develop # assuming you branch off from develop -git pull -``` - -### Opened against appropriate branch - -You must open the pull request against the branch you've branched from. - ### No merge conflicts Resolve any merge conflicts that may arise. (GitHub will display a warning on the pull request page.) @@ -82,14 +56,14 @@ GitHub will automatically update your pull request. ### Tests -All pull requests are automatically checked with Travis and Jenkins. If any of the tests fails, fix it or describe why it can't be done. +All pull requests are automatically checked with Travis and Jenkins. If any of the tests fails, fix it or describe why that can't be done. ### Review -The pull request must have at least two LGTM (Looks Good To Me) from the members of the team responsible for a changed component and shouldn't have any open review questions. +The pull request must have at least two LGTM (Looks Good To Me) from the members of the team responsible for a changed component and should have no unresolved review questions. ## Gatekeepers -Gatekeeper is a person who is responsible for the final review and merge; he is also responsible for managing git repositories. That is the only person who can write to master, develop and release branches. +Gatekeeper is a person who is responsible for the final review and merge; he is also responsible for managing git repositories. That is the only person who can write to master and release branches. If the pull request satisfies all merge requirements, one of gatekeepers should do a final review and merge. diff --git a/doc/Customization-guide/How-to-contribute/Jira-guide/index.md b/doc/Customization-guide/How-to-contribute/Jira-guide/index.md deleted file mode 100644 index 342c0bdc23..0000000000 --- a/doc/Customization-guide/How-to-contribute/Jira-guide/index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -layout: page -title: Jira guide -permalink: /:path/ -sort_idx: 20 ---- diff --git a/doc/Customization-guide/How-to-contribute/index.md b/doc/Customization-guide/How-to-contribute/index.md index 90dfd6d214..9c98049192 100644 --- a/doc/Customization-guide/How-to-contribute/index.md +++ b/doc/Customization-guide/How-to-contribute/index.md @@ -22,7 +22,7 @@ You can report your findings by creating a bug in [Jira®](http://jira.kaaprojec If you are willing to contribute to the Kaa code base, or to submit sample applications for Kaa Sandbox, you will need to register at [Kaa public Jira](http://jira.kaaproject.org/browse/KAA/), and then fill out and sign the [Individual Contributor Licensing Agreement](http://www.kaaproject.org/Uploads/ICLA.pdf) (ICLA). If you are contributing on behalf of an organization, you would also need to sign the [Corporate Contributor License Agreement](http://www.kaaproject.org/Uploads/CCLA.pdf) (CCLA). Please sign, scan and send the forms to [legal@kaaproject.org](mailto:legal@kaaproject.org). -To contribute to the source code, you will need to create a ticket describing the proposed change in [Jira](http://jira.kaaproject.org/browse/KAA/). See our [Jira guide]({{root_url}}Customization-guide/How-to-contribute/Jira-guide) for Jira procedure. +To contribute to the source code, you will need to create a ticket describing the proposed change in [Jira](http://jira.kaaproject.org/browse/KAA/). We prefer that you contribute by submitting [GitHub pull requests](https://help.github.com/articles/using-pull-requests/) and posting a pull request link in corresponding Jira tickets. The Kaa open-source project is located [here](https://github.com/kaaproject/kaa). See our [Git flow]({{root_url}}Customization-guide/How-to-contribute/Git-flow/) guide for more details. diff --git a/doc/Customization-guide/Kaa-Server/Architecture overview/index.md b/doc/Customization-guide/Kaa-Server/Architecture overview/index.md deleted file mode 100644 index 46adb86cc5..0000000000 --- a/doc/Customization-guide/Kaa-Server/Architecture overview/index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -layout: page -title: Architecture overview -permalink: /:path/ -sort_idx: 10 ---- diff --git a/doc/Customization-guide/Kaa-Server/Building server from source/index.md b/doc/Customization-guide/Kaa-Server/Building server from source/index.md deleted file mode 100644 index dd9c2c1bbc..0000000000 --- a/doc/Customization-guide/Kaa-Server/Building server from source/index.md +++ /dev/null @@ -1,90 +0,0 @@ ---- -layout: page -title: Building server from source -permalink: /:path/ -sort_idx: 20 ---- - -{% include variables.md %} - -* TOC -{:toc} - - -This page describes how to build the Kaa server from the source code available on [GitHub](https://github.com/kaaproject/kaa). -Before building the Kaa server from source, ensure that [Oracle JDK 8](http://www.oracle.com/technetwork/java/javase/downloads/index.html) and [Apache Maven](https://maven.apache.org/) are installed on your machine. - -### Fetching source code - -It is allowed to use any Git client to fetch the Kaa source code from the repository. - -[Set up your Git configuration](https://git-scm.com/book/tr/v2/Customizing-Git-Git-Configuration) (at least the username and email) and download Kaa repository as follows: - -```bash - $ git clone https://github.com/kaaproject/kaa.git -``` - -To build Kaa node Debian/RPM packages, execute the following command. - - -
    -

    - -```bash - $ mvn clean install -P jenkins,compile-gwt,mariadb-dao,mongo-dao -Dappenders -Dverifiers -DskipTests -``` - -

    - -```bash - $ mvn clean install -P jenkins,compile-gwt,mariadb-dao,mongo-dao,build-rpm -Dappenders -Dverifiers -DskipTests -``` - -

    - - -> **NOTE:** The Debian build will work correctly on both Linux and Windows operation systems, while the RPM build will work only on Linux operated machines with the RPM tool installed. - -> **NOTE:** If you want to enable execution of tests than remove "-DskipTests" suffix in mvn command. - - -## Available maven profiles - -| Maven profile | Description | -|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -|build-rpm | As implied in the profile name, it will force to generate .rpm packages. This is useful if you are going to install Kaa on .rpm based Linux distribution (Red Hat Linux, Oracle Linux, etc.)| -|compile-gwt | Compiles administration user interface. Can be skipped during regular builds. | -|compile-client-c | Compiles [C endpoint SDK](http://docs.kaaproject.org/display/KAA/Linux#Linux-CendpointSDK) and executes tests. | -|compile-client-cpp | Compiles [C++ endpoint SDK](http://docs.kaaproject.org/display/KAA/Linux#Linux-C++endpointSDK) and executes tests. | -|cassandra | Compiles [Cassandra](http://cassandra.apache.org/) log appender. | -|couchbase | Compiles [Couchbase](http://www.couchbase.com/) log appender. | -|kafka | Compiles [Kafka](http://kafka.apache.org/) log appender. | -|compile-client-objc | Compiles [Objective-C endpoint SDK](http://docs.kaaproject.org/display/KAA/iOS) and executes tests. Compiling only possible on OS X and CentOS operation systems. | -|oracle-nosql | Compiles [Oracle NoSQL](http://www.oracle.com/us/products/database/nosql/overview/index.html) log appender. | -|jenkins | Forces Kaa to execute integration tests. | -|cassandra-dao | Forces Kaa to use [Cassandra](http://cassandra.apache.org/) NoSQL storage. If none is set MongoDB used by default. | -|mariadb-dao | Forces Kaa to use [MariaDB](https://mariadb.org/) SQL storage. Enabled by default. | -|license | Forces Kaa to use [Maven License](http://code.mycila.com/license-maven-plugin/) plugin. | -|postgresql-dao | Forces Kaa to use [PostgreSQL](http://www.postgresql.org/) SQL storage. If none is set MariaDB used by default. | -|mongo-dao | Forces Kaa to use [MongoDB](https://www.mongodb.org/) NoSQL storage. Enabled by default. | -|compile-thrift | Forces [Thrift](https://thrift.apache.org/) compiler to generate code from thrift files. | - - - -## Build artifacts - -The following command can be used to browse the Kaa node build artifacts in case of successful build. - - $ ls server/node/target/kaa-node.deb - - $ ls server/node/target/rpm/kaa-node/RPMS/noarch/kaa-node*.rpm - -## Installing Kaa - -You can deploy Kaa server as a single node or as multi node cluster, for more details refer to corresponding pages: - -* [Single node installation]({{root_url}}Administration-guide/System-installation/Single-node-installation/) -* [Node cluster setup]({{root_url}}Administration-guide/System-installation/Cluster-setup/) \ No newline at end of file diff --git a/doc/Customization-guide/Kaa-Server/Compatibility-and-dependencies/index.md b/doc/Customization-guide/Kaa-Server/Compatibility-and-dependencies/index.md deleted file mode 100644 index 5e448df547..0000000000 --- a/doc/Customization-guide/Kaa-Server/Compatibility-and-dependencies/index.md +++ /dev/null @@ -1,94 +0,0 @@ ---- -layout: page -title: Compatibility and dependencies -permalink: /:path/ -sort_idx: 30 ---- - -* [Kaa server, Apache 2.0 license](#kaa-server-apache-20-license) -* [Kaa server, non-Apache 2.0 license](#kaa-server-non-apache-20-license) -* [Kaa server, testing](#kaa-server-testing) -* [Kaa endpoint](#kaa-endpoint) - -The following third-party software components are used in Kaa. - -# Kaa server, Apache 2.0 license - -| Component | Version | Licence | Language | -|-------------------------------------------|-----------------|--------------------|----------| -| Netty | 4.0.34.Final | Apache License 2.0 | Java | -| Akka | 2.4.1 | Apache License 2.0 | Scala | -| Google GWT | 2.7.0 | Apache License 2.0 | Java | -| Spring Framework | 4.0.2.RELEASE | Apache License 2.0 | Java | -| Apache Commons | misc | Apache License 2.0 | Java | -| Apache Http | 4.3.2 | Apache License 2.0 | Java | -| Apache Avro | 1.7.5 | Apache License 2.0 | Java | -| Apache Ant | 1.9.4 | Apache License 2.0 | Java | -| Apache Thrift | 0.9.3 | Apache License 2.0 | Java | -| Apache Curator | 2.9.0 | Apache License 2.0 | Java | -| Apache Velocity | 1.7 | Apache License 2.0 | Java | -| Apache ZooKeeper | 3.4.6 | Apache License 2.0 | Java | -| Twitter Commons | 0.0.64 | Apache License 2.0 | Java | -| Jackson | 2.4.1 | Apache License 2.0 | Java | -| MongoDB Driver* | 3.0.1 | Apache License 2.0 | Java | -| Oracle NoSQL Driver* | 3.1.7 | Apache License 2.0 | Java | -| CDAP Stream client* | 1.0.1 | Apache License 2.0 | Java | -| Apache Flume NG* | 1.5.0.1 | Apache License 2.0 | Java | -| Ehcache | 2.8.1 | Apache License 2.0 | Java | -| Log4j | 1.2.17 | Apache License 2.0 | Java | -| Guava GWT | 18.0 | Apache License 2.0 | Java | -| Joda time | 2.2 | Apache License 2.0 | Java | -| HikariCP | 2.4.2 | Apache License 2.0 | Java | -| DataStax Java Driver for Apache Cassandra | 3.0.0 | Apache License 2.0 | Java | -| Javassist | 3.18.1-GA | Apache License 2.0 | Java | -| Metrics Core | 3.1.0 | Apache License 2.0 | Java | -| Signpost | 1.2.1.2 | Apache License 2.0 | Java | -| Jetty | 9.2.2.v20140723 | Apache License 2.0 | Java | - - -"\*" - Depends on configuration of nosql database provider and/or log appenders. - -# Kaa server, non-Apache 2.0 license - -| Component | Version | Licence | Language | -|---------------------|-----------------|-------------------------------------------------------------------|----------| -| Hibernate Framework | 4.3.11.Final | [LGPL v2.1](http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html) | Java | -| Json | 20080701 | Json License [http://www.json.org/license.html](http://www.json.org/license.html) | Java | -| Scala library | 2.11.7 | BSD-like [http://www.scala-lang.org/downloads/license.html](http://www.scala-lang.org/downloads/license.html) | Scala | -| SLF4j | 1.7.7 | MIT License | Java | -| Jline | 2.11 | BSD | Java | -| PostgreSQL Driver | 9.3-1101-jdbc41 | BSD | Java | -| Javax Activation | 1.1 | Common Development and Distribution License (CDDL) v1.0 | Java | -| Javax Servlet-api | 2.5 | Common Development and Distribution License (CDDL) v1.0 | Java | -| Javax Mail | 1.4 | Common Development and Distribution License (CDDL) v1.0 | Java | -| Logback | 1.1.2 | Eclipse Public License - v 1.0; GNU Lesser General Public License | Java | -| AspectJ | 1.7.4 | Eclipse Public License - v 1.0 | Java | -| Base64 | 2.3.8 | Public domain | Java | -| Janino2.6.1New | BSD | License | Java | - -# Kaa server, testing - -| Component | Version | Licence | Language | -|----------------------|---------|-----------------------------------|----------| -| JUnit | 4.11 | Common Public License Version 1.0 | Java | -| Mockito | 1.9.5 | MIT License | Java | -| Embedded Mongo DB | 1.42 | Apache License 2.0 | Java | -| net.java.dev.jna:jna | 4.0.0 | LGPL, version 2.1 | Java | -| H2 Database Engine | 1.4.179 | MPL 2.0, and EPL 1.0 | Java | -| Powermock | 1.6.4 | Apache | Java | - -# Kaa endpoint - -| Component | Version | Licence | Language | -|--------------------------------------------|---------|------------------------|-------------| -| Apache Avro | 1.7.6 | Apache License 2.0 | Java/C++ | -| Boost | 1.54 | Boost Software License | C++ | -| Botan | 1.11 | BSD-2 license | C++ | -| SQLite | - | - | C++ | -| SLF4J | 1.7.6 | MIT License | Java | -| Apache HttpComponents | 4.3.2 | Apache License 2.0 | Java | -| EqualsVerifier (for unit testing purposes) | 1.7.6 | Apache License 2.0 | Java | -| JUnit (for unit testing purposes) | 4.11 | Common Public License | Java | -| Mockito (for unit testing purposes) | 1.9.5 | MIT License | Java | -| CocoaPods | 0.39.0 | СocoaPods License | Objective-C | -| XCode | 7.2 | Apple Software License | Objective-C | diff --git a/doc/Customization-guide/Kaa-Server/Development-environment-setup/index.md b/doc/Customization-guide/Kaa-Server/Development-environment-setup/index.md deleted file mode 100644 index f4a0afcb13..0000000000 --- a/doc/Customization-guide/Kaa-Server/Development-environment-setup/index.md +++ /dev/null @@ -1,892 +0,0 @@ ---- -layout: page -title: Development environment setup -permalink: /:path/ -sort_idx: 20 ---- - -{% include variables.md %} - -- [Creating custom log appender](#creating-custom-log-appender) - - [Configuration schema](#configuration-schema) - - [Log appender implementation](#log-appender-implementation) - - [Log appender descriptor](#log-appender-descriptor) - - [Log appender provisioning](#log-appender-provisioning) -- [Creating custom transport](#creating-custom-transport) - - [Introduction](#introduction) - - [Transport configuration schema](#transport-configuration-schema) - - [Transport descriptor implementation](#transport-descriptor-implementation) - - [Transport implementation](#transport-implementation) - - [Transport provisioning](#transport-provisioning) -- [Creating custom transport channel](#creating-custom-transport-channel) - - [Implement the KaaDataChannel interface (Java client)](#implement-the-kaadatachannel-interface-java-client) - - [Register your own channel using the Kaa Channel Manager](#register-your-own-channel-using-the-kaa-channel-manager) - - [Step 1 - Get an instance of KaaDataMultiplexer ](#step-1---get-an-instance-ofkaadatamultiplexer) - - [Step 2 - Prepare a request collecting information from the services](#step-2---prepare-a-requestcollecting-information-from-the-services) - - [Step 3 - Send the prepared request to the server and receive a response](#step-3---send-the-prepared-request-to-the-server-and-receive-a-response) - - [Step 4 - Get an instance of KaaDataDemultiplexer ](#step-4---get-an-instance-ofkaadatademultiplexer) - - [Step 5 - Push a response to the Kaa SDK](#step-5---push-a-response-to-the-kaa-sdk) -- [Creating custom user verifier](#creating-custom-user-verifier) - - [Configuration schema](#configuration-schema-1) - - [User verifier implementation](#user-verifier-implementation) - - [User verifier descriptor](#user-verifier-descriptor) - - [User verifier provisioning](#user-verifier-provisioning) - -This guide explains how to create your own versions of such Kaa entities as transports, log appenders, and user verifiers. Kaa supports various kinds of customization to provide you with maximum flexibility and freedom of choice for your particular project needs. - -In order for the guide to be useful, make sure that you have a development environment set up, including a Kaa server instance. We recommend that you use Kaa Sandbox with this guide, but you can use a Kaa cluster instead, if you like. - -# Creating custom log appender - -To implement a custom log appender, you need to complete the following steps. - -1. Design and compile a configuration schema. -2. Implement the log appender based on AbstractLogAppender. -3. Develop the log appender descriptor. -4. Provision the log appender. - -We recommend that you use one of the existing [log appender implementations](https://github.com/kaaproject/kaa/tree/v0.9.0/server/appenders) as a reference. - -## Configuration schema - -A log appender configuration schema is an Avro compatible schema that defines configuration parameters of the log appender. The following parameters in the schema affect Kaa Admin UI layout. - -* minRowCount - specifies a minimum number of rows in a UI table (only for arrays in the schema) -* displayName - displays the name of the field on UI -* displayNames - displays the name of each enumeration symbol on UI (only for enumeration fields in the schema) -* default - displays the default value of the field on UI -* optional - defines whether the field on UI is optional or mandatory -* weight - defines a relative width of the corresponding column on UI (only for arrays in the schema) - -```json - { - "namespace":"org.kaaproject.kaa.schema.sample", - "type":"record", - "name":"CustomAppenderConfiguration", - "fields":[ - { - "name":"servers", - "displayName":"Your server list", - "minRowCount":1, - "type":{ - "type":"array", - "items":{ - "namespace":"com.company.kaa.appender", - "type":"record", - "name":"Server", - "fields":[ - { - "name":"host", - "displayName":"Host", - "weight":0.75, - "default":"localhost", - "type":"string" - }, - { - "name":"port", - "displayName":"Port", - "weight":0.25, - "default":80, - "type":"int" - } - ] - } - } - }, - { - "name":"StringParameter", - "displayName":"String parameter name", - "type":"string" - }, - { - "name":"IntegerParameter", - "displayName":"Integer parameter name", - "default":1, - "optional":true, - "type":[ - "int", - "null" - ] - } - ] - } -``` - - -Once you have prepared your schema, you can compile it using the following command. - -``` -java -jar /path/to/avro-tools-1.7.7.jar compile schema -``` - -Please refer to [Compiling the schema](http://avro.apache.org/docs/current/gettingstartedjava.html#Compiling+the+schema) for more information. It is also possible to integrate the schema compilation with [avro-maven-plugin](http://avro.apache.org/docs/current/gettingstartedjava.html). - -## Log appender implementation - -All Kaa log appenders extend generic abstract class org.kaaproject.kaa.server.common.log.shared.appender.AbstractLogAppender. The following code example illustrates the implementation of a custom log appender. - -```Java -package org.kaaproject.kaa.sample.appender; - -import org.kaaproject.kaa.schema.sample.CustomAppenderConfiguration; -import org.kaaproject.kaa.common.dto.logs.LogAppenderDto; -import org.kaaproject.kaa.common.dto.logs.LogEventDto; -/** - * - * Sample appender implementation that uses {@link CustomAppenderConfiguration} as configuration. - * - */ -public class CustomLogAppender extends AbstractLogAppender { - - /** - * Inits the appender from configuration. - * - * @param appender the metadata object that contains useful info like application token, tenant id, etc. - * @param configuration the configuration object that you have specified during appender provisioning. - */ - @Override - protected void initFromConfiguration(LogAppenderDto appender, CustomAppenderConfiguration configuration) { - //Do some initialization here. - } - - /** - * Consumes and delivers logs. - * - * @param logEventPack container for log events with some metadata like log event schema. - * @param header additional data about log event source (endpoint key hash, application token, header version, timestamp). - */ - @Override - public void doAppend(LogEventPack logEventPack, RecordHeader header) { - //Append logs to your system here. - } - - /** - * Closes this appender and releases any resources associated with it. - * - */ - @Override - public void close() { - //Free allocated resources here. - } -} -``` - -## Log appender descriptor - -A log appender descriptior provides Kaa with the information on how to locate and configure your custom log appender. To implement a log appender descriptor, you need to implement the AppenderConfig interface at first. - -It is also important to provide your class with the @KaaPluginConfig annotation. This annotation helps Kaa Admin UI to find all available log appenders in the class path. - -**NOTE** -A log appender descriptor is optional if you are going to configure your log appenders using only REST API. - -The following code example illustrates the implementation of a log appender descriptor. - -```Java -package org.kaaproject.kaa.sample.appender.config; - -import org.apache.avro.Schema; -import org.kaaproject.kaa.schema.sample.CustomAppenderConfiguration; -import org.kaaproject.kaa.server.common.log.shared.annotation.KaaAppenderConfig; -import org.kaaproject.kaa.server.common.log.shared.config.AppenderConfig; - -/** - * - * Sample descriptor for org.kaaproject.kaa.sample.appender.CustomLogAppender appender. - * - */ -@KaaPluginConfig(pluginType = PluginType.LOG_APPENDER) -public class CustomAppenderDescriptor implements AppenderConfig { - - - public CustomAppenderDescriptor() { - } - /** - * Name of the appender will be used in Admin UI - */ - @Override - public String getName() { - return "Custom appender"; - } - /** - * Returns name of the appender class. - */ - @Override - public String getLogAppenderClass() { - return "org.kaaproject.kaa.sample.appender.CustomLogAppender"; - } - /** - * Returns avro schema of the appender configuration. - */ - @Override - public Schema getConfigSchema() { - return CustomAppenderConfiguration.getClassSchema(); - } -} -``` - -## Log appender provisioning - -To provision your log appender, do the following: - -1. Build your log appender using next command: - -``` - $ mvn clean install -``` - -2. Place the log appender \*.jar from /target folder into the /usr/lib/kaa-node/lib folder -3. If you using different package than org.kaaproject.kaa.\* you need to edit kaa-node.properties file in /usr/lib/kaa-node/conf folder. Specify additional package to scan kaa plugins configuration in parameter additional_plugins_scan_package. -4. Restart kaa-node service: - -``` - $ sudo service kaa-node restart -``` - -5. Use [Admin UI999](999) or [REST API99](999) to create/update/delete your log appender instances. - -# Creating custom transport - -## Introduction - -To implement a custom transport, you need to complete the following steps. - -1. Design and compile a configuration schema. -2. Implement the [TransportConfig](https://github.com/kaaproject/kaa/tree/v0.9.0/server/common/transport-shared/src/main/java/org/kaaproject/kaa/server/transport/TransportConfig.java) interface. -3. Implement [Transport](https://github.com/kaaproject/kaa/tree/v0.9.0/server/common/transport-shared/src/main/java/org/kaaproject/kaa/server/transport/Transport.java). -4. Provision the transport in a Bootstrap server and/or an Operations server. - -We recommend that you use one of the existing [transport implementations](https://github.com/kaaproject/kaa/tree/v0.9.0/server/transports) as a reference and also review the [transports design reference999](999). - -Please note that once a new transport is implemented, you will most likely need to [implement a corresponding transport channel](#creating-custom-transport-channel) for one or multiple endpoint SDK platforms. - -## Transport configuration schema - -A _transport configuration schema_ is an Avro compatible schema that defines configuration parameters for the transport. The following parameters in the schema affect Kaa Admin UI layout. - -* minRowCount - specifies a minimum number of rows in a UI table (If you are using arrays in your schema, you can specify a minimum number of elements in an array with this parameter) -* displayName - displays the name of the field on UI -* displayNames - displays the name of each enumeration symbol on UI (only for enumeration fields in the schema) -* default - displays the default value of the field on UI -* optional - defines whether the field on UI is optional or mandatory -* weight - defines a relative width of the corresponding column on UI (only for arrays in the schema) - -The following example illustrates a simple transport configuration schema with two fields (host and port). - -```json -{ - "namespace":"org.kaaproject.kaa.server.transport.custom.config", - "type":"record", - "name":"CustomConfig", - "fields":[ - { - "name":"host", - "type":"string" - }, - { - "name":"port", - "type":"int" - } - ] -} -``` - -Once you have prepared your schema, you can compile it using the following command. -`java -jar /path/to/avro-tools-1.7.7.jar compile schema ` -For more information, refer to [Compiling the schema](http://avro.apache.org/docs/current/gettingstartedjava.html#Compiling+the+schema). It is also possible to integrate the schema compilation with [avro-maven-plugin](http://avro.apache.org/docs/current/gettingstartedjava.html). - -## Transport descriptor implementation - -Once you have defined and compiled a transport configuration schema, you can proceed to the implementation of a transport descriptor. - -A transport descriptor should implement the [TransportConfig](https://github.com/kaaproject/kaa/tree/v0.9.0/server/common/transport-shared/src/main/java/org/kaaproject/kaa/server/transport/TransportConfig.java) interface and be annotated with the [KaaTransportConfig](https://github.com/kaaproject/kaa/tree/v0.9.0/server/common/transport-shared/src/main/java/org/kaaproject/kaa/server/transport/KaaTransportConfig.java) annotation for the provisioning purposes. - -**Note:** all transport descriptors should be inside the `org.kaaproject.kaa.server.transport` package or its subpackages. - -The following example illustrates a transport descriptor implementation based on the schema defined in the previous section. - -```Java -package org.kaaproject.kaa.server.transport.custom.config; - -import org.apache.avro.Schema; -import org.kaaproject.kaa.server.common.zk.ServerNameUtil; -import org.kaaproject.kaa.server.transport.KaaTransportConfig; -import org.kaaproject.kaa.server.transport.Transport; -import org.kaaproject.kaa.server.transport.TransportConfig; -import org.kaaproject.kaa.server.transport.TransportService; - -/** - * Configuration for the custom transport - */ -@KaaTransportConfig -public class CustomTransportConfig implements TransportConfig { - - private static final String CUSTOM_TRANSPORT_NAME = "org.kaaproject.kaa.server.transport.tcp"; - private static final int CUSTOM_TRANSPORT_ID = ServerNameUtil.crc32(CUSTOM_TRANSPORT_NAME); - private static final String CUSTOM_TRANSPORT_CLASS = "org.kaaproject.kaa.server.transports.tcp.transport.TcpTransport"; - private static final String CUSTOM_TRANSPORT_CONFIG = "custom-transport.config"; - - public CustomTransportConfig() { - super(); - } - - /** - * Returns the transport id. The transport id must be unique. - * - * @return the transport id - */ - @Override - public int getId() { - return CUSTOM_TRANSPORT_ID; - } - - /** - * Returns the transport name. There is no strict rule for this - * name to be unique. - * - * @return the transport name - */ - @Override - public String getName() { - return CUSTOM_TRANSPORT_NAME; - } - - /** - * Returns the class name of the {@link Transport} implementation. - * - * @return the class name of the {@link Transport} implementation - */ - @Override - public String getTransportClass() { - return CUSTOM_TRANSPORT_CLASS; - } - - /** - * Returns the avro schema of the {@link Transport} configuration. - * - * @return the avro schema of the {@link Transport} configuration - */ - @Override - public Schema getConfigSchema() { - return CustomConfig.getClassSchema(); - } - - /** - * Returns the configuration file name. This configuration file may - * be used by {@link TransportService} to initialize and configure - * the corresponding {@link Transport}. - * - * @return the configuration file name - */ - @Override - public String getConfigFileName() { - return CUSTOM_TRANSPORT_CONFIG; - } -} -``` - -## Transport implementation - -All transport implementations should implement the [Transport](https://github.com/kaaproject/kaa/tree/v0.9.0/server/common/transport-shared/src/main/java/org/kaaproject/kaa/server/transport/Transport.java) interface. We recommend extending [AbstractKaaTransport](https://github.com/kaaproject/kaa/tree/v0.9.0/server/common/transport-shared/src/main/java/org/kaaproject/kaa/server/transport/AbstractKaaTransport.java) for convenience. - -The following example illustrates a transport implementation based on the defined transport configuration schema. - -```Java -package org.kaaproject.kaa.server.transports.tcp.transport; -import java.nio.ByteBuffer; -import org.kaaproject.kaa.server.transport.AbstractKaaTransport; -import org.kaaproject.kaa.server.transport.KaaTransportConfig; -import org.kaaproject.kaa.server.transport.SpecificTransportContext; -import org.kaaproject.kaa.server.transport.Transport; -import org.kaaproject.kaa.server.transport.TransportLifecycleException; -import org.kaaproject.kaa.server.transport.custom.config.CustomConfig; - -public class CustomTransport extends AbstractKaaTransport{ - - /** - * Initialize a transport instance with a particular configuration and - * common transport properties that are accessible via the context. The configuration is an Avro - * object. The serializaion/deserialization is done using the schema specified in - * {@link KaaTransportConfig}. - * - * @param context - * the transport initialization context - * @throws TransportLifecycleException - */ - @Override - protected void init(SpecificTransportContext context) throws TransportLifecycleException { - // TODO Auto-generated method stub - } - - /** - * Retrieves the serialized connection data. This data will be used in an - * endpoint sdk to set up a connection to this transport instance. - * Used to provide implementation of {@link Transport#getConnectionInfo()}. - * - * @return the serialized connection data - */ - @Override - protected ByteBuffer getSerializedConnectionInfo() { - // TODO Auto-generated method stub - return null; - } - - /** - * Starts a transport instance. This method should block its caller thread - * until the transport is started. This method should not block its caller - * thread after the startup sequence is successfully completed. - */ - @Override - public void start() { - // TODO Auto-generated method stub - } - - /** - * Stops the transport instance. This method should block its current thread - * until the transport is stopped. The transport may be started again after it is - * stopped. - */ - @Override - public void stop() { - // TODO Auto-generated method stub - } - - /** - * Returns a min version of the transport protocol that is supported by this transport. - * Useful when a single transport instance needs to support multiple versions of the client protocol implementations. - */ - @Override - protected int getMinSupportedVersion() { - // TODO Auto-generated method stub - return 1; - } - - /** - * Returns a max version of the transport protocol that is supported by this transport. - * Useful when a single transport instance needs to support multiple versions of the client protocol implementations. - */ - @Override - protected int getMaxSupportedVersion() { - // TODO Auto-generated method stub - return 1; - } - - @Override - public Class getConfigurationClass() { - // TODO Auto-generated method stub - return CustomConfig.class; - } -} -``` - -## Transport provisioning - -To provision the implemented transport, you need to put all the transport related classes into the classpath of the server. Also, you need to make sure that the transport configuration file is present in the classpath and its schema and name match appropriate parameters from your transport descriptor. - -The following example illustrates the configuration file contents that match our transport. This file should be named `custom-transport.config.` - -```json -{ - "host":"${transport.bindInterface}", - "port":9997 -} -``` - -**Note:** you can use transport configuration variables from the `operations-server.properties` or `bootstrap-server.properties` files; these variables must have the `transport` prefix. - -# Creating custom transport channel - -To create your own channel using the Kaa SDK you have to implement the KaaDataChannel interface and register the implementation using the Kaa Channel Manager - -# Implement the KaaDataChannel interface (Java client) - -The implementation of the KaaDataChannel interface will contain methods that you will use to transfer data between endpoints and Servers using the protocol of your choice. - -For a definition of the KaaDataChannel interface please refer to the [javadoc](http://kaaproject.github.io/kaa/doc/client-java-core/latest/org/kaaproject/kaa/client/channel/KaaDataChannel.html). - -You can find examples of the interface implementation in the following java classes for the default transport channels: - -1. DefaultOperationsChannel - implementation of the Operation HTTP Long poll channel; -2. DefaultOperationHttpChannel - implementation of the Operation HTTP channel; -3. DefaultBootstrapChannel - implementation of the Bootstrap HTTP channel; -4. DefaultOperationTcpChannel - implementation of the Operation [Kaatcp999](http://docs.kaaproject.org/display/KAA09x/KaaTCP+channel) channel. - -## Register your own channel using the Kaa Channel Manager - -When the implementation of your channel is ready you should add the channel to Channel Manager by invoking the addChannel() method as follows: - - - -
    -
    - -```Java -KaaClient kaaClient = ...; -KaaDataChannel myChannel; -kaaClient.getChannelManager().addChannel(myChannel); -``` - -
    - -```Cpp -IDataChannelPtr myChannel; -Kaa::getKaaClient().getChannelManager().addChannel(myChannel); -``` - -
    - -```C -kaa_context_t kaa_context; -/* Assume Kaa SDK is already initialized */ -kaa_error_t error_code = kaa_channel_manager_add_transport_channel(kaa_context.channel_manager - , channel - , NULL); -/* Check error code */ -``` - -
    - -```Objective-C -id kaaClient = ...; -id myChannel; -[[kaaClient getChannelManager] addChannel:myChannel]; -``` - -
    - -Now Kaa SDK knows about your channel and will use it to send service data according to the channel settings. - -Notice that in java sdk, after adding new data channel multiplexer and demultiplexer will be setted regarding to channel server type. - -To send a request to the server and get a response please follow the steps described below. - -## Step 1 - Get an instance of KaaDataMultiplexer - -To prepare a request to the server, you have to use a data multiplexer that combines and serializes requests from different Kaa services. - -Kaa provides two data multiplexers. One should be used for communication with the Operations server and the other for communication with the Bootstrap server. - -To get an instance of [KaaDataMultiplexer](http://kaaproject.github.io/kaa/doc/client-java-core/latest/org/kaaproject/kaa/client/channel/KaaDataMultiplexer.html) for communication with the Operation server, use the getBootstrapMultiplexer() method: - -```Cpp -Kaa::getKaaClient().getOperationMultiplexer(); -``` - -To get an instance of KaaDataMultiplexer for communication with the Bootstrap server, use the getBootstrapMultiplexer() method: - -```Cpp -Kaa::getKaaClient().getBootstrapMultiplexer(); -``` - -## Step 2 - Prepare a request collecting information from the services - -In order to create a request to be sent to the server you have to collect data from Kaa services. Collecting data is performed using the KaaDataMultiplexer interface obtained in the previous step. - -The KaaDataMultiplexer interface has only one method: compileRequest () - - - -
    -
    - -```Java -byte [] compileRequest(Map types) throws Exception; -``` - -
    - -```Cpp -virtual std::vector compileRequest(const std::map& transportTypes) = 0; -``` - -
    - -```Objective-C -- (NSData *)compileRequestForTypes:(NSDictionary *)types; -``` - -
    - -where **types** is a map of Kaa services and their data exchange directions that are supported by your channel. - -For example, if you have implemented a channel with the following settings: - -* The channel is able to send events, but cannot receive events -* The channel is able to receive notifications, but cannot send notification requests -* The channel supports the Configuration service in both directions. - -then your **types** map will look as follows: - - - -
    -
    - -```Java -Map types = new HashMap(); -types.put(TransportType.CONFIGURATION, ChannelDirection.BIDIRECTIONAL); -types.put(TransportType.NOTIFICATION, ChannelDirection.DOWN); -types.put(TransportType.EVENT, ChannelDirection.UP); -``` - -
    - -```Cpp -std::map types = -{ - { TransportType::CONFIGURATION, ChannelDirection::BIDIRECTIONAL }, - { TransportType::NOTIFICATION, ChannelDirection::DOWN }, - { TransportType::EVENT, ChannelDirection::UP } -}; -``` - -
    - -```Objective-C -NSDictionary *types = @{ - @(TRANSPORT_TYPE_CONFIGURATION) : @(CHANNEL_DIRECTION_BIDIRECTIONAL), - @(TRANSPORT_TYPE_NOTIFICATION) : @(CHANNEL_DIRECTION_DOWN), - @(TRANSPORT_TYPE_EVENT) : @(CHANNEL_DIRECTION_UP) -}; -``` - -
    - -The method scans the services and collects data from those that have prepared data to be sent to the server. The method uses the **types** map to filter requests from the services. (For example, if for a Transport Type the "DOWN" direction is indicated in the type map, the request data from the respective service will be filtered out and will not be sent to the server.) - -The data collected from the services is combined into the SyncRequest and serialized. As a result, the method returns a byte array with serialized data. - -## Step 3 - Send the prepared request to the server and receive a response - -Insert the data returned by compileRequest into your transfer protocol and send it to the server. This step is performed using the methods that are in the implemented KaaDataChannel interface. - -The response is received as a byte array, and it contains serialized responses for all the services from which requests were sent. - -## Step 4 - Get an instance of KaaDataDemultiplexer - -To deserialize the received response and provide a response to each service, you have to use a data demultiplexer. - -Kaa provides two data demultiplexers. One should be used for communication with the Operations server and the other for communication with the Bootstrap server. - -To get an instance of [KaaDataDemultiplexer](http://kaaproject.github.io/kaa/doc/client-java-core/latest/org/kaaproject/kaa/client/channel/KaaDataDemultiplexer.html) for communication with the Operation server, use the getOperationDemultiplexer() method: - -```Cpp -Kaa::getKaaClient().getOperationDemultiplexer(); -``` - -To get an instance of KaaDataDemultiplexer for communication with the Bootstrap server, use the getBootstrapDemultiplexer() method: - -```Cpp -Kaa::getKaaClient().getBootstrapDemultiplexer(); -``` - -## Step 5 - Push a response to the Kaa SDK - -The data demultiplexer contains only one method - -[void processResponse(byte [] response)](http://kaaproject.github.io/kaa/doc/client-java-core/latest/org/kaaproject/kaa/client/channel/KaaDataDemultiplexer.html) - -The method deserializes the response and decodes the raw data into SyncResponse which consists of subresponses for all services. Then the subresponses are delivered to each service for subsequent processing. - -# Creating custom user verifier - -To implement a custom user verifier, you need to complete the following steps. - -1. Design and compile a configuration schema. -2. Implement the user verifier based on AbstractKaaUserVerifier. -3. Develop the user verifier descriptor. -4. Provision the user verifier. - -We recommend that you use one of the [existing user verifier implementations](https://github.com/kaaproject/kaa/tree/v0.9.0/server/verifiers) as a reference. - -## Configuration schema - -A user verifier configuration schema is an Avro compatible schema that defines configuration parameters of the user verifier. The following parameters in the schema affect Kaa Admin UI layout. - -* displayName - displays the name of the field on UI -* by_default - displays the default value of the field on UI - -```json - { - "namespace": "org.kaaproject.kaa.schema.sample", - "type": "record", - "name": "CustomUserVerifierConfiguration", - "fields": [ - { - "name": "app_id", - "displayName": "Application id", - "type": "string" - }, - { - "name": "app_secret", - "displayName": "Application secret", - "type": "string" - }, - { - "name": "max_parallel_connections", - "displayName": "Maximal number of allowed connections per verifier", - "type": "int", "by_default": "5" - } - ] - } -``` - -Once you have prepared your schema, you can compile it using the following command. -`java -jar /path/to/avro-tools-1.7.7.jar compile schema ` -Please refer to [Compiling the schema](http://avro.apache.org/docs/current/gettingstartedjava.html#Compiling+the+schema) for more information. It is also possible to integrate the schema compilation with [avro-maven-plugin](http://avro.apache.org/docs/current/gettingstartedjava.html). - -## User verifier implementation - -All Kaa user verifiers extend generic abstract class org.kaaproject.kaa.server.common.verifier.AbstractUserVerifier. The following code example illustrates the implementation of a custom user verifier. - -```Java -package org.kaaproject.kaa.sample.verifier; - -import org.kaaproject.kaa.server.common.verifier.AbstractKaaUserVerifier; -import org.kaaproject.kaa.server.common.verifier.UserVerifierCallback; -import org.kaaproject.kaa.server.common.verifier.UserVerifierContext; -import org.kaaproject.kaa.schema.sample.CustomUserVerifierConfiguration; - -/** - * - * Sample user verifier implementation that uses {@link CustomUserVerifierConfiguration} as configuration. - * - */ -public class CustomUserVerifier extends AbstractKaaUserVerifier { - /** - * Initialize a user verifier instance with a particular configuration and - * common transport properties. The configuration is a serialized Avro - * object. The serialization is done using the schema specified in - * {@link KaaUserVerifierConfig}. - * - * @param context the user verifier initialization context - * @param configuration the configuration object that you have specified during verifier provisioning. - */ - @Override - public void init(UserVerifierContext context, CustomUserVerifierConfiguration configuration) { - - } - - /** - * Verifies the access token. - * - * @param userExternalId the user external id - * @param userAccessToken the access token - * @param callback User verification callback, which helps to identify verification status and - * possible reason failure - * @return true, if verified - */ - @Override - public void checkAccessToken(String userExternalId, String userAccessToken, UserVerifierCallback callback) { - - } - - /** - * Starts a user verifier instance. This method should block its caller thread - * until the user verifier is started. This method should not block its caller - * thread after startup sequence is successfully completed. - */ - @Override - public void start() { - - } - - /** - * Stops the user verifier instance. This method should block its current thread - * until user verifier is stopped. User verifier may be started again after it is - * stopped. - */ - @Override - public void stop() { - - } - - /** - * Gets the configuration class. - * - * @return the configuration class - */ - @Override - public Class getConfigurationClass() { - return CustomUserVerifierConfiguration.class; - } -} -``` - - -## User verifier descriptor - -A user verifier descriptor provides Kaa with the information on how to locate and configure your custom user verifier. To implement a user verifier descriptor, you need to implement the PluginConfig interface at first. - -It is also important to provide your class with the @KaaPluginConfig annotiation. This annotation helps Kaa Admin UI to find all available user verifiers in the class path. - -**NOTE** -A user verifier descriptor is optional if you are going to configure your user verifiers using only REST API. - -The following code example illustrates the implementation of a user verifier descriptor. - -```Java -package org.kaaproject.kaa.sample.verifier.config; - -import org.apache.avro.Schema; -import org.kaaproject.kaa.server.common.plugin.KaaPluginConfig; -import org.kaaproject.kaa.server.common.plugin.PluginConfig; -import org.kaaproject.kaa.server.common.plugin.PluginType; -import org.kaaproject.kaa.schema.sample.CustomUserVerifierConfiguration; - -@KaaPluginConfig(pluginType = PluginType.USER_VERIFIER) -public class CustomUserVerifierConfig implements PluginConfig { - - /** - * Returns the plugin display name. There is no strict rule for this - * name to be unique. - * - * @return the plugin display name - */ - @Override - public String getPluginTypeName() { - return TRUSTFUL_VERIFIER_NAME; - } - - /** - * Returns the class name of the plugin implementation. - * - * @return the class name of the plugin implementation - */ - @Override - public String getPluginClassName() { - return "org.kaaproject.kaa.schema.sample.verifier.CustomUserVerifier"; - } - - /** - * Returns the avro schema of the plugin configuration. - * - * @return the avro schema of the plugin configuration - */ - @Override - public Schema getPluginConfigSchema() { - return CustomUserVerifierConfiguration.SCHEMA$; - } -} -``` - -## User verifier provisioning - -To provision your user verifier, do the following: - -1. Place the user verifier descriptor and configuration classes into the Admin UI class path. -2. Place the user verifier implementation classes into the Operations Server class path. -3. Use [Admin UI999](https://docs.kaaproject.org/display/KAA/Administration+UI+guide#AdministrationUIguide-Userverifiers) or [REST API999](https://docs.kaaproject.org/display/KAA/Admin+REST+API#AdminRESTAPI-Create/edituserverifier) to create/update/delete your user verifier instances. diff --git a/doc/Customization-guide/Kaa-Server/index.md b/doc/Customization-guide/Kaa-Server/index.md deleted file mode 100644 index 0a5b56157c..0000000000 --- a/doc/Customization-guide/Kaa-Server/index.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -layout: page -title: Kaa Server -permalink: /:path/ -sort_idx: 20 ---- - -Projects structure, dependencies, 3-rd party tools installation (links). Build set up. Project import into Eclipse and IntelliJ IDEA studio diff --git a/doc/Programming-guide/Debugging-and-troubleshooting/index.md b/doc/Programming-guide/Debugging-and-troubleshooting/index.md deleted file mode 100644 index 2393b4603f..0000000000 --- a/doc/Programming-guide/Debugging-and-troubleshooting/index.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -layout: page -title: Debugging and troubleshooting -permalink: /:path/ -sort_idx: 70 ---- -Log levels control. Frequently encountered errors. Refer to subject pages as much as possible. diff --git a/doc/Programming-guide/Key-platform-features/Configuration-management/attach/admin-ui/add_configuration_schema_1.png b/doc/Programming-guide/Key-platform-features/Configuration-management/attach/admin-ui/add_configuration_schema_1.png new file mode 100644 index 0000000000..75a51909d4 Binary files /dev/null and b/doc/Programming-guide/Key-platform-features/Configuration-management/attach/admin-ui/add_configuration_schema_1.png differ diff --git a/doc/Programming-guide/Key-platform-features/Configuration-management/attach/admin-ui/add_configuration_schema_2.png b/doc/Programming-guide/Key-platform-features/Configuration-management/attach/admin-ui/add_configuration_schema_2.png new file mode 100644 index 0000000000..b9ffef2c66 Binary files /dev/null and b/doc/Programming-guide/Key-platform-features/Configuration-management/attach/admin-ui/add_configuration_schema_2.png differ diff --git a/doc/Programming-guide/Key-platform-features/Configuration-management/attach/admin-ui/configuration-schema.png b/doc/Programming-guide/Key-platform-features/Configuration-management/attach/admin-ui/configuration-schema.png deleted file mode 100644 index 69c27305c9..0000000000 Binary files a/doc/Programming-guide/Key-platform-features/Configuration-management/attach/admin-ui/configuration-schema.png and /dev/null differ diff --git a/doc/Programming-guide/Key-platform-features/Configuration-management/index.md b/doc/Programming-guide/Key-platform-features/Configuration-management/index.md index 3adf5762bc..46854a3434 100644 --- a/doc/Programming-guide/Key-platform-features/Configuration-management/index.md +++ b/doc/Programming-guide/Key-platform-features/Configuration-management/index.md @@ -18,14 +18,14 @@ Since Kaa operates on uniformly structured data, you can: * Automatically generate a configuration object model in the endpoint SDK. * Automatically generate default configuration. -* Enforceme configuration integrity. +* Enforce configuration integrity. * View endpoint-specific configuration based on the endpoint group membership. ## Updating configuration data To provision a configuration schema, use the [server REST API]({{root_url}}Programming-guide/Server-REST-APIs/#!/Configuration/saveConfigurationSchema) or open the **Configuration** page of the application and follow the same steps as described in [Setting client-side EP profile schema]({{root_url}}Programming-guide/Key-platform-features/Endpoint-profiles/#setting-client-side-ep-profile-schema). -![Adding configuration schema from Administration UI](attach/admin-ui/configuration-schema.png) +![Adding configuration schema from Administration UI](attach/admin-ui/add_configuration_schema_1.png) Once a new configuration schema is provisioned, Kaa generates corresponding derivative schemas (a [base schema](#base-schema) and an [override schema](#override-schema)) and populates the group [all]({{root_url}}Glossary/#group-all) with the default configuration data using the [auto-generation algorithm](#automatic-generation-of-records). @@ -744,45 +744,36 @@ private static void printConfiguration(SampleConfiguration sampleConfiguration) ```c++ #include #include - #include #include #include #include -using namespace kaa; - const char savedConfig[] = "saved_config.cfg"; -class UserConfigurationReceiver : public IConfigurationReceiver { +class UserConfigurationReceiver : public kaa::IConfigurationReceiver { public: - virtual void onConfigurationUpdated(const KaaRootConfiguration &configuration) + virtual void onConfigurationUpdated(const kaa::KaaRootConfiguration &configuration) { // Add your code here. } }; - + int main() { // Initialize the Kaa endpoint. - auto kaaClient = Kaa::newClient(); - + auto kaaClient = kaa::Kaa::newClient(); // Set up a configuration subsystem. - IConfigurationStoragePtr storage(std::make_shared(savedConfig)); + kaa::IConfigurationStoragePtr storage(std::make_shared(savedConfig)); kaaClient->setConfigurationStorage(storage); - // Set configuration update receiver. UserConfigurationReceiver receiver; kaaClient->addConfigurationListener(receiver); - // Run the Kaa endpoint. kaaClient->start(); - std::cout << "Press Enter to stop" << std::endl; - // Wait for the Enter key before exiting. std::cin.get(); - return EXIT_SUCCESS; } @@ -911,4 +902,4 @@ int main(void) { ``` - \ No newline at end of file + diff --git a/doc/Programming-guide/Key-platform-features/Data-collection/Cassandra-log-appender/attach/column-mapping.png b/doc/Programming-guide/Key-platform-features/Data-collection/Cassandra-log-appender/attach/column-mapping.png index 5a6dc9ac18..2f3439c5f3 100644 Binary files a/doc/Programming-guide/Key-platform-features/Data-collection/Cassandra-log-appender/attach/column-mapping.png and b/doc/Programming-guide/Key-platform-features/Data-collection/Cassandra-log-appender/attach/column-mapping.png differ diff --git a/doc/Programming-guide/Key-platform-features/Data-collection/Cassandra-log-appender/attach/data-collection-demo-in-sandbox.png b/doc/Programming-guide/Key-platform-features/Data-collection/Cassandra-log-appender/attach/data-collection-demo-in-sandbox.png index c03e9ef823..9d700385c1 100644 Binary files a/doc/Programming-guide/Key-platform-features/Data-collection/Cassandra-log-appender/attach/data-collection-demo-in-sandbox.png and b/doc/Programming-guide/Key-platform-features/Data-collection/Cassandra-log-appender/attach/data-collection-demo-in-sandbox.png differ diff --git a/doc/Programming-guide/Key-platform-features/Data-collection/Cassandra-log-appender/index.md b/doc/Programming-guide/Key-platform-features/Data-collection/Cassandra-log-appender/index.md index fe31b643f0..e0caee5179 100644 --- a/doc/Programming-guide/Key-platform-features/Data-collection/Cassandra-log-appender/index.md +++ b/doc/Programming-guide/Key-platform-features/Data-collection/Cassandra-log-appender/index.md @@ -210,37 +210,19 @@ We have next log schema: ```json { "type":"record", - "name":"LogData", - "namespace":"org.kaaproject.kaa.schema.sample.logging", + "name":"Data", + "namespace":"org.kaaproject.kaa.scheme.sample", "fields":[ { - "name":"level", - "type":{ - "type":"enum", - "name":"Level", - "symbols":[ - "KAA_DEBUG", - "KAA_ERROR", - "KAA_FATAL", - "KAA_INFO", - "KAA_TRACE", - "KAA_WARN" - ] - } - }, - { - "name":"tag", - "type":"string" - }, - { - "name":"message", - "type":"string" + "name":"temperature", + "type":"int" }, { "name":"timeStamp", "type":"long" } - ] + ], + "displayName":"Logging scheme" } ``` @@ -248,10 +230,8 @@ The following JSON example matches the previous schema. ```json { - "level":"KAA_INFO", - "tag":"TEST_TAG", - "message":"My simple message", - "timeStamp":"1466075369795" + "temperature":"28", + "timeStamp":"1474366798" } ``` @@ -268,7 +248,7 @@ The following JSON example matches the previous schema. 8. Add new node in the **Configuration** section (localhost:9042) ![Add new node](attach/configuration-section.png) 9. Add auth details if needed (for Sandbox it's empty) -10. Fill keyspace name. "kaa" is used in this example, because it's already created on a Sandbox machine. +10. Fill **Keyspace name**. "kaa" is used in this example, because it's already created on a Sandbox machine. 11. "logs_example" is used as the **Table name pattern**. ![Keyspace configuration](attach/configuration-section-keyspace.png) 12. The important part of configuration is **Column Mapping**: @@ -279,24 +259,18 @@ The following JSON example matches the previous schema. ![Add button](attach/add-button.png) 15. Verify that newly created appender has appeared in list. ![Verify newly created appender](attach/verify-created-appender.png) -16. Use instructions from Sandbox to run Data collection demo application and verify that logs have been successfully sent to Kaa. +16. Use instructions from Sandbox to run Data collection demo application. 17. After this you should see something like below: ```bash - 2016-06-16 14:09:28,483 [main] INFO o.k.k.d.d.DataCollectionDemo - Data collection demo started - 2016-06-16 14:09:29,795 [pool-2-thread-1] INFO o.k.k.d.d.DataCollectionDemo - Kaa client started - 2016-06-16 14:09:29,798 [main] INFO o.k.k.d.d.DataCollectionDemo - Log record {"level": "KAA_INFO", "tag": "TAG", "message": "MESSAGE_0", "timeStamp": 1466075369795} sent - 2016-06-16 14:09:29,807 [main] INFO o.k.k.d.d.DataCollectionDemo - Log record {"level": "KAA_INFO", "tag": "TAG", "message": "MESSAGE_1", "timeStamp": 1466075369795} sent - 2016-06-16 14:09:29,807 [main] INFO o.k.k.d.d.DataCollectionDemo - Log record {"level": "KAA_INFO", "tag": "TAG", "message": "MESSAGE_2", "timeStamp": 1466075369795} sent - 2016-06-16 14:09:29,807 [main] INFO o.k.k.d.d.DataCollectionDemo - Log record {"level": "KAA_INFO", "tag": "TAG", "message": "MESSAGE_3", "timeStamp": 1466075369795} sent - 2016-06-16 14:09:29,807 [main] INFO o.k.k.d.d.DataCollectionDemo - Log record {"level": "KAA_INFO", "tag": "TAG", "message": "MESSAGE_4", "timeStamp": 1466075369795} sent - 2016-06-16 14:09:29,999 [main] INFO o.k.k.d.d.DataCollectionDemo - Received log record delivery info. Bucket Id [0]. Record delivery time [204 ms]. - 2016-06-16 14:09:30,000 [main] INFO o.k.k.d.d.DataCollectionDemo - Received log record delivery info. Bucket Id [0]. Record delivery time [205 ms]. - 2016-06-16 14:09:30,000 [main] INFO o.k.k.d.d.DataCollectionDemo - Received log record delivery info. Bucket Id [0]. Record delivery time [205 ms]. - 2016-06-16 14:09:30,000 [main] INFO o.k.k.d.d.DataCollectionDemo - Received log record delivery info. Bucket Id [0]. Record delivery time [205 ms]. - 2016-06-16 14:09:30,000 [main] INFO o.k.k.d.d.DataCollectionDemo - Received log record delivery info. Bucket Id [0]. Record delivery time [204 ms]. - 2016-06-16 14:09:30,001 [pool-2-thread-1] INFO o.k.k.d.d.DataCollectionDemo - Kaa client stopped - 2016-06-16 14:09:30,006 [main] INFO o.k.k.d.d.DataCollectionDemo - Data collection demo stopped + Data collection demo started + Received new sample period: 1 + Sampled temperature 28 1474366979 + Sampled temperature 31 1474366980 + Sampled temperature 32 1474366981 + Sampled temperature 30 1474366982 + Sampled temperature 28 1474366983 + ... ``` 18. Let's verify that our logs have been persisted in Cassandra. Go to Sandbox VM and run next command to connect Cassandra: @@ -314,15 +288,15 @@ The following JSON example matches the previous schema. 20. You should observe similar output: ```bash - level_field | date | application_token | tag_field | message_field | timestamp_field | id - -------------+------------------------------+----------------------+-----------+---------------+-----------------+-------------------------------------- - KAA_INFO | 2016-06-16-Time:01:08:03.301 | 82635305199158071549 | TAG | MESSAGE_0 | 1466075369795 | 92f326db-831f-419a-9fd0-142404ed1c4c - KAA_INFO | 2016-06-16-Time:01:08:03.301 | 82635305199158071549 | TAG | MESSAGE_1 | 1466075369795 | 6a5506bb-509d-4446-b667-75e256732f2d - KAA_INFO | 2016-06-16-Time:01:08:03.301 | 82635305199158071549 | TAG | MESSAGE_2 | 1466075369795 | a33e4693-d17f-4a9e-b85c-068d7e53ad5c - KAA_INFO | 2016-06-16-Time:01:08:03.301 | 82635305199158071549 | TAG | MESSAGE_3 | 1466075369795 | 2d7a3970-f6f5-4c64-a4ac-93e7dbab23b5 - KAA_INFO | 2016-06-16-Time:01:08:03.301 | 82635305199158071549 | TAG | MESSAGE_4 | 1466075369795 | fc98f7a2-4771-4aaa-88a1-476770134d2a - - (5 rows) + date | timestamp_field | id | application_token | temperature_field + ------------------------------+-----------------+--------------------------------------+----------------------+------------------- + 2016-09-20-Time:03:21:54.532 | 1474366979 | 8206acb5-e8b8-447f-bb61-757f25c154e9 | 65691512829156876532 | 28 + 2016-09-20-Time:03:21:54.532 | 1474366980 | 193df613-3b0a-4498-b0fe-71ac8f8f964d | 65691512829156876532 | 31 + 2016-09-20-Time:03:21:54.532 | 1474366981 | 26af685a-962a-4c6d-910d-3a08e66819cd | 65691512829156876532 | 32 + 2016-09-20-Time:03:21:54.532 | 1474366982 | 6a276954-4adc-41c2-b3cb-bb09bf683b4b | 65691512829156876532 | 30 + 2016-09-20-Time:03:21:54.532 | 1474366983 | 01e8408a-c2cd-451a-a402-ceafdd7c9df6 | 65691512829156876532 | 28 + ... +(5 rows) ``` If your output doesn't match above one, please follow our [troubleshooting guide]({{root_url}}Administration-guide/Troubleshooting). diff --git a/doc/Programming-guide/Key-platform-features/Data-collection/File-system-log-appender/attach/data-collection-demo-in-sandbox.png b/doc/Programming-guide/Key-platform-features/Data-collection/File-system-log-appender/attach/data-collection-demo-in-sandbox.png index b77603a247..9d700385c1 100644 Binary files a/doc/Programming-guide/Key-platform-features/Data-collection/File-system-log-appender/attach/data-collection-demo-in-sandbox.png and b/doc/Programming-guide/Key-platform-features/Data-collection/File-system-log-appender/attach/data-collection-demo-in-sandbox.png differ diff --git a/doc/Programming-guide/Key-platform-features/Data-collection/File-system-log-appender/index.md b/doc/Programming-guide/Key-platform-features/Data-collection/File-system-log-appender/index.md index 20c7b70bdf..c46e99d848 100644 --- a/doc/Programming-guide/Key-platform-features/Data-collection/File-system-log-appender/index.md +++ b/doc/Programming-guide/Key-platform-features/Data-collection/File-system-log-appender/index.md @@ -130,49 +130,45 @@ Example result: 1. Go to Data collection demos in Sandbox. And download binary. ![Data collection demo in Sandbox](attach/data-collection-demo-in-sandbox.png) -2. In the Admin UI follow to **Data collection demo** application. -3. Go to application's **Log appenders** configuration and add a new one. +2. Follow **Installation** instructions. +3. In the Admin UI follow to **Data collection demo** application. +4. Go to application's **Log appenders** configuration and add a new one. ![Add log appender](attach/data-collection-demo-application.png) -4. Enter name of the new appender (we use “Sample FileSystem log appender”). -5. Add Log metadata fields. -6. Select _File_ appender type. +5. Enter name of the new appender (we use “Sample File system log appender”). +6. Add Log metadata fields. +7. Select **File** appender type. See [Creating file system log appender in Admin UI](#creating-file-system-log-appender-in-admin-ui) section for details. -7. Verify that newly created appender has appeared in list. +8. Verify that newly created appender has appeared in list. ![Verify newly created log appender](attach/verify-created-appender.png) -8. Use instructions from Sandbox to run Data collection demo application and verify that logs have been successfully sent to Kaa. -9. After this you should see something like below: +9. Use instructions from Sandbox to run Data collection demo application. +10. After this you should see something like below: ```bash - 2016-06-17 11:59:24,004 [main] INFO o.k.k.d.d.DataCollectionDemo - Data collection demo started - 2016-06-17 11:59:25,457 [pool-2-thread-1] INFO o.k.k.d.d.DataCollectionDemo - Kaa client started - 2016-06-17 11:59:25,459 [main] INFO o.k.k.d.d.DataCollectionDemo - Log record {"level": "KAA_INFO", "tag": "TAG", "message": "MESSAGE_0", "timeStamp": 1466153965458} sent - 2016-06-17 11:59:25,460 [main] INFO o.k.k.d.d.DataCollectionDemo - Log record {"level": "KAA_INFO", "tag": "TAG", "message": "MESSAGE_1", "timeStamp": 1466153965458} sent - 2016-06-17 11:59:25,460 [main] INFO o.k.k.d.d.DataCollectionDemo - Log record {"level": "KAA_INFO", "tag": "TAG", "message": "MESSAGE_2", "timeStamp": 1466153965458} sent - 2016-06-17 11:59:25,460 [main] INFO o.k.k.d.d.DataCollectionDemo - Log record {"level": "KAA_INFO", "tag": "TAG", "message": "MESSAGE_3", "timeStamp": 1466153965458} sent - 2016-06-17 11:59:25,460 [main] INFO o.k.k.d.d.DataCollectionDemo - Log record {"level": "KAA_INFO", "tag": "TAG", "message": "MESSAGE_4", "timeStamp": 1466153965458} sent - 2016-06-17 11:59:27,102 [main] INFO o.k.k.d.d.DataCollectionDemo - Received log record delivery info. Bucket Id [0]. Record delivery time [1644 ms]. - 2016-06-17 11:59:27,102 [main] INFO o.k.k.d.d.DataCollectionDemo - Received log record delivery info. Bucket Id [0]. Record delivery time [1644 ms]. - 2016-06-17 11:59:27,102 [main] INFO o.k.k.d.d.DataCollectionDemo - Received log record delivery info. Bucket Id [0]. Record delivery time [1644 ms]. - 2016-06-17 11:59:27,102 [main] INFO o.k.k.d.d.DataCollectionDemo - Received log record delivery info. Bucket Id [0]. Record delivery time [1644 ms]. - 2016-06-17 11:59:27,102 [main] INFO o.k.k.d.d.DataCollectionDemo - Received log record delivery info. Bucket Id [0]. Record delivery time [1644 ms]. - 2016-06-17 11:59:27,103 [pool-2-thread-1] INFO o.k.k.d.d.DataCollectionDemo - Kaa client stopped - 2016-06-17 11:59:27,104 [main] INFO o.k.k.d.d.DataCollectionDemo - Data collection demo stopped + Data collection demo started + Received new sample period: 1 + Sampled temperature 28 1474622330 + Sampled temperature 31 1474622331 + Sampled temperature 32 1474622332 + Sampled temperature 30 1474622333 + Sampled temperature 28 1474622334 + ... ``` -10. Let's verify that our logs have been persisted in the local file system. Go to Sandbox VM and open the file - ```/kaa_log_uploads/tenant_'number_of_tenant'/application_'your_application_token'/application.log```. - In this example path to file ```application.log``` is ```kaa_log_uploads/tenant_1/application_82635305199158071549/```. +11. Let's verify that our logs have been persisted in the local file system. Go to Sandbox VM and open the file + ```/kaa_log_uploads/tenant_'number_of_tenant'/application_'your_application_token'/application.log```. + In this example path to file ```application.log``` is ```/kaa_log_uploads/tenant_1/application_24212667430286144698/```. - Your ```application.log``` should contain similar content: + Your ```application.log``` should contain similar content: - ``` - 261761 [EPS-log-dispatcher-10] INFO 1.82635305199158071549 - {"Log Header": "{"endpointKeyHash":{"string":"UtzjR4tTem5XDJRZRX9ftZfR7ng="},"applicationToken":{"string":"82635305199158071549"},"headerVersion":{"int":1},"timestamp":{"long":1466153967055},"logSchemaVersion":{"int":2}}", "Event": {"level":"KAA_INFO","tag":"TAG","message":"MESSAGE_0","timeStamp":1466153965458}} - 261761 [EPS-log-dispatcher-10] INFO 1.82635305199158071549 - {"Log Header": "{"endpointKeyHash":{"string":"UtzjR4tTem5XDJRZRX9ftZfR7ng="},"applicationToken":{"string":"82635305199158071549"},"headerVersion":{"int":1},"timestamp":{"long":1466153967055},"logSchemaVersion":{"int":2}}", "Event": {"level":"KAA_INFO","tag":"TAG","message":"MESSAGE_1","timeStamp":1466153965458}} - 261761 [EPS-log-dispatcher-10] INFO 1.82635305199158071549 - {"Log Header": "{"endpointKeyHash":{"string":"UtzjR4tTem5XDJRZRX9ftZfR7ng="},"applicationToken":{"string":"82635305199158071549"},"headerVersion":{"int":1},"timestamp":{"long":1466153967055},"logSchemaVersion":{"int":2}}", "Event": {"level":"KAA_INFO","tag":"TAG","message":"MESSAGE_2","timeStamp":1466153965458}} - 261761 [EPS-log-dispatcher-10] INFO 1.82635305199158071549 - {"Log Header": "{"endpointKeyHash":{"string":"UtzjR4tTem5XDJRZRX9ftZfR7ng="},"applicationToken":{"string":"82635305199158071549"},"headerVersion":{"int":1},"timestamp":{"long":1466153967055},"logSchemaVersion":{"int":2}}", "Event": {"level":"KAA_INFO","tag":"TAG","message":"MESSAGE_3","timeStamp":1466153965458}} - 261761 [EPS-log-dispatcher-10] INFO 1.82635305199158071549 - {"Log Header": "{"endpointKeyHash":{"string":"UtzjR4tTem5XDJRZRX9ftZfR7ng="},"applicationToken":{"string":"82635305199158071549"},"headerVersion":{"int":1},"timestamp":{"long":1466153967055},"logSchemaVersion":{"int":2}}", "Event": {"level":"KAA_INFO","tag":"TAG","message":"MESSAGE_4","timeStamp":1466153965458}} + ```bash + 643854 [EPS-log-dispatcher-10] INFO 1.24212667430286144698 - {"Log Header": "{"endpointKeyHash":{"string":"tqoeo8S49HgakOV/2DfiEZLjGls="},"applicationToken":{"string":"24212667430286144698"},"headerVersion":{"int":1},"timestamp":{"long":1474622333932},"logSchemaVersion":{"int":2}}", "Event": {"temperature":28,"timeStamp":1474622330}} + 643854 [EPS-log-dispatcher-10] INFO 1.24212667430286144698 - {"Log Header": "{"endpointKeyHash":{"string":"tqoeo8S49HgakOV/2DfiEZLjGls="},"applicationToken":{"string":"24212667430286144698"},"headerVersion":{"int":1},"timestamp":{"long":1474622333932},"logSchemaVersion":{"int":2}}", "Event": {"temperature":31,"timeStamp":1474622331}} + 643854 [EPS-log-dispatcher-10] INFO 1.24212667430286144698 - {"Log Header": "{"endpointKeyHash":{"string":"tqoeo8S49HgakOV/2DfiEZLjGls="},"applicationToken":{"string":"24212667430286144698"},"headerVersion":{"int":1},"timestamp":{"long":1474622333932},"logSchemaVersion":{"int":2}}", "Event": {"temperature":32,"timeStamp":1474622332}} + 643854 [EPS-log-dispatcher-10] INFO 1.24212667430286144698 - {"Log Header": "{"endpointKeyHash":{"string":"tqoeo8S49HgakOV/2DfiEZLjGls="},"applicationToken":{"string":"24212667430286144698"},"headerVersion":{"int":1},"timestamp":{"long":1474622333932},"logSchemaVersion":{"int":2}}", "Event": {"temperature":30,"timeStamp":1474622333}} + 643854 [EPS-log-dispatcher-10] INFO 1.24212667430286144698 - {"Log Header": "{"endpointKeyHash":{"string":"tqoeo8S49HgakOV/2DfiEZLjGls="},"applicationToken":{"string":"24212667430286144698"},"headerVersion":{"int":1},"timestamp":{"long":1474622333932},"logSchemaVersion":{"int":2}}", "Event": {"temperature":28,"timeStamp":1474622334}} + ... ``` If your output doesn't match above one, please follow our [troubleshooting guide]({{root_url}}Administration-guide/Troubleshooting). diff --git a/doc/Programming-guide/Key-platform-features/Data-collection/Flume-log-appender/attach/add-log-appender5.png b/doc/Programming-guide/Key-platform-features/Data-collection/Flume-log-appender/attach/add-log-appender5.png deleted file mode 100644 index b77603a247..0000000000 Binary files a/doc/Programming-guide/Key-platform-features/Data-collection/Flume-log-appender/attach/add-log-appender5.png and /dev/null differ diff --git a/doc/Programming-guide/Key-platform-features/Data-collection/Flume-log-appender/attach/data-collection-demo-in-sandbox.png b/doc/Programming-guide/Key-platform-features/Data-collection/Flume-log-appender/attach/data-collection-demo-in-sandbox.png new file mode 100644 index 0000000000..9d700385c1 Binary files /dev/null and b/doc/Programming-guide/Key-platform-features/Data-collection/Flume-log-appender/attach/data-collection-demo-in-sandbox.png differ diff --git a/doc/Programming-guide/Key-platform-features/Data-collection/Flume-log-appender/index.md b/doc/Programming-guide/Key-platform-features/Data-collection/Flume-log-appender/index.md index 51fecfe56e..2caad7b938 100644 --- a/doc/Programming-guide/Key-platform-features/Data-collection/Flume-log-appender/index.md +++ b/doc/Programming-guide/Key-platform-features/Data-collection/Flume-log-appender/index.md @@ -410,25 +410,19 @@ Finally, specify the cluster parameters: host, port and priority. We use localho 4. In case of success, you will see your new log appender in the log appenders list. ![Add log appender step 4](attach/add-log-appender4.png) 5. Go to the Data collection demos in Sandbox. -![Add log appender step 5](attach/add-log-appender5.png) -6. Use instructions from Sandbox to run Data collection demo application and verify that logs have been successfully sent to Kaa. +![Add log appender step 5](attach/data-collection-demo-in-sandbox.png.png) +6. Use instructions from Sandbox to run Data collection demo application. 7. After this you should see something like below: ```bash -2016-06-16 14:09:28,483 [main] INFO o.k.k.d.d.DataCollectionDemo - Data collection demo started -2016-06-16 14:09:29,795 [pool-2-thread-1] INFO o.k.k.d.d.DataCollectionDemo - Kaa client started -2016-06-16 14:09:29,798 [main] INFO o.k.k.d.d.DataCollectionDemo - Log record {"level": "KAA_INFO", "tag": "TAG", "message": "MESSAGE_0", "timeStamp": 1466075369795} sent -2016-06-16 14:09:29,807 [main] INFO o.k.k.d.d.DataCollectionDemo - Log record {"level": "KAA_INFO", "tag": "TAG", "message": "MESSAGE_1", "timeStamp": 1466075369795} sent -2016-06-16 14:09:29,807 [main] INFO o.k.k.d.d.DataCollectionDemo - Log record {"level": "KAA_INFO", "tag": "TAG", "message": "MESSAGE_2", "timeStamp": 1466075369795} sent -2016-06-16 14:09:29,807 [main] INFO o.k.k.d.d.DataCollectionDemo - Log record {"level": "KAA_INFO", "tag": "TAG", "message": "MESSAGE_3", "timeStamp": 1466075369795} sent -2016-06-16 14:09:29,807 [main] INFO o.k.k.d.d.DataCollectionDemo - Log record {"level": "KAA_INFO", "tag": "TAG", "message": "MESSAGE_4", "timeStamp": 1466075369795} sent -2016-06-16 14:09:29,999 [main] INFO o.k.k.d.d.DataCollectionDemo - Received log record delivery info. Bucket Id [0]. Record delivery time [204 ms]. -2016-06-16 14:09:30,000 [main] INFO o.k.k.d.d.DataCollectionDemo - Received log record delivery info. Bucket Id [0]. Record delivery time [205 ms]. -2016-06-16 14:09:30,000 [main] INFO o.k.k.d.d.DataCollectionDemo - Received log record delivery info. Bucket Id [0]. Record delivery time [205 ms]. -2016-06-16 14:09:30,000 [main] INFO o.k.k.d.d.DataCollectionDemo - Received log record delivery info. Bucket Id [0]. Record delivery time [205 ms]. -2016-06-16 14:09:30,000 [main] INFO o.k.k.d.d.DataCollectionDemo - Received log record delivery info. Bucket Id [0]. Record delivery time [204 ms]. -2016-06-16 14:09:30,001 [pool-2-thread-1] INFO o.k.k.d.d.DataCollectionDemo - Kaa client stopped -2016-06-16 14:09:30,006 [main] INFO o.k.k.d.d.DataCollectionDemo - Data collection demo stopped +Data collection demo started +Received new sample period: 1 +Sampled temperature 28 1474622330 +Sampled temperature 31 1474622331 +Sampled temperature 32 1474622332 +Sampled temperature 30 1474622333 +Sampled temperature 28 1474622334 +... ``` The logs are stored within the HDFS path defined during Kaa Flume sink setup. diff --git a/doc/Programming-guide/Key-platform-features/Data-collection/Kafka-log-appender/attach/data-collection-demo-in-sandbox.png b/doc/Programming-guide/Key-platform-features/Data-collection/Kafka-log-appender/attach/data-collection-demo-in-sandbox.png index b77603a247..9d700385c1 100644 Binary files a/doc/Programming-guide/Key-platform-features/Data-collection/Kafka-log-appender/attach/data-collection-demo-in-sandbox.png and b/doc/Programming-guide/Key-platform-features/Data-collection/Kafka-log-appender/attach/data-collection-demo-in-sandbox.png differ diff --git a/doc/Programming-guide/Key-platform-features/Data-collection/Kafka-log-appender/index.md b/doc/Programming-guide/Key-platform-features/Data-collection/Kafka-log-appender/index.md index 8deefa16ea..627632d4b9 100644 --- a/doc/Programming-guide/Key-platform-features/Data-collection/Kafka-log-appender/index.md +++ b/doc/Programming-guide/Key-platform-features/Data-collection/Kafka-log-appender/index.md @@ -170,37 +170,19 @@ We have next log schema: ```json { "type":"record", - "name":"LogData", - "namespace":"org.kaaproject.kaa.schema.sample.logging", + "name":"Data", + "namespace":"org.kaaproject.kaa.scheme.sample", "fields":[ { - "name":"level", - "type":{ - "type":"enum", - "name":"Level", - "symbols":[ - "KAA_DEBUG", - "KAA_ERROR", - "KAA_FATAL", - "KAA_INFO", - "KAA_TRACE", - "KAA_WARN" - ] - } - }, - { - "name":"tag", - "type":"string" - }, - { - "name":"message", - "type":"string" + "name":"temperature", + "type":"int" }, { "name":"timeStamp", "type":"long" } - ] + ], + "displayName":"Logging scheme" } ``` @@ -208,11 +190,10 @@ The following JSON example matches the schema above. ```json { - "level":"KAA_INFO", - "tag":"TEST_TAG", - "message":"My simple message", - "timeStamp":"1466075369795" + "temperature":"28", + "timeStamp":"1474366798" } + ``` 1. Go to the Data collection demos in Sandbox. @@ -239,24 +220,18 @@ In this example, Kafka server installed in the Sandbox VM. ``` This will bring up Kafka consumer, so we can see logs transferred from Kaa. -11. Use instructions from Sandbox to run Data collection demo application and verify that logs have been successfully sent to Kaa. +11. Use instructions from Sandbox to run Data collection demo application. 12. After this you should see something like below: - ``` - 2016-06-21 12:38:12,260 [main] INFO o.k.k.d.d.DataCollectionDemo - Data collection demo started - 2016-06-21 12:38:13,337 [pool-2-thread-1] INFO o.k.k.d.d.DataCollectionDemo - Kaa client started - 2016-06-21 12:38:13,339 [main] INFO o.k.k.d.d.DataCollectionDemo - Log record {"level": "KAA_INFO", "tag": "TAG", "message": "MESSAGE_0", "timeStamp": 1466501893337} sent - 2016-06-21 12:38:13,340 [main] INFO o.k.k.d.d.DataCollectionDemo - Log record {"level": "KAA_INFO", "tag": "TAG", "message": "MESSAGE_1", "timeStamp": 1466501893337} sent - 2016-06-21 12:38:13,340 [main] INFO o.k.k.d.d.DataCollectionDemo - Log record {"level": "KAA_INFO", "tag": "TAG", "message": "MESSAGE_2", "timeStamp": 1466501893337} sent - 2016-06-21 12:38:13,340 [main] INFO o.k.k.d.d.DataCollectionDemo - Log record {"level": "KAA_INFO", "tag": "TAG", "message": "MESSAGE_3", "timeStamp": 1466501893337} sent - 2016-06-21 12:38:13,340 [main] INFO o.k.k.d.d.DataCollectionDemo - Log record {"level": "KAA_INFO", "tag": "TAG", "message": "MESSAGE_4", "timeStamp": 1466501893337} sent - 2016-06-21 12:38:13,627 [main] INFO o.k.k.d.d.DataCollectionDemo - Received log record delivery info. Bucket Id [0]. Record delivery time [290 ms]. - 2016-06-21 12:38:13,627 [main] INFO o.k.k.d.d.DataCollectionDemo - Received log record delivery info. Bucket Id [0]. Record delivery time [290 ms]. - 2016-06-21 12:38:13,627 [main] INFO o.k.k.d.d.DataCollectionDemo - Received log record delivery info. Bucket Id [0]. Record delivery time [290 ms]. - 2016-06-21 12:38:13,627 [main] INFO o.k.k.d.d.DataCollectionDemo - Received log record delivery info. Bucket Id [0]. Record delivery time [290 ms]. - 2016-06-21 12:38:13,627 [main] INFO o.k.k.d.d.DataCollectionDemo - Received log record delivery info. Bucket Id [0]. Record delivery time [290 ms]. - 2016-06-21 12:38:13,628 [pool-2-thread-1] INFO o.k.k.d.d.DataCollectionDemo - Kaa client stopped - 2016-06-21 12:38:13,629 [main] INFO o.k.k.d.d.DataCollectionDemo - Data collection demo stopped + ```bash + Data collection demo started + Received new sample period: 1 + Sampled temperature 28 1474622330 + Sampled temperature 31 1474622331 + Sampled temperature 32 1474622332 + Sampled temperature 30 1474622333 + Sampled temperature 28 1474622334 + ... ``` 13. Let's verify that Kafka consumer receive logs. From Kafka installation directory run the next command: @@ -268,11 +243,11 @@ In this example, Kafka server installed in the Sandbox VM. 14. You should observe similar output: ``` - {"header":{"endpointKeyHash":{"string":"UtzjR4tTem5XDJRZRX9ftZfR7ng="},"applicationToken":{"string":"82635305199158071549"},"headerVersion":{"int":1},"timestamp":{"long":1466501893600},"logSchemaVersion":{"int":2}},"event":{"level":"KAA_INFO","tag":"TAG","message":"MESSAGE_0","timeStamp":1466501893337}} - {"header":{"endpointKeyHash":{"string":"UtzjR4tTem5XDJRZRX9ftZfR7ng="},"applicationToken":{"string":"82635305199158071549"},"headerVersion":{"int":1},"timestamp":{"long":1466501893600},"logSchemaVersion":{"int":2}},"event":{"level":"KAA_INFO","tag":"TAG","message":"MESSAGE_1","timeStamp":1466501893337}} - {"header":{"endpointKeyHash":{"string":"UtzjR4tTem5XDJRZRX9ftZfR7ng="},"applicationToken":{"string":"82635305199158071549"},"headerVersion":{"int":1},"timestamp":{"long":1466501893600},"logSchemaVersion":{"int":2}},"event":{"level":"KAA_INFO","tag":"TAG","message":"MESSAGE_2","timeStamp":1466501893337}} - {"header":{"endpointKeyHash":{"string":"UtzjR4tTem5XDJRZRX9ftZfR7ng="},"applicationToken":{"string":"82635305199158071549"},"headerVersion":{"int":1},"timestamp":{"long":1466501893600},"logSchemaVersion":{"int":2}},"event":{"level":"KAA_INFO","tag":"TAG","message":"MESSAGE_3","timeStamp":1466501893337}} - {"header":{"endpointKeyHash":{"string":"UtzjR4tTem5XDJRZRX9ftZfR7ng="},"applicationToken":{"string":"82635305199158071549"},"headerVersion":{"int":1},"timestamp":{"long":1466501893600},"logSchemaVersion":{"int":2}},"event":{"level":"KAA_INFO","tag":"TAG","message":"MESSAGE_4","timeStamp":1466501893337}} + {"header":{"endpointKeyHash":{"string":"tqoeo8S49HgakOV/2DfiEZLjGls="},"applicationToken":{"string":"24212667430286144698"},"headerVersion":{"int":1},"timestamp":{"long":1474622333932},"logSchemaVersion":{"int":2}},"event":{"temperature":28,"timeStamp":1474622330}} + {"header":{"endpointKeyHash":{"string":"tqoeo8S49HgakOV/2DfiEZLjGls="},"applicationToken":{"string":"24212667430286144698"},"headerVersion":{"int":1},"timestamp":{"long":1474622333932},"logSchemaVersion":{"int":2}},"event":{"temperature":28,"timeStamp":1474622330}} + {"header":{"endpointKeyHash":{"string":"tqoeo8S49HgakOV/2DfiEZLjGls="},"applicationToken":{"string":"24212667430286144698"},"headerVersion":{"int":1},"timestamp":{"long":1474622333932},"logSchemaVersion":{"int":2}},"event":{"temperature":28,"timeStamp":1474622330}} + {"header":{"endpointKeyHash":{"string":"tqoeo8S49HgakOV/2DfiEZLjGls="},"applicationToken":{"string":"24212667430286144698"},"headerVersion":{"int":1},"timestamp":{"long":1474622333932},"logSchemaVersion":{"int":2}},"event":{"temperature":28,"timeStamp":1474622330}} + {"header":{"endpointKeyHash":{"string":"tqoeo8S49HgakOV/2DfiEZLjGls="},"applicationToken":{"string":"24212667430286144698"},"headerVersion":{"int":1},"timestamp":{"long":1474622333932},"logSchemaVersion":{"int":2}},"event":{"temperature":28,"timeStamp":1474622330}} ``` If your output doesn't match above one, please follow our [troubleshooting guide]({{root_url}}Administration-guide/Troubleshooting). diff --git a/doc/Programming-guide/Key-platform-features/Data-collection/MongoDB-log-appender/attach/data-collection-demo-in-sandbox.png b/doc/Programming-guide/Key-platform-features/Data-collection/MongoDB-log-appender/attach/data-collection-demo-in-sandbox.png new file mode 100644 index 0000000000..9d700385c1 Binary files /dev/null and b/doc/Programming-guide/Key-platform-features/Data-collection/MongoDB-log-appender/attach/data-collection-demo-in-sandbox.png differ diff --git a/doc/Programming-guide/Key-platform-features/Data-collection/MongoDB-log-appender/attach/mongodb-log-appender1.png b/doc/Programming-guide/Key-platform-features/Data-collection/MongoDB-log-appender/attach/mongodb-log-appender1.png deleted file mode 100644 index b77603a247..0000000000 Binary files a/doc/Programming-guide/Key-platform-features/Data-collection/MongoDB-log-appender/attach/mongodb-log-appender1.png and /dev/null differ diff --git a/doc/Programming-guide/Key-platform-features/Data-collection/MongoDB-log-appender/index.md b/doc/Programming-guide/Key-platform-features/Data-collection/MongoDB-log-appender/index.md index 74c5e73c88..84d40e5e7b 100644 --- a/doc/Programming-guide/Key-platform-features/Data-collection/MongoDB-log-appender/index.md +++ b/doc/Programming-guide/Key-platform-features/Data-collection/MongoDB-log-appender/index.md @@ -167,60 +167,34 @@ We have next log schema: ```json { "type":"record", - "name":"LogData", - "namespace":"org.kaaproject.kaa.schema.sample.logging", + "name":"Data", + "namespace":"org.kaaproject.kaa.scheme.sample", "fields":[ { - "name":"level", - "type":{ - "type":"enum", - "name":"Level", - "symbols":[ - "KAA_DEBUG", - "KAA_ERROR", - "KAA_FATAL", - "KAA_INFO", - "KAA_TRACE", - "KAA_WARN" - ] - } - }, - { - "name":"tag", - "type":"string" - }, - { - "name":"message", - "type":"string" + "name":"temperature", + "type":"int" }, { "name":"timeStamp", "type":"long" } - ] + ], + "displayName":"Logging scheme" } ``` -Display string - -```json -"schema": "{\n \"type\":\"record\",\n \"name\":\"LogData\",\n \"namespace\":\"org.kaaproject.kaa.schema.sample.logging\",\n \"fields\":[\n Field (4 rows) \n]\n}" -``` - The following JSON example matches the previous schema. ```json { - "level":"KAA_INFO", - "tag":"TEST_TAG", - "message":"My simple message", - "timeStamp":"1466075369795" + "temperature":"28", + "timeStamp":"1474366798" } ``` 1. Go to Data collection demos in Sandbox. -![Data collection demo in Sandbox](attach/mongodb-log-appender1.png) +![Data collection demo in Sandbox](attach/data-collection-demo-in-sandbox.png) 2. In the Admin UI follow to **Data collection demo** application. ![Data collection Demo Admin UI](attach/mongodb-log-appender2.png) ![Add log appender](attach/mongodb-log-appender3.png) @@ -238,24 +212,18 @@ The following JSON example matches the previous schema. ![Add button](attach/mongodb-log-appender8.png) 10. Verify that newly created appender has appeared in list. ![Verify newly created log appender](attach/mongodb-log-appender9.png) -11. Now use instructions from Sandbox to run Data collection demo application and verify that logs have been successfully sent to Kaa. +11. Now use instructions from Sandbox to run Data collection demo application. 12. After this you should see something like below: - ``` - 2016-06-21 12:38:12,260 [main] INFO o.k.k.d.d.DataCollectionDemo - Data collection demo started - 2016-06-21 12:38:13,337 [pool-2-thread-1] INFO o.k.k.d.d.DataCollectionDemo - Kaa client started - 2016-06-21 12:38:13,339 [main] INFO o.k.k.d.d.DataCollectionDemo - Log record {"level": "KAA_INFO", "tag": "TAG", "message": "MESSAGE_0", "timeStamp": 1466501893337} sent - 2016-06-21 12:38:13,340 [main] INFO o.k.k.d.d.DataCollectionDemo - Log record {"level": "KAA_INFO", "tag": "TAG", "message": "MESSAGE_1", "timeStamp": 1466501893337} sent - 2016-06-21 12:38:13,340 [main] INFO o.k.k.d.d.DataCollectionDemo - Log record {"level": "KAA_INFO", "tag": "TAG", "message": "MESSAGE_2", "timeStamp": 1466501893337} sent - 2016-06-21 12:38:13,340 [main] INFO o.k.k.d.d.DataCollectionDemo - Log record {"level": "KAA_INFO", "tag": "TAG", "message": "MESSAGE_3", "timeStamp": 1466501893337} sent - 2016-06-21 12:38:13,340 [main] INFO o.k.k.d.d.DataCollectionDemo - Log record {"level": "KAA_INFO", "tag": "TAG", "message": "MESSAGE_4", "timeStamp": 1466501893337} sent - 2016-06-21 12:38:13,627 [main] INFO o.k.k.d.d.DataCollectionDemo - Received log record delivery info. Bucket Id [0]. Record delivery time [290 ms]. - 2016-06-21 12:38:13,627 [main] INFO o.k.k.d.d.DataCollectionDemo - Received log record delivery info. Bucket Id [0]. Record delivery time [290 ms]. - 2016-06-21 12:38:13,627 [main] INFO o.k.k.d.d.DataCollectionDemo - Received log record delivery info. Bucket Id [0]. Record delivery time [290 ms]. - 2016-06-21 12:38:13,627 [main] INFO o.k.k.d.d.DataCollectionDemo - Received log record delivery info. Bucket Id [0]. Record delivery time [290 ms]. - 2016-06-21 12:38:13,627 [main] INFO o.k.k.d.d.DataCollectionDemo - Received log record delivery info. Bucket Id [0]. Record delivery time [290 ms]. - 2016-06-21 12:38:13,628 [pool-2-thread-1] INFO o.k.k.d.d.DataCollectionDemo - Kaa client stopped - 2016-06-21 12:38:13,629 [main] INFO o.k.k.d.d.DataCollectionDemo - Data collection demo stopped + ```bash + Data collection demo started + Received new sample period: 1 + Sampled temperature 28 1474622330 + Sampled temperature 31 1474622331 + Sampled temperature 32 1474622332 + Sampled temperature 30 1474622333 + Sampled temperature 28 1474622334 + ... ``` 13. Let's verify that our logs have been persisted in MongoDB. Go to Sandbox VM and run next command to connect MongoDB: @@ -268,11 +236,12 @@ The following JSON example matches the previous schema. 14. You should observe similar output: ```bash - { "_id" : ObjectId("57690b05d55fb20804a7f40e"), "header" : { "endpointKeyHash" : { "string" : "UtzjR4tTem5XDJRZRX9ftZfR7ng=" }, "applicationToken" : { "string" : "82635305199158071549" }, "headerVersion" : { "int" : 1 }, "timestamp" : { "long" : NumberLong("1466501893596") }, "logSchemaVersion" : null }, "event" : { "level" : "KAA_INFO", "tag" : "TAG", "message" : "MESSAGE_0", "timeStamp" : NumberLong("1466501893337") } } - { "_id" : ObjectId("57690b05d55fb20804a7f40f"), "header" : { "endpointKeyHash" : { "string" : "UtzjR4tTem5XDJRZRX9ftZfR7ng=" }, "applicationToken" : { "string" : "82635305199158071549" }, "headerVersion" : { "int" : 1 }, "timestamp" : { "long" : NumberLong("1466501893596") }, "logSchemaVersion" : null }, "event" : { "level" : "KAA_INFO", "tag" : "TAG", "message" : "MESSAGE_1", "timeStamp" : NumberLong("1466501893337") } } - { "_id" : ObjectId("57690b05d55fb20804a7f410"), "header" : { "endpointKeyHash" : { "string" : "UtzjR4tTem5XDJRZRX9ftZfR7ng=" }, "applicationToken" : { "string" : "82635305199158071549" }, "headerVersion" : { "int" : 1 }, "timestamp" : { "long" : NumberLong("1466501893596") }, "logSchemaVersion" : null }, "event" : { "level" : "KAA_INFO", "tag" : "TAG", "message" : "MESSAGE_2", "timeStamp" : NumberLong("1466501893337") } } - { "_id" : ObjectId("57690b05d55fb20804a7f411"), "header" : { "endpointKeyHash" : { "string" : "UtzjR4tTem5XDJRZRX9ftZfR7ng=" }, "applicationToken" : { "string" : "82635305199158071549" }, "headerVersion" : { "int" : 1 }, "timestamp" : { "long" : NumberLong("1466501893596") }, "logSchemaVersion" : null }, "event" : { "level" : "KAA_INFO", "tag" : "TAG", "message" : "MESSAGE_3", "timeStamp" : NumberLong("1466501893337") } } - { "_id" : ObjectId("57690b05d55fb20804a7f412"), "header" : { "endpointKeyHash" : { "string" : "UtzjR4tTem5XDJRZRX9ftZfR7ng=" }, "applicationToken" : { "string" : "82635305199158071549" }, "headerVersion" : { "int" : 1 }, "timestamp" : { "long" : NumberLong("1466501893596") }, "logSchemaVersion" : null }, "event" : { "level" : "KAA_INFO", "tag" : "TAG", "message" : "MESSAGE_4", "timeStamp" : NumberLong("1466501893337") } } + { "_id" : ObjectId("57d916e8d55fb2073ae3cfbd"), "header" : { "endpointKeyHash" : { "string" : "H0Oclp3Wn/QS25dZCQSbV5ZkjRo=" }, "applicationToken" : { "string" : "65691512829156876532" }, "headerVersion" : { "int" : 1 }, "timestamp" : { "long" : NumberLong("1473844968489") }, "logSchemaVersion" : null }, "event" : { "temperature" : 28, "timeStamp" : 1474622330 } } + { "_id" : ObjectId("57d916e8d55fb2073ae3cfbe"), "header" : { "endpointKeyHash" : { "string" : "H0Oclp3Wn/QS25dZCQSbV5ZkjRo=" }, "applicationToken" : { "string" : "65691512829156876532" }, "headerVersion" : { "int" : 1 }, "timestamp" : { "long" : NumberLong("1473844968489") }, "logSchemaVersion" : null }, "event" : { "temperature" : 31, "timeStamp" : 1474622331 } } + { "_id" : ObjectId("57d916e8d55fb2073ae3cfbf"), "header" : { "endpointKeyHash" : { "string" : "H0Oclp3Wn/QS25dZCQSbV5ZkjRo=" }, "applicationToken" : { "string" : "65691512829156876532" }, "headerVersion" : { "int" : 1 }, "timestamp" : { "long" : NumberLong("1473844968489") }, "logSchemaVersion" : null }, "event" : { "temperature" : 32, "timeStamp" : 1474622332 } } + { "_id" : ObjectId("57d916e8d55fb2073ae3cfc0"), "header" : { "endpointKeyHash" : { "string" : "H0Oclp3Wn/QS25dZCQSbV5ZkjRo=" }, "applicationToken" : { "string" : "65691512829156876532" }, "headerVersion" : { "int" : 1 }, "timestamp" : { "long" : NumberLong("1473844968489") }, "logSchemaVersion" : null }, "event" : { "temperature" : 30, "timeStamp" : 1474622333 } } + { "_id" : ObjectId("57d916e8d55fb2073ae3cfc1"), "header" : { "endpointKeyHash" : { "string" : "H0Oclp3Wn/QS25dZCQSbV5ZkjRo=" }, "applicationToken" : { "string" : "65691512829156876532" }, "headerVersion" : { "int" : 1 }, "timestamp" : { "long" : NumberLong("1473844968489") }, "logSchemaVersion" : null }, "event" : { "temperature" : 28, "timeStamp" : 1474622334 } } + ... ``` If your output doesn't match above one, please follow our [troubleshooting guide]({{root_url}}Administration-guide/Troubleshooting). diff --git a/doc/Programming-guide/Key-platform-features/Data-collection/Rest-log-appender/index.md b/doc/Programming-guide/Key-platform-features/Data-collection/Rest-log-appender/index.md index f6de3c4f52..e3428f44a1 100644 --- a/doc/Programming-guide/Key-platform-features/Data-collection/Rest-log-appender/index.md +++ b/doc/Programming-guide/Key-platform-features/Data-collection/Rest-log-appender/index.md @@ -17,7 +17,7 @@ The REST log appender is responsible for transferring logs from Operations servi # Creating REST log appender with Admin UI -The easiest way to create a Cassandra log appender for your application is by using Admin UI. +The easiest way to create REST log appender for your application is by using Admin UI. To create a log appender, do the following: diff --git a/doc/Programming-guide/Key-platform-features/Data-collection/attach/add-log-schema.png b/doc/Programming-guide/Key-platform-features/Data-collection/attach/add-log-schema.png deleted file mode 100644 index c42cf82cfe..0000000000 Binary files a/doc/Programming-guide/Key-platform-features/Data-collection/attach/add-log-schema.png and /dev/null differ diff --git a/doc/Programming-guide/Key-platform-features/Data-collection/attach/add_log_schema_1.png b/doc/Programming-guide/Key-platform-features/Data-collection/attach/add_log_schema_1.png new file mode 100644 index 0000000000..ef14f44c00 Binary files /dev/null and b/doc/Programming-guide/Key-platform-features/Data-collection/attach/add_log_schema_1.png differ diff --git a/doc/Programming-guide/Key-platform-features/Data-collection/attach/add_log_schema_2.png b/doc/Programming-guide/Key-platform-features/Data-collection/attach/add_log_schema_2.png new file mode 100644 index 0000000000..35af8462c1 Binary files /dev/null and b/doc/Programming-guide/Key-platform-features/Data-collection/attach/add_log_schema_2.png differ diff --git a/doc/Programming-guide/Key-platform-features/Data-collection/attach/log_schema_details.png b/doc/Programming-guide/Key-platform-features/Data-collection/attach/log_schema_details.png index 313791f97c..68ba26bb57 100644 Binary files a/doc/Programming-guide/Key-platform-features/Data-collection/attach/log_schema_details.png and b/doc/Programming-guide/Key-platform-features/Data-collection/attach/log_schema_details.png differ diff --git a/doc/Programming-guide/Key-platform-features/Data-collection/index.md b/doc/Programming-guide/Key-platform-features/Data-collection/index.md index d44fc357a1..b359810f35 100644 --- a/doc/Programming-guide/Key-platform-features/Data-collection/index.md +++ b/doc/Programming-guide/Key-platform-features/Data-collection/index.md @@ -66,48 +66,13 @@ A simple definition of a log record with no data fields. } ``` -A simple log schema with the log level, tag, and message. - -```json -{ - "name":"LogData", - "namespace":"org.kaaproject.sample", - "type":"record", - "fields":[ - { - "name":"level", - "type":{ - "type":"enum", - "name":"Level", - "symbols":[ - "DEBUG", - "ERROR", - "FATAL", - "INFO", - "TRACE", - "WARN" - ] - } - }, - { - "name":"tag", - "type":"string" - }, - { - "name":"message", - "type":"string" - } - ] -} -``` - ### Adding log schema The default log schema installed for Kaa applications is empty. -You can configure your own log schema using the [Administration UI]({{root_url}}Glossary/#administration-ui) or [server REST API]({{root_url}}Programming-guide/Server-REST-APIs/#!/Logging/saveLogSchema). -See also this [server REST API]({{root_url}}Programming-guide/Server-REST-APIs/#/Logging). +To configure your own log schema, use the [server REST API]({{root_url}}Programming-guide/Server-REST-APIs/#!/Logging/saveLogSchema) or open the **Log** page of the application and follow the same steps as described in [Setting client-side EP profile schema]({{root_url}}Programming-guide/Key-platform-features/Endpoint-profiles/#setting-client-side-ep-profile-schema). +See also the [logging REST API]({{root_url}}Programming-guide/Server-REST-APIs/#/Logging). -For the purpose of this guide, we will use a typical log schema structure: +For the purpose of this guide, a typical log schema structure is used: * log level * tag @@ -146,21 +111,6 @@ For the purpose of this guide, we will use a typical log schema structure: } ``` -To create a new log schema for your application: - -1. Log in to the **Administration** page as a tenant developer. - -2. Under the **Schemas** section of the application, click **Log**, then click **Add schema**. - -3. On the **Add log schema** page, enter the name and description (optional) for your schema. -Use the **Schema** section to compose your schema. -For more details, see [schema form]({{root_url}}Administration-guide/Tenants-and-applications-management/#schema-form). - - Alternatively, click **Browse...**, select your schema file in the [Avro](http://avro.apache.org/docs/current/spec.html) format and click **Upload**. - - ![Add log schema](attach/add-log-schema.png) - -4. Click **Add** to save the schema. ## Schema for log record header @@ -353,20 +303,18 @@ RecordInfo logDeliveryReport = logDeliveryStatus.get(); ```cpp #include #include +#include -include - -using namespace kaa; +... // Create an endpoint instance -auto kaaClient = Kaa::newClient(); - +auto kaaClient = kaa::Kaa::newClient(); // Start an endpoint kaaClient->start(); - + // Create a log entity (according to the org.kaaproject.sample.LogData sample schema above) -KaaUserLogRecord logRecord; -logRecord.level = Level::INFO; +kaa::KaaUserLogRecord logRecord; +logRecord.level = kaa_log::Level::INFO; logRecord.tag = "tag"; logRecord.message = "message"; @@ -377,7 +325,7 @@ try { auto recordInfo = recordDeliveryCallback.get(); auto bucketInfo = recordInfo.getBucketInfo(); std::cout << "Received log record delivery info. Bucket Id [" << bucketInfo.getBucketId() << "]. " - << "Record delivery time [" << recordInfo.getRecordDeliveryTimeMs() << " ms]." << std::endl; + << "Record delivery time [" << recordInfo.getRecordDeliveryTimeMs() << " ms]." << std::endl; } catch (std::exception& e) { std::cout << "Exception was caught while waiting for callback result: " << e.what() << std::endl; } @@ -534,16 +482,17 @@ kaaClient.setLogStorage(new AndroidSQLiteDBLogStorage(/*Android context*/, "kaa_ ```cpp #include - #include - -using namespace kaa; +#include ... -auto persistentStorage = std::make_shared(kaaClient->getKaaClientContext()); +// Create an endpoint instance +auto kaaClient = kaa::Kaa::newClient(); +// Create the storage +auto persistentStorage = std::make_shared(kaaClient->getKaaClientContext()); // Setting SQLite log storage implementation -kaaClient->setStorage(persistentStorage); +kaaClient->setLogStorage(persistentStorage); ``` diff --git a/doc/Programming-guide/Key-platform-features/Endpoint-ownership/index.md b/doc/Programming-guide/Key-platform-features/Endpoint-ownership/index.md index 3494f45262..d9435b1050 100644 --- a/doc/Programming-guide/Key-platform-features/Endpoint-ownership/index.md +++ b/doc/Programming-guide/Key-platform-features/Endpoint-ownership/index.md @@ -10,53 +10,57 @@ sort_idx: 40 * TOC {:toc} -To exchange events between several endpoints, it is required that those endpoints were attached to the same owner. -Depending on the application, owners may be person, groups of people, or organizations. -As an example we can take your mobile phone or smart watch. -These devices are your possessions (attached to you) and you are owner of these devices. -Another example is smart TV located in your house and all your family members are users of this device. -In this case your family is group of people (owner) that own this smart TV and smart TV is endpoint attached to this group. -Kaa provides necessary APIs to attach/detach endpoints to/from owners through one of the following two flows: +In Kaa, users can associate [endpoints]({{root_url}}Glossary/#endpoint-ep) to owners. +Depending on the [application]({{root_url}}Glossary/#kaa-application), owners can be persons, groups of people, or organizations. -* [Owner access token flow](#owner-access-token-flow) -* [Endpoint access token flow](#endpoint-access-token-flow) +For example, if you have a smart TV in your house, all your family members are the users of the smart TV endpoint. +In this case, your family is the group of people (owner) that own the smart TV, and the smart TV is the endpoint attached to this group. +To attach/detach endpoints to/from owners, you can use either [owner access token](#using-the-owner-access-token), or [endpoint access token](#using-the-endpoint-access-token). +## Using the owner access token -# Owner access token flow # -In the *owner access token flow*, the owner authenticates himself in an external authentication system and obtains the *access token*. -The owner performs this authentication from the endpoint which is due to be registered with him in the Kaa instance. -Then, Kaa SDK transfers this token to the Kaa cluster over a secure channel. The Kaa cluster verifies the access token and attaches the endpoint to the owner. - +As an owner, you can authenticate using an external authentication system and obtain your _access token_. +You need to perform this authentication from the endpoint that is duly registered in the [Kaa instance]({{root_url}}Glossary/#kaa-instance-kaa-deployment). +Your [endpoint SDK]({{root_url}}Glossary/#endpoint-sdk) sends this token to the [Kaa cluster]({{root_url}}Glossary/#kaa-cluster) over a secure channel. +The Kaa cluster verifies the access token and attaches the endpoint to the owner. ![Owner access token flow](owner_attach_2.png "Owner access token flow") +### Owner verifiers + +The owner verification is handled by specific server components called _owner verifiers_. +There are several default implementations of the owner verifier available out of the box for each Kaa installation. +This section contains general information about the architecture, configuration, and administration of the default owner verifiers. +You can also plug in [custom verifier implementations](#custom-owner-verifier). +One [Kaa application]({{root_url}}Glossary/#kaa-application) can support multiple owner verifiers. -## Owner verifiers ## -The owner verification is handled by specific server components called owner verifiers. -There are several default owner verifier implementations that are available out of the box for each Kaa installation. -This section contains general information about the architecture, configuration and administration of the default owner verifiers. -It is also possible to plug in [custom verifier implementations](#custom-owner-verifier). Each Kaa application can support multiple owner verifiers. -You can add new verifier from Administration UI or with using [Admin REST API]({{root_url}}Programming-guide/Server-REST-APIs/#!/Verifiers/editUserVerifier). -The following image example illustrates how to add new verifier from Administration UI. +To add a new verifier, use the [server REST API]({{root_url}}Programming-guide/Server-REST-APIs/#!/Verifiers/editUserVerifier) or open the **User verifier** page of your application. ![new verifier](Admin-ui/adding-new-verifier.png "new verifier") - -## Trustful owner verifier ## -This owner verifier implementation is created for the test and debug purposes and always accepts provided owner id and access token. -It is recommended that you do not use this verifier in production because it may cause security issues. -There is no specific configuration for this verifier, because its schema is empty. -To create a trustful owner verifier, use either Administration UI or [Admin REST API]({{root_url}}Programming-guide/Server-REST-APIs/#!/Verifiers/editUserVerifier). -The following image example illustrates how to create a trustful owner verifier from Administration UI. + +### Trustful owner verifier + +This owner verifier implementation always accepts any owner ID and access token and is created for testing and debugging purposes. +Since the verifier schema is empty, there is no specific configuration for this verifier. + +To add a trustful verifier, use the [server REST API]({{root_url}}Programming-guide/Server-REST-APIs/#!/Verifiers/editUserVerifier) or choose the **trustful verifier** type from the drop-down list on the **Add user verifier details** page. ![trustful verifier](Admin-ui/verifier-trustful.png "trustful verifier") -## Facebook owner verifier ## -This owner verifier implementation is created for verification of Facebook accounts. It is especially useful for applications that are already integrated with Facebook. +>**CAUTION:** Do not use this owner verifier in production because it may cause security issues. +{:.caution} + +### Facebook owner verifier + +This owner verifier implementation is created to verify Facebook accounts. +It is especially useful for applications that are already integrated with Facebook. + +#### Configuration ### -### Configuration ### -The configuration should match the following Avro schema. Note that you need to create a [facebook application](https://developers.facebook.com/products/login/) -and specify its application id and [secret](https://developers.facebook.com/docs/graph-api/securing-requests) in the configuration. +First, create a [facebook application](https://developers.facebook.com/products/login/), then specify its application ID and [secret](https://developers.facebook.com/docs/graph-api/securing-requests) in the configuration. + +The following Avro schema defines the configuration. ```json { @@ -94,17 +98,21 @@ The following configuration example matches the previous schema. ``` -### Administration ### -To create a Facebook owner verifier, use either Administration UI or [Admin REST API]({{root_url}}Programming-guide/Server-REST-APIs/#!/Verifiers/editUserVerifier). -The following image example illustrates how to create a Facebook owner verifier from Administration UI. +#### Administration + +To create a Facebook owner verifier, use the [Administration UI]({{root_url}}Glossary/#administration-ui) or [server REST API]({{root_url}}Programming-guide/Server-REST-APIs/#!/Verifiers/editUserVerifier). +If you want to use the Administration UI, choose the **Facebook verifier** type from the drop-down list on the **Add user verifier details** page. ![facebook verifier](Admin-ui/verifier-facebook.png "facebook verifier") -## Google+ owner verifier ## -This owner verifier implementation is created for verification of Google+ accounts. It is especially useful for applications that are already integrated with Google+. +### Google+ owner verifier + +This owner verifier implementation is created to verify Google+ accounts. +It is especially useful for applications that are already integrated with Google+. + +#### Configuration -### Configuration ### -The configuration should match the following Avro schema. +The following Avro schema defines the configuration. ```json { @@ -131,17 +139,20 @@ The configuration should match the following Avro schema. } ``` -### Administration ### -To create a Google+ owner verifier, use either Administration UI or [Admin REST API]({{root_url}}Programming-guide/Server-REST-APIs/#!/Verifiers/editUserVerifier). -The following image example illustrates how to create a Google+ owner verifier from Administration UI. +#### Administration + +To create a Google+ owner verifier, use the [server REST API]({{root_url}}Programming-guide/Server-REST-APIs/#!/Verifiers/editUserVerifier) or choose the **Google+ verifier** type from the drop-down list on the **Add user verifier details** page. ![google verifier](Admin-ui/verifier-google.png "google verifier") -## Twitter owner verifier ## -This owner verifier implementation is created for verification of Twitter accounts. It is especially useful for applications that are already integrated with Twitter. +### Twitter owner verifier + +This owner verifier implementation is created to verify Twitter accounts. +It is especially useful for applications that are already integrated with Twitter. -### Configuration ### -The configuration should match the following Avro schema. +#### Configuration + +The following Avro schema defines the configuration. ```json { @@ -161,47 +172,51 @@ The configuration should match the following Avro schema. }, { "name": "max_parallel_connections", - "displayName": "Maximal number of allowed connections per verifier", + "displayName": "Maximum number of allowed connections per verifier", "type": "int", "by_default": "5" } ] } ``` -### Administration ### -To create a Twitter owner verifier, use either Administration UI or [Admin REST API]({{root_url}}Programming-guide/Server-REST-APIs/#!/Verifiers/editUserVerifier). -The following image example illustrates how to create a Twitter owner verifier from Administration UI. - +#### Administration + +To create a Twitter owner verifier, use the [server REST API]({{root_url}}Programming-guide/Server-REST-APIs/#!/Verifiers/editUserVerifier) or choose the **Twitter verifier** type from the drop-down list on the **Add user verifier details** page. + ![twitter verifier](Admin-ui/verifier-twitter.png "twitter verifier") -## Custom owner verifier ## -It is possible to implement and plug-in custom owner verifiers. You can find corresponding instructions on the -[Creating custom owner verifier]({{root_url}}Customization-guide/Kaa-Server/Development-environment-setup/#creating-custom-user-verifier) page. +### Custom owner verifier +You can implement a custom plug-in verifier. +To do this, follow the instructions in [Creating custom owner verifier]({{root_url}}Customization-guide/Kaa-Server/Development-environment-setup/#creating-custom-user-verifier). -# Endpoint access token flow # -In the *endpoint access token flow*, new endpoints are attached to the owner with the help of the endpoint which was attached to the owner beforehand. -The following steps illustrate this flow with the endpoint A, which is already attached to the owner, and the endpoint B, which is due to be attached: - 1. The endpoint B periodically generates and sends its access token to the Kaa cluster. - 2. The endpoint B displays its access token as a QR code on the screen (TV) or on the webpage (e.g., a router or other device with an embedded server). - 3. The endpoint A retrieves this token by scanning QR code or in any other suitable way and sends it in the endpoint attach request to the Kaa cluster. - 4. The Kaa cluster verifies the access code and attaches the endpoint B to the owner of the endpoint A. +## Using the endpoint access token +You can use an owner's endpoint to attach new endpoints to that owner. +Assume you have a new endpoint B that you want to attach to the owner using the previously attached endpoint A. -![Owner access token flow](endpoint_attach_2.png "Owner access token flow") +The process flows as follows: + +1. The endpoint B periodically generates and sends its access token to the Kaa cluster. +2. The endpoint B displays its access token as a QR code on the screen (TV) or on the webpage (e.g., a router or other device with an embedded server). -## Attach endpoint to owner ## +3. The endpoint A retrieves this token by scanning QR code or in any other suitable way and sends it in the endpoint attach request to the Kaa cluster. -To enable sending/receiving events to/from endpoints, at first the client should attach the endpoint to the owner as shown in the following examples for different platforms SDK. +4. The Kaa cluster verifies the access code and attaches the endpoint B to the owner of the endpoint A. -> Please refer to [Glossary]({{root_url}}Glossary/) for more details about **userExternalId**, **userAccessToken**, **userVerifierToken** ->and other parameters which are used by KaaClient methods. + +![Owner access token flow](endpoint_attach_2.png "Owner access token flow") + + +### Attach endpoint to owner + +[Kaa client]({{root_url}}Glossary/#kaa-client) attaches the endpoint to the owner as shown in the following examples for different [SDK types]({{root_url}}Glossary/#sdk-type). @@ -242,25 +257,22 @@ kaaClient.attachUser("userVerifierToken", "userExternalId", "userAccessToken", n ``` -
    +
    ```c++ #include #include - #include -#include +#include -using namespace kaa; - -class SimpleUserAttachCallback : public IUserAttachCallback { +class SimpleUserAttachCallback : public kaa::IUserAttachCallback { public: virtual void onAttachSuccess() { std::cout << "Endpoint is attached to a user" << std::endl; } - virtual void onAttachFailed(UserAttachErrorCode errorCode, const std::string& reason) + virtual void onAttachFailed(kaa::UserAttachErrorCode errorCode, const std::string& reason) { std::cout << "Failed to attach endpoint to a user: error code " << errorCode << ", reason '" << reason << "'" << std::endl; } @@ -269,13 +281,12 @@ public: ... // Create an endpoint instance -auto kaaClient = Kaa::newClient(); - +auto kaaClient = kaa::Kaa::newClient(); // Start an endpoint kaaClient->start(); - // Try to attach an endpoint to a user kaaClient->attachUser("userExternalId", "userAccessToken", std::make_shared()); + ```
    @@ -344,14 +355,17 @@ error_code = kaa_user_manager_default_attach_to_user(kaa_client_get_context(kaa_
    -## Assisted attach ## +### Assisted attachment -Specific endpoint may not be able to attach itself independently. E.g. in case if endpoint doesn't have an owner access token. -Another endpoint that already attached can assist in attachment process of the new endpoint. Below are examples of assisted attachment. +Some endpoints may not be able to attach themselves independently. +For example, when an endpoint does not have an owner access token. +In this case, another endpoint that is already attached can assist in the attachment process of the new endpoint. + +Below are examples of assisted attachment. @@ -360,61 +374,101 @@ Another endpoint that already attached can assist in attachment process of the n
    ```java + +import org.kaaproject.kaa.client.KaaClient; +import org.kaaproject.kaa.client.KaaDesktop; + +public class Preparation { + public static void main(String[] args) { + KaaClient kaaClientWithoutOwner = Kaa.newClient(new DesktopKaaPlatformContext(), new SimpleKaaClientStateListener() { + @Override + public void onStarted() { + System.out.println("Kaa client started"); + } + + @Override + public void onStopped() { + System.out.println("Kaa client stopped"); + } + }, true); + + kaaClientWithoutOwner.start(); + kaaClientWithoutOwner.setEndpointAccessToken("endpointAccessToken"); + } +} + import org.kaaproject.kaa.client.KaaClient; import org.kaaproject.kaa.client.KaaDesktop; import org.kaaproject.kaa.client.event.registration.OnAttachEndpointOperationCallback; - -/** -* Updates with new endpoint attach request -* -* @param endpointAccessToken Access token of the attaching endpoint -* @param resultListener Listener to notify about result of the endpoint attaching -* -*/ -kaaClient.attachEndpoint("endpointAccessToken", new OnAttachEndpointOperationCallback() -{ - @Override - public void onAttach(SyncResponseResultType result, EndpointKeyHash resultContext) { - // +public class AssistedAttachment { + public static void main(String[] args) { + KaaClient kaaClient = Kaa.newClient(new DesktopKaaPlatformContext(), new SimpleKaaClientStateListener() { + @Override + public void onStarted() { + System.out.println("Kaa client started"); + } + + @Override + public void onStopped() { + System.out.println("Kaa client stopped"); + } + }, true); + + /** + * Updates with new endpoint attach request + * + * @param endpointAccessToken Access token of the endpoint being attached + * @param resultListener Listener to notify about result of the endpoint attaching + * + */ + //kaaClient represents endpoint which already attached to owner + //endpoint with endpointAccessToken will be attached to the same owner + kaaClient.attachEndpoint("endpointAccessToken", new OnAttachEndpointOperationCallback() + { + @Override + public void onAttach(SyncResponseResultType result, EndpointKeyHash resultContext) { + if (result.equals(SyncResponseResultType.SUCCESS)) { + //assisted attachment was successful + } + else if (result.equals(SyncResponseResultType.FAILURE)) { + //assisted attachment failed + } + } + }); } -}); +} ```
    -
    +
    ```c++ #include #include - #include -#include - -using namespace kaa; +#include -class SimpleEndpointAttachCallback : public IAttachEndpointCallbackPtr { +class SimpleEndpointAttachCallback : public kaa::IAttachEndpointCallback { public: - virtual void onAttachSuccess() + virtual void onAttachSuccess(const std::string& endpointKeyHash) { - std::cout << "Endpoint is attached to a user" << std::endl; + std::cout << "Endpoint is attached to a user, key hash:" << endpointKeyHash << std::endl; } - - virtual void onAttachFailed(UserAttachErrorCode errorCode, const std::string& reason) + + virtual void onAttachFailed() { - std::cout << "Failed to attach endpoint to a user: error code " << errorCode << ", reason '" << reason << "'" << std::endl; + std::cout << "Failed to attach endpoint to a user" << std::endl; } }; ... // Create an endpoint instance -auto kaaClient = Kaa::newClient(); - +auto kaaClient = kaa::Kaa::newClient(); // Start an endpoint kaaClient->start(); - // Try to attach an endpoint to a user kaaClient->attachEndpoint("endpointAccessToken", std::make_shared()); ``` @@ -469,13 +523,15 @@ error_code = kaa_user_manager_attach_endpoint(kaa_client_get_context(kaa_client)
    -## Detach endpoint from owner ## +### Detach endpoint from owner + +An attached endpoint can assist in detachment process of another attached endpoint. -Another endpoint that already attached can assist in detachment process for another endpoint which attached too. Below are examples of assisted detachment. +Below are examples of assisted detachment. @@ -491,7 +547,7 @@ import org.kaaproject.kaa.client.event.registration.OnDetachEndpointOperationCal /** * Updates with new endpoint detach request * -* @param endpointKeyHash Key hash of the detaching endpoint +* @param endpointKeyHash Key hash of the endpoint being detached * @param resultListener Listener to notify about result of the enpoint attaching * */ @@ -506,39 +562,35 @@ kaaClient.detachEndpoint("endpointKeyHash", new OnDetachEndpointOperationCallbac ``` -
    +
    ```c++ #include #include - #include -#include - -using namespace kaa; - -class SimpleEndpointDetachCallback : public IDetachEndpointCallbackPtr { +#include + +class SimpleEndpointDetachCallback : public kaa::IDetachEndpointCallback { public: virtual void onDetachSuccess() { std::cout << "Endpoint is attached to a user" << std::endl; } - virtual void onDetachFailed(UserAttachErrorCode errorCode, const std::string& reason) + virtual void onDetachFailed() { - std::cout << "Failed to detach endpoint from user: error code " << errorCode << ", reason '" << reason << "'" << std::endl; + std::cout << "Failed to detach endpoint from user" << std::endl; } }; ... - + // Create an endpoint instance -auto kaaClient = Kaa::newClient(); +auto kaaClient = kaa::Kaa::newClient(); -// Start an endpoint -kaaClient->start(); +... -// Try to attach an endpoint to a user +// Try to detach an endpoint from a user kaaClient->detachEndpoint("endpointKeyHash", std::make_shared()); ``` diff --git a/doc/Programming-guide/Key-platform-features/Endpoint-profiles/index.md b/doc/Programming-guide/Key-platform-features/Endpoint-profiles/index.md index 005dd28097..f759d0fb37 100644 --- a/doc/Programming-guide/Key-platform-features/Endpoint-profiles/index.md +++ b/doc/Programming-guide/Key-platform-features/Endpoint-profiles/index.md @@ -10,38 +10,45 @@ sort_idx: 20 * TOC {:toc} -The structure of both client-side and server-side endpoint profile is a customizable structured data set that describes specific characteristics of the endpoint. Endpoint profiles are used to classify endpoints into -endpoint groups and are comprised of the client-side, server-side and system part. The structure of both client-side and server-side of endpoint profile is defined by -application developer using the [Apache Avro schema](http://avro.apache.org/docs/current/spec.html#schemas) format. Application developer may reuse and share certain data -structures using CTL. -Client-side structure is used during SDK generation. Thus, change to the client-side structure requires re-generation of the SDK -(for more details see [Endpoint SDK]({{root_url}}Programming-guide/Using-Kaa-endpoint-SDKs)). Application developer is able to define and -change server-side structure of endpoint profile at any time. The structure of the system part is identical across the applications and is used by Kaa internally for its -functions. Both client-side and server-side profile schemas are maintained within the corresponding application, with its own version that distinguishes it from the previous -schemas. Multiple schema versions and corresponding endpoint profiles created upon those schemas can coexist within a single application. - -## Client-side endpoint profile ## - -The client-side endpoint profile is initially generated at the stage of a new endpoint registration. Prior to that, the client-side endpoint profile values should be -specified by the client developer using the Kaa endpoint SDK. The client-side endpoint profile can be also updated at run time using SDK API call. In this case, SDK executes -profile update request and endpoint membership in the endpoint groups is re-evaluated and updated to match the new endpoint profile. -The client-side endpoint profile is unidirectionally synchronized, and thus should not be considered as a means to temporarily store endpoint data in the Kaa cluster. -There is no way for the endpoint to retrieve the profile information back from the Kaa cluster. At its start, the application must fill in the current endpoint profile -with the up-to-date data and execute corresponding SDK API calls. The endpoint SDK does not persist the profile information over the endpoint reboots. However, -it detects profile data changes and submits the new data to the Kaa cluster as a profile update. +[Endpoint profile]({{root_url}}Glossary/#endpoint-profile-client-side-server-side) (EP profile) is a structured set of data that describes specific characteristics of an [endpoint]({{root_url}}Glossary/#endpoint-ep). + +The profiles are used to attribute endpoints to [endpoint groups]({{root_url}}Glossary/#endpoint-group). +Every endpoint profile comprises the *client-side*, *server-side* and *system* parts. + +To select an endpoint profile schema, [application]({{root_url}}Glossary/#kaa-application) developer uses the [common type library (CTL)]({{root_url}}Glossary/#common-type-library-ctl). + +The client-side profile schema is used during the SDK generation. +Therefore, if you make changes to the client-side schema, you need to re-generate your SDK for the changes to take effect. +For more information, see [Endpoint SDK]({{root_url}}Programming-guide/Using-Kaa-endpoint-SDKs). + +The structure of the system part is identical across the applications and is used by [Kaa platform]({{root_url}}Glossary/#kaa-platform) to perform internal functions. + +## Client-side EP profile + +Client developer uses CTL to select a schema as the structure for the initial client-side EP profile data. +Then, the client-side endpoint profile is generated during [registration of a new endpoint]({{root_url}}Programming-guide/Key-platform-features/Devices-provisioning-and-registration/#endpoint-registration). + +The client-side endpoint profile can be updated at run time using an SDK API call. +After the SDK requested a profile update, the new profile is checked against the [profile filters]({{root_url}}Glossary/#profile filter) on the server side. +Based on the checking results, the group membership of the endpoint is re-evaluated and updated to match the new EP profile. +The client-side EP profile can change due to your client application logic or device state. +Since the client-side EP profile is unidirectionally synchronized, it should not be considered as a means to temporarily store endpoint data in the [Kaa cluster]({{root_url}}Glossary/#kaa-cluster). +Endpoints cannot retrieve the profile information back from the Kaa cluster. +The endpoint SDK does not persist the profile information over the endpoint reboots. +However, it detects profile data changes and submits the new data to the Kaa cluster as a profile update. -### Client-side endpoint profile example ### +### Example of a client-side EP profile -For the purpose of this guide we will use a fairly abstract client-side profile schema shown below. +For the purpose of this guide, we will use a fairly abstract client-side profile schema. The schema defines 4 fields: -* id - unique identifier -* os - operating system name -* os_version - version of operating system -* build - build version +* id --- unique identifier +* os --- operating system name +* os_version --- operating system version +* build --- build version ```json { @@ -77,7 +84,7 @@ The schema defines 4 fields: } ``` -The following client-side profile is based on the rules that sets schema. +The following client-side profile is based on the rules set in the schema. ```json { @@ -87,69 +94,53 @@ The following client-side profile is based on the rules that sets schema. "build" : "1" } ``` -The schema structure from our example allows filtering the endpoints by the operation systems of device (for example, to show only Android devices), os_version (for example, to push some -notifications only for the specified os version). It is allowed to create complex filtering conditions by combining as many filtering conditions as needed. -### Setting client-side endpoint profile schema from Admin UI +The schema structure from this example allows filtering the endpoints by the operation system of device (for example, to show only Android devices), OS version (for example, to push some notifications only for the specified OS version). +You can create complex filters by combining as many filtering conditions as needed. + +### Setting client-side EP profile schema -The list of client-side endpoint profile schemas created by a tenant developer for the application is shown in the **Client-side EP profile** schemas window, which can -be opened from the application menu on the navigation panel as illustrated by the following screenshot. +To view the list of all CT schemas available for a tenant, log in to [Administration UI]({{root_url}}Glossary/#administration-ui) and click **Tenant CTL**. + +To view the list of CT schema references for a particular application, open the the **Client-side EP profile** page under the **Schemas** section of the application. -To export the client-side EP profile schema, click **Export** in the last column of desired schema row and select export method from drop-down. -See [CT schema export support]({{root_url}}Programming-guide/Key-platform-features/Common-Type-Library/#ct-schema-export-support) for available export methods details. -As a tenant developer, you can create new client-side EP schemas for the application as follows: +To set your client-side EP profile schema, you can export an existing CT schema or create a new one. + +As a tenant developer, you can create new client-side EP schemas for your application as follows: + +1. Under the **Schemas** section of the application, click **Client-side EP profile schemas**, then click the **Add schema** button. + +2. On the **Add profile schema** page, enter your schema name and description (optional). -1. In the **Client-side EP profile schemas** window for the application, click **Add schema**. -2. In the **Add profile schema** window enter the name of the schema. 3. Then create a schema using one of the two options: - * Using the existing CT by clicking **Select existing type** and selecting exiting CT version from FQN and version drop-downs. + + * Use the existing [common type (CT)]({{root_url}}Glossary/#common-type-ct) by clicking **Select existing type**. + Click the **Select fully qualified name of existing type** field and select the CT from the drop-down list, then select the version from the corresponding drop-down list. - * Create new CT by clicking **Create new type**. In this case you will be redirected to **Add new type** window. Here you can create a schema either by using - the schema form or by uploading a schema in the [Avro](http://avro.apache.org/docs/current/spec.html) format from a file. + * Create new CT by clicking **Create new type**. + The **Add new type** page will open. + Here you can create a schema either by using the schema form or by uploading a file containing the schema in the [Avro](http://avro.apache.org/docs/current/spec.html) format. + See also [create a new CT]({{root_url}}Programming-guide/Key-platform-features/Common-Type-Library/#create-a-new-ct). - -4. Click **Add** at the top of the window to save the schema. -If you want to review the added Avro schema, open the corresponding **Client-side EP profile schema** window by clicking the schema in the **Client-side EP profile schemas** window. +4. Click **Add** to save your schema. - +>**NOTE:** Alternatively, you can use the [server REST API]({{root_url}}Programming-guide/Server-REST-APIs/#/Profiling) to set up your EP profile. +{:.note} -### REST API for Client-side endpoint profile +### SDK API for client-side EP profile -Visit [Admin REST API]({{root_url}}Programming-guide/Server-REST-APIs/#/Profiling) documentation page for detailed description of the REST API, -its purpose, interfaces and features supported. +The endpoint SDK checks for profile changes by comparing the new profile hash against the previously persisted one. +When SDK detects a profile change, the endpoint profile management module sends this information to the Operations service. +The Operations service then updates the endpoint profile information in the database and revises the endpoint group membership. -Admin REST API provides the following actions: - -* [Get profile based on endpoint key]({{root_url}}Programming-guide/Server-REST-APIs/#!/Profiling/getEndpointProfileByKeyHash) -* [Get client- and server-side endpoint profile bodies based on endpoint key]({{root_url}}Programming-guide/Server-REST-APIs/#!/Profiling/getEndpointProfileBodyByKeyHash) -* [Get endpoint profiles by owner ID]({{root_url}}Programming-guide/Server-REST-APIs/#!/Profiling/getEndpointProfilesByUserExternalId) -* [Get client-side endpoint profile schema]({{root_url}}Programming-guide/Server-REST-APIs/#!/Profiling/getProfileSchema) -* [Get client-side endpoint profile schemas]({{root_url}}Programming-guide/Server-REST-APIs/#!/Profiling/getProfileSchemasByApplicationToken) -* [Delete endpoint]({{root_url}}Programming-guide/Server-REST-APIs/#!/Profiling/removeEndpointProfileByKeyHash) -* [Create client-side endpoint profile schema]({{root_url}}Programming-guide/Server-REST-APIs/#!/Profiling/saveProfileSchema) - - -### Client side endpoint profile SDK API ### - -Endpoint profile information changes as the result of the client operation or user's actions, it is the client implementation responsibility to update the -profile via the endpoint SDK API calls. The endpoint SDK detects profile changes by comparing the new profile hash against the previously persisted one. Should there be a change, -the endpoint profile management module passes it to the Operations service, which in turn updates the endpoint profile information in the database and revises the endpoint -groups membership. - -Think about the client-side profile schema as of a structured data set of your endpoint application that will later be available to you in Kaa server and may change -due to your client application logic or device state. -You can configure your own client-side profile schema using the -[Admin UI](#setting-client-side-endpoint-profile-schema-from-admin-ui) or Admin REST API. -First of all you need to [create new CT schema]({{root_url}}Programming-guide/Server-REST-APIs/#!/Common_Type_Library/saveCTLSchemaWithAppToken) -after that [create client-side endpoint profile schema]({{root_url}}Programming-guide/Server-REST-APIs/#!/Profiling/saveProfileSchema) which will be contain a reference for this CT. -Client-side endpoint profile updates are reported to the endpoint SDK using a profile container. The profile related API varies depending on the target SDK platform, -however the general approach is the same. +Client-side endpoint profile updates are reported to the endpoint SDK using a profile container. +The profile-related API varies depending on the target SDK platform, however the general approach is the same.
    @@ -272,7 +296,7 @@ EventFamilyFactory *eventFamilyFactory = [kaaClient getEventFamilyFactory];
    -**Get specific ECF object from ECF factory:** +### Get ECF object