doc: Update list of user web service according to spec. 2009-10-30
[libisds.git] / src / isds.h
blobb0bc94f0c5d73f5fa2d1481b9cb93d9654118d2f
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 <sys/time.h> /* For struct timeval */
10 /* _deprecated macro marks library symbols as deprecated. Application should
11 * avoid using such function as soon as possible. */
12 #if defined(__GNUC__)
13 #define _deprecated __attribute__((deprecated))
14 #else
15 #define _deprecated
16 #endif
19 struct isds_ctx; /* Context for specific ISDS box */
21 typedef enum {
22 IE_SUCCESS = 0, /* No error, just for C conveniece (0 means Ok) */
23 IE_ERROR, /* Unspecified error */
24 IE_NOTSUP,
25 IE_INVAL,
26 IE_INVALID_CONTEXT,
27 IE_NOT_LOGGED_IN,
28 IE_CONNECTION_CLOSED,
29 IE_TIMED_OUT,
30 IE_NOEXIST,
31 IE_NOMEM,
32 IE_NETWORK,
33 IE_HTTP,
34 IE_SOAP,
35 IE_XML,
36 IE_ISDS,
37 IE_ENUM,
38 IE_DATE,
39 IE_2BIG,
40 IE_NOTUNIQ,
41 IE_NOTEQUAL
42 } isds_error;
44 typedef enum {
45 ILL_NONE = 0,
46 ILL_CRIT = 10,
47 ILL_ERR = 20,
48 ILL_WARNING = 30,
49 ILL_INFO = 40,
50 ILL_DEBUG = 50,
51 ILL_ALL = 100
52 } isds_log_level;
54 typedef enum {
55 ILF_NONE = 0x0,
56 ILF_HTTP = 0x1,
57 ILF_SOAP = 0x2,
58 ILF_ISDS = 0x4,
59 ILF_FILE = 0x8,
60 ILF_SEC = 0x10,
61 ILF_XML = 0x20,
62 ILF_ALL = 0xFF
63 } isds_log_facility;
65 /* Return text description of ISDS error */
66 char *isds_strerror(const isds_error error);
68 /* TLS libisds options */
69 typedef enum {
70 ITLS_VERIFY_SERVER, /* _Bool: Verify server idetity? */
71 ITLS_CA_FILE, /* char *: File name with CA certificates */
72 ITLS_CA_DIRECTORY /* char *: Directory name with CA certificates */
73 } isds_tls_option;
75 /* Box type */
76 typedef enum {
77 DBTYPE_SYSTEM = 0, /* This is special sender value for messages
78 sent by ISDS. */
79 DBTYPE_OVM = 10,
80 DBTYPE_OVM_NOTAR = 11,
81 DBTYPE_OVM_EXEKUT = 12,
82 DBTYPE_OVM_REQ = 13,
83 DBTYPE_PO = 20,
84 DBTYPE_PO_ZAK = 21,
85 DBTYPE_PO_REQ = 22,
86 DBTYPE_PFO = 30,
87 DBTYPE_PFO_ADVOK = 31,
88 DBTYPE_PFO_DANPOR = 32,
89 DBTYPE_PFO_INSSPR = 33,
90 DBTYPE_FO = 40
91 } isds_DbType;
93 /* Box status from point of view of accesibilty */
94 typedef enum {
95 DBSTATE_ACCESSIBLE = 1,
96 DBSTATE_TEMP_UNACCESSIBLE = 2,
97 DBSTATE_NOT_YET_ACCESSIBLE = 3,
98 DBSTATE_PERM_UNACCESSIBLE = 4,
99 DBSTATE_REMOVED = 5
100 } isds_DbState;
102 /* User permissions from point of view of ISDS.
103 * Instances can be bitmas of any discrete values. */
104 typedef enum {
105 PRIVIL_READ_NON_PERSONAL = 0x1, /* Can download and read messages with
106 dmPersonalDelivery == false */
107 PRIVIL_READ_ALL = 0x2, /* Can download and read messages with
108 dmPersonalDelivery == true */
109 PRIVIL_CREATE_DM = 0x4, /* Can create and sent messages,
110 can dowload outgoing (sent) messages */
111 PRIVIL_VIEW_INFO = 0x8, /* Can list messages and data about
112 post and delivery */
113 PRIVIL_SEARCH_DB = 0x10, /* Can search for boxes */
114 PRIVIL_OWNER_ADM = 0x20 /* Can administer his box (add/remove
115 permitted users and theirs
116 permissions) */
117 } isds_priviledges;
119 /* Message status */
120 typedef enum {
121 MESSAGESTATE_SENT = 0x2, /* Message has been put into ISDS */
122 MESSAGESTATE_STAMPED = 0x4, /* Message stamped by TSA */
123 MESSAGESTATE_INFECTED = 0x8, /* Message included virues,
124 infected document has been removed */
125 MESSAGESTATE_DELIVERED = 0x10, /* Message delivered
126 (dmDeliveryTime stored) */
127 MESSAGESTATE_SUBSTITUTED = 0x20, /* Message delivered through fiction,
128 dmAcceptanceTime stored */
129 MESSAGESTATE_RECIEVED = 0x40, /* Message devlivered by user login
130 dmAcceptanceTime stored */
131 MESSAGESTATE_READ = 0x80, /* Message has been read by user */
132 MESSAGESTATE_UNDELIVERABLE = 0x100, /* Message could not been delivered
133 (e.g. recipent box has been made
134 unaccessible meantime) */
135 MESSAGESTATE_REMOVED = 0x200 /* Message content deleted */
137 } isds_message_status;
138 #define MESSAGESTATE_ANY 0x3FE /* Union of all isds_message_status
139 values */
141 /* Hash algoritm types */
142 typedef enum {
143 HASH_ALGORITHM_MD5,
144 HASH_ALGORITHM_SHA_1,
145 HASH_ALGORITHM_SHA_256,
146 HASH_ALGORITHM_SHA_512,
147 } isds_hash_algorithm;
149 /* Buffer storage strategy.
150 * How function should embed application provided buffer into raw element of
151 * output structure. */
152 typedef enum {
153 BUFFER_DONT_STORE, /* Don't fill raw memeber */
154 BUFFER_COPY, /* Copy buffer content into newly allocated raw */
155 BUFFER_MOVE /* Just copy pointer.
156 But leave deallocation to isds_*_free(). */
157 } isds_buffer_strategy;
159 /* Hash value storage */
160 struct isds_hash {
161 isds_hash_algorithm algorithm; /* Hash algoritgm */
162 size_t length; /* Hash value lenght in bytes */
163 void *value; /* Hash value */
166 /* Name of person */
167 struct isds_PersonName {
168 char *pnFirstName;
169 char *pnMiddleName;
170 char *pnLastName;
171 char *pnLastNameAtBirth;
174 /* Date and place of birth */
175 struct isds_BirthInfo {
176 struct tm *biDate; /* Date of Birth in local time at birth place,
177 only tm_year, tm_mon and tm_mday carry sane
178 value */
179 char *biCity;
180 char *biCounty; /* German: Bezirk, Czech: okres */
181 char *biState;
184 /* Post address */
185 struct isds_Address {
186 char *adCity;
187 char *adStreet;
188 char *adNumberInStreet;
189 char *adNumberInMunicipality;
190 char *adZipCode;
191 char *adState;
194 /* Data about box and his owner.
195 * NULL pointer means undefined value */
196 struct isds_DbOwnerInfo {
197 char *dbID; /* Box ID */
198 isds_DbType *dbType; /* Box Type */
199 char *ic; /* ID */
200 struct isds_PersonName *personName; /* Name of person */
201 char *firmName; /* Name of firm */
202 struct isds_BirthInfo *birthInfo; /* Birth of person */
203 struct isds_Address *address; /* Post address */
204 char *nationality;
205 char *email;
206 char *telNumber;
207 char *identifier; /* External box identifier for data
208 provider (OVM, PO, maybe PFO)
209 [Max. 20 chars] */
210 char *registryCode; /* PFO External registry code
211 [Max. 5 chars] */
212 long int *dbState; /* Box state; 1 <=> active box;
213 long int beacause xsd:integer
214 TODO: enum? */
215 _Bool *dbEffectiveOVM; /* Box has OVM role (§ 5a) */
216 _Bool *dbOpenAddressing; /* Non-OVM Box is free to recieve
217 messages from anybody */
220 /* Message event type */
221 typedef enum {
222 EVENT_UKNOWN, /* Event unknown to this library */
223 EVENT_ACCEPTED_BY_RECIPIENT, /* Message has been delivered and accepted
224 by recipeint action */
225 EVENT_ACCEPTED_BY_FICTION, /* Message has been delivered, acceptance
226 timed out, considered as accepted */
227 EVENT_UNDELIVERABLE /* Recipient box made unaccessible,
228 thus message is undelivarable */
229 } isds_event_type;
231 /* Message event
232 * Alle members are optional as specification states so. */
233 struct isds_event {
234 struct timeval *time; /* When the event occurred */
235 isds_event_type *type; /* Type of the event */
236 char *description; /* Human readable event description
237 generated by ISDS (Czech) */
240 /* Message envelope
241 * Be ware that the string length contraints are forced only on output
242 * memebers transmitted to ISDS. The other direction (downloded from ISDS)
243 * can break these rules. It should not happen, but nobody knows how much
244 * incompatible new version of ISDS protocol will be. This is the gold
245 * Internet rule: be strict on what you put, be tollerant on what you get. */
246 struct isds_envelope {
247 /* Following memebers apply to incoming messages only: */
248 char *dmID; /* Message ID.
249 Maximal length is 20 characters. */
250 char *dbIDSender; /* Box ID of sender.
251 Special value "aaaaaaa" means sent by
252 ISDS.
253 Maximal length is 7 characters. */
254 char *dmSender; /* Sender name;
255 Maximal length is 100 characters. */
256 char *dmSenderAddress; /* Postal address of sender;
257 Maximal length is 100 characters. */
258 long int *dmSenderType; /* Gross Box type of sender
259 TODO: isds_DbType ? */
260 char *dmRecipient; /* Recipient name;
261 Maximal length is 100 characters. */
262 char *dmRecipientAddress; /* Postal address of recipient;
263 Maximal length is 100 characters. */
264 _Bool *dmAmbiguousRecipient; /* Recipient has OVM role */
266 /* Following memebers are assigned by ISDS in different phases of message
267 * life cycle. */
268 unsigned long int *dmOrdinal; /* Ordinal number in list of
269 incoming/outgoing messages */
270 isds_message_status *dmMessageStatus; /* Message state */
271 long int *dmAttachmentSize; /* Size of message documents in
272 kilobytes (rounded). */
273 struct timeval *dmDeliveryTime; /* Time of delivery into a box
274 NULL, if message has not been
275 delivered yet */
276 struct timeval *dmAcceptanceTime; /* Time of accpetance of the message
277 by an user. NULL if message has not
278 been accepted yet. */
279 struct isds_hash *hash; /* Message hash.
280 This is hash of isds:dmDM subtree. */
281 void *timestamp; /* Qualified time stamp */
282 size_t timestamp_length; /* Lenght of timestamp in bytes */
283 struct isds_list *events; /* Events message passed trough;
284 List of isds_event's. */
287 /* Following members apply to both outgoing and incoming messages: */
288 char *dmSenderOrgUnit; /* Organisation unit of sender as string;
289 Optional. */
290 long int *dmSenderOrgUnitNum; /* Organisation unit of sender as number;
291 Optional. */
292 char *dbIDRecipient; /* Box ID of recipient; Mandatory.
293 Maximal length is 7 characters. */
294 char *dmRecipientOrgUnit; /* Organisation unit of recipient as
295 string; Optional. */
296 long int *dmRecipientOrgUnitNum; /* Organisation unit of recipient as
297 number; Optional. */
298 char *dmToHands; /* Person in recipient organisation;
299 Optional. */
300 char *dmAnnotation; /* Subject (title) of the message.
301 Maximal length is 255 characters. */
302 char *dmRecipientRefNumber; /* Czech: číslo jednací příjemce; Optional.
303 Maximal length is 50 characters. */
304 char *dmSenderRefNumber; /* Czech: číslo jednací odesílatele;
305 Optional. Maximal lenght is 50 chars. */
306 char *dmRecipientIdent; /* Czech: spisová značka příjemce; Optional.
307 Maximal length is 50 characters. */
308 char *dmSenderIdent; /* Czech: spisová značka odesílatele;
309 Optional. Maximal lenght is 50 chars. */
311 /* Act addressing in Czech Republic:
312 * Point (Parahraph) § Section Law/Year Coll. */
313 long int *dmLegalTitleLaw; /* Number of act mandating authority */
314 long int *dmLegalTitleYear; /* Year of act issue mandating authority */
315 char *dmLegalTitleSect; /* Section of act mandating authority.
316 Czech: paragraf */
317 char *dmLegalTitlePar; /* Parahraph of act mandating authority.
318 Czech: odstavec */
319 char *dmLegalTitlePoint; /* Point of act mandating authority.
320 Czech: písmeno */
322 _Bool *dmPersonalDelivery; /* If true, only person with higher
323 priviledges can read this message */
324 _Bool *dmAllowSubstDelivery; /* Allow delivery through fiction.
325 I.e. Even if recipient did not read this
326 message, message is considered as
327 delivered after (currently) 10 days.
328 This is delivery through fiction.
329 Applies only to OVM dbType sender. */
330 _Bool *dmOVM; /* OVM sending mode.
331 Non-OVM dbType boxes that has
332 dbEffectiveOVM == true MUST select
333 between true (OVM mode) and
334 false (non-OVM mode).
335 Optionable; Implicit value is true. */
339 /* Document type from point of hiearchy */
340 typedef enum {
341 FILEMETATYPE_MAIN, /* Main document */
342 FILEMETATYPE_ENCLOSURE, /* Appendix */
343 FILEMETATYPE_SIGNATURE, /* Digital signature of other document */
344 FILEMETATYPE_META /* XML document for ESS (electronic
345 document information system) purposes */
346 } isds_FileMetaType;
348 /* Document */
349 struct isds_document {
350 void *data; /* Document content.
351 The encoding and interpretation depends
352 on dmMimeType.
353 TODO: inline XML */
354 size_t data_length; /* Length of the data in bytes */
355 char *dmMimeType; /* MIME type of data; Mandatory. */
356 isds_FileMetaType dmFileMetaType; /* Document type to create hierarchy */
357 char *dmFileGuid; /* Message-local document identifier;
358 Optional. */
359 char *dmUpFileGuid; /* Reference to upper document identifier
360 (dmFileGuid); Optional. */
361 char *dmFileDescr; /* Document name (title). E.g. file name;
362 Mandatory. */
363 char *dmFormat; /* Reference to XML form definition;
364 Defines howto interpret XML document;
365 Optional. */
368 /* Raw message representation content type.
369 * This is necessary to distinguish between different representations without
370 * expensive repated detection.
371 * Infix explanation:
372 * PLAIN_SIGNED data are XML with namespace mangled to signed alternative
373 * CMS_SIGNED data are XML with signed namespace encapsulated in CMS */
374 typedef enum {
375 RAWTYPE_INCOMING_MESSAGE,
376 RAWTYPE_PLAIN_SIGNED_INCOMING_MESSAGE,
377 RAWTYPE_CMS_SIGNED_INCOMING_MESSAGE,
378 RAWTYPE_PLAIN_SIGNED_OUTGOING_MESSAGE,
379 RAWTYPE_CMS_SIGNED_OUTGOING_MESSAGE,
380 RAWTYPE_DELIVERYINFO,
381 RAWTYPE_PLAIN_SIGNED_DELIVERYINFO,
382 RAWTYPE_CMS_SIGNED_DELIVERYINFO
383 } isds_raw_type;
385 /* Message */
386 struct isds_message {
387 void *raw; /* Raw message in XML format as send to or
388 from the ISDS. You can use it to store
389 local copy. This is binary buffer. */
390 size_t raw_length; /* Lenght of raw message in bytes */
391 isds_raw_type raw_type; /* Content type of raw representation
392 Meaningfull only with non-NULL raw
393 member */
394 struct isds_envelope *envelope; /* Message envelope */
395 struct isds_list *documents; /* List of isds_document's.
396 Valid message must contain exactly one
397 document of type FILEMETATYPE_MAIN and
398 can contain any number of other type
399 documents. Totol size of documents
400 must not exceed 10 MB. */
403 /* General linked list */
404 struct isds_list {
405 struct isds_list *next; /* Next list item,
406 or NULL if current is last */
407 void *data; /* Payload */
408 void (*destructor) (void **); /* Payload deallocator */
411 /* Free isds_list with all member data.
412 * @list list to free, on return will be NULL */
413 void isds_list_free(struct isds_list **list);
416 /* Initialize ISDS library.
417 * Global function, must be called before other functions.
418 * If it failes you can not use ISDS library and must call isds_cleanup() to
419 * free partially inititialized global variables. */
420 isds_error isds_init(void);
422 /* Deinicialize ISDS library.
423 * Global function, must be called as last library function. */
424 isds_error isds_cleanup(void);
426 /* Create ISDS context.
427 * Each context can be used for different sessions to (possibly) different
428 * ISDS server with different credentials.
429 * Returns new context, or NULL */
430 struct isds_ctx *isds_ctx_create(void);
432 /* Destroy ISDS context and free memmory.
433 * @context will be NULLed on success. */
434 isds_error isds_ctx_free(struct isds_ctx **context);
436 /* Return long message text produced by library fucntion, e.g. detailed error
437 * mesage. Returned pointer is only valid until new library function is
438 * called for the same context. Could be NULL, especially if NULL context is
439 * supplied. Return string is locale encoded. */
440 char *isds_long_message(const struct isds_ctx *context);
442 /* Set logging up.
443 * @facilities is bitmask of isds_log_facility values,
444 * @level is verbosity level. */
445 void isds_set_logging(const unsigned int facilities,
446 const isds_log_level level);
448 /* Connect to given url.
449 * It just makes TCP connection to ISDS server found in @url hostname part. */
450 /*int isds_connect(struct isds_ctx *context, const char *url);*/
452 /* Set timeout in miliseconds for each network job like connecting to server
453 * or sending message. Use 0 to disable timeout limits. */
454 isds_error isds_set_timeout(struct isds_ctx *context,
455 const unsigned int timeout);
458 /* Change SSL/TLS settings.
459 * @context is context which setting vill be applied to
460 * @option is name of option. It determines the type of last argument. See
461 * isds_tls_option definition for more info.
462 * @... is value of new setting. Type is determined by @option
463 * */
464 isds_error isds_set_tls(struct isds_ctx *context, const isds_tls_option option,
465 ...);
467 /* Connect and log in into ISDS server.
468 * @url is address of ISDS web service
469 * @username is user name of ISDS user
470 * @password is user's secret password
471 * @certificate is NULL terminated string with PEM formated client's
472 * certificate. Use NULL if only password autentication should be performed.
473 * @key is private key for client's certificate as (base64 encoded?) NULL
474 * terminated string. Use NULL if only password autentication is desired.
475 * */
476 isds_error isds_login(struct isds_ctx *context, const char *url,
477 const char *username, const char *password,
478 const char *certificate, const char* key);
480 /* Log out from ISDS server and close connection. */
481 isds_error isds_logout(struct isds_ctx *context);
483 /* Verify connection to ISDS is alive and server is responding.
484 * Sent dumy request to ISDS and expect dummy response. */
485 isds_error isds_ping(struct isds_ctx *context);
487 /* Get data about logged in user and his box. */
488 isds_error isds_GetOwnerInfoFromLogin(struct isds_ctx *context,
489 struct isds_DbOwnerInfo **db_owner_info);
491 /* Find boxes suiting given criteria.
492 * @context is ISDS session context.
493 * @criteria is filter. You should fill in at least some members.
494 * @boxes is automatically reallocated list of isds_DbOwnerInfo structures,
495 * possibly empty. Input NULL or valid old structure.
496 * @return:
497 * IE_SUCCESS if search sucseeded, @boxes contains usefull data
498 * IE_NOEXIST if no such box exists, @boxes will be NULL
499 * IE_2BIG if too much boxes exist and server truncated the resuluts, @boxes
500 * contains still valid data
501 * other code if something bad happens. @boxes will be NULL. */
502 isds_error isds_FindDataBox(struct isds_ctx *context,
503 const struct isds_DbOwnerInfo *criteria,
504 struct isds_list **boxes);
506 /* Get status of a box.
507 * @context is ISDS session context.
508 * @box_id is UTF-8 encoded box identifier as zero terminated string
509 * @box_status is return value of box status.
510 * @return:
511 * IE_SUCCESS if box has been found and its status retrieved
512 * IE_NOEXIST if box is not known to ISDS server
513 * or other appropriate error.
514 * You can use isds_DbState to enumerate box status. However out of enum
515 * range value can be returned too. This is feature because ISDS
516 * specification leaves the set of values open.
517 * Be ware that status DBSTATE_REMOVED is signaled as IE_SUCCESS. That means
518 * the box has been deleted, but ISDS still lists its former existence. */
519 isds_error isds_CheckDataBox(struct isds_ctx *context, const char *box_id,
520 long int *box_status);
522 /* Send a message via ISDS to a recipent
523 * @context is session context
524 * @outgoing_message is message to send; Some memebers are mandatory (like
525 * dbIDRecipient), some are optional and some are irrelevant (especialy data
526 * about sender). Included pointer to isds_list documents must contain at
527 * least one document of FILEMETATYPE_MAIN. This is read-write structure, some
528 * members will be filled with valid data from ISDS. Exact list of write
529 * members is subject to change. Currently dmId is changed.
530 * @return ISDS_SUCCESS, or other error code if something goes wrong. */
531 isds_error isds_send_message(struct isds_ctx *context,
532 struct isds_message *outgoing_message);
534 /* Get list of outgoing (already sent) messages.
535 * Any criterion argument can be NULL, if you don't care about it.
536 * @context is session context. Must not be NULL.
537 * @from_time is minimal time and date of message sending inclusive.
538 * @to_time is maximal time and date of message sending inclusive
539 * @dmSenderOrgUnitNum is the same as isds_envelope.dmSenderOrgUnitNum
540 * @status_filter is bit field of isds_message_status values. Use special
541 * value MESSAGESTATE_ANY to signal you don't care. (It's defined as union of
542 * all values, you can use bitwise arithmetic if you want.)
543 * @offset is index of first message we are interested in. First message is 1.
544 * Set to 0 (or 1) if you don't care.
545 * @number is maximal length of list you want to get as input value, outputs
546 * number of messages matching these criteria. Can be NULL if you don't care
547 * (applies to output value either).
548 * @messages is automatically reallocated list of isds_message's. Be ware that
549 * it returns only brief overview (envelope and some other fields) about each
550 * message, not the complete message. FIXME: Specify exact fields.
551 * The list is sorted by delivery time in ascending order.
552 * Use NULL if you don't care about the metadata (useful if you want to know
553 * only the @number). If you provide &NULL, list will be allocated on heap,
554 * if you provide pointer to non-NULL, list will be freed automacally at first.
555 * Also in case of error the list will be NULLed.
556 * @return IE_SUCCESS or appropriate error code. */
557 isds_error isds_get_list_of_sent_messages(struct isds_ctx *context,
558 const struct timeval *from_time, const struct timeval *to_time,
559 const long int *dmSenderOrgUnitNum, const unsigned int status_filter,
560 const unsigned long int offset, unsigned long int *number,
561 struct isds_list **messages);
563 /* Get list of incoming (addressed to you) messages.
564 * Any criterion argument can be NULL, if you don't care about it.
565 * @context is session context. Must not be NULL.
566 * @from_time is minimal time and date of message sending inclusive.
567 * @to_time is maximal time and date of message sending inclusive
568 * @dmSenderOrgUnitNum is the same as isds_envelope.dmSenderOrgUnitNum
569 * @status_filter is bit field of isds_message_status values. Use special
570 * value MESSAGESTATE_ANY to signal you don't care. (It's defined as union of
571 * all values, you can use bitwise arithmetic if you want.)
572 * @offset is index of first message we are interested in. First message is 1.
573 * Set to 0 (or 1) if you don't care.
574 * @number is maximal length of list you want to get as input value, outputs
575 * number of messages matching these criteria. Can be NULL if you don't care
576 * (applies to output value either).
577 * @messages is automatically reallocated list of isds_message's. Be ware that
578 * it returns only brief overview (envelope and some other fields) about each
579 * message, not the complete message. FIXME: Specify exact fields.
580 * Use NULL if you don't care about the metadata (useful if you want to know
581 * only the @number). If you provide &NULL, list will be allocated on heap,
582 * if you provide pointer to non-NULL, list will be freed automacally at first.
583 * Also in case of error the list will be NULLed.
584 * @return IE_SUCCESS or appropriate error code. */
585 isds_error isds_get_list_of_received_messages(struct isds_ctx *context,
586 const struct timeval *from_time, const struct timeval *to_time,
587 const long int *dmSenderOrgUnitNum, const unsigned int status_filter,
588 const unsigned long int offset, unsigned long int *number,
589 struct isds_list **messages);
591 /* Download incoming message envelope identified by ID.
592 * @context is session context
593 * @message_id is message identifier (you can get them from
594 * isds_get_list_of_received_messages())
595 * @message is automatically reallocated message retrieved from ISDS.
596 * It will miss documents per se. Use isds_get_received_message(), if you are
597 * interrested in documents (content) too.
598 * Returned hash and timestamp require documents to be verifiable. */
599 isds_error isds_get_received_envelope(struct isds_ctx *context,
600 const char *message_id, struct isds_message **message);
602 /* Load signed delivery info from buffer.
603 * @context is session context
604 * @buffer is DER encoded PKCS#7 structure with signed delivery info. You can
605 * retrieve such data from message->raw after calling
606 * isds_get_signed_delivery_info().
607 * @length is length of buffer in bytes.
608 * @message is automatically reallocated message parsed from @buffer.
609 * @strategy selects how buffer will be attached into raw isds_message member.
610 * */
611 isds_error isds_load_signed_delivery_info(struct isds_ctx *context,
612 const void *buffer, const size_t length,
613 struct isds_message **message, const isds_buffer_strategy strategy);
615 /* Download signed delivery infosheet of given message identified by ID.
616 * @context is session context
617 * @message_id is message identifier (you can get them from
618 * isds_get_list_of_{sent,received}_messages())
619 * @message is automatically reallocated message retrieved from ISDS.
620 * It will miss documents per se. Use isds_get_signed_received_message(),
621 * if you are interrested in documents (content). OTOH, only this function
622 * can get list events message has gone through. */
623 isds_error isds_get_signed_delivery_info(struct isds_ctx *context,
624 const char *message_id, struct isds_message **message);
626 /* Load delivery info from buffer.
627 * @context is session context
628 * @buffer is XML document stream with delivery info. You can retrieve such
629 * data from message->raw after calling isds_get_delivery_info().
630 * @length is length of buffer in bytes.
631 * @message is automatically reallocated message parsed from @buffer.
632 * @strategy selects how buffer will be attached into raw isds_message member.
633 * */
634 isds_error isds_load_delivery_info(struct isds_ctx *context,
635 const void *buffer, const size_t length,
636 struct isds_message **message, const isds_buffer_strategy strategy);
638 /* Download delivery infosheet of given message identified by ID.
639 * @context is session context
640 * @message_id is message identifier (you can get them from
641 * isds_get_list_of_{sent,received}_messages())
642 * @message is automatically reallocated message retrieved from ISDS.
643 * It will miss documents per se. Use isds_get_received_message(), if you are
644 * interrested in documents (content). OTOH, only this function can get list
645 * events message has gone through. */
646 isds_error isds_get_delivery_info(struct isds_ctx *context,
647 const char *message_id, struct isds_message **message);
649 /* Deprecated: Use isds_load_message() instead. */
650 /* Load incoming message from buffer.
651 * @context is session context
652 * @buffer XML stream with unsigned message. You can retrieve such data from
653 * message->raw after calling isds_get_received_message().
654 * @length is length of buffer in bytes.
655 * @message is automatically reallocated message parsed from @buffer.
656 * @strategy selects how buffer will be attached into raw isds_message member.
657 * */
658 isds_error isds_load_received_message(struct isds_ctx *context,
659 const void *buffer, const size_t length,
660 struct isds_message **message, const isds_buffer_strategy strategy)
661 _deprecated;
663 /* Download incoming message identified by ID.
664 * @context is session context
665 * @message_id is message identifier (you can get them from
666 * isds_get_list_of_received_messages())
667 * @message is automatically reallocated message retrieved from ISDS */
668 isds_error isds_get_received_message(struct isds_ctx *context,
669 const char *message_id, struct isds_message **message);
671 /* Deprecated: Use isds_load_message() instead. */
672 /* Load signed message from buffer.
673 * @context is session context
674 * @outgoing is true if message is outgoing, false if message is incoming
675 * @buffer is DER encoded PKCS#7 structure with signed message. You can
676 * retrieve such data from message->raw after calling
677 * isds_get_signed{received,sent}_message().
678 * @length is length of buffer in bytes.
679 * @message is automatically reallocated message parsed from @buffer.
680 * @strategy selects how buffer will be attached into raw isds_message member.
681 * */
682 isds_error isds_load_signed_message(struct isds_ctx *context,
683 const _Bool outgoing, const void *buffer, const size_t length,
684 struct isds_message **message, const isds_buffer_strategy strategy)
685 _deprecated;
687 /* Load message of any type from buffer.
688 * @context is session context
689 * @raw_type defines content type of @buffer. Only message types are allowed.
690 * @buffer is message raw representation. Format (CMS, plain signed,
691 * message direction) is defined in @raw_type. You can retrieve such data
692 * from message->raw after calling isds_get_[signed]{received,sent}_message().
693 * @length is length of buffer in bytes.
694 * @message is automatically reallocated message parsed from @buffer.
695 * @strategy selects how buffer will be attached into raw isds_message member.
696 * */
697 isds_error isds_load_message(struct isds_ctx *context,
698 const isds_raw_type raw_type, const void *buffer, const size_t length,
699 struct isds_message **message, const isds_buffer_strategy strategy);
701 /* Download signed incoming message identified by ID.
702 * @context is session context
703 * @message_id is message identifier (you can get them from
704 * isds_get_list_of_received_messages())
705 * @message is automatically reallocated message retrieved from ISDS. The raw
706 * memeber will be filled with PKCS#7 structure in DER format. */
707 isds_error isds_get_signed_received_message(struct isds_ctx *context,
708 const char *message_id, struct isds_message **message);
710 /* Download signed outgoing message identified by ID.
711 * @context is session context
712 * @message_id is message identifier (you can get them from
713 * isds_get_list_of_sent_messages())
714 * @message is automatically reallocated message retrieved from ISDS. The raw
715 * memeber will be filled with PKCS#7 structure in DER format. */
716 isds_error isds_get_signed_sent_message(struct isds_ctx *context,
717 const char *message_id, struct isds_message **message);
719 /* Retrieve hash of message identified by ID stored in ISDS.
720 * @context is session context
721 * @message_id is message identifier
722 * @hash is automatically reallocated message hash downloaded from ISDS.
723 * Message must exist in system and must not be deleted. */
724 isds_error isds_download_message_hash(struct isds_ctx *context,
725 const char *message_id, struct isds_hash **hash);
727 /* Compute hash of message from raw representation and store it into envelope.
728 * Original hash structure will be destroyed in envelope.
729 * @context is session context
730 * @message is message carrying raw XML message blob
731 * @algorithm is desired hash algorithm to use */
732 isds_error isds_compute_message_hash(struct isds_ctx *context,
733 struct isds_message *message, const isds_hash_algorithm algorithm);
735 /* Compare two hashes.
736 * @h1 is first hash
737 * @h2 is another hash
738 * @return
739 * IE_SUCCESS if hashes equal
740 * IE_NOTUNIQ if hashes are comparable, but they don't equal
741 * IE_ENUM if not comparable, but both structures defined
742 * IE_INVAL if some of the structures are undefined (NULL)
743 * IE_ERROR if internal error occurs */
744 isds_error isds_hash_cmp(const struct isds_hash *h1,
745 const struct isds_hash *h2);
747 /* Check message has gone through ISDS by comparing message hash stored in
748 * ISDS and locally computed hash. You must provide message with valid raw
749 * member (do not use isds_load_message(..., BUFFER_DONT_STORE)).
750 * This is convenient wrapper for isds_download_message_hash(),
751 * isds_compute_message_hash(), and isds_hash_cmp() sequence.
752 * @context is session context
753 * @message is message with valid raw and envelope member; envelope->hash
754 * member will be changed during funcion run. Use envelope on heap only.
755 * @return
756 * IE_SUCCESS if message originates in ISDS
757 * IE_NOTEQUAL if message is unknown to ISDS
758 * other code for other errors */
759 isds_error isds_verify_message_hash(struct isds_ctx *context,
760 struct isds_message *message);
762 /* Mark message as read. This is a transactional commit function to acknoledge
763 * to ISDS the message has been downloaded and processed by client properly.
764 * @context is session context
765 * @message_id is message identifier. */
766 isds_error isds_mark_message_read(struct isds_ctx *context,
767 const char *message_id);
769 /* Send bogus request to ISDS.
770 * Just for test purposes */
771 isds_error isds_bogus_request(struct isds_ctx *context);
773 /* Search for document by document ID in list of documents. IDs are compared
774 * as UTF-8 string.
775 * @documents is list of isds_documents
776 * @id is document identifier
777 * @return first matching document or NULL. */
778 const struct isds_document *isds_find_document_by_id(
779 const struct isds_list *documents, const char *id);
781 /* Deallocate structure isds_hash and NULL it.
782 * @hash hash to to free */
783 void isds_hash_free(struct isds_hash **hash);
785 /* Deallocate structure isds_DbOwnerInfo recursively and NULL it */
786 void isds_DbOwnerInfo_free(struct isds_DbOwnerInfo **db_owner_info);
788 /* Deallocate struct isds_event recursively and NULL it */
789 void isds_event_free(struct isds_event **event);
791 /* Deallocate struct isds_envelope recursively and NULL it */
792 void isds_envelope_free(struct isds_envelope **envelope);
794 /* Deallocate struct isds_document recursively and NULL it */
795 void isds_document_free(struct isds_document **document);
797 /* Deallocate struct isds_message recursively and NULL it */
798 void isds_message_free(struct isds_message **message);
800 #endif