Fix typo in isds_get_delivery_info() description
[libisds.git] / src / isds.h
blobfef4990bc51ad252ec5f79444b77eb3aa64f5431
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 #ifdef __cplusplus /* For C++ linker sake */
11 extern "C" {
12 #endif
14 /* _deprecated macro marks library symbols as deprecated. Application should
15 * avoid using such function as soon as possible. */
16 #if defined(__GNUC__)
17 #define _deprecated __attribute__((deprecated))
18 #else
19 #define _deprecated
20 #endif
22 /* Service locators */
23 /* Base URL of production ISDS instance */
24 extern const char isds_locator[]; /* Without client certificate auth. */
25 extern const char isds_cert_locator[]; /* With client certificate auth. */
26 /* Base URL of testing ISDS instance */
27 extern const char isds_testing_locator[]; /* Without client certificate auth. */
28 extern const char isds_testing_locator[]; /* With client certificate auth. */
31 struct isds_ctx; /* Context for specific ISDS box */
33 typedef enum {
34 IE_SUCCESS = 0, /* No error, just for C convenience (0 means Ok) */
35 IE_ERROR, /* Unspecified error */
36 IE_NOTSUP,
37 IE_INVAL,
38 IE_INVALID_CONTEXT,
39 IE_NOT_LOGGED_IN,
40 IE_CONNECTION_CLOSED,
41 IE_TIMED_OUT,
42 IE_NOEXIST,
43 IE_NOMEM,
44 IE_NETWORK,
45 IE_HTTP,
46 IE_SOAP,
47 IE_XML,
48 IE_ISDS,
49 IE_ENUM,
50 IE_DATE,
51 IE_2BIG,
52 IE_2SMALL,
53 IE_NOTUNIQ,
54 IE_NOTEQUAL,
55 IE_PARTIAL_SUCCESS,
56 IE_ABORTED
57 } isds_error;
59 typedef enum {
60 ILL_NONE = 0,
61 ILL_CRIT = 10,
62 ILL_ERR = 20,
63 ILL_WARNING = 30,
64 ILL_INFO = 40,
65 ILL_DEBUG = 50,
66 ILL_ALL = 100
67 } isds_log_level;
69 typedef enum {
70 ILF_NONE = 0x0,
71 ILF_HTTP = 0x1,
72 ILF_SOAP = 0x2,
73 ILF_ISDS = 0x4,
74 ILF_FILE = 0x8,
75 ILF_SEC = 0x10,
76 ILF_XML = 0x20,
77 ILF_ALL = 0xFF
78 } isds_log_facility;
80 /* Return text description of ISDS error */
81 const char *isds_strerror(const isds_error error);
83 /* libisds options */
84 typedef enum {
85 IOPT_TLS_VERIFY_SERVER, /* _Bool: Verify server identity?
86 Default value is true. */
87 IOPT_TLS_CA_FILE, /* char *: File name with CA certificates.
88 Default value depends on cryptographic
89 library. */
90 IOPT_TLS_CA_DIRECTORY, /* char *: Directory name with CA certificates.
91 Default value depends on cryptographic
92 library. */
93 IOPT_TLS_CRL_FILE, /* char *: File name with CRL in PEM format.
94 Default value depends on cryptographic
95 library. */
96 IOPT_NORMALIZE_MIME_TYPE, /* _Bool: Normalize MIME type values?
97 Default value is false. */
98 } isds_option;
100 /* TLS libisds options */
101 typedef enum {
102 ITLS_VERIFY_SERVER, /* _Bool: Verify server identity? */
103 ITLS_CA_FILE, /* char *: File name with CA certificates */
104 ITLS_CA_DIRECTORY, /* char *: Directory name with CA certificates */
105 ITLS_CRL_FILE /* char *: File name with CRL in PEM format */
106 } isds_tls_option;
108 /* Cryptographic material encoding */
109 typedef enum {
110 PKI_FORMAT_PEM, /* PEM format */
111 PKI_FORMAT_DER, /* DER format */
112 PKI_FORMAT_ENG /* Stored in crypto engine */
113 } isds_pki_format;
115 /* Public key crypto material to authenticate client */
116 struct isds_pki_credentials {
117 char *engine; /* String identifier of crypto engine to use
118 (where key is stored). Use NULL for no engine */
119 isds_pki_format certificate_format; /* Certificate format */
120 char *certificate; /* Path to client certificate, or certificate
121 nickname in case of NSS as curl back-end,
122 or key slot identifier inside crypto engine.
123 Some crypto engines can pair certificate with
124 key automatically (NULL value) */
125 isds_pki_format key_format; /* Private key format */
126 char *key; /* Path to client private key, or key identifier
127 in case of used engine */
128 char *passphrase; /* Zero terminated string with password for
129 decrypting private key, or engine PIN.
130 Use NULL for no pass-phrase or question by
131 engine. */
134 /* Box type */
135 typedef enum {
136 DBTYPE_SYSTEM = 0, /* This is special sender value for messages
137 sent by ISDS. */
138 DBTYPE_OVM = 10,
139 DBTYPE_OVM_NOTAR = 11,
140 DBTYPE_OVM_EXEKUT = 12,
141 DBTYPE_OVM_REQ = 13,
142 DBTYPE_PO = 20,
143 DBTYPE_PO_ZAK = 21,
144 DBTYPE_PO_REQ = 22,
145 DBTYPE_PFO = 30,
146 DBTYPE_PFO_ADVOK = 31,
147 DBTYPE_PFO_DANPOR = 32,
148 DBTYPE_PFO_INSSPR = 33,
149 DBTYPE_FO = 40
150 } isds_DbType;
152 /* Box status from point of view of accessibility */
153 typedef enum {
154 DBSTATE_ACCESSIBLE = 1,
155 DBSTATE_TEMP_UNACCESSIBLE = 2,
156 DBSTATE_NOT_YET_ACCESSIBLE = 3,
157 DBSTATE_PERM_UNACCESSIBLE = 4,
158 DBSTATE_REMOVED = 5
159 } isds_DbState;
161 /* User permissions from point of view of ISDS.
162 * Instances can be bitmaps of any discrete values. */
163 typedef enum {
164 PRIVIL_READ_NON_PERSONAL = 0x1, /* Can download and read messages with
165 dmPersonalDelivery == false */
166 PRIVIL_READ_ALL = 0x2, /* Can download and read messages with
167 dmPersonalDelivery == true */
168 PRIVIL_CREATE_DM = 0x4, /* Can create and sent messages,
169 can download outgoing (sent) messages */
170 PRIVIL_VIEW_INFO = 0x8, /* Can list messages and data about
171 post and delivery */
172 PRIVIL_SEARCH_DB = 0x10, /* Can search for boxes */
173 PRIVIL_OWNER_ADM = 0x20, /* Can administer his box (add/remove
174 permitted users and theirs
175 permissions) */
176 PRIVIL_READ_VAULT = 0x40, /* Can read message stored in data safe */
177 PRIVIL_ERASE_VAULT = 0x80 /* Can delete messages from data safe */
178 } isds_priviledges;
180 /* Message status */
181 typedef enum {
182 MESSAGESTATE_SENT = 0x2, /* Message has been put into ISDS */
183 MESSAGESTATE_STAMPED = 0x4, /* Message stamped by TSA */
184 MESSAGESTATE_INFECTED = 0x8, /* Message included viruses,
185 infected document has been removed */
186 MESSAGESTATE_DELIVERED = 0x10, /* Message delivered
187 (dmDeliveryTime stored) */
188 MESSAGESTATE_SUBSTITUTED = 0x20, /* Message delivered through fiction,
189 dmAcceptanceTime stored */
190 MESSAGESTATE_RECEIVED = 0x40, /* Message accepted (by user log-in or
191 user explicit request),
192 dmAcceptanceTime stored */
193 MESSAGESTATE_READ = 0x80, /* Message has been read by user */
194 MESSAGESTATE_UNDELIVERABLE = 0x100, /* Message could not been delivered
195 (e.g. recipient box has been made
196 inaccessible meantime) */
197 MESSAGESTATE_REMOVED = 0x200, /* Message content deleted */
198 MESSAGESTATE_IN_SAFE = 0x400 /* Message stored in data safe */
200 } isds_message_status;
201 #define MESSAGESTATE_ANY 0x7FE /* Union of all isds_message_status
202 values */
204 /* Hash algorithm types */
205 typedef enum {
206 HASH_ALGORITHM_MD5,
207 HASH_ALGORITHM_SHA_1,
208 HASH_ALGORITHM_SHA_224,
209 HASH_ALGORITHM_SHA_256,
210 HASH_ALGORITHM_SHA_384,
211 HASH_ALGORITHM_SHA_512,
212 } isds_hash_algorithm;
214 /* Buffer storage strategy.
215 * How function should embed application provided buffer into raw element of
216 * output structure. */
217 typedef enum {
218 BUFFER_DONT_STORE, /* Don't fill raw member */
219 BUFFER_COPY, /* Copy buffer content into newly allocated raw */
220 BUFFER_MOVE /* Just copy pointer.
221 But leave deallocation to isds_*_free(). */
222 } isds_buffer_strategy;
224 /* Hash value storage */
225 struct isds_hash {
226 isds_hash_algorithm algorithm; /* Hash algorithm */
227 size_t length; /* Hash value length in bytes */
228 void *value; /* Hash value */
231 /* Name of person */
232 struct isds_PersonName {
233 char *pnFirstName;
234 char *pnMiddleName;
235 char *pnLastName;
236 char *pnLastNameAtBirth;
239 /* Date and place of birth */
240 struct isds_BirthInfo {
241 struct tm *biDate; /* Date of Birth in local time at birth place,
242 only tm_year, tm_mon and tm_mday carry sane
243 value */
244 char *biCity;
245 char *biCounty; /* German: Bezirk, Czech: okres */
246 char *biState;
249 /* Post address */
250 struct isds_Address {
251 char *adCity;
252 char *adStreet;
253 char *adNumberInStreet;
254 char *adNumberInMunicipality;
255 char *adZipCode;
256 char *adState;
259 /* Data about box and his owner.
260 * NULL pointer means undefined value */
261 struct isds_DbOwnerInfo {
262 char *dbID; /* Box ID [Max. 7 chars] */
263 isds_DbType *dbType; /* Box Type */
264 char *ic; /* ID */
265 struct isds_PersonName *personName; /* Name of person */
266 char *firmName; /* Name of firm */
267 struct isds_BirthInfo *birthInfo; /* Birth of person */
268 struct isds_Address *address; /* Post address */
269 char *nationality;
270 char *email;
271 char *telNumber;
272 char *identifier; /* External box identifier for data
273 provider (OVM, PO, maybe PFO)
274 [Max. 20 chars] */
275 char *registryCode; /* PFO External registry code
276 [Max. 5 chars] */
277 long int *dbState; /* Box state; 1 <=> active box;
278 long int because xsd:integer
279 TODO: enum? */
280 _Bool *dbEffectiveOVM; /* Box has OVM role (§ 5a) */
281 _Bool *dbOpenAddressing; /* Non-OVM Box is free to receive
282 messages from anybody */
285 /* User type */
286 typedef enum {
287 USERTYPE_PRIMARY, /* Owner of the box */
288 USERTYPE_ENTRUSTED, /* User with limited access to the box */
289 USERTYPE_ADMINISTRATOR, /* User to manage ENTRUSTED_USERs */
290 USERTYPE_OFFICIAL /* ??? */
291 } isds_UserType;
293 /* Data about user.
294 * NULL pointer means undefined value */
295 struct isds_DbUserInfo {
296 char *userID; /* User ID [Min. 6, max. 12 characters] */
297 isds_UserType *userType; /* User type */
298 long int *userPrivils; /* Set of user permissions */
299 struct isds_PersonName *personName; /* Name of the person */
300 struct isds_Address *address; /* Post address */
301 struct tm *biDate; /* Date of birth in local time,
302 only tm_year, tm_mon and tm_mday carry sane
303 value */
304 char *ic; /* ID of a supervising firm [Max. 8 chars] */
305 char *firmName; /* Name of a supervising firm
306 [Max. 100 chars] */
307 char *caStreet; /* Street and number of contact address */
308 char *caCity; /* Czech City of contact address */
309 char *caZipCode; /* Post office code of contact address */
310 char *caState; /* Abbreviated country of contact address;
311 Implicit value is "CZ"; Optional. */
314 /* Message event type */
315 typedef enum {
316 EVENT_UKNOWN, /* Event unknown to this library */
317 EVENT_ACCEPTED_BY_RECIPIENT, /* Message has been delivered and accepted
318 by recipient action */
319 EVENT_ACCEPTED_BY_FICTION, /* Message has been delivered, acceptance
320 timed out, considered as accepted */
321 EVENT_UNDELIVERABLE, /* Recipient box made inaccessible,
322 thus message is undeliverable */
323 EVENT_COMMERCIAL_ACCEPTED /* Recipient confirmed acceptance of
324 commercial message */
325 } isds_event_type;
327 /* Message event
328 * All members are optional as specification states so. */
329 struct isds_event {
330 struct timeval *time; /* When the event occurred */
331 isds_event_type *type; /* Type of the event */
332 char *description; /* Human readable event description
333 generated by ISDS (Czech) */
336 /* Message envelope
337 * Be ware that the string length constraints are forced only on output
338 * members transmitted to ISDS. The other direction (downloaded from ISDS)
339 * can break these rules. It should not happen, but nobody knows how much
340 * incompatible new version of ISDS protocol will be. This is the gold
341 * Internet rule: be strict on what you put, be tolerant on what you get. */
342 struct isds_envelope {
343 /* Following members apply to incoming messages only: */
344 char *dmID; /* Message ID.
345 Maximal length is 20 characters. */
346 char *dbIDSender; /* Box ID of sender.
347 Special value "aaaaaaa" means sent by
348 ISDS.
349 Maximal length is 7 characters. */
350 char *dmSender; /* Sender name;
351 Maximal length is 100 characters. */
352 char *dmSenderAddress; /* Postal address of sender;
353 Maximal length is 100 characters. */
354 long int *dmSenderType; /* Gross Box type of sender
355 TODO: isds_DbType ? */
356 char *dmRecipient; /* Recipient name;
357 Maximal length is 100 characters. */
358 char *dmRecipientAddress; /* Postal address of recipient;
359 Maximal length is 100 characters. */
360 _Bool *dmAmbiguousRecipient; /* Recipient has OVM role */
362 /* Following members are assigned by ISDS in different phases of message
363 * life cycle. */
364 unsigned long int *dmOrdinal; /* Ordinal number in list of
365 incoming/outgoing messages */
366 isds_message_status *dmMessageStatus; /* Message state */
367 long int *dmAttachmentSize; /* Size of message documents in
368 kilobytes (rounded). */
369 struct timeval *dmDeliveryTime; /* Time of delivery into a box
370 NULL, if message has not been
371 delivered yet */
372 struct timeval *dmAcceptanceTime; /* Time of acceptance of the message
373 by an user. NULL if message has not
374 been accepted yet. */
375 struct isds_hash *hash; /* Message hash.
376 This is hash of isds:dmDM subtree. */
377 void *timestamp; /* Qualified time stamp; Optional. */
378 size_t timestamp_length; /* Length of timestamp in bytes */
379 struct isds_list *events; /* Events message passed trough;
380 List of isds_event's. */
383 /* Following members apply to both outgoing and incoming messages: */
384 char *dmSenderOrgUnit; /* Organisation unit of sender as string;
385 Optional. */
386 long int *dmSenderOrgUnitNum; /* Organisation unit of sender as number;
387 Optional. */
388 char *dbIDRecipient; /* Box ID of recipient; Mandatory.
389 Maximal length is 7 characters. */
390 char *dmRecipientOrgUnit; /* Organisation unit of recipient as
391 string; Optional. */
392 long int *dmRecipientOrgUnitNum; /* Organisation unit of recipient as
393 number; Optional. */
394 char *dmToHands; /* Person in recipient organisation;
395 Optional. */
396 char *dmAnnotation; /* Subject (title) of the message.
397 Maximal length is 255 characters. */
398 char *dmRecipientRefNumber; /* Czech: číslo jednací příjemce; Optional.
399 Maximal length is 50 characters. */
400 char *dmSenderRefNumber; /* Czech: číslo jednací odesílatele;
401 Optional. Maximal length is 50 chars. */
402 char *dmRecipientIdent; /* Czech: spisová značka příjemce; Optional.
403 Maximal length is 50 characters. */
404 char *dmSenderIdent; /* Czech: spisová značka odesílatele;
405 Optional. Maximal length is 50 chars. */
407 /* Act addressing in Czech Republic:
408 * Point (Paragraph) § Section Law/Year Coll. */
409 long int *dmLegalTitleLaw; /* Number of act mandating authority */
410 long int *dmLegalTitleYear; /* Year of act issue mandating authority */
411 char *dmLegalTitleSect; /* Section of act mandating authority.
412 Czech: paragraf */
413 char *dmLegalTitlePar; /* Paragraph of act mandating authority.
414 Czech: odstavec */
415 char *dmLegalTitlePoint; /* Point of act mandating authority.
416 Czech: písmeno */
418 _Bool *dmPersonalDelivery; /* If true, only person with higher
419 privileges can read this message */
420 _Bool *dmAllowSubstDelivery; /* Allow delivery through fiction.
421 I.e. Even if recipient did not read this
422 message, message is considered as
423 delivered after (currently) 10 days.
424 This is delivery through fiction.
425 Applies only to OVM dbType sender. */
426 _Bool *dmOVM; /* OVM sending mode.
427 Non-OVM dbType boxes that has
428 dbEffectiveOVM == true MUST select
429 between true (OVM mode) and
430 false (non-OVM mode).
431 Optional; Implicit value is true. */
432 char *dmType; /* Message type:
433 "V" is public message
434 "K" is commercial message
435 Default value for outgoing message is "V"
436 Length: Exact 1 UTF-8 character if
437 defined;
438 As 2010-05-20, used as output only. */
442 /* Document type from point of hierarchy */
443 typedef enum {
444 FILEMETATYPE_MAIN, /* Main document */
445 FILEMETATYPE_ENCLOSURE, /* Appendix */
446 FILEMETATYPE_SIGNATURE, /* Digital signature of other document */
447 FILEMETATYPE_META /* XML document for ESS (electronic
448 document information system) purposes */
449 } isds_FileMetaType;
451 /* Document */
452 struct isds_document {
453 void *data; /* Document content.
454 The encoding and interpretation depends
455 on dmMimeType.
456 TODO: in-line XML */
457 size_t data_length; /* Length of the data in bytes */
458 char *dmMimeType; /* MIME type of data; Mandatory. */
459 isds_FileMetaType dmFileMetaType; /* Document type to create hierarchy */
460 char *dmFileGuid; /* Message-local document identifier;
461 Optional. */
462 char *dmUpFileGuid; /* Reference to upper document identifier
463 (dmFileGuid); Optional. */
464 char *dmFileDescr; /* Document name (title). E.g. file name;
465 Mandatory. */
466 char *dmFormat; /* Reference to XML form definition;
467 Defines how to interpret XML document;
468 Optional. */
471 /* Raw message representation content type.
472 * This is necessary to distinguish between different representations without
473 * expensive repeated detection.
474 * Infix explanation:
475 * PLAIN_SIGNED data are XML with namespace mangled to signed alternative
476 * CMS_SIGNED data are XML with signed namespace encapsulated in CMS */
477 typedef enum {
478 RAWTYPE_INCOMING_MESSAGE,
479 RAWTYPE_PLAIN_SIGNED_INCOMING_MESSAGE,
480 RAWTYPE_CMS_SIGNED_INCOMING_MESSAGE,
481 RAWTYPE_PLAIN_SIGNED_OUTGOING_MESSAGE,
482 RAWTYPE_CMS_SIGNED_OUTGOING_MESSAGE,
483 RAWTYPE_DELIVERYINFO,
484 RAWTYPE_PLAIN_SIGNED_DELIVERYINFO,
485 RAWTYPE_CMS_SIGNED_DELIVERYINFO
486 } isds_raw_type;
488 /* Message */
489 struct isds_message {
490 void *raw; /* Raw message in XML format as send to or
491 from the ISDS. You can use it to store
492 local copy. This is binary buffer. */
493 size_t raw_length; /* Length of raw message in bytes */
494 isds_raw_type raw_type; /* Content type of raw representation
495 Meaningful only with non-NULL raw
496 member */
497 struct isds_envelope *envelope; /* Message envelope */
498 struct isds_list *documents; /* List of isds_document's.
499 Valid message must contain exactly one
500 document of type FILEMETATYPE_MAIN and
501 can contain any number of other type
502 documents. Total size of documents
503 must not exceed 10 MB. */
506 /* Message copy recipient and assigned message ID */
507 struct isds_message_copy {
508 /* Input members defined by application */
509 char *dbIDRecipient; /* Box ID of recipient; Mandatory.
510 Maximal length is 7 characters. */
511 char *dmRecipientOrgUnit; /* Organisation unit of recipient as
512 string; Optional. */
513 long int *dmRecipientOrgUnitNum; /* Organisation unit of recipient as
514 number; Optional. */
515 char *dmToHands; /* Person in recipient organisation;
516 Optional. */
518 /* Output members returned from ISDS */
519 isds_error error; /* libisds compatible error of delivery to o ne recipient */
520 char *dmStatus; /* Error description returned by ISDS;
521 Optional. */
522 char *dmID; /* Assigned message ID; Meaningful only
523 for error == IE_SUCCESS */
526 /* General linked list */
527 struct isds_list {
528 struct isds_list *next; /* Next list item,
529 or NULL if current is last */
530 void *data; /* Payload */
531 void (*destructor) (void **); /* Payload deallocator */
534 /* External box approval */
535 struct isds_approval {
536 _Bool approved; /* True if request for box has been
537 approved out of ISDS */
538 char *refference; /* Identifier of the approval */
542 /* Initialize ISDS library.
543 * Global function, must be called before other functions.
544 * If it fails you can not use ISDS library and must call isds_cleanup() to
545 * free partially initialized global variables. */
546 isds_error isds_init(void);
548 /* Deinitialize ISDS library.
549 * Global function, must be called as last library function. */
550 isds_error isds_cleanup(void);
552 /* Return version string of this library. Version of dependencies can be
553 * embedded. Do no try to parse it. You must free it. */
554 char *isds_version(void);
556 /* Create ISDS context.
557 * Each context can be used for different sessions to (possibly) different
558 * ISDS server with different credentials.
559 * Returns new context, or NULL */
560 struct isds_ctx *isds_ctx_create(void);
562 /* Destroy ISDS context and free memory.
563 * @context will be NULLed on success. */
564 isds_error isds_ctx_free(struct isds_ctx **context);
566 /* Return long message text produced by library function, e.g. detailed error
567 * message. Returned pointer is only valid until new library function is
568 * called for the same context. Could be NULL, especially if NULL context is
569 * supplied. Return string is locale encoded. */
570 char *isds_long_message(const struct isds_ctx *context);
572 /* Set logging up.
573 * @facilities is bit mask of isds_log_facility values,
574 * @level is verbosity level. */
575 void isds_set_logging(const unsigned int facilities,
576 const isds_log_level level);
578 /* Function provided by application libisds will call to pass log message.
579 * The message is usually locale encoded, but raw strings (UTF-8 usually) can
580 * occur when logging raw communication with ISDS servers. Infixed zero byte
581 * is not excluded, but should not present. Use @length argument to get real
582 * length of the message.
583 * TODO: We will try to fix the encoding issue
584 * @facility is log message class
585 * @level is log message severity
586 * @message is string with zero byte terminator. This can be any arbitrary
587 * chunk of a sentence with or without new line, a sentence can be splitted
588 * into more messages. However it should not happen. If you discover message
589 * without new line, report it as a bug.
590 * @length is size of @message string in bytes excluding trailing zero
591 * @data is pointer that will be passed unchanged to this function at run-time
592 * */
593 typedef void (*isds_log_callback)(
594 isds_log_facility facility, isds_log_level level,
595 const char *message, int length, void *data);
597 /* Register callback function libisds calls when new global log message is
598 * produced by library. Library logs to stderr by default.
599 * @callback is function provided by application libisds will call. See type
600 * definition for @callback argument explanation. Pass NULL to revert logging to
601 * default behaviour.
602 * @data is application specific data @callback gets as last argument */
603 void isds_set_log_callback(isds_log_callback callback, void *data);
605 /* Set timeout in milliseconds for each network job like connecting to server
606 * or sending message. Use 0 to disable timeout limits. */
607 isds_error isds_set_timeout(struct isds_ctx *context,
608 const unsigned int timeout);
610 /* Function provided by application libisds will call with
611 * following five arguments. Value zero of any argument means the value is
612 * unknown.
613 * @upload_total is expected total upload,
614 * @upload_current is cumulative current upload progress
615 * @dowload_total is expected total download
616 * @download_current is cumulative current download progress
617 * @data is pointer that will be passed unchanged to this function at run-time
618 * @return 0 to continue HTTP transfer, or non-zero to abort transfer */
619 typedef int (*isds_progress_callback)(
620 double upload_total, double upload_current,
621 double download_total, double download_current,
622 void *data);
624 /* Register callback function libisds calls periodically during HTTP data
625 * transfer.
626 * @context is session context
627 * @callback is function provided by application libisds will call. See type
628 * definition for @callback argument explanation.
629 * @data is application specific data @callback gets as last argument */
630 isds_error isds_set_progress_callback(struct isds_ctx *context,
631 isds_progress_callback callback, void *data);
633 /* Change context settings.
634 * @context is context which setting will be applied to
635 * @option is name of option. It determines the type of last argument. See
636 * isds_option definition for more info.
637 * @... is value of new setting. Type is determined by @option
638 * */
639 isds_error isds_set_opt(struct isds_ctx *context, const isds_option option,
640 ...);
642 /* Deprecated: Use isds_set_opt() instead.
643 * Change SSL/TLS settings.
644 * @context is context which setting will be applied to
645 * @option is name of option. It determines the type of last argument. See
646 * isds_tls_option definition for more info.
647 * @... is value of new setting. Type is determined by @option
648 * */
649 isds_error isds_set_tls(struct isds_ctx *context, const isds_tls_option option,
650 ...) _deprecated;
652 /* Connect and log in into ISDS server.
653 * All required arguments will be copied, you do not have to keep them after
654 * that.
655 * ISDS supports four different authentication methods. Exact method is
656 * selected on @username, @passwors and @pki_credentials arguments:
657 * - If @pki_credentials == NULL, @username and @password must be supplied
658 * - If @pki_credentials != NULL, then
659 * - If @username == NULL, only certificate will be used
660 * - If @username != NULL, then
661 * - If @password == NULL, then certificate will be used and
662 * @username shifts meaning to box ID. This is used for hosted
663 * services.
664 * - Otherwise all three arguments will be used.
665 * Please note, that different cases requires different certificate type
666 * (system qualified one or commercial non qualified one). This library does
667 * not check such political issues. Please see ISDS Specification for more
668 * details.
669 * @url is base address of ISDS web service. Pass extern isds_locator
670 * variable to use production ISDS instance without client certificate
671 * authentication (or extern isds_cert_locator with client certificate
672 * authentication). Passing NULL has the same effect, autoselection between
673 * isds_locator and isds_cert_locator is performed in addition. You can pass
674 * extern isds_testing_locator (or isds_cert_testing_locator) variable to
675 * select testing instance.
676 * @username is user name of ISDS user or box ID
677 * @password is user's secret password
678 * @pki_credentials defines public key cryptographic material to use in client
679 * authentication. */
680 isds_error isds_login(struct isds_ctx *context, const char *url,
681 const char *username, const char *password,
682 const struct isds_pki_credentials *pki_credentials);
684 /* Log out from ISDS server and close connection. */
685 isds_error isds_logout(struct isds_ctx *context);
687 /* Verify connection to ISDS is alive and server is responding.
688 * Sent dummy request to ISDS and expect dummy response. */
689 isds_error isds_ping(struct isds_ctx *context);
691 /* Get data about logged in user and his box. */
692 isds_error isds_GetOwnerInfoFromLogin(struct isds_ctx *context,
693 struct isds_DbOwnerInfo **db_owner_info);
695 /* Get data about logged in user. */
696 isds_error isds_GetUserInfoFromLogin(struct isds_ctx *context,
697 struct isds_DbUserInfo **db_user_info);
699 /* Get expiration time of current password
700 * @context is session context
701 * @expiration is automatically reallocated time when password expires, In
702 * case of error will be nulled. */
703 isds_error isds_get_password_expiration(struct isds_ctx *context,
704 struct timeval **expiration);
706 /* Change user password in ISDS.
707 * User must supply old password, new password will takes effect after some
708 * time, current session can continue. Password must fulfill some constraints.
709 * @context is session context
710 * @old_password is current password.
711 * @new_password is requested new password */
712 isds_error isds_change_password(struct isds_ctx *context,
713 const char *old_password, const char *new_password);
715 /* Create new box.
716 * @context is session context
717 * @box is box description to create including single primary user (in case of
718 * FO box type). It outputs box ID assigned by ISDS in dbID element.
719 * @users is list of struct isds_DbUserInfo (primary users in case of non-FO
720 * box, or contact address of PFO box owner)
721 * @former_names is optional undocumented string. Pass NULL if you don't care.
722 * @upper_box_id is optional ID of supper box if currently created box is
723 * subordinated.
724 * @ceo_label is optional title of OVM box owner (e.g. mayor)
725 * @approval is optional external approval of box manipulation
726 * @refnumber is reallocated serial number of request assigned by ISDS. Use
727 * NULL, if you don't care.*/
728 isds_error isds_add_box(struct isds_ctx *context,
729 struct isds_DbOwnerInfo *box, const struct isds_list *users,
730 const char *former_names, const char *upper_box_id,
731 const char *ceo_label, const struct isds_approval *approval,
732 char **refnumber);
734 /* Notify ISDS about new PFO entity.
735 * This function has no real effect.
736 * @context is session context
737 * @box is PFO description including single primary user.
738 * @users is list of struct isds_DbUserInfo (contact address of PFO box owner)
739 * @former_names is optional undocumented string. Pass NULL if you don't care.
740 * @upper_box_id is optional ID of supper box if currently created box is
741 * subordinated.
742 * @ceo_label is optional title of OVM box owner (e.g. mayor)
743 * @approval is optional external approval of box manipulation
744 * @refnumber is reallocated serial number of request assigned by ISDS. Use
745 * NULL, if you don't care.*/
746 isds_error isds_add_pfoinfo(struct isds_ctx *context,
747 const struct isds_DbOwnerInfo *box, const struct isds_list *users,
748 const char *former_names, const char *upper_box_id,
749 const char *ceo_label, const struct isds_approval *approval,
750 char **refnumber);
752 /* Remove given given box permanently.
753 * @context is session context
754 * @box is box description to delete
755 * @since is date of box owner cancellation. Only tm_year, tm_mon and tm_mday
756 * carry sane value.
757 * @approval is optional external approval of box manipulation
758 * @refnumber is reallocated serial number of request assigned by ISDS. Use
759 * NULL, if you don't care.*/
760 isds_error isds_delete_box(struct isds_ctx *context,
761 const struct isds_DbOwnerInfo *box, const struct tm *since,
762 const struct isds_approval *approval, char **refnumber);
764 /* Update data about given box.
765 * @context is session context
766 * @old_box current box description
767 * @new_box are updated data about @old_box
768 * @approval is optional external approval of box manipulation
769 * @refnumber is reallocated serial number of request assigned by ISDS. Use
770 * NULL, if you don't care.*/
771 isds_error isds_UpdateDataBoxDescr(struct isds_ctx *context,
772 const struct isds_DbOwnerInfo *old_box,
773 const struct isds_DbOwnerInfo *new_box,
774 const struct isds_approval *approval, char **refnumber);
776 /* Get data about all users assigned to given box.
777 * @context is session context
778 * @box_id is box ID
779 * @users is automatically reallocated list of struct isds_DbUserInfo */
780 isds_error isds_GetDataBoxUsers(struct isds_ctx *context, const char *box_id,
781 struct isds_list **users);
783 /* Update data about user assigned to given box.
784 * @context is session context
785 * @box is box identification
786 * @old_user identifies user to update
787 * @new_user are updated data about @old_user
788 * @refnumber is reallocated serial number of request assigned by ISDS. Use
789 * NULL, if you don't care.*/
790 isds_error isds_UpdateDataBoxUser(struct isds_ctx *context,
791 const struct isds_DbOwnerInfo *box,
792 const struct isds_DbUserInfo *old_user,
793 const struct isds_DbUserInfo *new_user,
794 char **refnumber);
796 /* Reset credentials of user assigned to given box.
797 * @context is session context
798 * @box is box identification
799 * @user identifies user to reset password
800 * @fee_paid is true if fee has been paid, false otherwise
801 * @approval is optional external approval of box manipulation
802 * @token is NULL if new password should be delivered off-line to the user.
803 * It is valid pointer if user should obtain new password on-line on dedicated
804 * web server. Then it output automatically reallocated token user needs to
805 * use to authorize on the web server to view his new password.
806 * @refnumber is reallocated serial number of request assigned by ISDS. Use
807 * NULL, if you don't care.*/
808 isds_error isds_reset_password(struct isds_ctx *context,
809 const struct isds_DbOwnerInfo *box,
810 const struct isds_DbUserInfo *user,
811 const _Bool fee_paid, const struct isds_approval *approval,
812 char **token, char **refnumber);
814 /* Assign new user to given box.
815 * @context is session context
816 * @box is box identification
817 * @user defines new user to add
818 * @approval is optional external approval of box manipulation
819 * @refnumber is reallocated serial number of request assigned by ISDS. Use
820 * NULL, if you don't care.*/
821 isds_error isds_add_user(struct isds_ctx *context,
822 const struct isds_DbOwnerInfo *box, const struct isds_DbUserInfo *user,
823 const struct isds_approval *approval, char **refnumber);
825 /* Remove user assigned to given box.
826 * @context is session context
827 * @box is box identification
828 * @user identifies user to remove
829 * @approval is optional external approval of box manipulation
830 * @refnumber is reallocated serial number of request assigned by ISDS. Use
831 * NULL, if you don't care.*/
832 isds_error isds_delete_user(struct isds_ctx *context,
833 const struct isds_DbOwnerInfo *box, const struct isds_DbUserInfo *user,
834 const struct isds_approval *approval, char **refnumber);
836 /* Find boxes suiting given criteria.
837 * @context is ISDS session context.
838 * @criteria is filter. You should fill in at least some members.
839 * @boxes is automatically reallocated list of isds_DbOwnerInfo structures,
840 * possibly empty. Input NULL or valid old structure.
841 * @return:
842 * IE_SUCCESS if search succeeded, @boxes contains useful data
843 * IE_NOEXIST if no such box exists, @boxes will be NULL
844 * IE_2BIG if too much boxes exist and server truncated the results, @boxes
845 * contains still valid data
846 * other code if something bad happens. @boxes will be NULL. */
847 isds_error isds_FindDataBox(struct isds_ctx *context,
848 const struct isds_DbOwnerInfo *criteria,
849 struct isds_list **boxes);
851 /* Get status of a box.
852 * @context is ISDS session context.
853 * @box_id is UTF-8 encoded box identifier as zero terminated string
854 * @box_status is return value of box status.
855 * @return:
856 * IE_SUCCESS if box has been found and its status retrieved
857 * IE_NOEXIST if box is not known to ISDS server
858 * or other appropriate error.
859 * You can use isds_DbState to enumerate box status. However out of enum
860 * range value can be returned too. This is feature because ISDS
861 * specification leaves the set of values open.
862 * Be ware that status DBSTATE_REMOVED is signaled as IE_SUCCESS. That means
863 * the box has been deleted, but ISDS still lists its former existence. */
864 isds_error isds_CheckDataBox(struct isds_ctx *context, const char *box_id,
865 long int *box_status);
867 /* Switch box into state where box can receive commercial messages (off by
868 * default)
869 * @context is ISDS session context.
870 * @box_id is UTF-8 encoded box identifier as zero terminated string
871 * @allow is true for enable, false for disable commercial messages income
872 * @approval is optional external approval of box manipulation
873 * @refnumber is reallocated serial number of request assigned by ISDS. Use
874 * NULL, if you don't care. */
875 isds_error isds_switch_commercial_receiving(struct isds_ctx *context,
876 const char *box_id, const _Bool allow,
877 const struct isds_approval *approval, char **refnumber);
879 /* Switch box into / out of state where non-OVM box can act as OVM (e.g. force
880 * message acceptance). This is just a box permission. Sender must apply
881 * such role by sending each message.
882 * @context is ISDS session context.
883 * @box_id is UTF-8 encoded box identifier as zero terminated string
884 * @allow is true for enable, false for disable OVM role permission
885 * @approval is optional external approval of box manipulation
886 * @refnumber is reallocated serial number of request assigned by ISDS. Use
887 * NULL, if you don't care. */
888 isds_error isds_switch_effective_ovm(struct isds_ctx *context,
889 const char *box_id, const _Bool allow,
890 const struct isds_approval *approval, char **refnumber);
892 /* Switch box accessibility state on request of box owner.
893 * Despite the name, owner must do the request off-line. This function is
894 * designed for such off-line meeting points (e.g. Czech POINT).
895 * @context is ISDS session context.
896 * @box identifies box to switch accessibility state.
897 * @allow is true for making accessible, false to disallow access.
898 * @approval is optional external approval of box manipulation
899 * @refnumber is reallocated serial number of request assigned by ISDS. Use
900 * NULL, if you don't care. */
901 isds_error isds_switch_box_accessibility_on_owner_request(
902 struct isds_ctx *context, const struct isds_DbOwnerInfo *box,
903 const _Bool allow, const struct isds_approval *approval,
904 char **refnumber);
906 /* Disable box accessibility on law enforcement (e.g. by prison) since exact
907 * date.
908 * @context is ISDS session context.
909 * @box identifies box to switch accessibility state.
910 * @since is date since accessibility has been denied. This can be past too.
911 * Only tm_year, tm_mon and tm_mday carry sane value.
912 * @approval is optional external approval of box manipulation
913 * @refnumber is reallocated serial number of request assigned by ISDS. Use
914 * NULL, if you don't care. */
915 isds_error isds_disable_box_accessibility_externaly(
916 struct isds_ctx *context, const struct isds_DbOwnerInfo *box,
917 const struct tm *since, const struct isds_approval *approval,
918 char **refnumber);
920 /* Send a message via ISDS to a recipient
921 * @context is session context
922 * @outgoing_message is message to send; Some members are mandatory (like
923 * dbIDRecipient), some are optional and some are irrelevant (especially data
924 * about sender). Included pointer to isds_list documents must contain at
925 * least one document of FILEMETATYPE_MAIN. This is read-write structure, some
926 * members will be filled with valid data from ISDS. Exact list of write
927 * members is subject to change. Currently dmId is changed.
928 * @return ISDS_SUCCESS, or other error code if something goes wrong. */
929 isds_error isds_send_message(struct isds_ctx *context,
930 struct isds_message *outgoing_message);
932 /* Send a message via ISDS to a multiple recipients
933 * @context is session context
934 * @outgoing_message is message to send; Some members are mandatory,
935 * some are optional and some are irrelevant (especially data
936 * about sender). Data about recipient will be substituted by ISDS from
937 * @copies. Included pointer to isds_list documents must
938 * contain at least one document of FILEMETATYPE_MAIN.
939 * @copies is list of isds_message_copy structures addressing all desired
940 * recipients. This is read-write structure, some members will be filled with
941 * valid data from ISDS (message IDs, error codes, error descriptions).
942 * @return
943 * ISDS_SUCCESS if all messages have been sent
944 * ISDS_PARTIAL_SUCCESS if sending of some messages has failed (failed and
945 * succeeded messages can be identified by copies->data->error),
946 * or other error code if something other goes wrong. */
947 isds_error isds_send_message_to_multiple_recipients(struct isds_ctx *context,
948 const struct isds_message *outgoing_message,
949 struct isds_list *copies);
951 /* Get list of outgoing (already sent) messages.
952 * Any criterion argument can be NULL, if you don't care about it.
953 * @context is session context. Must not be NULL.
954 * @from_time is minimal time and date of message sending inclusive.
955 * @to_time is maximal time and date of message sending inclusive
956 * @dmSenderOrgUnitNum is the same as isds_envelope.dmSenderOrgUnitNum
957 * @status_filter is bit field of isds_message_status values. Use special
958 * value MESSAGESTATE_ANY to signal you don't care. (It's defined as union of
959 * all values, you can use bit-wise arithmetic if you want.)
960 * @offset is index of first message we are interested in. First message is 1.
961 * Set to 0 (or 1) if you don't care.
962 * @number is maximal length of list you want to get as input value, outputs
963 * number of messages matching these criteria. Can be NULL if you don't care
964 * (applies to output value either).
965 * @messages is automatically reallocated list of isds_message's. Be ware that
966 * it returns only brief overview (envelope and some other fields) about each
967 * message, not the complete message. FIXME: Specify exact fields.
968 * The list is sorted by delivery time in ascending order.
969 * Use NULL if you don't care about the meta data (useful if you want to know
970 * only the @number). If you provide &NULL, list will be allocated on heap,
971 * if you provide pointer to non-NULL, list will be freed automatically at first.
972 * Also in case of error the list will be NULLed.
973 * @return IE_SUCCESS or appropriate error code. */
974 isds_error isds_get_list_of_sent_messages(struct isds_ctx *context,
975 const struct timeval *from_time, const struct timeval *to_time,
976 const long int *dmSenderOrgUnitNum, const unsigned int status_filter,
977 const unsigned long int offset, unsigned long int *number,
978 struct isds_list **messages);
980 /* Get list of incoming (addressed to you) messages.
981 * Any criterion argument can be NULL, if you don't care about it.
982 * @context is session context. Must not be NULL.
983 * @from_time is minimal time and date of message sending inclusive.
984 * @to_time is maximal time and date of message sending inclusive
985 * @dmSenderOrgUnitNum is the same as isds_envelope.dmSenderOrgUnitNum
986 * @status_filter is bit field of isds_message_status values. Use special
987 * value MESSAGESTATE_ANY to signal you don't care. (It's defined as union of
988 * all values, you can use bit-wise arithmetic if you want.)
989 * @offset is index of first message we are interested in. First message is 1.
990 * Set to 0 (or 1) if you don't care.
991 * @number is maximal length of list you want to get as input value, outputs
992 * number of messages matching these criteria. Can be NULL if you don't care
993 * (applies to output value either).
994 * @messages is automatically reallocated list of isds_message's. Be ware that
995 * it returns only brief overview (envelope and some other fields) about each
996 * message, not the complete message. FIXME: Specify exact fields.
997 * Use NULL if you don't care about the meta data (useful if you want to know
998 * only the @number). If you provide &NULL, list will be allocated on heap,
999 * if you provide pointer to non-NULL, list will be freed automatically at first.
1000 * Also in case of error the list will be NULLed.
1001 * @return IE_SUCCESS or appropriate error code. */
1002 isds_error isds_get_list_of_received_messages(struct isds_ctx *context,
1003 const struct timeval *from_time, const struct timeval *to_time,
1004 const long int *dmSenderOrgUnitNum, const unsigned int status_filter,
1005 const unsigned long int offset, unsigned long int *number,
1006 struct isds_list **messages);
1008 /* Download incoming message envelope identified by ID.
1009 * @context is session context
1010 * @message_id is message identifier (you can get them from
1011 * isds_get_list_of_received_messages())
1012 * @message is automatically reallocated message retrieved from ISDS.
1013 * It will miss documents per se. Use isds_get_received_message(), if you are
1014 * interested in documents (content) too.
1015 * Returned hash and timestamp require documents to be verifiable. */
1016 isds_error isds_get_received_envelope(struct isds_ctx *context,
1017 const char *message_id, struct isds_message **message);
1019 /* Download signed delivery info-sheet of given message identified by ID.
1020 * @context is session context
1021 * @message_id is message identifier (you can get them from
1022 * isds_get_list_of_{sent,received}_messages())
1023 * @message is automatically reallocated message retrieved from ISDS.
1024 * It will miss documents per se. Use isds_get_signed_received_message(),
1025 * if you are interested in documents (content). OTOH, only this function
1026 * can get list events message has gone through. */
1027 isds_error isds_get_signed_delivery_info(struct isds_ctx *context,
1028 const char *message_id, struct isds_message **message);
1030 /* Load delivery info of any format from buffer.
1031 * @context is session context
1032 * @raw_type advertises format of @buffer content. Only delivery info types
1033 * are accepted.
1034 * @buffer is DER encoded PKCS#7 structure with signed delivery info. You can
1035 * retrieve such data from message->raw after calling
1036 * isds_get_signed_delivery_info().
1037 * @length is length of buffer in bytes.
1038 * @message is automatically reallocated message parsed from @buffer.
1039 * @strategy selects how buffer will be attached into raw isds_message member.
1040 * */
1041 isds_error isds_load_delivery_info(struct isds_ctx *context,
1042 const isds_raw_type raw_type,
1043 const void *buffer, const size_t length,
1044 struct isds_message **message, const isds_buffer_strategy strategy);
1046 /* Download delivery info-sheet of given message identified by ID.
1047 * @context is session context
1048 * @message_id is message identifier (you can get them from
1049 * isds_get_list_of_{sent,received}_messages())
1050 * @message is automatically reallocated message retrieved from ISDS.
1051 * It will miss documents per se. Use isds_get_received_message(), if you are
1052 * interested in documents (content). OTOH, only this function can get list
1053 * of events message has gone through. */
1054 isds_error isds_get_delivery_info(struct isds_ctx *context,
1055 const char *message_id, struct isds_message **message);
1057 /* Download incoming message identified by ID.
1058 * @context is session context
1059 * @message_id is message identifier (you can get them from
1060 * isds_get_list_of_received_messages())
1061 * @message is automatically reallocated message retrieved from ISDS */
1062 isds_error isds_get_received_message(struct isds_ctx *context,
1063 const char *message_id, struct isds_message **message);
1065 /* Load message of any type from buffer.
1066 * @context is session context
1067 * @raw_type defines content type of @buffer. Only message types are allowed.
1068 * @buffer is message raw representation. Format (CMS, plain signed,
1069 * message direction) is defined in @raw_type. You can retrieve such data
1070 * from message->raw after calling isds_get_[signed]{received,sent}_message().
1071 * @length is length of buffer in bytes.
1072 * @message is automatically reallocated message parsed from @buffer.
1073 * @strategy selects how buffer will be attached into raw isds_message member.
1074 * */
1075 isds_error isds_load_message(struct isds_ctx *context,
1076 const isds_raw_type raw_type, const void *buffer, const size_t length,
1077 struct isds_message **message, const isds_buffer_strategy strategy);
1079 /* Determine type of raw message or delivery info according some heuristics.
1080 * It does not validate the raw blob.
1081 * @context is session context
1082 * @raw_type returns content type of @buffer. Valid only if exit code of this
1083 * function is IE_SUCCESS. The pointer must be valid. This is no automatically
1084 * reallocated memory.
1085 * @buffer is message raw representation.
1086 * @length is length of buffer in bytes. */
1087 isds_error isds_guess_raw_type(struct isds_ctx *context,
1088 isds_raw_type *raw_type, const void *buffer, const size_t length);
1090 /* Download signed incoming message identified by ID.
1091 * @context is session context
1092 * @message_id is message identifier (you can get them from
1093 * isds_get_list_of_received_messages())
1094 * @message is automatically reallocated message retrieved from ISDS. The raw
1095 * member will be filled with PKCS#7 structure in DER format. */
1096 isds_error isds_get_signed_received_message(struct isds_ctx *context,
1097 const char *message_id, struct isds_message **message);
1099 /* Download signed outgoing message identified by ID.
1100 * @context is session context
1101 * @message_id is message identifier (you can get them from
1102 * isds_get_list_of_sent_messages())
1103 * @message is automatically reallocated message retrieved from ISDS. The raw
1104 * member will be filled with PKCS#7 structure in DER format. */
1105 isds_error isds_get_signed_sent_message(struct isds_ctx *context,
1106 const char *message_id, struct isds_message **message);
1108 /* Retrieve hash of message identified by ID stored in ISDS.
1109 * @context is session context
1110 * @message_id is message identifier
1111 * @hash is automatically reallocated message hash downloaded from ISDS.
1112 * Message must exist in system and must not be deleted. */
1113 isds_error isds_download_message_hash(struct isds_ctx *context,
1114 const char *message_id, struct isds_hash **hash);
1116 /* Compute hash of message from raw representation and store it into envelope.
1117 * Original hash structure will be destroyed in envelope.
1118 * @context is session context
1119 * @message is message carrying raw XML message blob
1120 * @algorithm is desired hash algorithm to use */
1121 isds_error isds_compute_message_hash(struct isds_ctx *context,
1122 struct isds_message *message, const isds_hash_algorithm algorithm);
1124 /* Compare two hashes.
1125 * @h1 is first hash
1126 * @h2 is another hash
1127 * @return
1128 * IE_SUCCESS if hashes equal
1129 * IE_NOTUNIQ if hashes are comparable, but they don't equal
1130 * IE_ENUM if not comparable, but both structures defined
1131 * IE_INVAL if some of the structures are undefined (NULL)
1132 * IE_ERROR if internal error occurs */
1133 isds_error isds_hash_cmp(const struct isds_hash *h1,
1134 const struct isds_hash *h2);
1136 /* Check message has gone through ISDS by comparing message hash stored in
1137 * ISDS and locally computed hash. You must provide message with valid raw
1138 * member (do not use isds_load_message(..., BUFFER_DONT_STORE)).
1139 * This is convenient wrapper for isds_download_message_hash(),
1140 * isds_compute_message_hash(), and isds_hash_cmp() sequence.
1141 * @context is session context
1142 * @message is message with valid raw and envelope member; envelope->hash
1143 * member will be changed during function run. Use envelope on heap only.
1144 * @return
1145 * IE_SUCCESS if message originates in ISDS
1146 * IE_NOTEQUAL if message is unknown to ISDS
1147 * other code for other errors */
1148 isds_error isds_verify_message_hash(struct isds_ctx *context,
1149 struct isds_message *message);
1151 /* Mark message as read. This is a transactional commit function to acknowledge
1152 * to ISDS the message has been downloaded and processed by client properly.
1153 * @context is session context
1154 * @message_id is message identifier. */
1155 isds_error isds_mark_message_read(struct isds_ctx *context,
1156 const char *message_id);
1158 /* Mark message as received by recipient. This is applicable only to
1159 * commercial message. Use envelope->dmType message member to distinguish
1160 * commercial message from government message. Government message is
1161 * received automatically (by law), commercial message on recipient request.
1162 * @context is session context
1163 * @message_id is message identifier. */
1164 isds_error isds_mark_message_received(struct isds_ctx *context,
1165 const char *message_id);
1167 /* Send bogus request to ISDS.
1168 * Just for test purposes */
1169 isds_error isds_bogus_request(struct isds_ctx *context);
1171 /* Send document for authorize conversion into Czech POINT system.
1172 * This is public anonymous service, no log-in necessary. Special context is
1173 * used to reuse keep-a-live HTTPS connection.
1174 * @context is Czech POINT session context. DO NOT use context connected to
1175 * ISDS server. Use new context or context used by this function previously.
1176 * @document is document to convert. Only data, data_length and dmFileDescr
1177 * members are significant. Be ware that not all document formats can be
1178 * converted (signed PDF 1.3 and higher only (2010-02 state)).
1179 * @id is reallocated identifier assigned by Czech POINT system to
1180 * your document on submit. Use is to tell it to Czech POINT officer.
1181 * @date is reallocated document submit date (submitted documents
1182 * expires after some period). Only tm_year, tm_mon and tm_mday carry sane
1183 * value. */
1184 isds_error czp_convert_document(struct isds_ctx *context,
1185 const struct isds_document *document,
1186 char **id, struct tm **date);
1188 /* Close possibly opened connection to Czech POINT document deposit.
1189 * @context is Czech POINT session context. */
1190 isds_error czp_close_connection(struct isds_ctx *context);
1192 /* Send request for new box creation in testing ISDS instance.
1193 * It's not possible to request for a production box currently, as it
1194 * communicates via e-mail.
1195 * XXX: This function does not work either. Server complains about invalid
1196 * e-mail address.
1197 * XXX: Remove context->type hacks in isds.c and validator.c when removing
1198 * this function
1199 * @context is special session context for box creation request. DO NOT use
1200 * standard context as it could reveal your password. Use fresh new context or
1201 * context previously used by this function.
1202 * @box is box description to create including single primary user (in case of
1203 * FO box type). It outputs box ID assigned by ISDS in dbID element.
1204 * @users is list of struct isds_DbUserInfo (primary users in case of non-FO
1205 * box, or contact address of PFO box owner). The email member is mandatory as
1206 * it will be used to deliver credentials.
1207 * @former_names is optional undocumented string. Pass NULL if you don't care.
1208 * @approval is optional external approval of box manipulation
1209 * @refnumber is reallocated serial number of request assigned by ISDS. Use
1210 * NULL, if you don't care.*/
1211 isds_error isds_request_new_testing_box(struct isds_ctx *context,
1212 struct isds_DbOwnerInfo *box, const struct isds_list *users,
1213 const char *former_names, const struct isds_approval *approval,
1214 char **refnumber);
1216 /* Search for document by document ID in list of documents. IDs are compared
1217 * as UTF-8 string.
1218 * @documents is list of isds_documents
1219 * @id is document identifier
1220 * @return first matching document or NULL. */
1221 const struct isds_document *isds_find_document_by_id(
1222 const struct isds_list *documents, const char *id);
1224 /* Normalize @mime_type to be proper MIME type.
1225 * ISDS servers passes invalid MIME types (e.g. "pdf"). This function tries to
1226 * guess regular MIME type (e.g. "application/pdf").
1227 * @mime_type is UTF-8 encoded MIME type to fix
1228 * @return original @mime_type if no better interpretation exists, or array to
1229 * constant static UTF-8 encoded string with proper MIME type. */
1230 char *isds_normalize_mime_type(const char* mime_type);
1232 /* XXX: Deprecated: Use isds_set_opt() instead.
1233 * Switch MIME type normalization while message loading. Default state for new
1234 * context is no normalization.
1235 * @normalize use true to switch normalization on, false to switch off */
1236 isds_error isds_set_mime_type_normalization(struct isds_ctx *context,
1237 _Bool normalize) _deprecated;
1239 /* Free isds_list with all member data.
1240 * @list list to free, on return will be NULL */
1241 void isds_list_free(struct isds_list **list);
1243 /* Deallocate structure isds_hash and NULL it.
1244 * @hash hash to to free */
1245 void isds_hash_free(struct isds_hash **hash);
1247 /* Deallocate structure isds_DbOwnerInfo recursively and NULL it */
1248 void isds_DbOwnerInfo_free(struct isds_DbOwnerInfo **db_owner_info);
1250 /* Deallocate structure isds_DbUserInfo recursively and NULL it */
1251 void isds_DbUserInfo_free(struct isds_DbUserInfo **db_user_info);
1253 /* Deallocate struct isds_event recursively and NULL it */
1254 void isds_event_free(struct isds_event **event);
1256 /* Deallocate struct isds_envelope recursively and NULL it */
1257 void isds_envelope_free(struct isds_envelope **envelope);
1259 /* Deallocate struct isds_document recursively and NULL it */
1260 void isds_document_free(struct isds_document **document);
1262 /* Deallocate struct isds_message recursively and NULL it */
1263 void isds_message_free(struct isds_message **message);
1265 /* Deallocate struct isds_message_copy recursively and NULL it */
1266 void isds_message_copy_free(struct isds_message_copy **copy);
1268 /* Deallocate struct isds_approval recursively and NULL it */
1269 void isds_approval_free(struct isds_approval **approval);
1271 /* Copy structure isds_PersonName recursively */
1272 struct isds_PersonName *isds_PersonName_duplicate(
1273 const struct isds_PersonName *template);
1275 /* Copy structure isds_Address recursively */
1276 struct isds_Address *isds_Address_duplicate(
1277 const struct isds_Address *template);
1279 /* Copy structure isds_DbOwnerInfo recursively */
1280 struct isds_DbOwnerInfo *isds_DbOwnerInfo_duplicate(
1281 const struct isds_DbOwnerInfo *template);
1283 /* Copy structure isds_DbUserInfo recursively */
1284 struct isds_DbUserInfo *isds_DbUserInfo_duplicate(
1285 const struct isds_DbUserInfo *template);
1287 #ifdef __cplusplus /* For C++ linker sake */
1289 #endif
1291 #endif