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