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