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