1 #ifndef __ISDS_ISDS_PRIV_H__
2 #define __ISDS_ISDS_PRIV_H__
4 /* Feature macros to enable some declarations. This is kept here to align all
5 * header files to one shape. */
7 /* >= 500: strdup(3) from string.h, strptime(3) from time.h */
8 /* >= 600: setenv(3) */
9 /* >= 700: strndup(3) from string.h */
10 #define _XOPEN_SOURCE 700
14 /* defined: strtok_r */
18 /* Structures not to export outside library */
19 #include "../config.h"
22 #include <curl/curl.h>
24 #include <libxml/parser.h>
25 #include <libxml/xpath.h>
26 #include <libxml/xpathInternals.h>
27 #include <libxml/xmlsave.h>
30 #define _(x) ((const char *) dgettext(PACKAGE, (x)))
33 #define SOAP_NS "http://schemas.xmlsoap.org/soap/envelope/"
34 #define SOAP2_NS "http://www.w3.org/2003/05/soap-envelope"
35 #define ISDS1_NS "http://isds.czechpoint.cz"
36 #define ISDS_NS "http://isds.czechpoint.cz/v20"
37 #define SISDS_INCOMING_NS "http://isds.czechpoint.cz/v20/message"
38 #define SISDS_OUTGOING_NS "http://isds.czechpoint.cz/v20/SentMessage"
39 #define SISDS_DELIVERY_NS "http://isds.czechpoint.cz/v20/delivery"
40 #define SCHEMA_NS "http://www.w3.org/2001/XMLSchema"
41 #define DEPOSIT_NS "urn:uschovnaWSDL"
44 /* Used to choose proper name space for message elements.
45 * See _isds_register_namespaces(). */
49 MESSAGE_NS_SIGNED_INCOMING
,
50 MESSAGE_NS_SIGNED_OUTGOING
,
51 MESSAGE_NS_SIGNED_DELIVERY
54 /* Type of a context */
56 CTX_TYPE_NONE
= 0, /* Not configured for any connection yet */
57 CTX_TYPE_ISDS
, /* Connection to ISDS */
58 CTX_TYPE_CZP
, /* Connection to Czech POINT document deposit */
59 CTX_TYPE_TESTING_REQUEST_COLLECTOR
/* Connection to server collectiong
60 new testing box requests */
64 * Allocated in isds_init() and deallocated in isds_cleanup(). */
65 unsigned int log_facilities
;
66 isds_log_level log_level
;
67 isds_log_callback log_callback
; /* Pass global log message to application.
68 NULL to log to stderr itself */
69 void *log_callback_data
; /* Application specific data to pass to
70 registered log_callback function */
71 const char *version_gpgme
; /* Static string with GPGME version */
72 const char *version_gcrypt
; /* Static string with gcrypt version */
73 const char *version_expat
; /* Static string with expat version */
75 /* End of global variables */
79 context_type type
; /* Context type */
81 unsigned int timeout
; /* milliseconds */
82 char *url
; /* URL of the ISDS web service */
85 struct isds_pki_credentials
*pki_credentials
;
86 _Bool otp
; /* This is OTP-authenticated context */
87 struct isds_otp
*otp_credentials
; /* Weak pointer to OTP credentials */
88 char *saved_username
; /* User name preserved after OTP log-in for OTP
90 CURL
*curl
; /* CURL session handle */
91 _Bool
*tls_verify_server
; /* Verify the server? */
92 isds_progress_callback progress_callback
; /* Call it during
93 communication with server.
95 void *progress_callback_data
; /* Application provided argument
96 for progress_callback */
97 char *tls_ca_file
; /* File name with CA certificates */
98 char *tls_ca_dir
; /* Directory name with CA certificates */
99 char *tls_crl_file
; /* File name with CRL in PEM format */
100 #endif /* HAVE_LIBCURL */
101 _Bool normalize_mime_type
; /* Normalize document MIME types? */
102 char *long_message
; /* message buffer */
105 /* Stores message into context' long_message buffer.
106 * Application can pick the message up using isds_long_message().
107 * NULL @message truncates the buffer but does not deallocate it.
108 * @message is coded in locale encoding */
109 isds_error
isds_log_message(struct isds_ctx
*context
, const char *message
);
111 /* Appends message into context' long_message buffer.
112 * Application can pick the message up using isds_long_message().
113 * NULL message has void effect. */
114 isds_error
isds_append_message(struct isds_ctx
*context
, const char *message
);
116 /* Stores formated message into context' long_message buffer.
117 * Application can pick the message up using isds_long_message(). */
118 isds_error
isds_printf_message(struct isds_ctx
*context
,
119 const char *format
, ...);
121 /* Log @message in class @facility with log @level into global log. @message
122 * is printf(3) formating string, variadic arguments may be neccessary.
123 * For debugging purposes. */
124 isds_error
isds_log(const isds_log_facility facility
,
125 const isds_log_level level
, const char *message
, ...);
127 /* Makes known all relevant namespaces to given XPath context
128 * @xpath_ctx is XPath context
129 * @message_ns selects propper message name space. Unsisnged and signed
130 * messages and delivery infos differ in prefix and URI. */
131 isds_error
_isds_register_namespaces(xmlXPathContextPtr xpath_ctx
,
132 const message_ns_type message_ns
);
135 /* Discard credentials.
136 * @context is ISDS context
137 * @discard_saved_username is true for removing saved username, false for
139 * Only that. It does not cause log out, connection close or similar. */
140 isds_error
_isds_discard_credentials(struct isds_ctx
*context
,
141 _Bool discard_saved_username
);
142 #endif /* HAVE_LIBCURL */