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