From ec4bbe020ff0cb3a0df32874c5f5ed571c1db25c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Petr=20P=C3=ADsa=C5=99?= Date: Mon, 21 Dec 2015 17:30:24 +0100 Subject: [PATCH] Add AIFOTicket to isds_DbUserInfo as aifo_ticket This adds new member to isds_DbUserInfo structure. It's optional and used only when creating a box, adding a user to a box, or listing box users. It allows to specify or retrieve a person reference to citizen registery. It does not break API, but because it changes a structure size, it breaks ABI, thus soname was bumped. I also increased version of the libisds at this moment. --- client/common.c | 1 + configure.ac | 2 +- doc/libisds.xml | 6 +++++ src/Makefile.am | 2 +- src/isds.c | 40 ++++++++++++++++++++++---------- src/isds.h | 9 +++---- test/offline/isds_DbUserInfo_duplicate.c | 4 +++- test/offline/isds_DbUserInfo_free.c | 1 + 8 files changed, 46 insertions(+), 19 deletions(-) diff --git a/client/common.c b/client/common.c index cd12fe5..9b4f906 100644 --- a/client/common.c +++ b/client/common.c @@ -371,6 +371,7 @@ void print_DbUserInfo(const struct isds_DbUserInfo *info) { printf("\tcaCity = %s\n", info->caCity); printf("\tcaZipCode = %s\n", info->caZipCode); printf("\tcaState = %s\n", info->caState); + printf("\taifo_ticket = %s\n", info->aifo_ticket); printf("}\n"); } diff --git a/configure.ac b/configure.ac index ef41d1b..e166b9b 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ([2.63]) -AC_INIT([libisds], [0.10], [petr.pisar@atlas.cz]) +AC_INIT([libisds], [0.11], [petr.pisar@atlas.cz]) AM_INIT_AUTOMAKE AC_LANG([C]) AC_CONFIG_SRCDIR([src/isds.c]) diff --git a/doc/libisds.xml b/doc/libisds.xml index d4ad17e..70b1ba0 100644 --- a/doc/libisds.xml +++ b/doc/libisds.xml @@ -1499,6 +1499,12 @@ err = isds_cleanup(); is optional and implicit meaning is CZ. + + + char *aifo_ticket; + Reference to citizen registry. This value is + optional. + diff --git a/src/Makefile.am b/src/Makefile.am index 824f7a9..4c152f8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -48,5 +48,5 @@ libisds_la_HEADERS = isds.h libisds_la_CPPFLAGS = @XML_CPPFLAGS@ @LIBCURL_CPPFLAGS@ \ -DLOCALEDIR=\"$(localedir)\" libisds_la_CFLAGS = @LIBGCRYPT_CFLAGS@ @GPGME_CFLAGS@ -libisds_la_LDFLAGS = -version-info 9:0:4 @XML_LIBS@ @LIBCURL@ @LIBGCRYPT_LIBS@ \ +libisds_la_LDFLAGS = -version-info 10:0:0 @XML_LIBS@ @LIBCURL@ @LIBGCRYPT_LIBS@ \ @GPGME_LIBS@ @EXPAT_LIBS@ @LTLIBINTL@ diff --git a/src/isds.c b/src/isds.c index cee85f0..06f7e3d 100644 --- a/src/isds.c +++ b/src/isds.c @@ -239,6 +239,7 @@ void isds_DbUserInfo_free(struct isds_DbUserInfo **db_user_info) { free((*db_user_info)->caCity); free((*db_user_info)->caZipCode); free((*db_user_info)->caState); + free((*db_user_info)->aifo_ticket); zfree(*db_user_info); } @@ -654,6 +655,7 @@ struct isds_DbUserInfo *isds_DbUserInfo_duplicate( STRDUP_OR_ERROR(new->caCity, src->caCity); STRDUP_OR_ERROR(new->caZipCode, src->caZipCode); STRDUP_OR_ERROR(new->caState, src->caState); + STRDUP_OR_ERROR(new->aifo_ticket, src->aifo_ticket); return new; @@ -3244,6 +3246,8 @@ static isds_error extract_DbUserInfo(struct isds_ctx *context, goto leave; } + EXTRACT_STRING_ATTRIBUTE("AIFOTicket", (*db_user_info)->aifo_ticket, 0); + EXTRACT_STRING("isds:userID", (*db_user_info)->userID); EXTRACT_STRING("isds:userType", string); @@ -3311,18 +3315,28 @@ leave: /* Insert struct isds_DbUserInfo data (user description) into XML tree * @context is session context * @user is libisds structure with user description + * @honor_aifo_ticket is true for inserting @user's aifo_ticket member * @db_user_info is XML element of XSD:tDbUserInfo */ static isds_error insert_DbUserInfo(struct isds_ctx *context, - const struct isds_DbUserInfo *user, xmlNodePtr db_user_info) { + const struct isds_DbUserInfo *user, _Bool honor_aifo_ticket, + xmlNodePtr db_user_info) { isds_error err = IE_SUCCESS; xmlNodePtr node; + xmlAttrPtr attribute_node; xmlChar *string = NULL; if (!context) return IE_INVALID_CONTEXT; if (!user || !db_user_info) return IE_INVAL; /* Build XSD:tDbUserInfo */ + + /* XXX: Insert AIFOTicket attribute only when allowed. XML schema does not + * allow it everywhere. */ + if (honor_aifo_ticket && user->aifo_ticket) { + INSERT_STRING_ATTRIBUTE(db_user_info, "AIFOTicket", user->aifo_ticket); + } + if (user->personName) { INSERT_STRING(db_user_info, "pnFirstName", user->personName->pnFirstName); @@ -6119,7 +6133,7 @@ static isds_error build_CreateDBInput_request(struct isds_ctx *context, if (item->data) { INSERT_ELEMENT(node, dbPrimaryUsers, "dbUserInfo"); err = insert_DbUserInfo(context, - (struct isds_DbUserInfo *) item->data, node); + (struct isds_DbUserInfo *) item->data, 1, node); if (err) goto leave; } } @@ -6644,8 +6658,8 @@ leave: /* Update data about user assigned to given box. * @context is session context * @box is box identification - * @old_user identifies user to update - * @new_user are updated data about @old_user + * @old_user identifies user to update, aifo_ticket member is ignored + * @new_user are updated data about @old_user, aifo_ticket member is ignored * @refnumber is reallocated serial number of request assigned by ISDS. Use * NULL, if you don't care.*/ isds_error isds_UpdateDataBoxUser(struct isds_ctx *context, @@ -6687,11 +6701,11 @@ isds_error isds_UpdateDataBoxUser(struct isds_ctx *context, if (err) goto leave; INSERT_ELEMENT(node, request, "dbOldUserInfo"); - err = insert_DbUserInfo(context, old_user, node); + err = insert_DbUserInfo(context, old_user, 0, node); if (err) goto leave; INSERT_ELEMENT(node, request, "dbNewUserInfo"); - err = insert_DbUserInfo(context, new_user, node); + err = insert_DbUserInfo(context, new_user, 0, node); if (err) goto leave; /* Send it to server and process response */ @@ -6823,7 +6837,7 @@ leave: /* Reset credentials of user assigned to given box. * @context is session context * @box is box identification - * @user identifies user to reset password + * @user identifies user to reset password, aifo_ticket member is ignored * @fee_paid is true if fee has been paid, false otherwise * @approval is optional external approval of box manipulation * @credentials_delivery is NULL if new password should be delivered off-line @@ -6882,7 +6896,7 @@ isds_error isds_reset_password(struct isds_ctx *context, if (err) goto leave; INSERT_ELEMENT(node, request, "dbUserInfo"); - err = insert_DbUserInfo(context, user, node); + err = insert_DbUserInfo(context, user, 0, node); if (err) goto leave; INSERT_SCALAR_BOOLEAN(request, "dbFeePaid", fee_paid); @@ -6926,6 +6940,7 @@ leave: * @service_name is name of SERVICE_DB_MANIPULATION service * @box is box identification * @user identifies user to remove + * @honor_aifo_ticket is true for inserting @user's aifo_ticket member * @credentials_delivery is NULL if new user's password should be delivered * off-line to the user. It is valid pointer if user should obtain new * password on-line on dedicated web server. Then input @@ -6941,6 +6956,7 @@ leave: static isds_error build_send_manipulationboxuser_request_check_drop_response( struct isds_ctx *context, const xmlChar *service_name, const struct isds_DbOwnerInfo *box, const struct isds_DbUserInfo *user, + _Bool honor_aifo_ticket, struct isds_credentials_delivery *credentials_delivery, const struct isds_approval *approval, xmlChar **refnumber) { isds_error err = IE_SUCCESS; @@ -6984,7 +7000,7 @@ static isds_error build_send_manipulationboxuser_request_check_drop_response( if (err) goto leave; INSERT_ELEMENT(node, request, "dbUserInfo"); - err = insert_DbUserInfo(context, user, node); + err = insert_DbUserInfo(context, user, honor_aifo_ticket, node); if (err) goto leave; err = insert_credentials_delivery(context, credentials_delivery, request); @@ -7046,7 +7062,7 @@ isds_error isds_add_user(struct isds_ctx *context, struct isds_credentials_delivery *credentials_delivery, const struct isds_approval *approval, char **refnumber) { return build_send_manipulationboxuser_request_check_drop_response(context, - BAD_CAST "AddDataBoxUser", box, user, credentials_delivery, + BAD_CAST "AddDataBoxUser", box, user, 1, credentials_delivery, approval, (xmlChar **) refnumber); } @@ -7054,7 +7070,7 @@ isds_error isds_add_user(struct isds_ctx *context, /* Remove user assigned to given box. * @context is session context * @box is box identification - * @user identifies user to remove + * @user identifies user to remove, aifo_ticket member is ignored * @approval is optional external approval of box manipulation * @refnumber is reallocated serial number of request assigned by ISDS. Use * NULL, if you don't care.*/ @@ -7062,7 +7078,7 @@ isds_error isds_delete_user(struct isds_ctx *context, const struct isds_DbOwnerInfo *box, const struct isds_DbUserInfo *user, const struct isds_approval *approval, char **refnumber) { return build_send_manipulationboxuser_request_check_drop_response(context, - BAD_CAST "DeleteDataBoxUser", box, user, NULL, approval, + BAD_CAST "DeleteDataBoxUser", box, user, 0, NULL, approval, (xmlChar **) refnumber); } diff --git a/src/isds.h b/src/isds.h index bb80835..cd4d624 100644 --- a/src/isds.h +++ b/src/isds.h @@ -358,6 +358,7 @@ struct isds_DbUserInfo { char *caZipCode; /* Post office code of contact address */ char *caState; /* Abbreviated country of contact address; Implicit value is "CZ"; Optional. */ + char *aifo_ticket; /* AIFO ticket; Optional. */ }; /* Message event type */ @@ -1113,8 +1114,8 @@ isds_error isds_GetDataBoxUsers(struct isds_ctx *context, const char *box_id, /* Update data about user assigned to given box. * @context is session context * @box is box identification - * @old_user identifies user to update - * @new_user are updated data about @old_user + * @old_user identifies user to update, aifo_ticket member is ignored + * @new_user are updated data about @old_user, aifo_ticket member is ignored * @refnumber is reallocated serial number of request assigned by ISDS. Use * NULL, if you don't care.*/ isds_error isds_UpdateDataBoxUser(struct isds_ctx *context, @@ -1137,7 +1138,7 @@ isds_error isds_activate(struct isds_ctx *context, /* Reset credentials of user assigned to given box. * @context is session context * @box is box identification - * @user identifies user to reset password + * @user identifies user to reset password, aifo_ticket member is ignored * @fee_paid is true if fee has been paid, false otherwise * @approval is optional external approval of box manipulation * @credentials_delivery is NULL if new password should be delivered off-line @@ -1182,7 +1183,7 @@ isds_error isds_add_user(struct isds_ctx *context, /* Remove user assigned to given box. * @context is session context * @box is box identification - * @user identifies user to remove + * @user identifies user to remove, aifo_ticket member is ignored * @approval is optional external approval of box manipulation * @refnumber is reallocated serial number of request assigned by ISDS. Use * NULL, if you don't care.*/ diff --git a/test/offline/isds_DbUserInfo_duplicate.c b/test/offline/isds_DbUserInfo_duplicate.c index 3f6532d..eaab61a 100644 --- a/test/offline/isds_DbUserInfo_duplicate.c +++ b/test/offline/isds_DbUserInfo_duplicate.c @@ -57,6 +57,7 @@ static int test_isds_DbUserInfo_duplicate(struct isds_DbUserInfo *origin) { TEST_INTPTR_DUPLICITY(origin->caCity, copy->caCity); TEST_INTPTR_DUPLICITY(origin->caZipCode, copy->caZipCode); TEST_INTPTR_DUPLICITY(origin->caState, copy->caState); + TEST_INTPTR_DUPLICITY(origin->aifo_ticket, copy->aifo_ticket); PASS_TEST; } @@ -108,7 +109,8 @@ int main(void) { .caStreet = "9", .caCity = "10", .caZipCode = "11", - .caState = "12" + .caState = "12", + .aifo_ticket = "13" }; TEST("Full structure", test_isds_DbUserInfo_duplicate, &full); diff --git a/test/offline/isds_DbUserInfo_free.c b/test/offline/isds_DbUserInfo_free.c index b51dd87..e10e18a 100644 --- a/test/offline/isds_DbUserInfo_free.c +++ b/test/offline/isds_DbUserInfo_free.c @@ -53,6 +53,7 @@ int main(void) { TEST_FILL_STRING(DbUserInfo->caCity); TEST_FILL_STRING(DbUserInfo->caZipCode); TEST_FILL_STRING(DbUserInfo->caState); + TEST_FILL_STRING(DbUserInfo->aifo_ticket); TEST("Full structure", test_isds_DbUserInfo_free, &DbUserInfo); isds_cleanup(); -- 2.11.4.GIT