Added a new value into isds_DbState.
[libisds.git] / src / isds.h
blob49ad35b85d03c9f1e63b6f85f3c360987e7be8e2
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 <time.h> /* For struct tm */
9 #include <sys/time.h> /* For struct timeval */
10 #include <libxml/tree.h> /* For xmlDoc and xmlNodePtr */
12 #ifdef __cplusplus /* For C++ linker sake */
13 extern "C" {
14 #endif
16 /* _deprecated macro marks library symbols as deprecated. Application should
17 * avoid using such function as soon as possible. */
18 #if defined(__GNUC__)
19 #define _deprecated __attribute__((deprecated))
20 #else
21 #define _deprecated
22 #endif
24 /* Service locators */
25 /* Base URL of production ISDS instance */
26 extern const char isds_locator[]; /* Without client certificate auth. */
27 extern const char isds_cert_locator[]; /* With client certificate auth. */
28 extern const char isds_otp_locator[]; /* With OTP authentication */
29 /* Base URL of testing ISDS instance */
30 extern const char isds_testing_locator[]; /* Without client certificate */
31 extern const char isds_cert_testing_locator[]; /* With client certificate */
32 extern const char isds_otp_testing_locator[]; /* With OTP authentication */
35 struct isds_ctx; /* Context for specific ISDS box */
37 typedef enum {
38 IE_SUCCESS = 0, /* No error, just for C convenience (0 means Ok) */
39 IE_ERROR, /* Unspecified error */
40 IE_NOTSUP,
41 IE_INVAL,
42 IE_INVALID_CONTEXT,
43 IE_NOT_LOGGED_IN,
44 IE_CONNECTION_CLOSED,
45 IE_TIMED_OUT,
46 IE_NOEXIST,
47 IE_NOMEM,
48 IE_NETWORK,
49 IE_HTTP,
50 IE_SOAP,
51 IE_XML,
52 IE_ISDS,
53 IE_ENUM,
54 IE_DATE,
55 IE_2BIG,
56 IE_2SMALL,
57 IE_NOTUNIQ,
58 IE_NOTEQUAL,
59 IE_PARTIAL_SUCCESS,
60 IE_ABORTED,
61 IE_SECURITY
62 } isds_error;
64 typedef enum {
65 ILL_NONE = 0,
66 ILL_CRIT = 10,
67 ILL_ERR = 20,
68 ILL_WARNING = 30,
69 ILL_INFO = 40,
70 ILL_DEBUG = 50,
71 ILL_ALL = 100
72 } isds_log_level;
74 typedef enum {
75 ILF_NONE = 0x0,
76 ILF_HTTP = 0x1,
77 ILF_SOAP = 0x2,
78 ILF_ISDS = 0x4,
79 ILF_FILE = 0x8,
80 ILF_SEC = 0x10,
81 ILF_XML = 0x20,
82 ILF_ALL = 0xFF
83 } isds_log_facility;
85 /* Return text description of ISDS error */
86 const char *isds_strerror(const isds_error error);
88 /* libisds options */
89 typedef enum {
90 IOPT_TLS_VERIFY_SERVER, /* _Bool: Verify server identity?
91 Default value is true. */
92 IOPT_TLS_CA_FILE, /* char *: File name with CA certificates.
93 Default value depends on cryptographic
94 library. */
95 IOPT_TLS_CA_DIRECTORY, /* char *: Directory name with CA certificates.
96 Default value depends on cryptographic
97 library. */
98 IOPT_TLS_CRL_FILE, /* char *: File name with CRL in PEM format.
99 Default value depends on cryptographic
100 library. */
101 IOPT_NORMALIZE_MIME_TYPE, /* _Bool: Normalize MIME type values?
102 Default value is false. */
103 } isds_option;
105 /* TLS libisds options */
106 typedef enum {
107 ITLS_VERIFY_SERVER, /* _Bool: Verify server identity? */
108 ITLS_CA_FILE, /* char *: File name with CA certificates */
109 ITLS_CA_DIRECTORY, /* char *: Directory name with CA certificates */
110 ITLS_CRL_FILE /* char *: File name with CRL in PEM format */
111 } isds_tls_option;
113 /* Cryptographic material encoding */
114 typedef enum {
115 PKI_FORMAT_PEM, /* PEM format */
116 PKI_FORMAT_DER, /* DER format */
117 PKI_FORMAT_ENG /* Stored in crypto engine */
118 } isds_pki_format;
120 /* Public key crypto material to authenticate client */
121 struct isds_pki_credentials {
122 char *engine; /* String identifier of crypto engine to use
123 (where key is stored). Use NULL for no engine */
124 isds_pki_format certificate_format; /* Certificate format */
125 char *certificate; /* Path to client certificate, or certificate
126 nickname in case of NSS as curl back-end,
127 or key slot identifier inside crypto engine.
128 Some crypto engines can pair certificate with
129 key automatically (NULL value) */
130 isds_pki_format key_format; /* Private key format */
131 char *key; /* Path to client private key, or key identifier
132 in case of used engine */
133 char *passphrase; /* Zero terminated string with password for
134 decrypting private key, or engine PIN.
135 Use NULL for no pass-phrase or question by
136 engine. */
139 /* One-time password authentication method */
140 typedef enum {
141 OTP_HMAC = 0, /* HMAC-based OTP method */
142 OTP_TIME /* Time-based OTP method */
143 } isds_otp_method;
145 /* One-time passwed authentication resolution */
146 typedef enum {
147 OTP_RESOLUTION_SUCCESS = 0, /* Authentication succeded */
148 OTP_RESOLUTION_UNKNOWN, /* Status is unkown */
149 OTP_RESOLUTION_BAD_AUTHENTICATION, /* Bad log-in, retry */
150 OTP_RESOLUTION_ACCESS_BLOCKED, /* Access blocked for 60 minutes
151 (brute force attack detected) */
152 OTP_RESOLUTION_PASSWORD_EXPIRED, /* Password has expired.
153 ???: OTP or regular password
154 expired? */
155 OTP_RESOLUTION_TO_FAST, /* OTP cannot be sent repeatedly
156 at this rate (minimal delay
157 depends on TOTP window setting) */
158 OTP_RESOLUTION_UNAUTHORIZED, /* User name is not allowed to
159 access requested URI */
160 OTP_RESOLUTION_TOTP_SENT, /* OTP has been generated and sent by
161 ISDS */
162 OTP_RESOLUTION_TOTP_NOT_SENT, /* OTP could not been sent.
163 Retry later. */
164 } isds_otp_resolution;
166 /* One-time password to authenticate client */
167 struct isds_otp {
168 /* Input members */
169 isds_otp_method method; /* Select OTP method to use */
170 char *otp_code; /* One-time password to use. Pass NULL,
171 if you do not know it yet (e.g. in case
172 of first phase of time-based OTP to
173 request new code from ISDS.) */
174 /* Output members */
175 isds_otp_resolution resolution; /* Fine-grade resolution of OTP
176 authentication attempt. */
179 /* Box type */
180 typedef enum {
181 DBTYPE_SYSTEM = 0, /* This is special sender value for messages
182 sent by ISDS. */
183 DBTYPE_OVM = 10,
184 DBTYPE_OVM_NOTAR = 11,
185 DBTYPE_OVM_EXEKUT = 12,
186 DBTYPE_OVM_REQ = 13,
187 DBTYPE_PO = 20,
188 DBTYPE_PO_ZAK = 21,
189 DBTYPE_PO_REQ = 22,
190 DBTYPE_PFO = 30,
191 DBTYPE_PFO_ADVOK = 31,
192 DBTYPE_PFO_DANPOR = 32,
193 DBTYPE_PFO_INSSPR = 33,
194 DBTYPE_FO = 40
195 } isds_DbType;
197 /* Box status from point of view of accessibility */
198 typedef enum {
199 DBSTATE_ACCESSIBLE = 1,
200 DBSTATE_TEMP_UNACCESSIBLE = 2,
201 DBSTATE_NOT_YET_ACCESSIBLE = 3,
202 DBSTATE_PERM_UNACCESSIBLE = 4,
203 DBSTATE_REMOVED = 5,
204 DBSTATE_TEMP_UNACCESSIBLE_LAW = 6
205 } isds_DbState;
207 /* User permissions from point of view of ISDS.
208 * Instances can be bitmaps of any discrete values. */
209 typedef enum {
210 PRIVIL_READ_NON_PERSONAL = 0x1, /* Can download and read messages with
211 dmPersonalDelivery == false */
212 PRIVIL_READ_ALL = 0x2, /* Can download and read messages with
213 dmPersonalDelivery == true */
214 PRIVIL_CREATE_DM = 0x4, /* Can create and sent messages,
215 can download outgoing (sent) messages */
216 PRIVIL_VIEW_INFO = 0x8, /* Can list messages and data about
217 post and delivery */
218 PRIVIL_SEARCH_DB = 0x10, /* Can search for boxes */
219 PRIVIL_OWNER_ADM = 0x20, /* Can administer his box (add/remove
220 permitted users and theirs
221 permissions) */
222 PRIVIL_READ_VAULT = 0x40, /* Can read message stored in long term
223 storage (does not exists since
224 2012-05) */
225 PRIVIL_ERASE_VAULT = 0x80 /* Can delete messages from long term
226 storage */
227 } isds_priviledges;
229 /* Message status */
230 typedef enum {
231 MESSAGESTATE_SENT = 0x2, /* Message has been put into ISDS */
232 MESSAGESTATE_STAMPED = 0x4, /* Message stamped by TSA */
233 MESSAGESTATE_INFECTED = 0x8, /* Message included viruses,
234 infected document has been removed */
235 MESSAGESTATE_DELIVERED = 0x10, /* Message delivered
236 (dmDeliveryTime stored) */
237 MESSAGESTATE_SUBSTITUTED = 0x20, /* Message delivered through fiction,
238 dmAcceptanceTime stored */
239 MESSAGESTATE_RECEIVED = 0x40, /* Message accepted (by user log-in or
240 user explicit request),
241 dmAcceptanceTime stored */
242 MESSAGESTATE_READ = 0x80, /* Message has been read by user */
243 MESSAGESTATE_UNDELIVERABLE = 0x100, /* Message could not been delivered
244 (e.g. recipient box has been made
245 inaccessible meantime) */
246 MESSAGESTATE_REMOVED = 0x200, /* Message content deleted */
247 MESSAGESTATE_IN_SAFE = 0x400 /* Message stored in long term storage */
248 } isds_message_status;
249 #define MESSAGESTATE_ANY 0x7FE /* Union of all isds_message_status
250 values */
252 /* Hash algorithm types */
253 typedef enum {
254 HASH_ALGORITHM_MD5,
255 HASH_ALGORITHM_SHA_1,
256 HASH_ALGORITHM_SHA_224,
257 HASH_ALGORITHM_SHA_256,
258 HASH_ALGORITHM_SHA_384,
259 HASH_ALGORITHM_SHA_512,
260 } isds_hash_algorithm;
262 /* Buffer storage strategy.
263 * How function should embed application provided buffer into raw element of
264 * output structure. */
265 typedef enum {
266 BUFFER_DONT_STORE, /* Don't fill raw member */
267 BUFFER_COPY, /* Copy buffer content into newly allocated raw */
268 BUFFER_MOVE /* Just copy pointer.
269 But leave deallocation to isds_*_free(). */
270 } isds_buffer_strategy;
272 /* Hash value storage */
273 struct isds_hash {
274 isds_hash_algorithm algorithm; /* Hash algorithm */
275 size_t length; /* Hash value length in bytes */
276 void *value; /* Hash value */
279 /* Name of person */
280 struct isds_PersonName {
281 char *pnFirstName;
282 char *pnMiddleName;
283 char *pnLastName;
284 char *pnLastNameAtBirth;
287 /* Date and place of birth */
288 struct isds_BirthInfo {
289 struct tm *biDate; /* Date of Birth in local time at birth place,
290 only tm_year, tm_mon and tm_mday carry sane
291 value */
292 char *biCity;
293 char *biCounty; /* German: Bezirk, Czech: okres */
294 char *biState;
297 /* Post address */
298 struct isds_Address {
299 char *adCity;
300 char *adStreet;
301 char *adNumberInStreet;
302 char *adNumberInMunicipality;
303 char *adZipCode;
304 char *adState;
307 /* Data about box and his owner.
308 * NULL pointer means undefined value */
309 struct isds_DbOwnerInfo {
310 char *dbID; /* Box ID [Max. 7 chars] */
311 isds_DbType *dbType; /* Box Type */
312 char *ic; /* ID */
313 struct isds_PersonName *personName; /* Name of person */
314 char *firmName; /* Name of firm */
315 struct isds_BirthInfo *birthInfo; /* Birth of person */
316 struct isds_Address *address; /* Post address */
317 char *nationality;
318 char *email;
319 char *telNumber;
320 char *identifier; /* External box identifier for data
321 provider (OVM, PO, maybe PFO)
322 [Max. 20 chars] */
323 char *registryCode; /* PFO External registry code
324 [Max. 5 chars] */
325 long int *dbState; /* Box state; 1 <=> active box;
326 long int because xsd:integer
327 TODO: enum? */
328 _Bool *dbEffectiveOVM; /* Box has OVM role (§ 5a) */
329 _Bool *dbOpenAddressing; /* Non-OVM Box is free to receive
330 messages from anybody */
333 /* User type */
334 typedef enum {
335 USERTYPE_PRIMARY, /* Owner of the box */
336 USERTYPE_ENTRUSTED, /* User with limited access to the box */
337 USERTYPE_ADMINISTRATOR, /* User to manage ENTRUSTED_USERs */
338 USERTYPE_OFFICIAL, /* ??? */
339 USERTYPE_OFFICIAL_CERT, /* ??? */
340 USERTYPE_LIQUIDATOR /* Company liquidator */
341 } isds_UserType;
343 /* Data about user.
344 * NULL pointer means undefined value */
345 struct isds_DbUserInfo {
346 char *userID; /* User ID [Min. 6, max. 12 characters] */
347 isds_UserType *userType; /* User type */
348 long int *userPrivils; /* Set of user permissions */
349 struct isds_PersonName *personName; /* Name of the person */
350 struct isds_Address *address; /* Post address */
351 struct tm *biDate; /* Date of birth in local time,
352 only tm_year, tm_mon and tm_mday carry sane
353 value */
354 char *ic; /* ID of a supervising firm [Max. 8 chars] */
355 char *firmName; /* Name of a supervising firm
356 [Max. 100 chars] */
357 char *caStreet; /* Street and number of contact address */
358 char *caCity; /* Czech City of contact address */
359 char *caZipCode; /* Post office code of contact address */
360 char *caState; /* Abbreviated country of contact address;
361 Implicit value is "CZ"; Optional. */
364 /* Message event type */
365 typedef enum {
366 EVENT_UKNOWN, /* Event unknown to this library */
367 EVENT_ACCEPTED_BY_RECIPIENT, /* Message has been delivered and accepted
368 by recipient action */
369 EVENT_ACCEPTED_BY_FICTION, /* Message has been delivered, acceptance
370 timed out, considered as accepted */
371 EVENT_UNDELIVERABLE, /* Recipient box made inaccessible,
372 thus message is undeliverable */
373 EVENT_COMMERCIAL_ACCEPTED, /* Recipient confirmed acceptance of
374 commercial message */
375 EVENT_ENTERED_SYSTEM, /* Message entered ISDS, i.e. has been just
376 sent by sender */
377 EVENT_DELIVERED, /* Message has been delivered */
378 EVENT_PRIMARY_LOGIN, /* Primary user has logged in */
379 EVENT_ENTRUSTED_LOGIN, /* Entrusted user with capability to read
380 has logged in */
381 EVENT_SYSCERT_LOGIN /* Application authenticated by `system'
382 certificate has logged in */
383 } isds_event_type;
385 /* Message event
386 * All members are optional as specification states so. */
387 struct isds_event {
388 struct timeval *time; /* When the event occurred */
389 isds_event_type *type; /* Type of the event */
390 char *description; /* Human readable event description
391 generated by ISDS (Czech) */
394 /* Message envelope
395 * Be ware that the string length constraints are forced only on output
396 * members transmitted to ISDS. The other direction (downloaded from ISDS)
397 * can break these rules. It should not happen, but nobody knows how much
398 * incompatible new version of ISDS protocol will be. This is the gold
399 * Internet rule: be strict on what you put, be tolerant on what you get. */
400 struct isds_envelope {
401 /* Following members apply to incoming messages only: */
402 char *dmID; /* Message ID.
403 Maximal length is 20 characters. */
404 char *dbIDSender; /* Box ID of sender.
405 Special value "aaaaaaa" means sent by
406 ISDS.
407 Maximal length is 7 characters. */
408 char *dmSender; /* Sender name;
409 Maximal length is 100 characters. */
410 char *dmSenderAddress; /* Postal address of sender;
411 Maximal length is 100 characters. */
412 long int *dmSenderType; /* Gross Box type of sender
413 TODO: isds_DbType ? */
414 char *dmRecipient; /* Recipient name;
415 Maximal length is 100 characters. */
416 char *dmRecipientAddress; /* Postal address of recipient;
417 Maximal length is 100 characters. */
418 _Bool *dmAmbiguousRecipient; /* Recipient has OVM role */
420 /* Following members are assigned by ISDS in different phases of message
421 * life cycle. */
422 unsigned long int *dmOrdinal; /* Ordinal number in list of
423 incoming/outgoing messages */
424 isds_message_status *dmMessageStatus; /* Message state */
425 long int *dmAttachmentSize; /* Size of message documents in
426 kilobytes (rounded). */
427 struct timeval *dmDeliveryTime; /* Time of delivery into a box
428 NULL, if message has not been
429 delivered yet */
430 struct timeval *dmAcceptanceTime; /* Time of acceptance of the message
431 by an user. NULL if message has not
432 been accepted yet. */
433 struct isds_hash *hash; /* Message hash.
434 This is hash of isds:dmDM subtree. */
435 void *timestamp; /* Qualified time stamp; Optional. */
436 size_t timestamp_length; /* Length of timestamp in bytes */
437 struct isds_list *events; /* Events message passed trough;
438 List of isds_event's. */
441 /* Following members apply to both outgoing and incoming messages: */
442 char *dmSenderOrgUnit; /* Organisation unit of sender as string;
443 Optional. */
444 long int *dmSenderOrgUnitNum; /* Organisation unit of sender as number;
445 Optional. */
446 char *dbIDRecipient; /* Box ID of recipient; Mandatory.
447 Maximal length is 7 characters. */
448 char *dmRecipientOrgUnit; /* Organisation unit of recipient as
449 string; Optional. */
450 long int *dmRecipientOrgUnitNum; /* Organisation unit of recipient as
451 number; Optional. */
452 char *dmToHands; /* Person in recipient organisation;
453 Optional. */
454 char *dmAnnotation; /* Subject (title) of the message.
455 Maximal length is 255 characters. */
456 char *dmRecipientRefNumber; /* Czech: číslo jednací příjemce; Optional.
457 Maximal length is 50 characters. */
458 char *dmSenderRefNumber; /* Czech: číslo jednací odesílatele;
459 Optional. Maximal length is 50 chars. */
460 char *dmRecipientIdent; /* Czech: spisová značka příjemce; Optional.
461 Maximal length is 50 characters. */
462 char *dmSenderIdent; /* Czech: spisová značka odesílatele;
463 Optional. Maximal length is 50 chars. */
465 /* Act addressing in Czech Republic:
466 * Point (Paragraph) § Section Law/Year Coll. */
467 long int *dmLegalTitleLaw; /* Number of act mandating authority */
468 long int *dmLegalTitleYear; /* Year of act issue mandating authority */
469 char *dmLegalTitleSect; /* Section of act mandating authority.
470 Czech: paragraf */
471 char *dmLegalTitlePar; /* Paragraph of act mandating authority.
472 Czech: odstavec */
473 char *dmLegalTitlePoint; /* Point of act mandating authority.
474 Czech: písmeno */
476 _Bool *dmPersonalDelivery; /* If true, only person with higher
477 privileges can read this message */
478 _Bool *dmAllowSubstDelivery; /* Allow delivery through fiction.
479 I.e. Even if recipient did not read this
480 message, message is considered as
481 delivered after (currently) 10 days.
482 This is delivery through fiction.
483 Applies only to OVM dbType sender. */
484 char *dmType; /* Message type (commercial subtypes or
485 government message):
486 Input values (when sending a message):
487 "I" is commercial message offering
488 paying the response (initiatory
489 message);
490 it's necessary to define
491 dmSenderRefNumber
492 "K" is commercial message paid by sender
493 if this message
494 "O" is commercial response paid by
495 sender of initiatory message; it's
496 necessary to copy value from
497 dmSenderRefNumber of initiatory
498 message to dmRecipientRefNumber
499 of this message
500 "V" is noncommercial government message
501 Default value while sending is undefined
502 which has the same meaning as "V".
503 Output values (when retrieving
504 a message):
505 "A" is subsidized initiatory commercial
506 message which can pay a response
507 "B" is subsidized initiatory commercial
508 message which has already paid the
509 response
510 "C" is subsidized initiatory commercial
511 message where the response offer has
512 expired
513 "D" is externally subsidized commercial
514 messsage
515 "E" is commercial message prepaid by
516 a stamp
517 "G" is commerical message paid by
518 a sponsor
523 "X" is initiatory commercial message
524 where the response offer has expired
525 "Y" initiatory commercial message which
526 has already paid the response
527 "Z" is limitedly subsidized commercial
528 message
529 Length: Exactly 1 UTF-8 character if
530 defined; */
532 /* Following members apply to outgoing messages only: */
533 _Bool *dmOVM; /* OVM sending mode.
534 Non-OVM dbType boxes that has
535 dbEffectiveOVM == true MUST select
536 between true (OVM mode) and
537 false (non-OVM mode).
538 Optional; Implicit value is true. */
539 _Bool *dmPublishOwnID; /* Allow sender to express his name shall
540 be available to recipient by
541 isds_get_message_sender(). Sender type
542 will be always available.
543 Optional; Default value is false. */
547 /* Document type from point of hierarchy */
548 typedef enum {
549 FILEMETATYPE_MAIN, /* Main document */
550 FILEMETATYPE_ENCLOSURE, /* Appendix */
551 FILEMETATYPE_SIGNATURE, /* Digital signature of other document */
552 FILEMETATYPE_META /* XML document for ESS (electronic
553 document information system) purposes */
554 } isds_FileMetaType;
556 /* Document */
557 struct isds_document {
558 _Bool is_xml; /* True if document is ISDS XML document.
559 False if document is ISDS binary
560 document. */
561 xmlNodePtr xml_node_list; /* XML node-set presenting current XML
562 document content. This is pointer to
563 first node of the document in
564 isds_message.xml tree. Use `children'
565 and `next' members to iterate the
566 document.
567 It will be NULL if document is empty.
568 Valid only if is_xml is true. */
569 void *data; /* Document content.
570 The encoding and interpretation depends
571 on dmMimeType.
572 Valid only if is_xml is false. */
573 size_t data_length; /* Length of the data in bytes.
574 Valid only if is_xml is false. */
576 char *dmMimeType; /* MIME type of data; Mandatory. */
577 isds_FileMetaType dmFileMetaType; /* Document type to create hierarchy */
578 char *dmFileGuid; /* Message-local document identifier;
579 Optional. */
580 char *dmUpFileGuid; /* Reference to upper document identifier
581 (dmFileGuid); Optional. */
582 char *dmFileDescr; /* Document name (title). E.g. file name;
583 Mandatory. */
584 char *dmFormat; /* Reference to XML form definition;
585 Defines how to interpret XML document;
586 Optional. */
589 /* Raw message representation content type.
590 * This is necessary to distinguish between different representations without
591 * expensive repeated detection.
592 * Infix explanation:
593 * PLAIN_SIGNED data are XML with namespace mangled to signed alternative
594 * CMS_SIGNED data are XML with signed namespace encapsulated in CMS */
595 typedef enum {
596 RAWTYPE_INCOMING_MESSAGE,
597 RAWTYPE_PLAIN_SIGNED_INCOMING_MESSAGE,
598 RAWTYPE_CMS_SIGNED_INCOMING_MESSAGE,
599 RAWTYPE_PLAIN_SIGNED_OUTGOING_MESSAGE,
600 RAWTYPE_CMS_SIGNED_OUTGOING_MESSAGE,
601 RAWTYPE_DELIVERYINFO,
602 RAWTYPE_PLAIN_SIGNED_DELIVERYINFO,
603 RAWTYPE_CMS_SIGNED_DELIVERYINFO
604 } isds_raw_type;
606 /* Message */
607 struct isds_message {
608 void *raw; /* Raw message in XML format as send to or
609 from the ISDS. You can use it to store
610 local copy. This is binary buffer. */
611 size_t raw_length; /* Length of raw message in bytes */
612 isds_raw_type raw_type; /* Content type of raw representation
613 Meaningful only with non-NULL raw
614 member */
615 xmlDocPtr xml; /* Parsed XML document with attached ISDS
616 message XML documents.
617 Can be NULL. May be freed AFTER deallocating
618 documents member structure. */
619 struct isds_envelope *envelope; /* Message envelope */
620 struct isds_list *documents; /* List of isds_document's.
621 Valid message must contain exactly one
622 document of type FILEMETATYPE_MAIN and
623 can contain any number of other type
624 documents. Total size of documents
625 must not exceed 10 MB. */
628 /* Message copy recipient and assigned message ID */
629 struct isds_message_copy {
630 /* Input members defined by application */
631 char *dbIDRecipient; /* Box ID of recipient; Mandatory.
632 Maximal length is 7 characters. */
633 char *dmRecipientOrgUnit; /* Organisation unit of recipient as
634 string; Optional. */
635 long int *dmRecipientOrgUnitNum; /* Organisation unit of recipient as
636 number; Optional. */
637 char *dmToHands; /* Person in recipient organisation;
638 Optional. */
640 /* Output members returned from ISDS */
641 isds_error error; /* libisds compatible error of delivery to o ne recipient */
642 char *dmStatus; /* Error description returned by ISDS;
643 Optional. */
644 char *dmID; /* Assigned message ID; Meaningful only
645 for error == IE_SUCCESS */
648 /* Message state change event */
649 struct isds_message_status_change {
650 char *dmID; /* Message ID. */
651 isds_message_status *dmMessageStatus; /* Message state */
652 struct timeval *time; /* When the state changed */
655 /* How outgoing commercial message gets paid */
656 typedef enum {
657 PAYMENT_SENDER, /* Payed by a sender */
658 PAYMENT_STAMP, /* Pre-paid by a sender */
659 PAYMENT_SPONSOR, /* A sponsor pays all messages */
660 PAYMENT_RESPONSE, /* Recipient pays a response */
661 PAYMENT_SPONSOR_LIMITED, /* Undocumented */
662 PAYMENT_SPONSOR_EXTERNAL /* Undocomented */
663 } isds_payment_type;
665 /* Permission to send commercial message */
666 struct isds_commercial_permission {
667 isds_payment_type type; /* Payment method */
668 char *recipient; /* Send to this box ID only;
669 NULL means to anybody. */
670 char *payer; /* Owner of this box ID pays */
671 struct timeval *expiration; /* This permissions is valid until;
672 NULL means indefinitivly. */
673 unsigned long int *count; /* Number of messages that can be sent
674 on this permission;
675 NULL means unlimited. */
676 char *reply_identifier; /* Identifier to pair request and response
677 message. Meaningful only with type
678 PAYMENT_RESPONSE. */
681 /* Type of credit change event */
682 typedef enum {
683 ISDS_CREDIT_CHARGED, /* Credit has been charged */
684 ISDS_CREDIT_DISCHARGED, /* Credit has been discharged */
685 ISDS_CREDIT_MESSAGE_SENT, /* Credit has been spent for sending
686 a commerical message */
687 ISDS_CREDIT_STORAGE_SET, /* Credit has been spent for setting
688 a long-term storage */
689 ISDS_CREDIT_EXPIRED /* Credit has expired */
690 } isds_credit_event_type;
692 /* Data specific for ISDS_CREDIT_CHARGED isds_credit_event_type */
693 struct isds_credit_event_charged {
694 char *transaction; /* Transaction identifier;
695 NULL-terminated string. */
698 /* Data specific for ISDS_CREDIT_DISCHARGED isds_credit_event_type */
699 struct isds_credit_event_discharged {
700 char *transaction; /* Transaction identifier;
701 NULL-terminated string. */
704 /* Data specific for ISDS_CREDIT_MESSAGE_SENT isds_credit_event_type */
705 struct isds_credit_event_message_sent {
706 char *recipient; /* Recipent's box ID of the sent message */
707 char *message_id; /* ID of the sent message */
710 /* Data specific for ISDS_CREDIT_STORAGE_SET isds_credit_event_type */
711 struct isds_credit_event_storage_set {
712 long int new_capacity; /* New storage capacity. The unit is
713 a message. */
714 struct tm *new_valid_from; /* The new capacity is available since
715 date. */
716 struct tm *new_valid_to; /* The new capacity expires on date. */
717 long int *old_capacity; /* Previous storage capacity; Optional.
718 The unit is a message. */
719 struct tm *old_valid_from; /* Date; Optional; Only tm_year,
720 tm_mon, and tm_mday carry sane value. */
721 struct tm *old_valid_to; /* Date; Optional. */
722 char *initiator; /* Name of a user who initiated this
723 change; Optional. */
726 /* Event about change of credit for sending commerical services */
727 struct isds_credit_event {
728 /* Common fields */
729 struct timeval *time; /* When the credit was changed. */
730 long int credit_change; /* Difference in credit value caused by
731 this event. The unit is 1/100 CZK. */
732 long int new_credit; /* Credit value after this event.
733 The unit is 1/100 CZK. */
734 isds_credit_event_type type; /* Type of the event */
736 /* Datails specific for the type */
737 union {
738 struct isds_credit_event_charged charged;
739 /* ISDS_CREDIT_CHARGED */
740 struct isds_credit_event_discharged discharged;
741 /* ISDS_CREDIT_DISCHAGED */
742 struct isds_credit_event_message_sent message_sent;
743 /* ISDS_CREDIT_MESSAGE_SENT */
744 struct isds_credit_event_storage_set storage_set;
745 /* ISDS_CREDIT_STORAGE_SET */
746 } details;
749 /* General linked list */
750 struct isds_list {
751 struct isds_list *next; /* Next list item,
752 or NULL if current is last */
753 void *data; /* Payload */
754 void (*destructor) (void **); /* Payload deallocator;
755 Use NULL to have static data member. */
758 /* External box approval */
759 struct isds_approval {
760 _Bool approved; /* True if request for box has been
761 approved out of ISDS */
762 char *refference; /* Identifier of the approval */
765 /* Message sender type.
766 * Similar but not equivalent to isds_UserType. */
767 typedef enum {
768 SENDERTYPE_PRIMARY, /* Owner of the box */
769 SENDERTYPE_ENTRUSTED, /* User with limited access to the box */
770 SENDERTYPE_ADMINISTRATOR, /* User to manage ENTRUSTED_USERs */
771 SENDERTYPE_OFFICIAL, /* ISDS; sender of system message */
772 SENDERTYPE_VIRTUAL, /* An application (e.g. document
773 information system) */
774 SENDERTYPE_OFFICIAL_CERT, /* ???; Non-normative */
775 SENDERTYPE_LIQUIDATOR /* Liquidator of the company; Non-normative */
776 } isds_sender_type;
778 /* Digital delivery of credentials */
779 struct isds_credentials_delivery {
780 /* Input members */
781 char *email; /* e-mail address where to send
782 notification with link to service where
783 user can get know his new credentials */
784 /* Output members */
785 char *token; /* token user needs to use to authorize on
786 the web server to view his new
787 credentials. */
788 char *new_user_name; /* user's log-in name that ISDS created/
789 changed up on a call. */
792 /* Box attribute to search while performing full-text search */
793 typedef enum {
794 FULLTEXT_ALL, /* search in address, organization identifier, and
795 box id */
796 FULLTEXT_ADDRESS, /* search in address */
797 FULLTEXT_IC, /* search in organization identifier */
798 FULLTEXT_BOX_ID /* search in box ID */
799 } isds_fulltext_target;
801 /* A box matching full-text search */
802 struct isds_fulltext_result {
803 char *dbID; /* Box ID */
804 isds_DbType dbType; /* Box Type */
805 char *name; /* Subject owning the box */
806 struct isds_list *name_match_start; /* List of pointers into `name'
807 field string. Point to first
808 characters of a matched query
809 word. */
810 struct isds_list *name_match_end; /* List of pointers into `name'
811 field string. Point after last
812 characters of a matched query
813 word. */
814 char *address; /* Post address */
815 struct isds_list *address_match_start; /* List of pointers into `address'
816 field string. Point to first
817 characters of a matched query
818 word. */
819 struct isds_list *address_match_end; /* List of pointers into `address'
820 field string. Point after last
821 characters of a matched query
822 word. */
823 char *ic; /* Organization identifier */
824 struct tm *biDate; /* Date of birth in local time at birth place,
825 only tm_year, tm_mon and tm_mday carry sane
826 value */
827 _Bool dbEffectiveOVM; /* Box has OVM role (§ 5a) */
828 _Bool active; /* Box is active */
829 _Bool public_sending; /* Current box can send non-commercial
830 messages into this box */
831 _Bool commercial_sending; /* Current box can send commercial messages
832 into this box */
835 /* Initialize ISDS library.
836 * Global function, must be called before other functions.
837 * If it fails you can not use ISDS library and must call isds_cleanup() to
838 * free partially initialized global variables. */
839 isds_error isds_init(void);
841 /* Deinitialize ISDS library.
842 * Global function, must be called as last library function. */
843 isds_error isds_cleanup(void);
845 /* Return version string of this library. Version of dependencies can be
846 * embedded. Do no try to parse it. You must free it. */
847 char *isds_version(void);
849 /* Create ISDS context.
850 * Each context can be used for different sessions to (possibly) different
851 * ISDS server with different credentials.
852 * Returns new context, or NULL */
853 struct isds_ctx *isds_ctx_create(void);
855 /* Destroy ISDS context and free memory.
856 * @context will be NULLed on success. */
857 isds_error isds_ctx_free(struct isds_ctx **context);
859 /* Return long message text produced by library function, e.g. detailed error
860 * message. Returned pointer is only valid until new library function is
861 * called for the same context. Could be NULL, especially if NULL context is
862 * supplied. Return string is locale encoded. */
863 char *isds_long_message(const struct isds_ctx *context);
865 /* Set logging up.
866 * @facilities is bit mask of isds_log_facility values,
867 * @level is verbosity level. */
868 void isds_set_logging(const unsigned int facilities,
869 const isds_log_level level);
871 /* Function provided by application libisds will call to pass log message.
872 * The message is usually locale encoded, but raw strings (UTF-8 usually) can
873 * occur when logging raw communication with ISDS servers. Infixed zero byte
874 * is not excluded, but should not present. Use @length argument to get real
875 * length of the message.
876 * TODO: We will try to fix the encoding issue
877 * @facility is log message class
878 * @level is log message severity
879 * @message is string with zero byte terminator. This can be any arbitrary
880 * chunk of a sentence with or without new line, a sentence can be splitted
881 * into more messages. However it should not happen. If you discover message
882 * without new line, report it as a bug.
883 * @length is size of @message string in bytes excluding trailing zero
884 * @data is pointer that will be passed unchanged to this function at run-time
885 * */
886 typedef void (*isds_log_callback)(
887 isds_log_facility facility, isds_log_level level,
888 const char *message, int length, void *data);
890 /* Register callback function libisds calls when new global log message is
891 * produced by library. Library logs to stderr by default.
892 * @callback is function provided by application libisds will call. See type
893 * definition for @callback argument explanation. Pass NULL to revert logging to
894 * default behaviour.
895 * @data is application specific data @callback gets as last argument */
896 void isds_set_log_callback(isds_log_callback callback, void *data);
898 /* Set timeout in milliseconds for each network job like connecting to server
899 * or sending message. Use 0 to disable timeout limits. */
900 isds_error isds_set_timeout(struct isds_ctx *context,
901 const unsigned int timeout);
903 /* Function provided by application libisds will call with
904 * following five arguments. Value zero of any argument means the value is
905 * unknown.
906 * @upload_total is expected total upload,
907 * @upload_current is cumulative current upload progress
908 * @dowload_total is expected total download
909 * @download_current is cumulative current download progress
910 * @data is pointer that will be passed unchanged to this function at run-time
911 * @return 0 to continue HTTP transfer, or non-zero to abort transfer */
912 typedef int (*isds_progress_callback)(
913 double upload_total, double upload_current,
914 double download_total, double download_current,
915 void *data);
917 /* Register callback function libisds calls periodically during HTTP data
918 * transfer.
919 * @context is session context
920 * @callback is function provided by application libisds will call. See type
921 * definition for @callback argument explanation.
922 * @data is application specific data @callback gets as last argument */
923 isds_error isds_set_progress_callback(struct isds_ctx *context,
924 isds_progress_callback callback, void *data);
926 /* Change context settings.
927 * @context is context which setting will be applied to
928 * @option is name of option. It determines the type of last argument. See
929 * isds_option definition for more info.
930 * @... is value of new setting. Type is determined by @option
931 * */
932 isds_error isds_set_opt(struct isds_ctx *context, const isds_option option,
933 ...);
935 /* Connect and log into ISDS server.
936 * All required arguments will be copied, you do not have to keep them after
937 * that.
938 * ISDS supports six different authentication methods. Exact method is
939 * selected on @username, @password, @pki_credentials, and @otp arguments:
940 * - If @pki_credentials == NULL, @username and @password must be supplied
941 * and then
942 * - If @otp == NULL, simple authentication by username and password will
943 * be proceeded.
944 * - If @otp != NULL, authentication by username and password and OTP
945 * will be used.
946 * - If @pki_credentials != NULL, then
947 * - If @username == NULL, only certificate will be used
948 * - If @username != NULL, then
949 * - If @password == NULL, then certificate will be used and
950 * @username shifts meaning to box ID. This is used for hosted
951 * services.
952 * - Otherwise all three arguments will be used.
953 * Please note, that different cases require different certificate type
954 * (system qualified one or commercial non qualified one). This library
955 * does not check such political issues. Please see ISDS Specification
956 * for more details.
957 * @url is base address of ISDS web service. Pass extern isds_locator
958 * variable to use production ISDS instance without client certificate
959 * authentication (or extern isds_cert_locator with client certificate
960 * authentication or extern isds_otp_locators with OTP authentication).
961 * Passing NULL has the same effect, autoselection between isds_locator,
962 * isds_cert_locator, and isds_otp_locator is performed in addition. You can
963 * pass extern isds_testing_locator (or isds_cert_testing_locator or
964 * isds_otp_testing_locator) variable to select testing instance.
965 * @username is user name of ISDS user or box ID
966 * @password is user's secret password
967 * @pki_credentials defines public key cryptographic material to use in client
968 * authentication.
969 * @otp selects one-time password authentication method to use, defines OTP
970 * code (if known) and returns fine grade resolution of OTP procedure.
971 * @return:
972 * IE_SUCCESS if authentication succeeds
973 * IE_NOT_LOGGED_IN if authentication fails. If OTP authentication has been
974 * requested, fine grade reason will be set into @otp->resolution. Error
975 * message from server can be obtained by isds_long_message() call.
976 * IE_PARTIAL_SUCCESS if time-based OTP authentication has been requested and
977 * server has sent OTP code through side channel. Application is expected to
978 * fill the code into @otp->otp_code, keep other arguments unchanged, and retry
979 * this call to complete second phase of TOTP authentication;
980 * or other appropriate error. */
981 isds_error isds_login(struct isds_ctx *context, const char *url,
982 const char *username, const char *password,
983 const struct isds_pki_credentials *pki_credentials,
984 struct isds_otp *otp);
986 /* Log out from ISDS server and close connection. */
987 isds_error isds_logout(struct isds_ctx *context);
989 /* Verify connection to ISDS is alive and server is responding.
990 * Send dummy request to ISDS and expect dummy response. */
991 isds_error isds_ping(struct isds_ctx *context);
993 /* Get data about logged in user and his box. */
994 isds_error isds_GetOwnerInfoFromLogin(struct isds_ctx *context,
995 struct isds_DbOwnerInfo **db_owner_info);
997 /* Get data about logged in user. */
998 isds_error isds_GetUserInfoFromLogin(struct isds_ctx *context,
999 struct isds_DbUserInfo **db_user_info);
1001 /* Get expiration time of current password
1002 * @context is session context
1003 * @expiration is automatically reallocated time when password expires. If
1004 * password expiration is disabled, NULL will be returned. In case of error
1005 * it will be nulled too. */
1006 isds_error isds_get_password_expiration(struct isds_ctx *context,
1007 struct timeval **expiration);
1009 /* Change user password in ISDS.
1010 * User must supply old password, new password will takes effect after some
1011 * time, current session can continue. Password must fulfill some constraints.
1012 * @context is session context
1013 * @old_password is current password.
1014 * @new_password is requested new password
1015 * @otp auxiliary data required if one-time password authentication is in use,
1016 * defines OTP code (if known) and returns fine grade resolution of OTP
1017 * procedure. Pass NULL, if one-time password authentication is not needed.
1018 * Please note the @otp argument must match OTP method used at log-in time. See
1019 * isds_login() function for more details.
1020 * @refnumber is reallocated serial number of request assigned by ISDS. Use
1021 * NULL, if you don't care.
1022 * @return IE_SUCCESS, if password has been changed. Or returns appropriate
1023 * error code. It can return IE_PARTIAL_SUCCESS if OTP is in use and server is
1024 * awaiting OTP code that has been delivered by side channel to the user. */
1025 isds_error isds_change_password(struct isds_ctx *context,
1026 const char *old_password, const char *new_password,
1027 struct isds_otp *otp, char **refnumber);
1029 /* Create new box.
1030 * @context is session context
1031 * @box is box description to create including single primary user (in case of
1032 * FO box type). It outputs box ID assigned by ISDS in dbID element.
1033 * @users is list of struct isds_DbUserInfo (primary users in case of non-FO
1034 * box, or contact address of PFO box owner)
1035 * @former_names is optional former name of box owner. Pass NULL if you don't care.
1036 * @upper_box_id is optional ID of supper box if currently created box is
1037 * subordinated.
1038 * @ceo_label is optional title of OVM box owner (e.g. mayor)
1039 * @credentials_delivery is NULL if new password should be delivered off-line
1040 * to box owner. It is valid pointer if owner should obtain new password on-line
1041 * on dedicated web server. Then input @credentials_delivery.email value is
1042 * his e-mail address he must provide to dedicated web server together
1043 * with output reallocated @credentials_delivery.token member. Output
1044 * member @credentials_delivery.new_user_name is unused up on this call.
1045 * @approval is optional external approval of box manipulation
1046 * @refnumber is reallocated serial number of request assigned by ISDS. Use
1047 * NULL, if you don't care.*/
1048 isds_error isds_add_box(struct isds_ctx *context,
1049 struct isds_DbOwnerInfo *box, const struct isds_list *users,
1050 const char *former_names, const char *upper_box_id,
1051 const char *ceo_label,
1052 struct isds_credentials_delivery *credentials_delivery,
1053 const struct isds_approval *approval, char **refnumber);
1055 /* Notify ISDS about new PFO entity.
1056 * This function has no real effect.
1057 * @context is session context
1058 * @box is PFO description including single primary user.
1059 * @users is list of struct isds_DbUserInfo (contact address of PFO box owner)
1060 * @former_names is optional undocumented string. Pass NULL if you don't care.
1061 * @upper_box_id is optional ID of supper box if currently created box is
1062 * subordinated.
1063 * @ceo_label is optional title of OVM box owner (e.g. mayor)
1064 * @approval is optional external approval of box manipulation
1065 * @refnumber is reallocated serial number of request assigned by ISDS. Use
1066 * NULL, if you don't care.*/
1067 isds_error isds_add_pfoinfo(struct isds_ctx *context,
1068 const struct isds_DbOwnerInfo *box, const struct isds_list *users,
1069 const char *former_names, const char *upper_box_id,
1070 const char *ceo_label, const struct isds_approval *approval,
1071 char **refnumber);
1073 /* Remove given box permanently.
1074 * @context is session context
1075 * @box is box description to delete
1076 * @since is date of box owner cancellation. Only tm_year, tm_mon and tm_mday
1077 * carry sane value.
1078 * @approval is optional external approval of box manipulation
1079 * @refnumber is reallocated serial number of request assigned by ISDS. Use
1080 * NULL, if you don't care.*/
1081 isds_error isds_delete_box(struct isds_ctx *context,
1082 const struct isds_DbOwnerInfo *box, const struct tm *since,
1083 const struct isds_approval *approval, char **refnumber);
1085 /* Undocumented function.
1086 * @context is session context
1087 * @box is box description to delete
1088 * @approval is optional external approval of box manipulation
1089 * @refnumber is reallocated serial number of request assigned by ISDS. Use
1090 * NULL, if you don't care.*/
1091 isds_error isds_delete_box_promptly(struct isds_ctx *context,
1092 const struct isds_DbOwnerInfo *box,
1093 const struct isds_approval *approval, char **refnumber);
1095 /* Update data about given box.
1096 * @context is session context
1097 * @old_box current box description
1098 * @new_box are updated data about @old_box
1099 * @approval is optional external approval of box manipulation
1100 * @refnumber is reallocated serial number of request assigned by ISDS. Use
1101 * NULL, if you don't care.*/
1102 isds_error isds_UpdateDataBoxDescr(struct isds_ctx *context,
1103 const struct isds_DbOwnerInfo *old_box,
1104 const struct isds_DbOwnerInfo *new_box,
1105 const struct isds_approval *approval, char **refnumber);
1107 /* Get data about all users assigned to given box.
1108 * @context is session context
1109 * @box_id is box ID
1110 * @users is automatically reallocated list of struct isds_DbUserInfo */
1111 isds_error isds_GetDataBoxUsers(struct isds_ctx *context, const char *box_id,
1112 struct isds_list **users);
1114 /* Update data about user assigned to given box.
1115 * @context is session context
1116 * @box is box identification
1117 * @old_user identifies user to update
1118 * @new_user are updated data about @old_user
1119 * @refnumber is reallocated serial number of request assigned by ISDS. Use
1120 * NULL, if you don't care.*/
1121 isds_error isds_UpdateDataBoxUser(struct isds_ctx *context,
1122 const struct isds_DbOwnerInfo *box,
1123 const struct isds_DbUserInfo *old_user,
1124 const struct isds_DbUserInfo *new_user,
1125 char **refnumber);
1127 /* Undocumented function.
1128 * @context is session context
1129 * @box_id is UTF-8 encoded box identifier
1130 * @token is UTF-8 encoded temporary password
1131 * @user_id outputs UTF-8 encoded reallocated user identifier
1132 * @password outpus UTF-8 encoded reallocated user password
1133 * Output arguments will be nulled in case of error */
1134 isds_error isds_activate(struct isds_ctx *context,
1135 const char *box_id, const char *token,
1136 char **user_id, char **password);
1138 /* Reset credentials of user assigned to given box.
1139 * @context is session context
1140 * @box is box identification
1141 * @user identifies user to reset password
1142 * @fee_paid is true if fee has been paid, false otherwise
1143 * @approval is optional external approval of box manipulation
1144 * @credentials_delivery is NULL if new password should be delivered off-line
1145 * to the user. It is valid pointer if user should obtain new password on-line
1146 * on dedicated web server. Then input @credentials_delivery.email value is
1147 * user's e-mail address user must provide to dedicated web server together
1148 * with @credentials_delivery.token. The output reallocated token user needs
1149 * to use to authorize on the web server to view his new password. Output
1150 * reallocated @credentials_delivery.new_user_name is user's log-in name that
1151 * ISDS changed up on this call. (No reason why server could change the name
1152 * is known now.)
1153 * @refnumber is reallocated serial number of request assigned by ISDS. Use
1154 * NULL, if you don't care.*/
1155 isds_error isds_reset_password(struct isds_ctx *context,
1156 const struct isds_DbOwnerInfo *box,
1157 const struct isds_DbUserInfo *user,
1158 const _Bool fee_paid, const struct isds_approval *approval,
1159 struct isds_credentials_delivery *credentials_delivery,
1160 char **refnumber);
1162 /* Assign new user to given box.
1163 * @context is session context
1164 * @box is box identification
1165 * @user defines new user to add
1166 * @credentials_delivery is NULL if new user's password should be delivered
1167 * off-line to the user. It is valid pointer if user should obtain new
1168 * password on-line on dedicated web server. Then input
1169 * @credentials_delivery.email value is user's e-mail address user must
1170 * provide to dedicated web server together with @credentials_delivery.token.
1171 * The output reallocated token user needs to use to authorize on the web
1172 * server to view his new password. Output reallocated
1173 * @credentials_delivery.new_user_name is user's log-in name that ISDS
1174 * assingned up on this call.
1175 * @approval is optional external approval of box manipulation
1176 * @refnumber is reallocated serial number of request assigned by ISDS. Use
1177 * NULL, if you don't care.*/
1178 isds_error isds_add_user(struct isds_ctx *context,
1179 const struct isds_DbOwnerInfo *box, const struct isds_DbUserInfo *user,
1180 struct isds_credentials_delivery *credentials_delivery,
1181 const struct isds_approval *approval, char **refnumber);
1183 /* Remove user assigned to given box.
1184 * @context is session context
1185 * @box is box identification
1186 * @user identifies user to remove
1187 * @approval is optional external approval of box manipulation
1188 * @refnumber is reallocated serial number of request assigned by ISDS. Use
1189 * NULL, if you don't care.*/
1190 isds_error isds_delete_user(struct isds_ctx *context,
1191 const struct isds_DbOwnerInfo *box, const struct isds_DbUserInfo *user,
1192 const struct isds_approval *approval, char **refnumber);
1194 /* Get list of boxes in ZIP archive.
1195 * @context is session context
1196 * @list_identifier is UTF-8 encoded string identifying boxes of interrest.
1197 * System recognizes following values currently: ALL (all boxes), UPG
1198 * (effectively OVM boxes), OVM (OVM gross type boxes), OPN (boxes allowing
1199 * receiving commercial messages). This argument is a string because
1200 * specification states new values can appear in the future. Not all list
1201 * types are available to all users.
1202 * @buffer is automatically reallocated memory to store the list of boxes. The
1203 * list is zipped CSV file.
1204 * @buffer_length is size of @buffer data in bytes.
1205 * In case of error @buffer will be freed and @buffer_length will be
1206 * undefined.*/
1207 isds_error isds_get_box_list_archive(struct isds_ctx *context,
1208 const char *list_identifier, void **buffer, size_t *buffer_length);
1210 /* Find boxes suiting given criteria.
1211 * @context is ISDS session context.
1212 * @criteria is filter. You should fill in at least some members.
1213 * @boxes is automatically reallocated list of isds_DbOwnerInfo structures,
1214 * possibly empty. Input NULL or valid old structure.
1215 * @return:
1216 * IE_SUCCESS if search succeeded, @boxes contains useful data
1217 * IE_NOEXIST if no such box exists, @boxes will be NULL
1218 * IE_2BIG if too much boxes exist and server truncated the results, @boxes
1219 * contains still valid data
1220 * other code if something bad happens. @boxes will be NULL. */
1221 isds_error isds_FindDataBox(struct isds_ctx *context,
1222 const struct isds_DbOwnerInfo *criteria,
1223 struct isds_list **boxes);
1225 /* Find boxes matching a given full-text criteria.
1226 * @context is a session context
1227 * @query is a non-empty string which consists of words to search
1228 * @target selects box attributes to search for @query words. Pass NULL if you
1229 * don't care.
1230 * @box_type restricts searching to given box type. Value DBTYPE_SYSTEM means
1231 * to search in all box types. Pass NULL to let server to use default value
1232 * which is DBTYPE_SYSTEM.
1233 * @page_size defines count of boxes to constitute a response page. It counts
1234 * from zero. Pass NULL to let server to use a default value (50 now).
1235 * @page_number defines ordinar number of the response page to return. It
1236 * counts from zero. Pass NULL to let server to use a default value (0 now).
1237 * @track_matches points to true for marking @query words found in the box
1238 * attributes. It points to false for not marking. Pass NULL to let the server
1239 * to use default value (false now).
1240 * @total_matching_boxes outputs reallocated number of all boxes matching the
1241 * query. Will be pointer to NULL if server did not provide the value.
1242 * Pass NULL if you don't care.
1243 * @current_page_beginning outputs reallocated ordinar number of the first box
1244 * in this @boxes page. It counts from zero. It will be pointer to NULL if the
1245 * server did not provide the value. Pass NULL if you don't care.
1246 * @current_page_size outputs reallocated count of boxes in the this @boxes
1247 * page. It will be pointer to NULL if the server did not provide the value.
1248 * Pass NULL if you don't care.
1249 * @last_page outputs pointer to reallocated boolean. True if this @boxes page
1250 * is the last one, false if more boxes match, NULL if the server did not
1251 * provude the value. Pass NULL if you don't care.
1252 * @boxes outputs reallocated list of isds_fulltext_result structures,
1253 * possibly empty.
1254 * @return:
1255 * IE_SUCCESS if search succeeded
1256 * IE_2BIG if @page_size is too large
1257 * other code if something bad happens; output arguments will be NULL. */
1258 isds_error isds_find_box_by_fulltext(struct isds_ctx *context,
1259 const char *query,
1260 const isds_fulltext_target *target,
1261 const isds_DbType *box_type,
1262 const unsigned long int *page_size,
1263 const unsigned long int *page_number,
1264 const _Bool *track_matches,
1265 unsigned long int **total_matching_boxes,
1266 unsigned long int **current_page_beginning,
1267 unsigned long int **current_page_size,
1268 _Bool **last_page,
1269 struct isds_list **boxes);
1271 /* Get status of a box.
1272 * @context is ISDS session context.
1273 * @box_id is UTF-8 encoded box identifier as zero terminated string
1274 * @box_status is return value of box status.
1275 * @return:
1276 * IE_SUCCESS if box has been found and its status retrieved
1277 * IE_NOEXIST if box is not known to ISDS server
1278 * or other appropriate error.
1279 * You can use isds_DbState to enumerate box status. However out of enum
1280 * range value can be returned too. This is feature because ISDS
1281 * specification leaves the set of values open.
1282 * Be ware that status DBSTATE_REMOVED is signaled as IE_SUCCESS. That means
1283 * the box has been deleted, but ISDS still lists its former existence. */
1284 isds_error isds_CheckDataBox(struct isds_ctx *context, const char *box_id,
1285 long int *box_status);
1287 /* Get list of permissions to send commercial messages.
1288 * @context is ISDS session context.
1289 * @box_id is UTF-8 encoded sender box identifier as zero terminated string
1290 * @permissions is a reallocated list of permissions (struct
1291 * isds_commercial_permission*) to send commercial messages from @box_id. The
1292 * order of permissions is significant as the server applies the permissions
1293 * and associated pre-paid credits in the order. Empty list means no
1294 * permission.
1295 * @return:
1296 * IE_SUCCESS if the list has been obtained correctly,
1297 * or other appropriate error. */
1298 isds_error isds_get_commercial_permissions(struct isds_ctx *context,
1299 const char *box_id, struct isds_list **permissions);
1301 /* Get details about credit for sending pre-paid commercial messages.
1302 * @context is ISDS session context.
1303 * @box_id is UTF-8 encoded sender box identifier as zero terminated string.
1304 * @from_date is first day of credit history to return in @history. Only
1305 * tm_year, tm_mon and tm_mday carry sane value.
1306 * @to_date is last day of credit history to return in @history. Only
1307 * tm_year, tm_mon and tm_mday carry sane value.
1308 * @credit outputs current credit value into pre-allocated memory. Pass NULL
1309 * if you don't care. This and all other credit values are integers in
1310 * hundredths of Czech Crowns.
1311 * @email outputs notification e-mail address where notifications about credit
1312 * are sent. This is automatically reallocated string. Pass NULL if you don't
1313 * care. It can return NULL if no address is defined.
1314 * @history outputs auto-reallocated list of pointers to struct
1315 * isds_credit_event. Events in closed interval @from_time to @to_time are
1316 * returned. Pass NULL @to_time and @from_time if you don't care. The events
1317 * are sorted by time.
1318 * @return:
1319 * IE_SUCCESS if the credit details have been obtained correctly,
1320 * or other appropriate error. Please note that server allows to retrieve
1321 * only limited history of events. */
1322 isds_error isds_get_commercial_credit(struct isds_ctx *context,
1323 const char *box_id,
1324 const struct tm *from_date, const struct tm *to_date,
1325 long int *credit, char **email, struct isds_list **history);
1327 /* Switch box into state where box can receive commercial messages (off by
1328 * default)
1329 * @context is ISDS session context.
1330 * @box_id is UTF-8 encoded box identifier as zero terminated string
1331 * @allow is true for enable, false for disable commercial messages income
1332 * @approval is optional external approval of box manipulation
1333 * @refnumber is reallocated serial number of request assigned by ISDS. Use
1334 * NULL, if you don't care. */
1335 isds_error isds_switch_commercial_receiving(struct isds_ctx *context,
1336 const char *box_id, const _Bool allow,
1337 const struct isds_approval *approval, char **refnumber);
1339 /* Switch box into / out of state where non-OVM box can act as OVM (e.g. force
1340 * message acceptance). This is just a box permission. Sender must apply
1341 * such role by sending each message.
1342 * @context is ISDS session context.
1343 * @box_id is UTF-8 encoded box identifier as zero terminated string
1344 * @allow is true for enable, false for disable OVM role permission
1345 * @approval is optional external approval of box manipulation
1346 * @refnumber is reallocated serial number of request assigned by ISDS. Use
1347 * NULL, if you don't care. */
1348 isds_error isds_switch_effective_ovm(struct isds_ctx *context,
1349 const char *box_id, const _Bool allow,
1350 const struct isds_approval *approval, char **refnumber);
1352 /* Switch box accessibility state on request of box owner.
1353 * Despite the name, owner must do the request off-line. This function is
1354 * designed for such off-line meeting points (e.g. Czech POINT).
1355 * @context is ISDS session context.
1356 * @box identifies box to switch accessibility state.
1357 * @allow is true for making accessible, false to disallow access.
1358 * @approval is optional external approval of box manipulation
1359 * @refnumber is reallocated serial number of request assigned by ISDS. Use
1360 * NULL, if you don't care. */
1361 isds_error isds_switch_box_accessibility_on_owner_request(
1362 struct isds_ctx *context, const struct isds_DbOwnerInfo *box,
1363 const _Bool allow, const struct isds_approval *approval,
1364 char **refnumber);
1366 /* Disable box accessibility on law enforcement (e.g. by prison) since exact
1367 * date.
1368 * @context is ISDS session context.
1369 * @box identifies box to switch accessibility state.
1370 * @since is date since accessibility has been denied. This can be past too.
1371 * Only tm_year, tm_mon and tm_mday carry sane value.
1372 * @approval is optional external approval of box manipulation
1373 * @refnumber is reallocated serial number of request assigned by ISDS. Use
1374 * NULL, if you don't care. */
1375 isds_error isds_disable_box_accessibility_externaly(
1376 struct isds_ctx *context, const struct isds_DbOwnerInfo *box,
1377 const struct tm *since, const struct isds_approval *approval,
1378 char **refnumber);
1380 /* Send a message via ISDS to a recipient
1381 * @context is session context
1382 * @outgoing_message is message to send; Some members are mandatory (like
1383 * dbIDRecipient), some are optional and some are irrelevant (especially data
1384 * about sender). Included pointer to isds_list documents must contain at
1385 * least one document of FILEMETATYPE_MAIN. This is read-write structure, some
1386 * members will be filled with valid data from ISDS. Exact list of write
1387 * members is subject to change. Currently dmID is changed.
1388 * @return ISDS_SUCCESS, or other error code if something goes wrong. */
1389 isds_error isds_send_message(struct isds_ctx *context,
1390 struct isds_message *outgoing_message);
1392 /* Send a message via ISDS to a multiple recipients
1393 * @context is session context
1394 * @outgoing_message is message to send; Some members are mandatory,
1395 * some are optional and some are irrelevant (especially data
1396 * about sender). Data about recipient will be substituted by ISDS from
1397 * @copies. Included pointer to isds_list documents must
1398 * contain at least one document of FILEMETATYPE_MAIN.
1399 * @copies is list of isds_message_copy structures addressing all desired
1400 * recipients. This is read-write structure, some members will be filled with
1401 * valid data from ISDS (message IDs, error codes, error descriptions).
1402 * @return
1403 * ISDS_SUCCESS if all messages have been sent
1404 * ISDS_PARTIAL_SUCCESS if sending of some messages has failed (failed and
1405 * succeeded messages can be identified by copies->data->error),
1406 * or other error code if something other goes wrong. */
1407 isds_error isds_send_message_to_multiple_recipients(struct isds_ctx *context,
1408 const struct isds_message *outgoing_message,
1409 struct isds_list *copies);
1411 /* Get list of outgoing (already sent) messages.
1412 * Any criterion argument can be NULL, if you don't care about it.
1413 * @context is session context. Must not be NULL.
1414 * @from_time is minimal time and date of message sending inclusive.
1415 * @to_time is maximal time and date of message sending inclusive
1416 * @dmSenderOrgUnitNum is the same as isds_envelope.dmSenderOrgUnitNum
1417 * @status_filter is bit field of isds_message_status values. Use special
1418 * value MESSAGESTATE_ANY to signal you don't care. (It's defined as union of
1419 * all values, you can use bit-wise arithmetic if you want.)
1420 * @offset is index of first message we are interested in. First message is 1.
1421 * Set to 0 (or 1) if you don't care.
1422 * @number is maximal length of list you want to get as input value, outputs
1423 * number of messages matching these criteria. Can be NULL if you don't care
1424 * (applies to output value either).
1425 * @messages is automatically reallocated list of isds_message's. Be ware that
1426 * it returns only brief overview (envelope and some other fields) about each
1427 * message, not the complete message. FIXME: Specify exact fields.
1428 * The list is sorted by delivery time in ascending order.
1429 * Use NULL if you don't care about the meta data (useful if you want to know
1430 * only the @number). If you provide &NULL, list will be allocated on heap,
1431 * if you provide pointer to non-NULL, list will be freed automatically at
1432 * first. Also in case of error the list will be NULLed.
1433 * @return IE_SUCCESS or appropriate error code. */
1434 isds_error isds_get_list_of_sent_messages(struct isds_ctx *context,
1435 const struct timeval *from_time, const struct timeval *to_time,
1436 const long int *dmSenderOrgUnitNum, const unsigned int status_filter,
1437 const unsigned long int offset, unsigned long int *number,
1438 struct isds_list **messages);
1440 /* Get list of incoming (addressed to you) messages.
1441 * Any criterion argument can be NULL, if you don't care about it.
1442 * @context is session context. Must not be NULL.
1443 * @from_time is minimal time and date of message sending inclusive.
1444 * @to_time is maximal time and date of message sending inclusive
1445 * @dmRecipientOrgUnitNum is the same as isds_envelope.dmRecipientOrgUnitNum
1446 * @status_filter is bit field of isds_message_status values. Use special
1447 * value MESSAGESTATE_ANY to signal you don't care. (It's defined as union of
1448 * all values, you can use bit-wise arithmetic if you want.)
1449 * @offset is index of first message we are interested in. First message is 1.
1450 * Set to 0 (or 1) if you don't care.
1451 * @number is maximal length of list you want to get as input value, outputs
1452 * number of messages matching these criteria. Can be NULL if you don't care
1453 * (applies to output value either).
1454 * @messages is automatically reallocated list of isds_message's. Be ware that
1455 * it returns only brief overview (envelope and some other fields) about each
1456 * message, not the complete message. FIXME: Specify exact fields.
1457 * Use NULL if you don't care about the meta data (useful if you want to know
1458 * only the @number). If you provide &NULL, list will be allocated on heap,
1459 * if you provide pointer to non-NULL, list will be freed automatically at
1460 * first. Also in case of error the list will be NULLed.
1461 * @return IE_SUCCESS or appropriate error code. */
1462 isds_error isds_get_list_of_received_messages(struct isds_ctx *context,
1463 const struct timeval *from_time, const struct timeval *to_time,
1464 const long int *dmRecipientOrgUnitNum,
1465 const unsigned int status_filter,
1466 const unsigned long int offset, unsigned long int *number,
1467 struct isds_list **messages);
1469 /* Get list of sent message state changes.
1470 * Any criterion argument can be NULL, if you don't care about it.
1471 * @context is session context. Must not be NULL.
1472 * @from_time is minimal time and date of status changes inclusive
1473 * @to_time is maximal time and date of status changes inclusive
1474 * @changed_states is automatically reallocated list of
1475 * isds_message_status_change's. If you provide &NULL, list will be allocated
1476 * on heap, if you provide pointer to non-NULL, list will be freed
1477 * automatically at first. Also in case of error the list will be NULLed.
1478 * XXX: The list item ordering is not specified.
1479 * XXX: Server provides only `recent' changes.
1480 * @return IE_SUCCESS or appropriate error code. */
1481 isds_error isds_get_list_of_sent_message_state_changes(
1482 struct isds_ctx *context,
1483 const struct timeval *from_time, const struct timeval *to_time,
1484 struct isds_list **changed_states);
1486 /* Download incoming message envelope identified by ID.
1487 * @context is session context
1488 * @message_id is message identifier (you can get them from
1489 * isds_get_list_of_received_messages())
1490 * @message is automatically reallocated message retrieved from ISDS.
1491 * It will miss documents per se. Use isds_get_received_message(), if you are
1492 * interested in documents (content) too.
1493 * Returned hash and timestamp require documents to be verifiable. */
1494 isds_error isds_get_received_envelope(struct isds_ctx *context,
1495 const char *message_id, struct isds_message **message);
1497 /* Download signed delivery info-sheet of given message identified by ID.
1498 * @context is session context
1499 * @message_id is message identifier (you can get them from
1500 * isds_get_list_of_{sent,received}_messages())
1501 * @message is automatically reallocated message retrieved from ISDS.
1502 * It will miss documents per se. Use isds_get_signed_received_message(),
1503 * if you are interested in documents (content). OTOH, only this function
1504 * can get list events message has gone through. */
1505 isds_error isds_get_signed_delivery_info(struct isds_ctx *context,
1506 const char *message_id, struct isds_message **message);
1508 /* Load delivery info of any format from buffer.
1509 * @context is session context
1510 * @raw_type advertises format of @buffer content. Only delivery info types
1511 * are accepted.
1512 * @buffer is DER encoded PKCS#7 structure with signed delivery info. You can
1513 * retrieve such data from message->raw after calling
1514 * isds_get_signed_delivery_info().
1515 * @length is length of buffer in bytes.
1516 * @message is automatically reallocated message parsed from @buffer.
1517 * @strategy selects how buffer will be attached into raw isds_message member.
1518 * */
1519 isds_error isds_load_delivery_info(struct isds_ctx *context,
1520 const isds_raw_type raw_type,
1521 const void *buffer, const size_t length,
1522 struct isds_message **message, const isds_buffer_strategy strategy);
1524 /* Download delivery info-sheet of given message identified by ID.
1525 * @context is session context
1526 * @message_id is message identifier (you can get them from
1527 * isds_get_list_of_{sent,received}_messages())
1528 * @message is automatically reallocated message retrieved from ISDS.
1529 * It will miss documents per se. Use isds_get_received_message(), if you are
1530 * interested in documents (content). OTOH, only this function can get list
1531 * of events message has gone through. */
1532 isds_error isds_get_delivery_info(struct isds_ctx *context,
1533 const char *message_id, struct isds_message **message);
1535 /* Download incoming message identified by ID.
1536 * @context is session context
1537 * @message_id is message identifier (you can get them from
1538 * isds_get_list_of_received_messages())
1539 * @message is automatically reallocated message retrieved from ISDS */
1540 isds_error isds_get_received_message(struct isds_ctx *context,
1541 const char *message_id, struct isds_message **message);
1543 /* Load message of any type from buffer.
1544 * @context is session context
1545 * @raw_type defines content type of @buffer. Only message types are allowed.
1546 * @buffer is message raw representation. Format (CMS, plain signed,
1547 * message direction) is defined in @raw_type. You can retrieve such data
1548 * from message->raw after calling isds_get_[signed]{received,sent}_message().
1549 * @length is length of buffer in bytes.
1550 * @message is automatically reallocated message parsed from @buffer.
1551 * @strategy selects how buffer will be attached into raw isds_message member.
1552 * */
1553 isds_error isds_load_message(struct isds_ctx *context,
1554 const isds_raw_type raw_type, const void *buffer, const size_t length,
1555 struct isds_message **message, const isds_buffer_strategy strategy);
1557 /* Determine type of raw message or delivery info according some heuristics.
1558 * It does not validate the raw blob.
1559 * @context is session context
1560 * @raw_type returns content type of @buffer. Valid only if exit code of this
1561 * function is IE_SUCCESS. The pointer must be valid. This is no automatically
1562 * reallocated memory.
1563 * @buffer is message raw representation.
1564 * @length is length of buffer in bytes. */
1565 isds_error isds_guess_raw_type(struct isds_ctx *context,
1566 isds_raw_type *raw_type, const void *buffer, const size_t length);
1568 /* Download signed incoming message identified by ID.
1569 * @context is session context
1570 * @message_id is message identifier (you can get them from
1571 * isds_get_list_of_received_messages())
1572 * @message is automatically reallocated message retrieved from ISDS. The raw
1573 * member will be filled with PKCS#7 structure in DER format. */
1574 isds_error isds_get_signed_received_message(struct isds_ctx *context,
1575 const char *message_id, struct isds_message **message);
1577 /* Download signed outgoing message identified by ID.
1578 * @context is session context
1579 * @message_id is message identifier (you can get them from
1580 * isds_get_list_of_sent_messages())
1581 * @message is automatically reallocated message retrieved from ISDS. The raw
1582 * member will be filled with PKCS#7 structure in DER format. */
1583 isds_error isds_get_signed_sent_message(struct isds_ctx *context,
1584 const char *message_id, struct isds_message **message);
1586 /* Get type and name of user who sent a message identified by ID.
1587 * @context is session context
1588 * @message_id is message identifier
1589 * @sender_type is pointer to automatically allocated type of sender detected
1590 * from @raw_sender_type string. If @raw_sender_type is unknown to this
1591 * library or to the server, NULL will be returned. Pass NULL if you don't
1592 * care about it.
1593 * @raw_sender_type is automatically reallocated UTF-8 string describing
1594 * sender type or NULL if not known to server. Pass NULL if you don't care.
1595 * @sender_name is automatically reallocated UTF-8 name of user who sent the
1596 * message, or NULL if not known to ISDS. Pass NULL if you don't care. */
1597 isds_error isds_get_message_sender(struct isds_ctx *context,
1598 const char *message_id, isds_sender_type **sender_type,
1599 char **raw_sender_type, char **sender_name);
1601 /* Retrieve hash of message identified by ID stored in ISDS.
1602 * @context is session context
1603 * @message_id is message identifier
1604 * @hash is automatically reallocated message hash downloaded from ISDS.
1605 * Message must exist in system and must not be deleted. */
1606 isds_error isds_download_message_hash(struct isds_ctx *context,
1607 const char *message_id, struct isds_hash **hash);
1609 /* Compute hash of message from raw representation and store it into envelope.
1610 * Original hash structure will be destroyed in envelope.
1611 * @context is session context
1612 * @message is message carrying raw XML message blob
1613 * @algorithm is desired hash algorithm to use */
1614 isds_error isds_compute_message_hash(struct isds_ctx *context,
1615 struct isds_message *message, const isds_hash_algorithm algorithm);
1617 /* Compare two hashes.
1618 * @h1 is first hash
1619 * @h2 is another hash
1620 * @return
1621 * IE_SUCCESS if hashes equal
1622 * IE_NOTUNIQ if hashes are comparable, but they don't equal
1623 * IE_ENUM if not comparable, but both structures defined
1624 * IE_INVAL if some of the structures are undefined (NULL)
1625 * IE_ERROR if internal error occurs */
1626 isds_error isds_hash_cmp(const struct isds_hash *h1,
1627 const struct isds_hash *h2);
1629 /* Check message has gone through ISDS by comparing message hash stored in
1630 * ISDS and locally computed hash. You must provide message with valid raw
1631 * member (do not use isds_load_message(..., BUFFER_DONT_STORE)).
1632 * This is convenient wrapper for isds_download_message_hash(),
1633 * isds_compute_message_hash(), and isds_hash_cmp() sequence.
1634 * @context is session context
1635 * @message is message with valid raw and envelope member; envelope->hash
1636 * member will be changed during function run. Use envelope on heap only.
1637 * @return
1638 * IE_SUCCESS if message originates in ISDS
1639 * IE_NOTEQUAL if message is unknown to ISDS
1640 * other code for other errors */
1641 isds_error isds_verify_message_hash(struct isds_ctx *context,
1642 struct isds_message *message);
1644 /* Submit CMS signed message to ISDS to verify its originality. This is
1645 * stronger form of isds_verify_message_hash() because ISDS does more checks
1646 * than simple one (potentialy old weak) hash comparison.
1647 * @context is session context
1648 * @message is memory with raw CMS signed message bit stream
1649 * @length is @message size in bytes
1650 * @return
1651 * IE_SUCCESS if message originates in ISDS
1652 * IE_NOTEQUAL if message is unknown to ISDS
1653 * other code for other errors */
1654 isds_error isds_authenticate_message(struct isds_ctx *context,
1655 const void *message, size_t length);
1657 /* Submit CMS signed message or delivery info to ISDS to re-sign the content
1658 * including adding new CMS time stamp. Only CMS blobs without time stamp can
1659 * be re-signed.
1660 * @context is session context
1661 * @input_data is memory with raw CMS signed message or delivery info bit
1662 * stream to re-sign
1663 * @input_length is @input_data size in bytes
1664 * @output_data is pointer to auto-allocated memory where to store re-signed
1665 * input data blob. Caller must free it.
1666 * @output_data is pointer where to store @output_data size in bytes
1667 * @valid_to is pointer to auto-allocated date of time stamp expiration.
1668 * Only tm_year, tm_mon and tm_mday will be set. Pass NULL, if you don't care.
1669 * @return
1670 * IE_SUCCESS if CMS blob has been re-signed successfully
1671 * other code for other errors */
1672 isds_error isds_resign_message(struct isds_ctx *context,
1673 const void *input_data, size_t input_length,
1674 void **output_data, size_t *output_length, struct tm **valid_to);
1676 /* Erase message specified by @message_id from long term storage. Other
1677 * message cannot be erased on user request.
1678 * @context is session context
1679 * @message_id is message identifier.
1680 * @incoming is true for incoming message, false for outgoing message.
1681 * @return
1682 * IE_SUCCESS if message has ben removed
1683 * IE_INVAL if message does not exist in long term storage or message
1684 * belongs to different box
1685 * TODO: IE_NOEPRM if user has no permission to erase a message */
1686 isds_error isds_delete_message_from_storage(struct isds_ctx *context,
1687 const char *message_id, _Bool incoming);
1689 /* Mark message as read. This is a transactional commit function to acknowledge
1690 * to ISDS the message has been downloaded and processed by client properly.
1691 * @context is session context
1692 * @message_id is message identifier. */
1693 isds_error isds_mark_message_read(struct isds_ctx *context,
1694 const char *message_id);
1696 /* Mark message as received by recipient. This is applicable only to
1697 * commercial message. Use envelope->dmType message member to distinguish
1698 * commercial message from government message. Government message is
1699 * received automatically (by law), commercial message on recipient request.
1700 * @context is session context
1701 * @message_id is message identifier. */
1702 isds_error isds_mark_message_received(struct isds_ctx *context,
1703 const char *message_id);
1705 /* Send bogus request to ISDS.
1706 * Just for test purposes */
1707 isds_error isds_bogus_request(struct isds_ctx *context);
1709 /* Send document for authorized conversion into Czech POINT system.
1710 * This is public anonymous service, no log-in necessary. Special context is
1711 * used to reuse keep-a-live HTTPS connection.
1712 * @context is Czech POINT session context. DO NOT use context connected to
1713 * ISDS server. Use new context or context used by this function previously.
1714 * @document is document to convert. Only data, data_length, dmFileDescr and
1715 * is_xml members are significant. Be ware that not all document formats can be
1716 * converted (signed PDF 1.3 and higher only (2010-02 state)).
1717 * @id is reallocated identifier assigned by Czech POINT system to
1718 * your document on submit. Use is to tell it to Czech POINT officer.
1719 * @date is reallocated document submit date (submitted documents
1720 * expires after some period). Only tm_year, tm_mon and tm_mday carry sane
1721 * value. */
1722 isds_error czp_convert_document(struct isds_ctx *context,
1723 const struct isds_document *document,
1724 char **id, struct tm **date);
1726 /* Close possibly opened connection to Czech POINT document deposit.
1727 * @context is Czech POINT session context. */
1728 isds_error czp_close_connection(struct isds_ctx *context);
1730 /* Send request for new box creation in testing ISDS instance.
1731 * It's not possible to request for a production box currently, as it
1732 * communicates via e-mail.
1733 * XXX: This function does not work either. Server complains about invalid
1734 * e-mail address.
1735 * XXX: Remove context->type hacks in isds.c and validator.c when removing
1736 * this function
1737 * @context is special session context for box creation request. DO NOT use
1738 * standard context as it could reveal your password. Use fresh new context or
1739 * context previously used by this function.
1740 * @box is box description to create including single primary user (in case of
1741 * FO box type). It outputs box ID assigned by ISDS in dbID element.
1742 * @users is list of struct isds_DbUserInfo (primary users in case of non-FO
1743 * box, or contact address of PFO box owner). The email member is mandatory as
1744 * it will be used to deliver credentials.
1745 * @former_names is optional undocumented string. Pass NULL if you don't care.
1746 * @approval is optional external approval of box manipulation
1747 * @refnumber is reallocated serial number of request assigned by ISDS. Use
1748 * NULL, if you don't care.*/
1749 isds_error isds_request_new_testing_box(struct isds_ctx *context,
1750 struct isds_DbOwnerInfo *box, const struct isds_list *users,
1751 const char *former_names, const struct isds_approval *approval,
1752 char **refnumber);
1754 /* Search for document by document ID in list of documents. IDs are compared
1755 * as UTF-8 string.
1756 * @documents is list of isds_documents
1757 * @id is document identifier
1758 * @return first matching document or NULL. */
1759 const struct isds_document *isds_find_document_by_id(
1760 const struct isds_list *documents, const char *id);
1762 /* Normalize @mime_type to be proper MIME type.
1763 * ISDS servers pass invalid MIME types (e.g. "pdf"). This function tries to
1764 * guess regular MIME type (e.g. "application/pdf").
1765 * @mime_type is UTF-8 encoded MIME type to fix
1766 * @return original @mime_type if no better interpretation exists, or
1767 * constant static UTF-8 encoded string with proper MIME type. */
1768 const char *isds_normalize_mime_type(const char *mime_type);
1770 /* Deallocate structure isds_pki_credentials and NULL it.
1771 * Pass-phrase is discarded.
1772 * @pki credentials to to free */
1773 void isds_pki_credentials_free(struct isds_pki_credentials **pki);
1775 /* Free isds_list with all member data.
1776 * @list list to free, on return will be NULL */
1777 void isds_list_free(struct isds_list **list);
1779 /* Deallocate structure isds_hash and NULL it.
1780 * @hash hash to to free */
1781 void isds_hash_free(struct isds_hash **hash);
1783 /* Deallocate structure isds_PersonName recursively and NULL it */
1784 void isds_PersonName_free(struct isds_PersonName **person_name);
1786 /* Deallocate structure isds_BirthInfo recursively and NULL it */
1787 void isds_BirthInfo_free(struct isds_BirthInfo **birth_info);
1789 /* Deallocate structure isds_Address recursively and NULL it */
1790 void isds_Address_free(struct isds_Address **address);
1792 /* Deallocate structure isds_DbOwnerInfo recursively and NULL it */
1793 void isds_DbOwnerInfo_free(struct isds_DbOwnerInfo **db_owner_info);
1795 /* Deallocate structure isds_DbUserInfo recursively and NULL it */
1796 void isds_DbUserInfo_free(struct isds_DbUserInfo **db_user_info);
1798 /* Deallocate struct isds_event recursively and NULL it */
1799 void isds_event_free(struct isds_event **event);
1801 /* Deallocate struct isds_envelope recursively and NULL it */
1802 void isds_envelope_free(struct isds_envelope **envelope);
1804 /* Deallocate struct isds_document recursively and NULL it */
1805 void isds_document_free(struct isds_document **document);
1807 /* Deallocate struct isds_message recursively and NULL it */
1808 void isds_message_free(struct isds_message **message);
1810 /* Deallocate struct isds_message_copy recursively and NULL it */
1811 void isds_message_copy_free(struct isds_message_copy **copy);
1813 /* Deallocate struct isds_message_status_change recursively and NULL it */
1814 void isds_message_status_change_free(
1815 struct isds_message_status_change **message_status_change);
1817 /* Deallocate struct isds_approval recursively and NULL it */
1818 void isds_approval_free(struct isds_approval **approval);
1820 /* Deallocate struct isds_commercial_permission recursively and NULL it */
1821 void isds_commercial_permission_free(
1822 struct isds_commercial_permission **permission);
1824 /* Deallocate struct isds_credit_event recursively and NULL it */
1825 void isds_credit_event_free(struct isds_credit_event **event);
1827 /* Deallocate struct isds_credentials_delivery recursively and NULL it.
1828 * The email string is deallocated too. */
1829 void isds_credentials_delivery_free(
1830 struct isds_credentials_delivery **credentials_delivery);
1832 /* Deallocate struct isds_fulltext_result recursively and NULL it */
1833 void isds_fulltext_result_free(
1834 struct isds_fulltext_result **result);
1836 /* Copy structure isds_PersonName recursively */
1837 struct isds_PersonName *isds_PersonName_duplicate(
1838 const struct isds_PersonName *src);
1840 /* Copy structure isds_Address recursively */
1841 struct isds_Address *isds_Address_duplicate(
1842 const struct isds_Address *src);
1844 /* Copy structure isds_DbOwnerInfo recursively */
1845 struct isds_DbOwnerInfo *isds_DbOwnerInfo_duplicate(
1846 const struct isds_DbOwnerInfo *src);
1848 /* Copy structure isds_DbUserInfo recursively */
1849 struct isds_DbUserInfo *isds_DbUserInfo_duplicate(
1850 const struct isds_DbUserInfo *src);
1852 #ifdef __cplusplus /* For C++ linker sake */
1854 #endif
1856 #endif