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