Implement CreateDataBoxPFOInfo as isds_add_pfoinfo()
[libisds.git] / src / isds.h
blobd85a9c6ad45d8d4dd6be58d506ed5b48ee4eb788
1 #ifndef __ISDS_ISDS_H__
2 #define __ISDS_ISDS_H__
4 /* Public interface for libisds.
5 * Private declarations in isds_priv.h. */
7 #include <stdlib.h> /* For size_t */
8 #include <sys/time.h> /* For struct timeval */
10 /* _deprecated macro marks library symbols as deprecated. Application should
11 * avoid using such function as soon as possible. */
12 #if defined(__GNUC__)
13 #define _deprecated __attribute__((deprecated))
14 #else
15 #define _deprecated
16 #endif
19 struct isds_ctx; /* Context for specific ISDS box */
21 typedef enum {
22 IE_SUCCESS = 0, /* No error, just for C conveniece (0 means Ok) */
23 IE_ERROR, /* Unspecified error */
24 IE_NOTSUP,
25 IE_INVAL,
26 IE_INVALID_CONTEXT,
27 IE_NOT_LOGGED_IN,
28 IE_CONNECTION_CLOSED,
29 IE_TIMED_OUT,
30 IE_NOEXIST,
31 IE_NOMEM,
32 IE_NETWORK,
33 IE_HTTP,
34 IE_SOAP,
35 IE_XML,
36 IE_ISDS,
37 IE_ENUM,
38 IE_DATE,
39 IE_2BIG,
40 IE_2SMALL,
41 IE_NOTUNIQ,
42 IE_NOTEQUAL,
43 IE_PARTIAL_SUCCESS
44 } isds_error;
46 typedef enum {
47 ILL_NONE = 0,
48 ILL_CRIT = 10,
49 ILL_ERR = 20,
50 ILL_WARNING = 30,
51 ILL_INFO = 40,
52 ILL_DEBUG = 50,
53 ILL_ALL = 100
54 } isds_log_level;
56 typedef enum {
57 ILF_NONE = 0x0,
58 ILF_HTTP = 0x1,
59 ILF_SOAP = 0x2,
60 ILF_ISDS = 0x4,
61 ILF_FILE = 0x8,
62 ILF_SEC = 0x10,
63 ILF_XML = 0x20,
64 ILF_ALL = 0xFF
65 } isds_log_facility;
67 /* Return text description of ISDS error */
68 const char *isds_strerror(const isds_error error);
70 /* TLS libisds options */
71 typedef enum {
72 ITLS_VERIFY_SERVER, /* _Bool: Verify server idetity? */
73 ITLS_CA_FILE, /* char *: File name with CA certificates */
74 ITLS_CA_DIRECTORY /* char *: Directory name with CA certificates */
75 } isds_tls_option;
77 /* Box type */
78 typedef enum {
79 DBTYPE_SYSTEM = 0, /* This is special sender value for messages
80 sent by ISDS. */
81 DBTYPE_OVM = 10,
82 DBTYPE_OVM_NOTAR = 11,
83 DBTYPE_OVM_EXEKUT = 12,
84 DBTYPE_OVM_REQ = 13,
85 DBTYPE_PO = 20,
86 DBTYPE_PO_ZAK = 21,
87 DBTYPE_PO_REQ = 22,
88 DBTYPE_PFO = 30,
89 DBTYPE_PFO_ADVOK = 31,
90 DBTYPE_PFO_DANPOR = 32,
91 DBTYPE_PFO_INSSPR = 33,
92 DBTYPE_FO = 40
93 } isds_DbType;
95 /* Box status from point of view of accesibilty */
96 typedef enum {
97 DBSTATE_ACCESSIBLE = 1,
98 DBSTATE_TEMP_UNACCESSIBLE = 2,
99 DBSTATE_NOT_YET_ACCESSIBLE = 3,
100 DBSTATE_PERM_UNACCESSIBLE = 4,
101 DBSTATE_REMOVED = 5
102 } isds_DbState;
104 /* User permissions from point of view of ISDS.
105 * Instances can be bitmaps of any discrete values. */
106 typedef enum {
107 PRIVIL_READ_NON_PERSONAL = 0x1, /* Can download and read messages with
108 dmPersonalDelivery == false */
109 PRIVIL_READ_ALL = 0x2, /* Can download and read messages with
110 dmPersonalDelivery == true */
111 PRIVIL_CREATE_DM = 0x4, /* Can create and sent messages,
112 can dowload outgoing (sent) messages */
113 PRIVIL_VIEW_INFO = 0x8, /* Can list messages and data about
114 post and delivery */
115 PRIVIL_SEARCH_DB = 0x10, /* Can search for boxes */
116 PRIVIL_OWNER_ADM = 0x20, /* Can administer his box (add/remove
117 permitted users and theirs
118 permissions) */
119 PRIVIL_READ_VAULT = 0x40, /* Cen read message stored in data safe */
120 PRIVIL_ERASE_VAULT = 0x80 /* Can delete messages from data safe */
121 } isds_priviledges;
123 /* Message status */
124 typedef enum {
125 MESSAGESTATE_SENT = 0x2, /* Message has been put into ISDS */
126 MESSAGESTATE_STAMPED = 0x4, /* Message stamped by TSA */
127 MESSAGESTATE_INFECTED = 0x8, /* Message included virues,
128 infected document has been removed */
129 MESSAGESTATE_DELIVERED = 0x10, /* Message delivered
130 (dmDeliveryTime stored) */
131 MESSAGESTATE_SUBSTITUTED = 0x20, /* Message delivered through fiction,
132 dmAcceptanceTime stored */
133 MESSAGESTATE_RECEIVED = 0x40, /* Message accepted (by user login or
134 user explicit request),
135 dmAcceptanceTime stored */
136 MESSAGESTATE_READ = 0x80, /* Message has been read by user */
137 MESSAGESTATE_UNDELIVERABLE = 0x100, /* Message could not been delivered
138 (e.g. recipent box has been made
139 unaccessible meantime) */
140 MESSAGESTATE_REMOVED = 0x200, /* Message content deleted */
141 MESSAGESTATE_IN_SAFE = 0x400 /* Message stored in data safe */
143 } isds_message_status;
144 #define MESSAGESTATE_ANY 0x7FE /* Union of all isds_message_status
145 values */
147 /* Hash algoritm types */
148 typedef enum {
149 HASH_ALGORITHM_MD5,
150 HASH_ALGORITHM_SHA_1,
151 HASH_ALGORITHM_SHA_256,
152 HASH_ALGORITHM_SHA_512,
153 } isds_hash_algorithm;
155 /* Buffer storage strategy.
156 * How function should embed application provided buffer into raw element of
157 * output structure. */
158 typedef enum {
159 BUFFER_DONT_STORE, /* Don't fill raw memeber */
160 BUFFER_COPY, /* Copy buffer content into newly allocated raw */
161 BUFFER_MOVE /* Just copy pointer.
162 But leave deallocation to isds_*_free(). */
163 } isds_buffer_strategy;
165 /* Hash value storage */
166 struct isds_hash {
167 isds_hash_algorithm algorithm; /* Hash algoritgm */
168 size_t length; /* Hash value lenght in bytes */
169 void *value; /* Hash value */
172 /* Name of person */
173 struct isds_PersonName {
174 char *pnFirstName;
175 char *pnMiddleName;
176 char *pnLastName;
177 char *pnLastNameAtBirth;
180 /* Date and place of birth */
181 struct isds_BirthInfo {
182 struct tm *biDate; /* Date of Birth in local time at birth place,
183 only tm_year, tm_mon and tm_mday carry sane
184 value */
185 char *biCity;
186 char *biCounty; /* German: Bezirk, Czech: okres */
187 char *biState;
190 /* Post address */
191 struct isds_Address {
192 char *adCity;
193 char *adStreet;
194 char *adNumberInStreet;
195 char *adNumberInMunicipality;
196 char *adZipCode;
197 char *adState;
200 /* Data about box and his owner.
201 * NULL pointer means undefined value */
202 struct isds_DbOwnerInfo {
203 char *dbID; /* Box ID [Max. 7 chars] */
204 isds_DbType *dbType; /* Box Type */
205 char *ic; /* ID */
206 struct isds_PersonName *personName; /* Name of person */
207 char *firmName; /* Name of firm */
208 struct isds_BirthInfo *birthInfo; /* Birth of person */
209 struct isds_Address *address; /* Post address */
210 char *nationality;
211 char *email;
212 char *telNumber;
213 char *identifier; /* External box identifier for data
214 provider (OVM, PO, maybe PFO)
215 [Max. 20 chars] */
216 char *registryCode; /* PFO External registry code
217 [Max. 5 chars] */
218 long int *dbState; /* Box state; 1 <=> active box;
219 long int beacause xsd:integer
220 TODO: enum? */
221 _Bool *dbEffectiveOVM; /* Box has OVM role (§ 5a) */
222 _Bool *dbOpenAddressing; /* Non-OVM Box is free to recieve
223 messages from anybody */
226 /* User type */
227 typedef enum {
228 USERTYPE_PRIMARY, /* Owner of the box */
229 USERTYPE_ENTRUSTED, /* User with limited access to the box */
230 USERTYPE_ADMINISTRATOR, /* User to manage ENTRUSTED_USERs */
231 USERTYPE_OFFICIAL /* ??? */
232 } isds_UserType;
234 /* Data about user.
235 * NULL pointer means undefined value */
236 struct isds_DbUserInfo {
237 char *userID; /* User ID [Min. 6, max. 12 characters] */
238 isds_UserType *userType; /* User type */
239 long int *userPrivils; /* Set of user permissions */
240 struct isds_PersonName *personName; /* Name of the person */
241 struct isds_Address *address; /* Post address */
242 struct tm *biDate; /* Date of birth in local time,
243 only tm_year, tm_mon and tm_mday carry sane
244 value */
245 char *ic; /* ID of a supervising firm [Max. 8 chars] */
246 char *firmName; /* Name of a supervising firm
247 [Max. 100 chars] */
248 char *caStreet; /* Street and number of contact address */
249 char *caCity; /* Czech City of contact address */
250 char *caZipCode; /* Post office code of contact address */
253 /* Message event type */
254 typedef enum {
255 EVENT_UKNOWN, /* Event unknown to this library */
256 EVENT_ACCEPTED_BY_RECIPIENT, /* Message has been delivered and accepted
257 by recipeint action */
258 EVENT_ACCEPTED_BY_FICTION, /* Message has been delivered, acceptance
259 timed out, considered as accepted */
260 EVENT_UNDELIVERABLE, /* Recipient box made unaccessible,
261 thus message is undelivarable */
262 EVENT_COMMERCIAL_ACCEPTED /* Recipient confirmed acceptace of
263 commercial message */
264 } isds_event_type;
266 /* Message event
267 * Alle members are optional as specification states so. */
268 struct isds_event {
269 struct timeval *time; /* When the event occurred */
270 isds_event_type *type; /* Type of the event */
271 char *description; /* Human readable event description
272 generated by ISDS (Czech) */
275 /* Message envelope
276 * Be ware that the string length contraints are forced only on output
277 * memebers transmitted to ISDS. The other direction (downloded from ISDS)
278 * can break these rules. It should not happen, but nobody knows how much
279 * incompatible new version of ISDS protocol will be. This is the gold
280 * Internet rule: be strict on what you put, be tollerant on what you get. */
281 struct isds_envelope {
282 /* Following memebers apply to incoming messages only: */
283 char *dmID; /* Message ID.
284 Maximal length is 20 characters. */
285 char *dbIDSender; /* Box ID of sender.
286 Special value "aaaaaaa" means sent by
287 ISDS.
288 Maximal length is 7 characters. */
289 char *dmSender; /* Sender name;
290 Maximal length is 100 characters. */
291 char *dmSenderAddress; /* Postal address of sender;
292 Maximal length is 100 characters. */
293 long int *dmSenderType; /* Gross Box type of sender
294 TODO: isds_DbType ? */
295 char *dmRecipient; /* Recipient name;
296 Maximal length is 100 characters. */
297 char *dmRecipientAddress; /* Postal address of recipient;
298 Maximal length is 100 characters. */
299 _Bool *dmAmbiguousRecipient; /* Recipient has OVM role */
300 char *dmType; /* Message type:
301 "V" is public message
302 "K" is commercial message */
304 /* Following memebers are assigned by ISDS in different phases of message
305 * life cycle. */
306 unsigned long int *dmOrdinal; /* Ordinal number in list of
307 incoming/outgoing messages */
308 isds_message_status *dmMessageStatus; /* Message state */
309 long int *dmAttachmentSize; /* Size of message documents in
310 kilobytes (rounded). */
311 struct timeval *dmDeliveryTime; /* Time of delivery into a box
312 NULL, if message has not been
313 delivered yet */
314 struct timeval *dmAcceptanceTime; /* Time of accpetance of the message
315 by an user. NULL if message has not
316 been accepted yet. */
317 struct isds_hash *hash; /* Message hash.
318 This is hash of isds:dmDM subtree. */
319 void *timestamp; /* Qualified time stamp */
320 size_t timestamp_length; /* Lenght of timestamp in bytes */
321 struct isds_list *events; /* Events message passed trough;
322 List of isds_event's. */
325 /* Following members apply to both outgoing and incoming messages: */
326 char *dmSenderOrgUnit; /* Organisation unit of sender as string;
327 Optional. */
328 long int *dmSenderOrgUnitNum; /* Organisation unit of sender as number;
329 Optional. */
330 char *dbIDRecipient; /* Box ID of recipient; Mandatory.
331 Maximal length is 7 characters. */
332 char *dmRecipientOrgUnit; /* Organisation unit of recipient as
333 string; Optional. */
334 long int *dmRecipientOrgUnitNum; /* Organisation unit of recipient as
335 number; Optional. */
336 char *dmToHands; /* Person in recipient organisation;
337 Optional. */
338 char *dmAnnotation; /* Subject (title) of the message.
339 Maximal length is 255 characters. */
340 char *dmRecipientRefNumber; /* Czech: číslo jednací příjemce; Optional.
341 Maximal length is 50 characters. */
342 char *dmSenderRefNumber; /* Czech: číslo jednací odesílatele;
343 Optional. Maximal lenght is 50 chars. */
344 char *dmRecipientIdent; /* Czech: spisová značka příjemce; Optional.
345 Maximal length is 50 characters. */
346 char *dmSenderIdent; /* Czech: spisová značka odesílatele;
347 Optional. Maximal lenght is 50 chars. */
349 /* Act addressing in Czech Republic:
350 * Point (Parahraph) § Section Law/Year Coll. */
351 long int *dmLegalTitleLaw; /* Number of act mandating authority */
352 long int *dmLegalTitleYear; /* Year of act issue mandating authority */
353 char *dmLegalTitleSect; /* Section of act mandating authority.
354 Czech: paragraf */
355 char *dmLegalTitlePar; /* Parahraph of act mandating authority.
356 Czech: odstavec */
357 char *dmLegalTitlePoint; /* Point of act mandating authority.
358 Czech: písmeno */
360 _Bool *dmPersonalDelivery; /* If true, only person with higher
361 priviledges can read this message */
362 _Bool *dmAllowSubstDelivery; /* Allow delivery through fiction.
363 I.e. Even if recipient did not read this
364 message, message is considered as
365 delivered after (currently) 10 days.
366 This is delivery through fiction.
367 Applies only to OVM dbType sender. */
368 _Bool *dmOVM; /* OVM sending mode.
369 Non-OVM dbType boxes that has
370 dbEffectiveOVM == true MUST select
371 between true (OVM mode) and
372 false (non-OVM mode).
373 Optionable; Implicit value is true. */
377 /* Document type from point of hiearchy */
378 typedef enum {
379 FILEMETATYPE_MAIN, /* Main document */
380 FILEMETATYPE_ENCLOSURE, /* Appendix */
381 FILEMETATYPE_SIGNATURE, /* Digital signature of other document */
382 FILEMETATYPE_META /* XML document for ESS (electronic
383 document information system) purposes */
384 } isds_FileMetaType;
386 /* Document */
387 struct isds_document {
388 void *data; /* Document content.
389 The encoding and interpretation depends
390 on dmMimeType.
391 TODO: inline XML */
392 size_t data_length; /* Length of the data in bytes */
393 char *dmMimeType; /* MIME type of data; Mandatory. */
394 isds_FileMetaType dmFileMetaType; /* Document type to create hierarchy */
395 char *dmFileGuid; /* Message-local document identifier;
396 Optional. */
397 char *dmUpFileGuid; /* Reference to upper document identifier
398 (dmFileGuid); Optional. */
399 char *dmFileDescr; /* Document name (title). E.g. file name;
400 Mandatory. */
401 char *dmFormat; /* Reference to XML form definition;
402 Defines howto interpret XML document;
403 Optional. */
406 /* Raw message representation content type.
407 * This is necessary to distinguish between different representations without
408 * expensive repated detection.
409 * Infix explanation:
410 * PLAIN_SIGNED data are XML with namespace mangled to signed alternative
411 * CMS_SIGNED data are XML with signed namespace encapsulated in CMS */
412 typedef enum {
413 RAWTYPE_INCOMING_MESSAGE,
414 RAWTYPE_PLAIN_SIGNED_INCOMING_MESSAGE,
415 RAWTYPE_CMS_SIGNED_INCOMING_MESSAGE,
416 RAWTYPE_PLAIN_SIGNED_OUTGOING_MESSAGE,
417 RAWTYPE_CMS_SIGNED_OUTGOING_MESSAGE,
418 RAWTYPE_DELIVERYINFO,
419 RAWTYPE_PLAIN_SIGNED_DELIVERYINFO,
420 RAWTYPE_CMS_SIGNED_DELIVERYINFO
421 } isds_raw_type;
423 /* Message */
424 struct isds_message {
425 void *raw; /* Raw message in XML format as send to or
426 from the ISDS. You can use it to store
427 local copy. This is binary buffer. */
428 size_t raw_length; /* Lenght of raw message in bytes */
429 isds_raw_type raw_type; /* Content type of raw representation
430 Meaningfull only with non-NULL raw
431 member */
432 struct isds_envelope *envelope; /* Message envelope */
433 struct isds_list *documents; /* List of isds_document's.
434 Valid message must contain exactly one
435 document of type FILEMETATYPE_MAIN and
436 can contain any number of other type
437 documents. Totol size of documents
438 must not exceed 10 MB. */
441 /* Message copy recipient and assigned message ID */
442 struct isds_message_copy {
443 /* Input members defined by application */
444 char *dbIDRecipient; /* Box ID of recipient; Mandatory.
445 Maximal length is 7 characters. */
446 char *dmRecipientOrgUnit; /* Organisation unit of recipient as
447 string; Optional. */
448 long int *dmRecipientOrgUnitNum; /* Organisation unit of recipient as
449 number; Optional. */
450 char *dmToHands; /* Person in recipient organisation;
451 Optional. */
453 /* Output members returned from ISDS */
454 isds_error error; /* libisds compatible error of delivery to o ne recipient */
455 char *dmStatus; /* Error description returned by ISDS;
456 Optional. */
457 char *dmID; /* Assigned message ID; Meaningfull only
458 for error == IE_SUCCESS */
461 /* General linked list */
462 struct isds_list {
463 struct isds_list *next; /* Next list item,
464 or NULL if current is last */
465 void *data; /* Payload */
466 void (*destructor) (void **); /* Payload deallocator */
469 /* Free isds_list with all member data.
470 * @list list to free, on return will be NULL */
471 void isds_list_free(struct isds_list **list);
474 /* Initialize ISDS library.
475 * Global function, must be called before other functions.
476 * If it failes you can not use ISDS library and must call isds_cleanup() to
477 * free partially inititialized global variables. */
478 isds_error isds_init(void);
480 /* Deinicialize ISDS library.
481 * Global function, must be called as last library function. */
482 isds_error isds_cleanup(void);
484 /* Create ISDS context.
485 * Each context can be used for different sessions to (possibly) different
486 * ISDS server with different credentials.
487 * Returns new context, or NULL */
488 struct isds_ctx *isds_ctx_create(void);
490 /* Destroy ISDS context and free memmory.
491 * @context will be NULLed on success. */
492 isds_error isds_ctx_free(struct isds_ctx **context);
494 /* Return long message text produced by library fucntion, e.g. detailed error
495 * mesage. Returned pointer is only valid until new library function is
496 * called for the same context. Could be NULL, especially if NULL context is
497 * supplied. Return string is locale encoded. */
498 char *isds_long_message(const struct isds_ctx *context);
500 /* Set logging up.
501 * @facilities is bitmask of isds_log_facility values,
502 * @level is verbosity level. */
503 void isds_set_logging(const unsigned int facilities,
504 const isds_log_level level);
507 /* Set timeout in miliseconds for each network job like connecting to server
508 * or sending message. Use 0 to disable timeout limits. */
509 isds_error isds_set_timeout(struct isds_ctx *context,
510 const unsigned int timeout);
512 /* Function provided by application libsds will call with
513 * following five arguments. Value zero of any argument means the value is
514 * unknown.
515 * @upload_total is expected total upload,
516 * @upload_current is cumulative current upload progress
517 * @dowload_total is expected total download
518 * @download_current is cumulative current download progress
519 * @data is pointer that will be passed unchanged to this function at run-time
520 * @return 0 to continue HTTP transfaer, or non-zero to abort transfer */
521 typedef int (*isds_progress_callback)(
522 double upload_total, double upload_current,
523 double download_total, double download_current,
524 void *data);
526 /* Register callback function libisds calls periodocally during HTTP data
527 * transfer.
528 * @context is session context
529 * @callback is function provided by application libsds will call. See type
530 * defition for @callback argument explanation.
531 * @data is application specific data @callback gets as last argument */
532 isds_error isds_set_progress_callback(struct isds_ctx *context,
533 isds_progress_callback callback, void *data);
535 /* Change SSL/TLS settings.
536 * @context is context which setting vill be applied to
537 * @option is name of option. It determines the type of last argument. See
538 * isds_tls_option definition for more info.
539 * @... is value of new setting. Type is determined by @option
540 * */
541 isds_error isds_set_tls(struct isds_ctx *context, const isds_tls_option option,
542 ...);
544 /* Connect and log in into ISDS server.
545 * @url is address of ISDS web service
546 * @username is user name of ISDS user
547 * @password is user's secret password
548 * @certificate is NULL terminated string with PEM formated client's
549 * certificate. Use NULL if only password autentication should be performed.
550 * @key is private key for client's certificate as (base64 encoded?) NULL
551 * terminated string. Use NULL if only password autentication is desired.
552 * */
553 isds_error isds_login(struct isds_ctx *context, const char *url,
554 const char *username, const char *password,
555 const char *certificate, const char* key);
557 /* Log out from ISDS server and close connection. */
558 isds_error isds_logout(struct isds_ctx *context);
560 /* Verify connection to ISDS is alive and server is responding.
561 * Sent dumy request to ISDS and expect dummy response. */
562 isds_error isds_ping(struct isds_ctx *context);
564 /* Get data about logged in user and his box. */
565 isds_error isds_GetOwnerInfoFromLogin(struct isds_ctx *context,
566 struct isds_DbOwnerInfo **db_owner_info);
568 /* Get data about logged in user. */
569 isds_error isds_GetUserInfoFromLogin(struct isds_ctx *context,
570 struct isds_DbUserInfo **db_user_info);
572 /* Get expiration time of current password
573 * @context is session context
574 * @expiration is automatically reallocated time when password expires, In
575 * case of error will be nulled. */
576 isds_error isds_get_password_expiration(struct isds_ctx *context,
577 struct timeval **expiration);
579 /* Change user password in ISDS.
580 * User must supply old password, new password will takes effect after some
581 * time, current session can continue. Password must fulfill some constraints.
582 * @context is session context
583 * @old_password is current password.
584 * @new_password is requested new password */
585 isds_error isds_change_password(struct isds_ctx *context,
586 const char *old_password, const char *new_password);
588 /* Create new box.
589 * @context is session context
590 * @box is box description to create including single primary user (in case of
591 * FO box type). It outputs box ID assigned by ISDS in dbID element.
592 * @users is list of struct isds_DbUserInfo (primary users in case of non-FO
593 * box, or contact address of PFO box owner)
594 * @former_names is optional undocumented string. Pass NULL if you don't care.
595 * @upper_box_id is optional ID of supper box if currently created box is
596 * subordinated.
597 * @ceo_label is optional title of OVM box owner (e.g. mayor)
598 * @refnumber is reallocated serial number of request assigned by ISDS. Use
599 * NULL, if you don't care.*/
600 isds_error isds_add_box(struct isds_ctx *context,
601 struct isds_DbOwnerInfo *box, const struct isds_list *users,
602 const char *former_names, const char *upper_box_id,
603 const char *ceo_label, char **refnumber);
605 /* Notify ISDS about new PFO entity.
606 * This function has no real effect.
607 * @context is session context
608 * @box is PFO description including single primary user.
609 * @users is list of struct isds_DbUserInfo (contact address of PFO box owner)
610 * @former_names is optional undocumented string. Pass NULL if you don't care.
611 * @upper_box_id is optional ID of supper box if currently created box is
612 * subordinated.
613 * @ceo_label is optional title of OVM box owner (e.g. mayor)
614 * @refnumber is reallocated serial number of request assigned by ISDS. Use
615 * NULL, if you don't care.*/
616 isds_error isds_add_pfoinfo(struct isds_ctx *context,
617 const struct isds_DbOwnerInfo *box, const struct isds_list *users,
618 const char *former_names, const char *upper_box_id,
619 const char *ceo_label, char **refnumber);
621 /* Remove given given box permanetly.
622 * @context is session context
623 * @box is box description to delete
624 * @since is date of box owner cancalation. Only tm_year, tm_mon and tm_mday
625 * carry sane value.
626 * @refnumber is reallocated serial number of request assigned by ISDS. Use
627 * NULL, if you don't care.*/
628 isds_error isds_delete_box(struct isds_ctx *context,
629 const struct isds_DbOwnerInfo *box, const struct tm *since,
630 char **refnumber);
632 /* Update data about given box.
633 * @context is session context
634 * @old_box current box description
635 * @new_box are updated data about @old_box
636 * @refnumber is reallocated serial number of request assigned by ISDS. Use
637 * NULL, if you don't care.*/
638 isds_error isds_UpdateDataBoxDescr(struct isds_ctx *context,
639 const struct isds_DbOwnerInfo *old_box,
640 const struct isds_DbOwnerInfo *new_box,
641 char **refnumber);
643 /* Get data about all users assigned to given box.
644 * @context is session context
645 * @box_id is box ID
646 * @users is automatically reallocated list of struct isds_DbUserInfo */
647 isds_error isds_GetDataBoxUsers(struct isds_ctx *context, const char *box_id,
648 struct isds_list **users);
650 /* Update data about user assigned to given box.
651 * @context is session context
652 * @box is box identification
653 * @old_user identifies user to update
654 * @new_user are updated data about @old_user
655 * @refnumber is reallocated serial number of request assigned by ISDS. Use
656 * NULL, if you don't care.*/
657 isds_error isds_UpdateDataBoxUser(struct isds_ctx *context,
658 const struct isds_DbOwnerInfo *box,
659 const struct isds_DbUserInfo *old_user,
660 const struct isds_DbUserInfo *new_user,
661 char **refnumber);
663 /* Reset credentials of user assigned to given box.
664 * @context is session context
665 * @box is box identification
666 * @user identifies user to reset password
667 * @fee_paid is true if fee has been paid, false otherwise
668 * @token is NULL if new password should be delivered off-line to the user.
669 * It is valid pointer if user should obtain new password on-line on dedicated
670 * web server. Then it output automatically reallocated token user needs to
671 * use to athtorize on the web server to view his new password.
672 * @refnumber is reallocated serial number of request assigned by ISDS. Use
673 * NULL, if you don't care.*/
674 isds_error isds_reset_password(struct isds_ctx *context,
675 const struct isds_DbOwnerInfo *box,
676 const struct isds_DbUserInfo *user,
677 const _Bool fee_paid,
678 char **token, char **refnumber);
680 /* Assign new user to given box.
681 * @context is session context
682 * @box is box identification
683 * @user defines new user to add
684 * @refnumber is reallocated serial number of request assigned by ISDS. Use
685 * NULL, if you don't care.*/
686 isds_error isds_add_user(struct isds_ctx *context,
687 const struct isds_DbOwnerInfo *box, const struct isds_DbUserInfo *user,
688 char **refnumber);
690 /* Remove user assigned to given box.
691 * @context is session context
692 * @box is box identification
693 * @user identifies user to removve
694 * @refnumber is reallocated serial number of request assigned by ISDS. Use
695 * NULL, if you don't care.*/
696 isds_error isds_delete_user(struct isds_ctx *context,
697 const struct isds_DbOwnerInfo *box, const struct isds_DbUserInfo *user,
698 char **refnumber);
700 /* Find boxes suiting given criteria.
701 * @context is ISDS session context.
702 * @criteria is filter. You should fill in at least some members.
703 * @boxes is automatically reallocated list of isds_DbOwnerInfo structures,
704 * possibly empty. Input NULL or valid old structure.
705 * @return:
706 * IE_SUCCESS if search sucseeded, @boxes contains usefull data
707 * IE_NOEXIST if no such box exists, @boxes will be NULL
708 * IE_2BIG if too much boxes exist and server truncated the resuluts, @boxes
709 * contains still valid data
710 * other code if something bad happens. @boxes will be NULL. */
711 isds_error isds_FindDataBox(struct isds_ctx *context,
712 const struct isds_DbOwnerInfo *criteria,
713 struct isds_list **boxes);
715 /* Get status of a box.
716 * @context is ISDS session context.
717 * @box_id is UTF-8 encoded box identifier as zero terminated string
718 * @box_status is return value of box status.
719 * @return:
720 * IE_SUCCESS if box has been found and its status retrieved
721 * IE_NOEXIST if box is not known to ISDS server
722 * or other appropriate error.
723 * You can use isds_DbState to enumerate box status. However out of enum
724 * range value can be returned too. This is feature because ISDS
725 * specification leaves the set of values open.
726 * Be ware that status DBSTATE_REMOVED is signaled as IE_SUCCESS. That means
727 * the box has been deleted, but ISDS still lists its former existence. */
728 isds_error isds_CheckDataBox(struct isds_ctx *context, const char *box_id,
729 long int *box_status);
731 /* Switch box into state where box can receive commercial messages (off by
732 * default)
733 * @context is ISDS session context.
734 * @box_id is UTF-8 encoded box identifier as zero terminated string
735 * @allow is true for enable, false for disable commercial messages income
736 * @refnumber is reallocated serial number of request assigned by ISDS. Use
737 * NULL, if you don't care. */
738 isds_error isds_switch_commercial_receiving(struct isds_ctx *context,
739 const char *box_id, const _Bool allow, char **refnumber);
741 /* Switch box into / out of state where non-OVM box can act as OVM (e.g. force
742 * message acceptance). This is just a box permission. Sender must apply
743 * such role by sending each message.
744 * @context is ISDS session context.
745 * @box_id is UTF-8 encoded box identifier as zero terminated string
746 * @allow is true for enable, false for disable OVM role permission
747 * @refnumber is reallocated serial number of request assigned by ISDS. Use
748 * NULL, if you don't care. */
749 isds_error isds_switch_effective_ovm(struct isds_ctx *context,
750 const char *box_id, const _Bool allow, char **refnumber);
752 /* Switch box accessibility state on request of box owner.
753 * Despite the name, owner must do the requst off-line. This function is
754 * designed for such off-line meeting points (e.g. Czech POINT).
755 * @context is ISDS session context.
756 * @box identifies box to swith accesibilty state.
757 * @allow is true for making accesibale, false to disallow access.
758 * @refnumber is reallocated serial number of request assigned by ISDS. Use
759 * NULL, if you don't care. */
760 isds_error isds_switch_box_accessibility_on_owner_request(
761 struct isds_ctx *context, const struct isds_DbOwnerInfo *box,
762 const _Bool allow, char **refnumber);
764 /* Disable box accessibility on law enforcement (e.g. by prison) since exact
765 * date.
766 * @context is ISDS session context.
767 * @box identifies box to swith accesibilty state.
768 * @since is date since accesseibility has been denied. This can be past too.
769 * Only tm_year, tm_mon and tm_mday carry sane value.
770 * @refnumber is reallocated serial number of request assigned by ISDS. Use
771 * NULL, if you don't care. */
772 isds_error isds_disable_box_accessibility_externaly(
773 struct isds_ctx *context, const struct isds_DbOwnerInfo *box,
774 const struct tm *since, char **refnumber);
776 /* Send a message via ISDS to a recipent
777 * @context is session context
778 * @outgoing_message is message to send; Some memebers are mandatory (like
779 * dbIDRecipient), some are optional and some are irrelevant (especialy data
780 * about sender). Included pointer to isds_list documents must contain at
781 * least one document of FILEMETATYPE_MAIN. This is read-write structure, some
782 * members will be filled with valid data from ISDS. Exact list of write
783 * members is subject to change. Currently dmId is changed.
784 * @return ISDS_SUCCESS, or other error code if something goes wrong. */
785 isds_error isds_send_message(struct isds_ctx *context,
786 struct isds_message *outgoing_message);
788 /* Send a message via ISDS to a multiple recipents
789 * @context is session context
790 * @outgoing_message is message to send; Some memebers are mandatory,
791 * some are optional and some are irrelevant (especialy data
792 * about sender). Data about recipient will be substituted by ISDS from
793 * @copies. Included pointer to isds_list documents must
794 * contain at least one document of FILEMETATYPE_MAIN.
795 * @copies is list of isds_message_copy structures addressing all desired
796 * recipients. This is read-write structure, some members will be filled with
797 * valid data from ISDS (message IDs, error codes, error descriptions).
798 * @return
799 * ISDS_SUCCESS if all messages have been sent
800 * ISDS_PARTIAL_SUCCESS if sending of some messages has failed (failed and
801 * succesed messages can be identified by copies->data->error),
802 * or other error code if something other goes wrong. */
803 isds_error isds_send_message_to_multiple_recipients(struct isds_ctx *context,
804 const struct isds_message *outgoing_message,
805 struct isds_list *copies);
807 /* Get list of outgoing (already sent) messages.
808 * Any criterion argument can be NULL, if you don't care about it.
809 * @context is session context. Must not be NULL.
810 * @from_time is minimal time and date of message sending inclusive.
811 * @to_time is maximal time and date of message sending inclusive
812 * @dmSenderOrgUnitNum is the same as isds_envelope.dmSenderOrgUnitNum
813 * @status_filter is bit field of isds_message_status values. Use special
814 * value MESSAGESTATE_ANY to signal you don't care. (It's defined as union of
815 * all values, you can use bitwise arithmetic if you want.)
816 * @offset is index of first message we are interested in. First message is 1.
817 * Set to 0 (or 1) if you don't care.
818 * @number is maximal length of list you want to get as input value, outputs
819 * number of messages matching these criteria. Can be NULL if you don't care
820 * (applies to output value either).
821 * @messages is automatically reallocated list of isds_message's. Be ware that
822 * it returns only brief overview (envelope and some other fields) about each
823 * message, not the complete message. FIXME: Specify exact fields.
824 * The list is sorted by delivery time in ascending order.
825 * Use NULL if you don't care about the metadata (useful if you want to know
826 * only the @number). If you provide &NULL, list will be allocated on heap,
827 * if you provide pointer to non-NULL, list will be freed automacally at first.
828 * Also in case of error the list will be NULLed.
829 * @return IE_SUCCESS or appropriate error code. */
830 isds_error isds_get_list_of_sent_messages(struct isds_ctx *context,
831 const struct timeval *from_time, const struct timeval *to_time,
832 const long int *dmSenderOrgUnitNum, const unsigned int status_filter,
833 const unsigned long int offset, unsigned long int *number,
834 struct isds_list **messages);
836 /* Get list of incoming (addressed to you) messages.
837 * Any criterion argument can be NULL, if you don't care about it.
838 * @context is session context. Must not be NULL.
839 * @from_time is minimal time and date of message sending inclusive.
840 * @to_time is maximal time and date of message sending inclusive
841 * @dmSenderOrgUnitNum is the same as isds_envelope.dmSenderOrgUnitNum
842 * @status_filter is bit field of isds_message_status values. Use special
843 * value MESSAGESTATE_ANY to signal you don't care. (It's defined as union of
844 * all values, you can use bitwise arithmetic if you want.)
845 * @offset is index of first message we are interested in. First message is 1.
846 * Set to 0 (or 1) if you don't care.
847 * @number is maximal length of list you want to get as input value, outputs
848 * number of messages matching these criteria. Can be NULL if you don't care
849 * (applies to output value either).
850 * @messages is automatically reallocated list of isds_message's. Be ware that
851 * it returns only brief overview (envelope and some other fields) about each
852 * message, not the complete message. FIXME: Specify exact fields.
853 * Use NULL if you don't care about the metadata (useful if you want to know
854 * only the @number). If you provide &NULL, list will be allocated on heap,
855 * if you provide pointer to non-NULL, list will be freed automacally at first.
856 * Also in case of error the list will be NULLed.
857 * @return IE_SUCCESS or appropriate error code. */
858 isds_error isds_get_list_of_received_messages(struct isds_ctx *context,
859 const struct timeval *from_time, const struct timeval *to_time,
860 const long int *dmSenderOrgUnitNum, const unsigned int status_filter,
861 const unsigned long int offset, unsigned long int *number,
862 struct isds_list **messages);
864 /* Download incoming message envelope identified by ID.
865 * @context is session context
866 * @message_id is message identifier (you can get them from
867 * isds_get_list_of_received_messages())
868 * @message is automatically reallocated message retrieved from ISDS.
869 * It will miss documents per se. Use isds_get_received_message(), if you are
870 * interrested in documents (content) too.
871 * Returned hash and timestamp require documents to be verifiable. */
872 isds_error isds_get_received_envelope(struct isds_ctx *context,
873 const char *message_id, struct isds_message **message);
875 /* Download signed delivery infosheet of given message identified by ID.
876 * @context is session context
877 * @message_id is message identifier (you can get them from
878 * isds_get_list_of_{sent,received}_messages())
879 * @message is automatically reallocated message retrieved from ISDS.
880 * It will miss documents per se. Use isds_get_signed_received_message(),
881 * if you are interrested in documents (content). OTOH, only this function
882 * can get list events message has gone through. */
883 isds_error isds_get_signed_delivery_info(struct isds_ctx *context,
884 const char *message_id, struct isds_message **message);
886 /* Load delivery info of any format from buffer.
887 * @context is session context
888 * @raw_type advertises format of @buffer content. Only delivery info types
889 * are accepted.
890 * @buffer is DER encoded PKCS#7 structure with signed delivery info. You can
891 * retrieve such data from message->raw after calling
892 * isds_get_signed_delivery_info().
893 * @length is length of buffer in bytes.
894 * @message is automatically reallocated message parsed from @buffer.
895 * @strategy selects how buffer will be attached into raw isds_message member.
896 * */
897 isds_error isds_load_delivery_info(struct isds_ctx *context,
898 const isds_raw_type raw_type,
899 const void *buffer, const size_t length,
900 struct isds_message **message, const isds_buffer_strategy strategy);
902 /* Download delivery infosheet of given message identified by ID.
903 * @context is session context
904 * @message_id is message identifier (you can get them from
905 * isds_get_list_of_{sent,received}_messages())
906 * @message is automatically reallocated message retrieved from ISDS.
907 * It will miss documents per se. Use isds_get_received_message(), if you are
908 * interrested in documents (content). OTOH, only this function can get list
909 * events message has gone through. */
910 isds_error isds_get_delivery_info(struct isds_ctx *context,
911 const char *message_id, struct isds_message **message);
913 /* Deprecated: Use isds_load_message() instead. */
914 /* Load incoming message from buffer.
915 * @context is session context
916 * @buffer XML stream with unsigned message. You can retrieve such data from
917 * message->raw after calling isds_get_received_message().
918 * @length is length of buffer in bytes.
919 * @message is automatically reallocated message parsed from @buffer.
920 * @strategy selects how buffer will be attached into raw isds_message member.
921 * */
922 isds_error isds_load_received_message(struct isds_ctx *context,
923 const void *buffer, const size_t length,
924 struct isds_message **message, const isds_buffer_strategy strategy)
925 _deprecated;
927 /* Download incoming message identified by ID.
928 * @context is session context
929 * @message_id is message identifier (you can get them from
930 * isds_get_list_of_received_messages())
931 * @message is automatically reallocated message retrieved from ISDS */
932 isds_error isds_get_received_message(struct isds_ctx *context,
933 const char *message_id, struct isds_message **message);
935 /* Deprecated: Use isds_load_message() instead. */
936 /* Load signed message from buffer.
937 * @context is session context
938 * @outgoing is true if message is outgoing, false if message is incoming
939 * @buffer is DER encoded PKCS#7 structure with signed message. You can
940 * retrieve such data from message->raw after calling
941 * isds_get_signed{received,sent}_message().
942 * @length is length of buffer in bytes.
943 * @message is automatically reallocated message parsed from @buffer.
944 * @strategy selects how buffer will be attached into raw isds_message member.
945 * */
946 isds_error isds_load_signed_message(struct isds_ctx *context,
947 const _Bool outgoing, const void *buffer, const size_t length,
948 struct isds_message **message, const isds_buffer_strategy strategy)
949 _deprecated;
951 /* Load message of any type from buffer.
952 * @context is session context
953 * @raw_type defines content type of @buffer. Only message types are allowed.
954 * @buffer is message raw representation. Format (CMS, plain signed,
955 * message direction) is defined in @raw_type. You can retrieve such data
956 * from message->raw after calling isds_get_[signed]{received,sent}_message().
957 * @length is length of buffer in bytes.
958 * @message is automatically reallocated message parsed from @buffer.
959 * @strategy selects how buffer will be attached into raw isds_message member.
960 * */
961 isds_error isds_load_message(struct isds_ctx *context,
962 const isds_raw_type raw_type, const void *buffer, const size_t length,
963 struct isds_message **message, const isds_buffer_strategy strategy);
965 /* Download signed incoming message identified by ID.
966 * @context is session context
967 * @message_id is message identifier (you can get them from
968 * isds_get_list_of_received_messages())
969 * @message is automatically reallocated message retrieved from ISDS. The raw
970 * memeber will be filled with PKCS#7 structure in DER format. */
971 isds_error isds_get_signed_received_message(struct isds_ctx *context,
972 const char *message_id, struct isds_message **message);
974 /* Download signed outgoing message identified by ID.
975 * @context is session context
976 * @message_id is message identifier (you can get them from
977 * isds_get_list_of_sent_messages())
978 * @message is automatically reallocated message retrieved from ISDS. The raw
979 * memeber will be filled with PKCS#7 structure in DER format. */
980 isds_error isds_get_signed_sent_message(struct isds_ctx *context,
981 const char *message_id, struct isds_message **message);
983 /* Retrieve hash of message identified by ID stored in ISDS.
984 * @context is session context
985 * @message_id is message identifier
986 * @hash is automatically reallocated message hash downloaded from ISDS.
987 * Message must exist in system and must not be deleted. */
988 isds_error isds_download_message_hash(struct isds_ctx *context,
989 const char *message_id, struct isds_hash **hash);
991 /* Compute hash of message from raw representation and store it into envelope.
992 * Original hash structure will be destroyed in envelope.
993 * @context is session context
994 * @message is message carrying raw XML message blob
995 * @algorithm is desired hash algorithm to use */
996 isds_error isds_compute_message_hash(struct isds_ctx *context,
997 struct isds_message *message, const isds_hash_algorithm algorithm);
999 /* Compare two hashes.
1000 * @h1 is first hash
1001 * @h2 is another hash
1002 * @return
1003 * IE_SUCCESS if hashes equal
1004 * IE_NOTUNIQ if hashes are comparable, but they don't equal
1005 * IE_ENUM if not comparable, but both structures defined
1006 * IE_INVAL if some of the structures are undefined (NULL)
1007 * IE_ERROR if internal error occurs */
1008 isds_error isds_hash_cmp(const struct isds_hash *h1,
1009 const struct isds_hash *h2);
1011 /* Check message has gone through ISDS by comparing message hash stored in
1012 * ISDS and locally computed hash. You must provide message with valid raw
1013 * member (do not use isds_load_message(..., BUFFER_DONT_STORE)).
1014 * This is convenient wrapper for isds_download_message_hash(),
1015 * isds_compute_message_hash(), and isds_hash_cmp() sequence.
1016 * @context is session context
1017 * @message is message with valid raw and envelope member; envelope->hash
1018 * member will be changed during funcion run. Use envelope on heap only.
1019 * @return
1020 * IE_SUCCESS if message originates in ISDS
1021 * IE_NOTEQUAL if message is unknown to ISDS
1022 * other code for other errors */
1023 isds_error isds_verify_message_hash(struct isds_ctx *context,
1024 struct isds_message *message);
1026 /* Mark message as read. This is a transactional commit function to acknoledge
1027 * to ISDS the message has been downloaded and processed by client properly.
1028 * @context is session context
1029 * @message_id is message identifier. */
1030 isds_error isds_mark_message_read(struct isds_ctx *context,
1031 const char *message_id);
1033 /* Mark message as received by recipient. This is applicable only to
1034 * commercial message. There is no specified way how to distinguishe
1035 * commercial message from government message yet. Government message is
1036 * received automatically (by law), commenrcial message on recipient request.
1037 * @context is session context
1038 * @message_id is message identifier. */
1039 isds_error isds_mark_message_received(struct isds_ctx *context,
1040 const char *message_id);
1042 /* Send bogus request to ISDS.
1043 * Just for test purposes */
1044 isds_error isds_bogus_request(struct isds_ctx *context);
1046 /* Search for document by document ID in list of documents. IDs are compared
1047 * as UTF-8 string.
1048 * @documents is list of isds_documents
1049 * @id is document identifier
1050 * @return first matching document or NULL. */
1051 const struct isds_document *isds_find_document_by_id(
1052 const struct isds_list *documents, const char *id);
1054 /* Deallocate structure isds_hash and NULL it.
1055 * @hash hash to to free */
1056 void isds_hash_free(struct isds_hash **hash);
1058 /* Deallocate structure isds_DbOwnerInfo recursively and NULL it */
1059 void isds_DbOwnerInfo_free(struct isds_DbOwnerInfo **db_owner_info);
1061 /* Deallocate structure isds_DbUserInfo recursively and NULL it */
1062 void isds_DbUserInfo_free(struct isds_DbUserInfo **db_user_info);
1064 /* Deallocate struct isds_event recursively and NULL it */
1065 void isds_event_free(struct isds_event **event);
1067 /* Deallocate struct isds_envelope recursively and NULL it */
1068 void isds_envelope_free(struct isds_envelope **envelope);
1070 /* Deallocate struct isds_document recursively and NULL it */
1071 void isds_document_free(struct isds_document **document);
1073 /* Deallocate struct isds_message recursively and NULL it */
1074 void isds_message_free(struct isds_message **message);
1076 /* Deallocate struct isds_message_copy recursively and NULL it */
1077 void isds_message_copy_free(struct isds_message_copy **copy);
1079 /* Copy structure isds_PersonName recursively */
1080 struct isds_PersonName *isds_PersonName_duplicate(
1081 const struct isds_PersonName *template);
1083 /* Copy structure isds_Address recursively */
1084 struct isds_Address *isds_Address_duplicate(
1085 const struct isds_Address *template);
1087 /* Copy structure isds_DbOwnerInfo recursively */
1088 struct isds_DbOwnerInfo *isds_DbOwnerInfo_duplicate(
1089 const struct isds_DbOwnerInfo *template);
1091 /* Copy structure isds_DbUserInfo recursively */
1092 struct isds_DbUserInfo *isds_DbUserInfo_duplicate(
1093 const struct isds_DbUserInfo *template);
1095 #endif