Save XML into message by extract_TReturnedMessage()
[libisds.git] / src / isds.h
blob73a5c0a8eea1fb5f229dbf842e833732f61aea66
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; /* Parsed XML document with attached ISDS
491 message XML documents.
492 Can be NULL. May be freed AFTER deallocating
493 documents member structure. */
494 struct isds_envelope *envelope; /* Message envelope */
495 struct isds_list *documents; /* List of isds_document's.
496 Valid message must contain exactly one
497 document of type FILEMETATYPE_MAIN and
498 can contain any number of other type
499 documents. Totol size of documents
500 must not exceed 10 MB. */
503 /* Message copy recipient and assigned message ID */
504 struct isds_message_copy {
505 /* Input members defined by application */
506 char *dbIDRecipient; /* Box ID of recipient; Mandatory.
507 Maximal length is 7 characters. */
508 char *dmRecipientOrgUnit; /* Organisation unit of recipient as
509 string; Optional. */
510 long int *dmRecipientOrgUnitNum; /* Organisation unit of recipient as
511 number; Optional. */
512 char *dmToHands; /* Person in recipient organisation;
513 Optional. */
515 /* Output members returned from ISDS */
516 isds_error error; /* libisds compatible error of delivery to o ne recipient */
517 char *dmStatus; /* Error description returned by ISDS;
518 Optional. */
519 char *dmID; /* Assigned message ID; Meaningfull only
520 for error == IE_SUCCESS */
523 /* General linked list */
524 struct isds_list {
525 struct isds_list *next; /* Next list item,
526 or NULL if current is last */
527 void *data; /* Payload */
528 void (*destructor) (void **); /* Payload deallocator */
531 /* External box approval */
532 struct isds_approval {
533 _Bool approved; /* True if request for box has been
534 approvedout of ISDS */
535 char *refference; /* Identifier of the approval */
539 /* Initialize ISDS library.
540 * Global function, must be called before other functions.
541 * If it failes you can not use ISDS library and must call isds_cleanup() to
542 * free partially inititialized global variables. */
543 isds_error isds_init(void);
545 /* Deinicialize ISDS library.
546 * Global function, must be called as last library function. */
547 isds_error isds_cleanup(void);
549 /* Return version string of this library. Version of dependecies can be
550 * embedded. Do no try to parse it. You must free it. */
551 char *isds_version(void);
553 /* Create ISDS context.
554 * Each context can be used for different sessions to (possibly) different
555 * ISDS server with different credentials.
556 * Returns new context, or NULL */
557 struct isds_ctx *isds_ctx_create(void);
559 /* Destroy ISDS context and free memmory.
560 * @context will be NULLed on success. */
561 isds_error isds_ctx_free(struct isds_ctx **context);
563 /* Return long message text produced by library fucntion, e.g. detailed error
564 * mesage. Returned pointer is only valid until new library function is
565 * called for the same context. Could be NULL, especially if NULL context is
566 * supplied. Return string is locale encoded. */
567 char *isds_long_message(const struct isds_ctx *context);
569 /* Set logging up.
570 * @facilities is bitmask of isds_log_facility values,
571 * @level is verbosity level. */
572 void isds_set_logging(const unsigned int facilities,
573 const isds_log_level level);
575 /* Function provided by application libisds will call to pass log message.
576 * The message is ussually locale encoded, but raw strings (UTF-8 usually) can
577 * occur when logging raw communitication with ISDS servers. Infixed zero byte
578 * is not excluded, but should not present. Use @length argument to get real
579 * length of the message.
580 * TODO: We will try to fix the encoding issue
581 * @facility is log message class
582 * @level is log message severity
583 * @message is string with zero byte terminator. This can be any arbitrary
584 * chunk of a sentence with or without new line, a sentence can be splitted
585 * into more messages. However it should not happen. If you discover message
586 * without new line, report it as a bug.
587 * @length is size of @message string in bytes excluding trailing zero
588 * @data is pointer that will be passed unchanged to this function at run-time
589 * */
590 typedef void (*isds_log_callback)(
591 isds_log_facility facility, isds_log_level level,
592 const char *message, int length, void *data);
594 /* Register callback function libisds calls when new global log message is
595 * produced by library. Library logs to stderr by default.
596 * @callback is function provided by application libsds will call. See type
597 * defition for @callback argument explanation. Pass NULL to revert logging to
598 * default behaviour.
599 * @data is application specific data @callback gets as last argument */
600 void isds_set_log_callback(isds_log_callback callback, void *data);
602 /* Set timeout in miliseconds for each network job like connecting to server
603 * or sending message. Use 0 to disable timeout limits. */
604 isds_error isds_set_timeout(struct isds_ctx *context,
605 const unsigned int timeout);
607 /* Function provided by application libsds will call with
608 * following five arguments. Value zero of any argument means the value is
609 * unknown.
610 * @upload_total is expected total upload,
611 * @upload_current is cumulative current upload progress
612 * @dowload_total is expected total download
613 * @download_current is cumulative current download progress
614 * @data is pointer that will be passed unchanged to this function at run-time
615 * @return 0 to continue HTTP transfaer, or non-zero to abort transfer */
616 typedef int (*isds_progress_callback)(
617 double upload_total, double upload_current,
618 double download_total, double download_current,
619 void *data);
621 /* Register callback function libisds calls periodocally during HTTP data
622 * transfer.
623 * @context is session context
624 * @callback is function provided by application libsds will call. See type
625 * defition for @callback argument explanation.
626 * @data is application specific data @callback gets as last argument */
627 isds_error isds_set_progress_callback(struct isds_ctx *context,
628 isds_progress_callback callback, void *data);
630 /* Change context settings.
631 * @context is context which setting vill be applied to
632 * @option is name of option. It determines the type of last argument. See
633 * isds_option definition for more info.
634 * @... is value of new setting. Type is determined by @option
635 * */
636 isds_error isds_set_opt(struct isds_ctx *context, const isds_option option,
637 ...);
639 /* Deprecated: Use isds_set_opt() instead.
640 * Change SSL/TLS settings.
641 * @context is context which setting will be applied to
642 * @option is name of option. It determines the type of last argument. See
643 * isds_tls_option definition for more info.
644 * @... is value of new setting. Type is determined by @option
645 * */
646 isds_error isds_set_tls(struct isds_ctx *context, const isds_tls_option option,
647 ...) _deprecated;
649 /* Connect and log in into ISDS server.
650 * All required arguments will be copied, you do not have to keep them after
651 * that.
652 * ISDS supports four different authentication methods. Exact method is
653 * selected on @username, @passwors and @pki_credentials arguments:
654 * - If @pki_credentials == NULL, @username and @password must be supplied
655 * - If @pki_credentials != NULL, then
656 * - If @username == NULL, only certificate will be used
657 * - If @username != NULL, then
658 * - If @password == NULL, then certificate will be used and
659 * @username shifts meaning to box ID. This is used for hosted
660 * services.
661 * - Otherwise all three arguments will be used.
662 * Please note, that differen cases requires different certificate type
663 * (system qualified one or commercial non qualified one). This library does
664 * not check such political issues. Please see ISDS Specification for more
665 * details.
666 * @url is base address of ISDS web service. Pass NULL or extern isds_locator
667 * variable to use production ISDS instance. You can pass extern
668 * isds_testing_locator variable to select testing instance.
669 * @username is user name of ISDS user or box ID
670 * @password is user's secret password
671 * @pki_credentials defines public key cryptographic material to use in client
672 * authentication. */
673 isds_error isds_login(struct isds_ctx *context, const char *url,
674 const char *username, const char *password,
675 const struct isds_pki_credentials *pki_credentials);
677 /* Log out from ISDS server and close connection. */
678 isds_error isds_logout(struct isds_ctx *context);
680 /* Verify connection to ISDS is alive and server is responding.
681 * Sent dumy request to ISDS and expect dummy response. */
682 isds_error isds_ping(struct isds_ctx *context);
684 /* Get data about logged in user and his box. */
685 isds_error isds_GetOwnerInfoFromLogin(struct isds_ctx *context,
686 struct isds_DbOwnerInfo **db_owner_info);
688 /* Get data about logged in user. */
689 isds_error isds_GetUserInfoFromLogin(struct isds_ctx *context,
690 struct isds_DbUserInfo **db_user_info);
692 /* Get expiration time of current password
693 * @context is session context
694 * @expiration is automatically reallocated time when password expires, In
695 * case of error will be nulled. */
696 isds_error isds_get_password_expiration(struct isds_ctx *context,
697 struct timeval **expiration);
699 /* Change user password in ISDS.
700 * User must supply old password, new password will takes effect after some
701 * time, current session can continue. Password must fulfill some constraints.
702 * @context is session context
703 * @old_password is current password.
704 * @new_password is requested new password */
705 isds_error isds_change_password(struct isds_ctx *context,
706 const char *old_password, const char *new_password);
708 /* Create new box.
709 * @context is session context
710 * @box is box description to create including single primary user (in case of
711 * FO box type). It outputs box ID assigned by ISDS in dbID element.
712 * @users is list of struct isds_DbUserInfo (primary users in case of non-FO
713 * box, or contact address of PFO box owner)
714 * @former_names is optional undocumented string. Pass NULL if you don't care.
715 * @upper_box_id is optional ID of supper box if currently created box is
716 * subordinated.
717 * @ceo_label is optional title of OVM box owner (e.g. mayor)
718 * @approval is optional external approval of box manipulation
719 * @refnumber is reallocated serial number of request assigned by ISDS. Use
720 * NULL, if you don't care.*/
721 isds_error isds_add_box(struct isds_ctx *context,
722 struct isds_DbOwnerInfo *box, const struct isds_list *users,
723 const char *former_names, const char *upper_box_id,
724 const char *ceo_label, const struct isds_approval *approval,
725 char **refnumber);
727 /* Notify ISDS about new PFO entity.
728 * This function has no real effect.
729 * @context is session context
730 * @box is PFO description including single primary user.
731 * @users is list of struct isds_DbUserInfo (contact address of PFO box owner)
732 * @former_names is optional undocumented string. Pass NULL if you don't care.
733 * @upper_box_id is optional ID of supper box if currently created box is
734 * subordinated.
735 * @ceo_label is optional title of OVM box owner (e.g. mayor)
736 * @approval is optional external approval of box manipulation
737 * @refnumber is reallocated serial number of request assigned by ISDS. Use
738 * NULL, if you don't care.*/
739 isds_error isds_add_pfoinfo(struct isds_ctx *context,
740 const struct isds_DbOwnerInfo *box, const struct isds_list *users,
741 const char *former_names, const char *upper_box_id,
742 const char *ceo_label, const struct isds_approval *approval,
743 char **refnumber);
745 /* Remove given given box permanetly.
746 * @context is session context
747 * @box is box description to delete
748 * @since is date of box owner cancalation. Only tm_year, tm_mon and tm_mday
749 * carry sane value.
750 * @approval is optional external approval of box manipulation
751 * @refnumber is reallocated serial number of request assigned by ISDS. Use
752 * NULL, if you don't care.*/
753 isds_error isds_delete_box(struct isds_ctx *context,
754 const struct isds_DbOwnerInfo *box, const struct tm *since,
755 const struct isds_approval *approval, char **refnumber);
757 /* Update data about given box.
758 * @context is session context
759 * @old_box current box description
760 * @new_box are updated data about @old_box
761 * @approval is optional external approval of box manipulation
762 * @refnumber is reallocated serial number of request assigned by ISDS. Use
763 * NULL, if you don't care.*/
764 isds_error isds_UpdateDataBoxDescr(struct isds_ctx *context,
765 const struct isds_DbOwnerInfo *old_box,
766 const struct isds_DbOwnerInfo *new_box,
767 const struct isds_approval *approval, char **refnumber);
769 /* Get data about all users assigned to given box.
770 * @context is session context
771 * @box_id is box ID
772 * @users is automatically reallocated list of struct isds_DbUserInfo */
773 isds_error isds_GetDataBoxUsers(struct isds_ctx *context, const char *box_id,
774 struct isds_list **users);
776 /* Update data about user assigned to given box.
777 * @context is session context
778 * @box is box identification
779 * @old_user identifies user to update
780 * @new_user are updated data about @old_user
781 * @refnumber is reallocated serial number of request assigned by ISDS. Use
782 * NULL, if you don't care.*/
783 isds_error isds_UpdateDataBoxUser(struct isds_ctx *context,
784 const struct isds_DbOwnerInfo *box,
785 const struct isds_DbUserInfo *old_user,
786 const struct isds_DbUserInfo *new_user,
787 char **refnumber);
789 /* Reset credentials of user assigned to given box.
790 * @context is session context
791 * @box is box identification
792 * @user identifies user to reset password
793 * @fee_paid is true if fee has been paid, false otherwise
794 * @approval is optional external approval of box manipulation
795 * @token is NULL if new password should be delivered off-line to the user.
796 * It is valid pointer if user should obtain new password on-line on dedicated
797 * web server. Then it output automatically reallocated token user needs to
798 * use to athtorize on the web server to view his new password.
799 * @refnumber is reallocated serial number of request assigned by ISDS. Use
800 * NULL, if you don't care.*/
801 isds_error isds_reset_password(struct isds_ctx *context,
802 const struct isds_DbOwnerInfo *box,
803 const struct isds_DbUserInfo *user,
804 const _Bool fee_paid, const struct isds_approval *approval,
805 char **token, char **refnumber);
807 /* Assign new user to given box.
808 * @context is session context
809 * @box is box identification
810 * @user defines new user to add
811 * @approval is optional external approval of box manipulation
812 * @refnumber is reallocated serial number of request assigned by ISDS. Use
813 * NULL, if you don't care.*/
814 isds_error isds_add_user(struct isds_ctx *context,
815 const struct isds_DbOwnerInfo *box, const struct isds_DbUserInfo *user,
816 const struct isds_approval *approval, char **refnumber);
818 /* Remove user assigned to given box.
819 * @context is session context
820 * @box is box identification
821 * @user identifies user to removve
822 * @approval is optional external approval of box manipulation
823 * @refnumber is reallocated serial number of request assigned by ISDS. Use
824 * NULL, if you don't care.*/
825 isds_error isds_delete_user(struct isds_ctx *context,
826 const struct isds_DbOwnerInfo *box, const struct isds_DbUserInfo *user,
827 const struct isds_approval *approval, char **refnumber);
829 /* Find boxes suiting given criteria.
830 * @context is ISDS session context.
831 * @criteria is filter. You should fill in at least some members.
832 * @boxes is automatically reallocated list of isds_DbOwnerInfo structures,
833 * possibly empty. Input NULL or valid old structure.
834 * @return:
835 * IE_SUCCESS if search sucseeded, @boxes contains usefull data
836 * IE_NOEXIST if no such box exists, @boxes will be NULL
837 * IE_2BIG if too much boxes exist and server truncated the resuluts, @boxes
838 * contains still valid data
839 * other code if something bad happens. @boxes will be NULL. */
840 isds_error isds_FindDataBox(struct isds_ctx *context,
841 const struct isds_DbOwnerInfo *criteria,
842 struct isds_list **boxes);
844 /* Get status of a box.
845 * @context is ISDS session context.
846 * @box_id is UTF-8 encoded box identifier as zero terminated string
847 * @box_status is return value of box status.
848 * @return:
849 * IE_SUCCESS if box has been found and its status retrieved
850 * IE_NOEXIST if box is not known to ISDS server
851 * or other appropriate error.
852 * You can use isds_DbState to enumerate box status. However out of enum
853 * range value can be returned too. This is feature because ISDS
854 * specification leaves the set of values open.
855 * Be ware that status DBSTATE_REMOVED is signaled as IE_SUCCESS. That means
856 * the box has been deleted, but ISDS still lists its former existence. */
857 isds_error isds_CheckDataBox(struct isds_ctx *context, const char *box_id,
858 long int *box_status);
860 /* Switch box into state where box can receive commercial messages (off by
861 * default)
862 * @context is ISDS session context.
863 * @box_id is UTF-8 encoded box identifier as zero terminated string
864 * @allow is true for enable, false for disable commercial messages income
865 * @approval is optional external approval of box manipulation
866 * @refnumber is reallocated serial number of request assigned by ISDS. Use
867 * NULL, if you don't care. */
868 isds_error isds_switch_commercial_receiving(struct isds_ctx *context,
869 const char *box_id, const _Bool allow,
870 const struct isds_approval *approval, char **refnumber);
872 /* Switch box into / out of state where non-OVM box can act as OVM (e.g. force
873 * message acceptance). This is just a box permission. Sender must apply
874 * such role by sending each message.
875 * @context is ISDS session context.
876 * @box_id is UTF-8 encoded box identifier as zero terminated string
877 * @allow is true for enable, false for disable OVM role permission
878 * @approval is optional external approval of box manipulation
879 * @refnumber is reallocated serial number of request assigned by ISDS. Use
880 * NULL, if you don't care. */
881 isds_error isds_switch_effective_ovm(struct isds_ctx *context,
882 const char *box_id, const _Bool allow,
883 const struct isds_approval *approval, char **refnumber);
885 /* Switch box accessibility state on request of box owner.
886 * Despite the name, owner must do the request off-line. This function is
887 * designed for such off-line meeting points (e.g. Czech POINT).
888 * @context is ISDS session context.
889 * @box identifies box to swith accesibilty state.
890 * @allow is true for making accesibale, false to disallow access.
891 * @approval is optional external approval of box manipulation
892 * @refnumber is reallocated serial number of request assigned by ISDS. Use
893 * NULL, if you don't care. */
894 isds_error isds_switch_box_accessibility_on_owner_request(
895 struct isds_ctx *context, const struct isds_DbOwnerInfo *box,
896 const _Bool allow, const struct isds_approval *approval,
897 char **refnumber);
899 /* Disable box accessibility on law enforcement (e.g. by prison) since exact
900 * date.
901 * @context is ISDS session context.
902 * @box identifies box to swith accesibilty state.
903 * @since is date since accesseibility has been denied. This can be past too.
904 * Only tm_year, tm_mon and tm_mday carry sane value.
905 * @approval is optional external approval of box manipulation
906 * @refnumber is reallocated serial number of request assigned by ISDS. Use
907 * NULL, if you don't care. */
908 isds_error isds_disable_box_accessibility_externaly(
909 struct isds_ctx *context, const struct isds_DbOwnerInfo *box,
910 const struct tm *since, const struct isds_approval *approval,
911 char **refnumber);
913 /* Send a message via ISDS to a recipent
914 * @context is session context
915 * @outgoing_message is message to send; Some memebers are mandatory (like
916 * dbIDRecipient), some are optional and some are irrelevant (especialy data
917 * about sender). Included pointer to isds_list documents must contain at
918 * least one document of FILEMETATYPE_MAIN. This is read-write structure, some
919 * members will be filled with valid data from ISDS. Exact list of write
920 * members is subject to change. Currently dmId is changed.
921 * @return ISDS_SUCCESS, or other error code if something goes wrong. */
922 isds_error isds_send_message(struct isds_ctx *context,
923 struct isds_message *outgoing_message);
925 /* Send a message via ISDS to a multiple recipents
926 * @context is session context
927 * @outgoing_message is message to send; Some memebers are mandatory,
928 * some are optional and some are irrelevant (especialy data
929 * about sender). Data about recipient will be substituted by ISDS from
930 * @copies. Included pointer to isds_list documents must
931 * contain at least one document of FILEMETATYPE_MAIN.
932 * @copies is list of isds_message_copy structures addressing all desired
933 * recipients. This is read-write structure, some members will be filled with
934 * valid data from ISDS (message IDs, error codes, error descriptions).
935 * @return
936 * ISDS_SUCCESS if all messages have been sent
937 * ISDS_PARTIAL_SUCCESS if sending of some messages has failed (failed and
938 * succesed messages can be identified by copies->data->error),
939 * or other error code if something other goes wrong. */
940 isds_error isds_send_message_to_multiple_recipients(struct isds_ctx *context,
941 const struct isds_message *outgoing_message,
942 struct isds_list *copies);
944 /* Get list of outgoing (already sent) messages.
945 * Any criterion argument can be NULL, if you don't care about it.
946 * @context is session context. Must not be NULL.
947 * @from_time is minimal time and date of message sending inclusive.
948 * @to_time is maximal time and date of message sending inclusive
949 * @dmSenderOrgUnitNum is the same as isds_envelope.dmSenderOrgUnitNum
950 * @status_filter is bit field of isds_message_status values. Use special
951 * value MESSAGESTATE_ANY to signal you don't care. (It's defined as union of
952 * all values, you can use bitwise arithmetic if you want.)
953 * @offset is index of first message we are interested in. First message is 1.
954 * Set to 0 (or 1) if you don't care.
955 * @number is maximal length of list you want to get as input value, outputs
956 * number of messages matching these criteria. Can be NULL if you don't care
957 * (applies to output value either).
958 * @messages is automatically reallocated list of isds_message's. Be ware that
959 * it returns only brief overview (envelope and some other fields) about each
960 * message, not the complete message. FIXME: Specify exact fields.
961 * The list is sorted by delivery time in ascending order.
962 * Use NULL if you don't care about the metadata (useful if you want to know
963 * only the @number). If you provide &NULL, list will be allocated on heap,
964 * if you provide pointer to non-NULL, list will be freed automacally at first.
965 * Also in case of error the list will be NULLed.
966 * @return IE_SUCCESS or appropriate error code. */
967 isds_error isds_get_list_of_sent_messages(struct isds_ctx *context,
968 const struct timeval *from_time, const struct timeval *to_time,
969 const long int *dmSenderOrgUnitNum, const unsigned int status_filter,
970 const unsigned long int offset, unsigned long int *number,
971 struct isds_list **messages);
973 /* Get list of incoming (addressed to you) messages.
974 * Any criterion argument can be NULL, if you don't care about it.
975 * @context is session context. Must not be NULL.
976 * @from_time is minimal time and date of message sending inclusive.
977 * @to_time is maximal time and date of message sending inclusive
978 * @dmSenderOrgUnitNum is the same as isds_envelope.dmSenderOrgUnitNum
979 * @status_filter is bit field of isds_message_status values. Use special
980 * value MESSAGESTATE_ANY to signal you don't care. (It's defined as union of
981 * all values, you can use bitwise arithmetic if you want.)
982 * @offset is index of first message we are interested in. First message is 1.
983 * Set to 0 (or 1) if you don't care.
984 * @number is maximal length of list you want to get as input value, outputs
985 * number of messages matching these criteria. Can be NULL if you don't care
986 * (applies to output value either).
987 * @messages is automatically reallocated list of isds_message's. Be ware that
988 * it returns only brief overview (envelope and some other fields) about each
989 * message, not the complete message. FIXME: Specify exact fields.
990 * Use NULL if you don't care about the metadata (useful if you want to know
991 * only the @number). If you provide &NULL, list will be allocated on heap,
992 * if you provide pointer to non-NULL, list will be freed automacally at first.
993 * Also in case of error the list will be NULLed.
994 * @return IE_SUCCESS or appropriate error code. */
995 isds_error isds_get_list_of_received_messages(struct isds_ctx *context,
996 const struct timeval *from_time, const struct timeval *to_time,
997 const long int *dmSenderOrgUnitNum, const unsigned int status_filter,
998 const unsigned long int offset, unsigned long int *number,
999 struct isds_list **messages);
1001 /* Download incoming message envelope identified by ID.
1002 * @context is session context
1003 * @message_id is message identifier (you can get them from
1004 * isds_get_list_of_received_messages())
1005 * @message is automatically reallocated message retrieved from ISDS.
1006 * It will miss documents per se. Use isds_get_received_message(), if you are
1007 * interrested in documents (content) too.
1008 * Returned hash and timestamp require documents to be verifiable. */
1009 isds_error isds_get_received_envelope(struct isds_ctx *context,
1010 const char *message_id, struct isds_message **message);
1012 /* Download signed delivery infosheet of given message identified by ID.
1013 * @context is session context
1014 * @message_id is message identifier (you can get them from
1015 * isds_get_list_of_{sent,received}_messages())
1016 * @message is automatically reallocated message retrieved from ISDS.
1017 * It will miss documents per se. Use isds_get_signed_received_message(),
1018 * if you are interrested in documents (content). OTOH, only this function
1019 * can get list events message has gone through. */
1020 isds_error isds_get_signed_delivery_info(struct isds_ctx *context,
1021 const char *message_id, struct isds_message **message);
1023 /* Load delivery info of any format from buffer.
1024 * @context is session context
1025 * @raw_type advertises format of @buffer content. Only delivery info types
1026 * are accepted.
1027 * @buffer is DER encoded PKCS#7 structure with signed delivery info. You can
1028 * retrieve such data from message->raw after calling
1029 * isds_get_signed_delivery_info().
1030 * @length is length of buffer in bytes.
1031 * @message is automatically reallocated message parsed from @buffer.
1032 * @strategy selects how buffer will be attached into raw isds_message member.
1033 * */
1034 isds_error isds_load_delivery_info(struct isds_ctx *context,
1035 const isds_raw_type raw_type,
1036 const void *buffer, const size_t length,
1037 struct isds_message **message, const isds_buffer_strategy strategy);
1039 /* Download delivery infosheet of given message identified by ID.
1040 * @context is session context
1041 * @message_id is message identifier (you can get them from
1042 * isds_get_list_of_{sent,received}_messages())
1043 * @message is automatically reallocated message retrieved from ISDS.
1044 * It will miss documents per se. Use isds_get_received_message(), if you are
1045 * interrested in documents (content). OTOH, only this function can get list
1046 * events message has gone through. */
1047 isds_error isds_get_delivery_info(struct isds_ctx *context,
1048 const char *message_id, struct isds_message **message);
1050 /* Download incoming message identified by ID.
1051 * @context is session context
1052 * @message_id is message identifier (you can get them from
1053 * isds_get_list_of_received_messages())
1054 * @message is automatically reallocated message retrieved from ISDS */
1055 isds_error isds_get_received_message(struct isds_ctx *context,
1056 const char *message_id, struct isds_message **message);
1058 /* Load message of any type from buffer.
1059 * @context is session context
1060 * @raw_type defines content type of @buffer. Only message types are allowed.
1061 * @buffer is message raw representation. Format (CMS, plain signed,
1062 * message direction) is defined in @raw_type. You can retrieve such data
1063 * from message->raw after calling isds_get_[signed]{received,sent}_message().
1064 * @length is length of buffer in bytes.
1065 * @message is automatically reallocated message parsed from @buffer.
1066 * @strategy selects how buffer will be attached into raw isds_message member.
1067 * */
1068 isds_error isds_load_message(struct isds_ctx *context,
1069 const isds_raw_type raw_type, const void *buffer, const size_t length,
1070 struct isds_message **message, const isds_buffer_strategy strategy);
1072 /* Determine type of raw message or delivery info according some heuristics.
1073 * It does not validate the raw blob.
1074 * @context is session context
1075 * @raw_type returns content type of @buffer. Valid only if exit code of this
1076 * function is IE_SUCCESS. The pointer must be valid. This is no automatically
1077 * reallocted memory.
1078 * @buffer is message raw representation.
1079 * @length is length of buffer in bytes. */
1080 isds_error isds_guess_raw_type(struct isds_ctx *context,
1081 isds_raw_type *raw_type, const void *buffer, const size_t length);
1083 /* Download signed incoming message identified by ID.
1084 * @context is session context
1085 * @message_id is message identifier (you can get them from
1086 * isds_get_list_of_received_messages())
1087 * @message is automatically reallocated message retrieved from ISDS. The raw
1088 * memeber will be filled with PKCS#7 structure in DER format. */
1089 isds_error isds_get_signed_received_message(struct isds_ctx *context,
1090 const char *message_id, struct isds_message **message);
1092 /* Download signed outgoing message identified by ID.
1093 * @context is session context
1094 * @message_id is message identifier (you can get them from
1095 * isds_get_list_of_sent_messages())
1096 * @message is automatically reallocated message retrieved from ISDS. The raw
1097 * memeber will be filled with PKCS#7 structure in DER format. */
1098 isds_error isds_get_signed_sent_message(struct isds_ctx *context,
1099 const char *message_id, struct isds_message **message);
1101 /* Retrieve hash of message identified by ID stored in ISDS.
1102 * @context is session context
1103 * @message_id is message identifier
1104 * @hash is automatically reallocated message hash downloaded from ISDS.
1105 * Message must exist in system and must not be deleted. */
1106 isds_error isds_download_message_hash(struct isds_ctx *context,
1107 const char *message_id, struct isds_hash **hash);
1109 /* Compute hash of message from raw representation and store it into envelope.
1110 * Original hash structure will be destroyed in envelope.
1111 * @context is session context
1112 * @message is message carrying raw XML message blob
1113 * @algorithm is desired hash algorithm to use */
1114 isds_error isds_compute_message_hash(struct isds_ctx *context,
1115 struct isds_message *message, const isds_hash_algorithm algorithm);
1117 /* Compare two hashes.
1118 * @h1 is first hash
1119 * @h2 is another hash
1120 * @return
1121 * IE_SUCCESS if hashes equal
1122 * IE_NOTUNIQ if hashes are comparable, but they don't equal
1123 * IE_ENUM if not comparable, but both structures defined
1124 * IE_INVAL if some of the structures are undefined (NULL)
1125 * IE_ERROR if internal error occurs */
1126 isds_error isds_hash_cmp(const struct isds_hash *h1,
1127 const struct isds_hash *h2);
1129 /* Check message has gone through ISDS by comparing message hash stored in
1130 * ISDS and locally computed hash. You must provide message with valid raw
1131 * member (do not use isds_load_message(..., BUFFER_DONT_STORE)).
1132 * This is convenient wrapper for isds_download_message_hash(),
1133 * isds_compute_message_hash(), and isds_hash_cmp() sequence.
1134 * @context is session context
1135 * @message is message with valid raw and envelope member; envelope->hash
1136 * member will be changed during funcion run. Use envelope on heap only.
1137 * @return
1138 * IE_SUCCESS if message originates in ISDS
1139 * IE_NOTEQUAL if message is unknown to ISDS
1140 * other code for other errors */
1141 isds_error isds_verify_message_hash(struct isds_ctx *context,
1142 struct isds_message *message);
1144 /* Mark message as read. This is a transactional commit function to acknoledge
1145 * to ISDS the message has been downloaded and processed by client properly.
1146 * @context is session context
1147 * @message_id is message identifier. */
1148 isds_error isds_mark_message_read(struct isds_ctx *context,
1149 const char *message_id);
1151 /* Mark message as received by recipient. This is applicable only to
1152 * commercial message. There is no specified way how to distinguishe
1153 * commercial message from government message yet. Government message is
1154 * received automatically (by law), commenrcial message on recipient request.
1155 * @context is session context
1156 * @message_id is message identifier. */
1157 isds_error isds_mark_message_received(struct isds_ctx *context,
1158 const char *message_id);
1160 /* Send bogus request to ISDS.
1161 * Just for test purposes */
1162 isds_error isds_bogus_request(struct isds_ctx *context);
1164 /* Send document for authorize conversion into Czech POINT system.
1165 * This is public anonymous service, no login necessary. Special context is
1166 * used to reuse keep-a-live HTTPS connection.
1167 * @context is Czech POINT session context. DO NOT use context connected to
1168 * ISDS server. Use new context or context used by this function previously.
1169 * @document is document to convert. Only data, data_length and dmFileDescr
1170 * memebers are signifact. Be ware that not all document formats can be
1171 * converted (signed PDF 1.3 and higher only (2010-02 state)).
1172 * @id is reallocated identifier assigned by Czech POINT system to
1173 * your document on submit. Use is to tell it to Czech POINT officer.
1174 * @date is reallocated document submit date (submitted documents
1175 * expires after some period). Only tm_year, tm_mon and tm_mday carry sane
1176 * value. */
1177 isds_error czp_convert_document(struct isds_ctx *context,
1178 const struct isds_document *document,
1179 char **id, struct tm **date);
1181 /* Close possibly opened connection to Czech POINT document deposit.
1182 * @context is Czech POINT session context. */
1183 isds_error czp_close_connection(struct isds_ctx *context);
1185 /* Send request for new box creation in testing ISDS instance.
1186 * It's not possible to requst for a production box currently, as it
1187 * communicates via e-mail.
1188 * XXX: This function does not work either. Server complains about invalid
1189 * e-mail address.
1190 * XXX: Remove context->type hacks in isds.c and validator.c when removing
1191 * this function
1192 * @context is special session context for box creation request. DO NOT use
1193 * standard context as it could reveal your password. Use fresh new context or
1194 * context previously used by this function.
1195 * @box is box description to create including single primary user (in case of
1196 * FO box type). It outputs box ID assigned by ISDS in dbID element.
1197 * @users is list of struct isds_DbUserInfo (primary users in case of non-FO
1198 * box, or contact address of PFO box owner). The email member is mandatory as
1199 * it will be used to deliver credentials.
1200 * @former_names is optional undocumented string. Pass NULL if you don't care.
1201 * @approval is optional external approval of box manipulation
1202 * @refnumber is reallocated serial number of request assigned by ISDS. Use
1203 * NULL, if you don't care.*/
1204 isds_error isds_request_new_testing_box(struct isds_ctx *context,
1205 struct isds_DbOwnerInfo *box, const struct isds_list *users,
1206 const char *former_names, const struct isds_approval *approval,
1207 char **refnumber);
1209 /* Search for document by document ID in list of documents. IDs are compared
1210 * as UTF-8 string.
1211 * @documents is list of isds_documents
1212 * @id is document identifier
1213 * @return first matching document or NULL. */
1214 const struct isds_document *isds_find_document_by_id(
1215 const struct isds_list *documents, const char *id);
1217 /* Normalize @mime_type to be proper MIME type.
1218 * ISDS servers passes invalid MIME types (e.g. "pdf"). This function tries to
1219 * guess regular MIME type (e.g. "application/pdf").
1220 * @mime_type is UTF-8 encoded MIME type to fix
1221 * @return original @mime_type if no better interpretation exists, or array to
1222 * constant static UTF-8 encoded string with proper MIME type. */
1223 char *isds_normalize_mime_type(const char* mime_type);
1225 /* XXX: Deprecated: Use isds_set_opt() instead.
1226 * Switch MIME type normalization while message loading. Default state for new
1227 * context is no normalization.
1228 * @normalize use true to switch normalization on, false to switch off */
1229 isds_error isds_set_mime_type_normalization(struct isds_ctx *context,
1230 _Bool normalize) _deprecated;
1232 /* Free isds_list with all member data.
1233 * @list list to free, on return will be NULL */
1234 void isds_list_free(struct isds_list **list);
1236 /* Deallocate structure isds_hash and NULL it.
1237 * @hash hash to to free */
1238 void isds_hash_free(struct isds_hash **hash);
1240 /* Deallocate structure isds_DbOwnerInfo recursively and NULL it */
1241 void isds_DbOwnerInfo_free(struct isds_DbOwnerInfo **db_owner_info);
1243 /* Deallocate structure isds_DbUserInfo recursively and NULL it */
1244 void isds_DbUserInfo_free(struct isds_DbUserInfo **db_user_info);
1246 /* Deallocate struct isds_event recursively and NULL it */
1247 void isds_event_free(struct isds_event **event);
1249 /* Deallocate struct isds_envelope recursively and NULL it */
1250 void isds_envelope_free(struct isds_envelope **envelope);
1252 /* Deallocate struct isds_document recursively and NULL it */
1253 void isds_document_free(struct isds_document **document);
1255 /* Deallocate struct isds_message recursively and NULL it */
1256 void isds_message_free(struct isds_message **message);
1258 /* Deallocate struct isds_message_copy recursively and NULL it */
1259 void isds_message_copy_free(struct isds_message_copy **copy);
1261 /* Deallocate struct isds_approval recursively and NULL it */
1262 void isds_approval_free(struct isds_approval **approval);
1264 /* Copy structure isds_PersonName recursively */
1265 struct isds_PersonName *isds_PersonName_duplicate(
1266 const struct isds_PersonName *template);
1268 /* Copy structure isds_Address recursively */
1269 struct isds_Address *isds_Address_duplicate(
1270 const struct isds_Address *template);
1272 /* Copy structure isds_DbOwnerInfo recursively */
1273 struct isds_DbOwnerInfo *isds_DbOwnerInfo_duplicate(
1274 const struct isds_DbOwnerInfo *template);
1276 /* Copy structure isds_DbUserInfo recursively */
1277 struct isds_DbUserInfo *isds_DbUserInfo_duplicate(
1278 const struct isds_DbUserInfo *template);
1280 #ifdef __cplusplus /* For C++ linker sake */
1282 #endif
1284 #endif