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 OISDS_NS "http://isds.czechpoint.cz/v20/asws"
38 #define SISDS_INCOMING_NS "http://isds.czechpoint.cz/v20/message"
39 #define SISDS_OUTGOING_NS "http://isds.czechpoint.cz/v20/SentMessage"
40 #define SISDS_DELIVERY_NS "http://isds.czechpoint.cz/v20/delivery"
41 #define SCHEMA_NS "http://www.w3.org/2001/XMLSchema"
42 #define DEPOSIT_NS "urn:uschovnaWSDL"
45 /* Used to choose proper name space for message elements.
46 * See _isds_register_namespaces(). */
50 MESSAGE_NS_SIGNED_INCOMING
,
51 MESSAGE_NS_SIGNED_OUTGOING
,
52 MESSAGE_NS_SIGNED_DELIVERY
55 /* Type of a context */
57 CTX_TYPE_NONE
= 0, /* Not configured for any connection yet */
58 CTX_TYPE_ISDS
, /* Connection to ISDS */
59 CTX_TYPE_CZP
, /* Connection to Czech POINT document deposit */
60 CTX_TYPE_TESTING_REQUEST_COLLECTOR
/* Connection to server collectiong
61 new testing box requests */
65 * Allocated in isds_init() and deallocated in isds_cleanup(). */
66 extern unsigned int log_facilities
;
67 extern isds_log_level log_level
;
68 extern isds_log_callback log_callback
; /* Pass global log message to
69 application. NULL to log to stderr
71 extern void *log_callback_data
; /* Application specific data to pass to
72 registered log_callback function */
73 extern const char *version_gpgme
; /* Static string with GPGME version */
74 extern const char *version_gcrypt
; /* Static string with gcrypt version */
75 extern const char *version_openssl
; /* Static string with OpenSSL version */
76 extern const char *version_expat
; /* Static string with expat version */
77 /* End of global variables */
81 context_type type
; /* Context type */
83 unsigned int timeout
; /* milliseconds */
84 char *url
; /* URL of the ISDS web service */
87 struct isds_pki_credentials
*pki_credentials
;
88 _Bool otp
; /* This is OTP-authenticated context */
89 struct isds_otp
*otp_credentials
; /* Weak pointer to OTP credentials */
90 char *saved_username
; /* User name preserved after OTP log-in for OTP
92 CURL
*curl
; /* CURL session handle */
93 _Bool
*tls_verify_server
; /* Verify the server? */
94 isds_progress_callback progress_callback
; /* Call it during
95 communication with server.
97 void *progress_callback_data
; /* Application provided argument
98 for progress_callback */
99 char *tls_ca_file
; /* File name with CA certificates */
100 char *tls_ca_dir
; /* Directory name with CA certificates */
101 char *tls_crl_file
; /* File name with CRL in PEM format */
102 #endif /* HAVE_LIBCURL */
103 _Bool normalize_mime_type
; /* Normalize document MIME types? */
104 char *long_message
; /* message buffer */
107 /* Stores message into context' long_message buffer.
108 * Application can pick the message up using isds_long_message().
109 * NULL @message truncates the buffer but does not deallocate it.
110 * @message is coded in locale encoding */
111 isds_error
isds_log_message(struct isds_ctx
*context
, const char *message
);
113 /* Appends message into context' long_message buffer.
114 * Application can pick the message up using isds_long_message().
115 * NULL message has void effect. */
116 isds_error
isds_append_message(struct isds_ctx
*context
, const char *message
);
118 /* Stores formated message into context' long_message buffer.
119 * Application can pick the message up using isds_long_message(). */
120 isds_error
isds_printf_message(struct isds_ctx
*context
,
121 const char *format
, ...);
123 /* Log @message in class @facility with log @level into global log. @message
124 * is printf(3) formating string, variadic arguments may be neccessary.
125 * For debugging purposes. */
126 isds_error
isds_log(const isds_log_facility facility
,
127 const isds_log_level level
, const char *message
, ...);
129 /* Makes known all relevant namespaces to given XPath context
130 * @xpath_ctx is XPath context
131 * @message_ns selects propper message name space. Unsisnged and signed
132 * messages and delivery infos differ in prefix and URI. */
133 isds_error
_isds_register_namespaces(xmlXPathContextPtr xpath_ctx
,
134 const message_ns_type message_ns
);
137 /* Discard credentials.
138 * @context is ISDS context
139 * @discard_saved_username is true for removing saved username, false for
141 * Only that. It does not cause log out, connection close or similar. */
142 isds_error
_isds_discard_credentials(struct isds_ctx
*context
,
143 _Bool discard_saved_username
);
144 #endif /* HAVE_LIBCURL */