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