defined mapping of IKEv2 identity types to IF-MAP identity types
[strongswan.git] / src / libcharon / plugins / tnc_ifmap / tnc_ifmap_soap.c
1 /*
2 * Copyright (C) 2011 Andreas Steffen
3 * HSR Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 #include "tnc_ifmap_soap.h"
17
18 #include <debug.h>
19
20 #include <axis2_util.h>
21 #include <axis2_client.h>
22 #include <axis2_http_transport.h>
23 #include <axis2_http_transport_sender.h>
24 #include <axiom_soap.h>
25
26 #define IFMAP_NS "http://www.trustedcomputinggroup.org/2010/IFMAP/2"
27 #define IFMAP_META_NS "http://www.trustedcomputinggroup.org/2010/IFMAP-METADATA/2"
28 #define IFMAP_LOGFILE "strongswan_ifmap.log"
29 #define IFMAP_SERVER "https://localhost:8443/"
30
31 typedef struct private_tnc_ifmap_soap_t private_tnc_ifmap_soap_t;
32
33 /**
34 * Private data of an tnc_ifmap_soap_t object.
35 */
36 struct private_tnc_ifmap_soap_t {
37
38 /**
39 * Public tnc_ifmap_soap_t interface.
40 */
41 tnc_ifmap_soap_t public;
42
43 /**
44 * Axis2/C environment
45 */
46 axutil_env_t *env;
47
48 /**
49 * Axis2 service client
50 */
51 axis2_svc_client_t* svc_client;
52
53 /**
54 * SOAP Session ID
55 */
56 char *session_id;
57
58 /**
59 * IF-MAP Publisher ID
60 */
61 char *ifmap_publisher_id;
62
63 /**
64 * PEP and PDP device name
65 */
66 char *device_name;
67
68 };
69
70 /**
71 * Send request and receive result via SOAP
72 */
73 static bool send_receive(private_tnc_ifmap_soap_t *this,
74 char *request_qname, axiom_node_t *request,
75 char *receipt_qname, axiom_node_t **result)
76
77 {
78 axiom_node_t *parent, *node;
79 axiom_element_t *el;
80 axutil_qname_t *qname;
81 bool success = FALSE;
82
83 /* send request and receive result */
84 DBG2(DBG_TNC, "sending ifmap %s", request_qname);
85
86 parent = axis2_svc_client_send_receive(this->svc_client, this->env, request);
87 if (!parent)
88 {
89 DBG1(DBG_TNC, "no ifmap %s received from MAP server", receipt_qname);
90 return FALSE;
91 }
92
93 /* pre-process result */
94 node = axiom_node_get_first_child(parent, this->env);
95 if (node && axiom_node_get_node_type(node, this->env) == AXIOM_ELEMENT)
96 {
97 el = (axiom_element_t *)axiom_node_get_data_element(node, this->env);
98
99 qname = axiom_element_get_qname(el, this->env, node);
100 success = streq(receipt_qname, axutil_qname_to_string(qname, this->env));
101 if (success)
102 {
103 DBG2(DBG_TNC, "received ifmap %s", receipt_qname);
104 if (result)
105 {
106 *result = parent;
107 }
108 else
109 {
110 /* no further processing requested */
111 axiom_node_free_tree(parent, this->env);
112 }
113 return TRUE;
114 }
115 /* TODO proper error handling */
116 DBG1(DBG_TNC, "%s", axiom_element_to_string(el, this->env, node));
117 }
118
119 /* free parent in the error case */
120 axiom_node_free_tree(parent, this->env);
121
122 return FALSE;
123 }
124
125 METHOD(tnc_ifmap_soap_t, newSession, bool,
126 private_tnc_ifmap_soap_t *this)
127 {
128 axiom_node_t *request, *result, *node;
129 axiom_element_t *el;
130 axiom_namespace_t *ns;
131 axis2_char_t *value;
132
133
134 /* build newSession request */
135 ns = axiom_namespace_create(this->env, IFMAP_NS, "ifmap");
136 el = axiom_element_create(this->env, NULL, "newSession", ns, &request);
137
138 /* send newSession request and receive newSessionResult */
139 if (!send_receive(this, "newSession", request, "newSessionResult", &result))
140 {
141 return FALSE;
142 }
143
144 /* process newSessionResult */
145 node = axiom_node_get_first_child(result, this->env);
146 el = (axiom_element_t *)axiom_node_get_data_element(node, this->env);
147
148 /* get session-id */
149 value = axiom_element_get_attribute_value_by_name(el, this->env,
150 "session-id");
151 this->session_id = strdup(value);
152
153 /* get ifmap-publisher-id */
154 value = axiom_element_get_attribute_value_by_name(el, this->env,
155 "ifmap-publisher-id");
156 this->ifmap_publisher_id = strdup(value);
157
158 DBG1(DBG_TNC, "session-id: %s, ifmap-publisher-id: %s",
159 this->session_id, this->ifmap_publisher_id);
160
161 /* set PEP and PDP device name (defaults to IF-MAP Publisher ID) */
162 this->device_name = lib->settings->get_str(lib->settings,
163 "charon.plugins.tnc-ifmap.device_name",
164 this->ifmap_publisher_id);
165 this->device_name = strdup(this->device_name);
166
167 /* free result */
168 axiom_node_free_tree(result, this->env);
169
170 return this->session_id && this->ifmap_publisher_id;
171 }
172
173 METHOD(tnc_ifmap_soap_t, purgePublisher, bool,
174 private_tnc_ifmap_soap_t *this)
175 {
176 axiom_node_t *request;
177 axiom_element_t *el;
178 axiom_namespace_t *ns;
179 axiom_attribute_t *attr;
180
181 /* build purgePublisher request */
182 ns = axiom_namespace_create(this->env, IFMAP_NS, "ifmap");
183 el = axiom_element_create(this->env, NULL, "purgePublisher", ns, &request);
184 attr = axiom_attribute_create(this->env, "session-id",
185 this->session_id, NULL);
186 axiom_element_add_attribute(el, this->env, attr, request);
187 attr = axiom_attribute_create(this->env, "ifmap-publisher-id",
188 this->ifmap_publisher_id, NULL);
189 axiom_element_add_attribute(el, this->env, attr, request);
190
191 /* send purgePublisher request and receive purgePublisherReceived */
192 return send_receive(this, "purgePublisher", request,
193 "purgePublisherReceived", NULL);
194 }
195
196 /**
197 * Create an access-request based on device_name and ike_sa_id
198 */
199 static axiom_node_t* create_access_request(private_tnc_ifmap_soap_t *this,
200 u_int32_t id)
201 {
202 axiom_element_t *el;
203 axiom_node_t *node;
204 axiom_attribute_t *attr;
205 char buf[BUF_LEN];
206
207 el = axiom_element_create(this->env, NULL, "access-request", NULL, &node);
208
209 snprintf(buf, BUF_LEN, "%s:%d", this->device_name, id);
210 attr = axiom_attribute_create(this->env, "name", buf, NULL);
211 axiom_element_add_attribute(el, this->env, attr, node);
212
213 return node;
214 }
215
216 /**
217 * Create an identity
218 */
219 static axiom_node_t* create_identity(private_tnc_ifmap_soap_t *this,
220 identification_t *id, bool is_user)
221 {
222 axiom_element_t *el;
223 axiom_node_t *node;
224 axiom_attribute_t *attr;
225 char buf[BUF_LEN], *id_type;
226
227 el = axiom_element_create(this->env, NULL, "identity", NULL, &node);
228
229 snprintf(buf, BUF_LEN, "%Y", id);
230 attr = axiom_attribute_create(this->env, "name", buf, NULL);
231 axiom_element_add_attribute(el, this->env, attr, node);
232
233 switch (id->get_type(id))
234 {
235 case ID_IPV4_ADDR:
236 id_type = "other";
237 attr = axiom_attribute_create(this->env, "other-type-definition",
238 "36906:ipv4-address", NULL);
239 axiom_element_add_attribute(el, this->env, attr, node);
240 break;
241 case ID_FQDN:
242 id_type = is_user ? "username" : "dns-name";
243 break;
244 case ID_RFC822_ADDR:
245 id_type = "email-address";
246 break;
247 case ID_IPV6_ADDR:
248 id_type = "other";
249 attr = axiom_attribute_create(this->env, "other-type-definition",
250 "36906:ipv6-address", NULL);
251 axiom_element_add_attribute(el, this->env, attr, node);
252 break;
253 case ID_DER_ASN1_DN:
254 id_type = "distinguished-name";
255 break;
256 case ID_KEY_ID:
257 id_type = "other";
258 attr = axiom_attribute_create(this->env, "other-type-definition",
259 "36906:key-id", NULL);
260 axiom_element_add_attribute(el, this->env, attr, node);
261 break;
262 default:
263 id_type = "other";
264 attr = axiom_attribute_create(this->env, "other-type-definition",
265 "36906:other", NULL);
266 axiom_element_add_attribute(el, this->env, attr, node);
267 }
268 attr = axiom_attribute_create(this->env, "type", id_type, NULL);
269 axiom_element_add_attribute(el, this->env, attr, node);
270
271 return node;
272 }
273
274 /**
275 * Create an ip-address
276 */
277 static axiom_node_t* create_ip_address(private_tnc_ifmap_soap_t *this,
278 host_t *host)
279 {
280 axiom_element_t *el;
281 axiom_node_t *node;
282 axiom_attribute_t *attr;
283 char buf[BUF_LEN];
284
285 el = axiom_element_create(this->env, NULL, "ip-address", NULL, &node);
286
287 if (host->get_family(host) == AF_INET6)
288 {
289 chunk_t address;
290 int len, written, i;
291 char *pos;
292 bool first = TRUE;
293
294 /* output IPv6 address in canonical IF-MAP 2.0 format */
295 address = host->get_address(host);
296 pos = buf;
297 len = sizeof(buf);
298
299 for (i = 0; i < address.len; i = i + 2)
300 {
301 written = snprintf(pos, len, "%s%x", first ? "" : ":",
302 256*address.ptr[i] + address.ptr[i+1]);
303 if (written < 0 || written > len)
304 {
305 break;
306 }
307 pos += written;
308 len -= written;
309 first = FALSE;
310 }
311 }
312 else
313 {
314 snprintf(buf, BUF_LEN, "%H", host);
315 }
316 attr = axiom_attribute_create(this->env, "value", buf, NULL);
317 axiom_element_add_attribute(el, this->env, attr, node);
318
319 attr = axiom_attribute_create(this->env, "type",
320 host->get_family(host) == AF_INET ? "IPv4" : "IPv6", NULL);
321 axiom_element_add_attribute(el, this->env, attr, node);
322
323 return node;
324 }
325
326 /**
327 * Create a device
328 */
329 static axiom_node_t* create_device(private_tnc_ifmap_soap_t *this)
330 {
331 axiom_element_t *el;
332 axiom_node_t *node, *node2, *node3;
333 axiom_text_t *text;
334
335 el = axiom_element_create(this->env, NULL, "device", NULL, &node);
336 el = axiom_element_create(this->env, NULL, "name", NULL, &node2);
337 axiom_node_add_child(node, this->env, node2);
338 text = axiom_text_create(this->env, node2, this->device_name, &node3);
339
340 return node;
341 }
342
343 /**
344 * Create metadata
345 */
346 static axiom_node_t* create_metadata(private_tnc_ifmap_soap_t *this,
347 char *metadata)
348 {
349 axiom_element_t *el;
350 axiom_node_t *node, *node2;
351 axiom_attribute_t *attr;
352 axiom_namespace_t *ns_meta;
353
354 el = axiom_element_create(this->env, NULL, "metadata", NULL, &node);
355 ns_meta = axiom_namespace_create(this->env, IFMAP_META_NS, "meta");
356
357 el = axiom_element_create(this->env, NULL, metadata, ns_meta, &node2);
358 axiom_node_add_child(node, this->env, node2);
359 attr = axiom_attribute_create(this->env, "ifmap-cardinality", "singleValue",
360 NULL);
361 axiom_element_add_attribute(el, this->env, attr, node2);
362
363 return node;
364 }
365
366 /**
367 * Create capability metadata
368 */
369 static axiom_node_t* create_capability(private_tnc_ifmap_soap_t *this,
370 identification_t *name)
371 {
372 axiom_element_t *el;
373 axiom_node_t *node, *node2, *node3;
374 axiom_namespace_t *ns_meta;
375 axiom_attribute_t *attr;
376 axiom_text_t *text;
377 char buf[BUF_LEN];
378
379 ns_meta = axiom_namespace_create(this->env, IFMAP_META_NS, "meta");
380 el = axiom_element_create(this->env, NULL, "capability", ns_meta, &node);
381 attr = axiom_attribute_create(this->env, "ifmap-cardinality", "multiValue",
382 NULL);
383 axiom_element_add_attribute(el, this->env, attr, node);
384
385 el = axiom_element_create(this->env, NULL, "name", NULL, &node2);
386 axiom_node_add_child(node, this->env, node2);
387 snprintf(buf, BUF_LEN, "%Y", name);
388 text = axiom_text_create(this->env, node2, buf, &node3);
389
390 el = axiom_element_create(this->env, NULL, "administrative-domain", NULL, &node2);
391 axiom_node_add_child(node, this->env, node2);
392 text = axiom_text_create(this->env, node2, "strongswan", &node3);
393
394 return node;
395 }
396
397 /**
398 * Create delete filter
399 */
400 static axiom_node_t* create_delete_filter(private_tnc_ifmap_soap_t *this,
401 char *metadata)
402 {
403 axiom_element_t *el;
404 axiom_node_t *node;
405 axiom_attribute_t *attr;
406 char buf[BUF_LEN];
407
408 el = axiom_element_create(this->env, NULL, "delete", NULL, &node);
409
410 snprintf(buf, BUF_LEN, "meta:%s[@ifmap-publisher-id='%s']",
411 metadata, this->ifmap_publisher_id);
412 attr = axiom_attribute_create(this->env, "filter", buf, NULL);
413 axiom_element_add_attribute(el, this->env, attr, node);
414
415 return node;
416 }
417
418 METHOD(tnc_ifmap_soap_t, publish_ike_sa, bool,
419 private_tnc_ifmap_soap_t *this, ike_sa_t *ike_sa, bool up)
420 {
421 axiom_node_t *request, *node, *node2;
422 axiom_element_t *el;
423 axiom_namespace_t *ns, *ns_meta;
424 axiom_attribute_t *attr;
425
426 enumerator_t *e1, *e2;
427 auth_rule_t type;
428 identification_t *id, *eap_id, *group;
429 host_t *host;
430 auth_cfg_t *auth;
431 u_int32_t ike_sa_id;
432 bool is_user, first = TRUE;
433
434 /* extract relevant data from IKE_SA*/
435 ike_sa_id = ike_sa->get_unique_id(ike_sa);
436 id = ike_sa->get_other_id(ike_sa);
437 eap_id = ike_sa->get_other_eap_id(ike_sa);
438 host = ike_sa->get_other_host(ike_sa);
439
440 /* in the presence of an EAP Identity, treat it as a username */
441 is_user = !id->equals(id, eap_id);
442
443 /* build publish request */
444 ns = axiom_namespace_create(this->env, IFMAP_NS, "ifmap");
445 el = axiom_element_create(this->env, NULL, "publish", ns, &request);
446 ns_meta = axiom_namespace_create(this->env, IFMAP_META_NS, "meta");
447 axiom_element_declare_namespace(el, this->env, request, ns_meta);
448 attr = axiom_attribute_create(this->env, "session-id", this->session_id,
449 NULL);
450 axiom_element_add_attribute(el, this->env, attr, request);
451
452 /**
453 * update or delete authenticated-as metadata
454 */
455 if (up)
456 {
457 el = axiom_element_create(this->env, NULL, "update", NULL, &node);
458 }
459 else
460 {
461 node = create_delete_filter(this, "authenticated-as");
462 }
463 axiom_node_add_child(request, this->env, node);
464
465 /* add access-request, identity and [if up] metadata */
466 axiom_node_add_child(node, this->env,
467 create_access_request(this, ike_sa_id));
468 axiom_node_add_child(node, this->env,
469 create_identity(this, id, is_user));
470 if (up)
471 {
472 axiom_node_add_child(node, this->env,
473 create_metadata(this, "authenticated-as"));
474 }
475
476 /**
477 * update or delete access-request-ip metadata
478 */
479 if (up)
480 {
481 el = axiom_element_create(this->env, NULL, "update", NULL, &node);
482 }
483 else
484 {
485 node = create_delete_filter(this, "access-request-ip");
486 }
487 axiom_node_add_child(request, this->env, node);
488
489 /* add access-request, ip-address and [if up] metadata */
490 axiom_node_add_child(node, this->env,
491 create_access_request(this, ike_sa_id));
492 axiom_node_add_child(node, this->env,
493 create_ip_address(this, host));
494 if (up)
495 {
496 axiom_node_add_child(node, this->env,
497 create_metadata(this, "access-request-ip"));
498 }
499
500 /**
501 * update or delete authenticated-by metadata
502 */
503 if (up)
504 {
505 el = axiom_element_create(this->env, NULL, "update", NULL, &node);
506 }
507 else
508 {
509 node = create_delete_filter(this, "authenticated-by");
510 }
511 axiom_node_add_child(request, this->env, node);
512
513 /* add access-request, device and [if up] metadata */
514 axiom_node_add_child(node, this->env,
515 create_access_request(this, ike_sa_id));
516 axiom_node_add_child(node, this->env,
517 create_device(this));
518 if (up)
519 {
520 axiom_node_add_child(node, this->env,
521 create_metadata(this, "authenticated-by"));
522 }
523
524 /**
525 * update or delete capability metadata
526 */
527 e1 = ike_sa->create_auth_cfg_enumerator(ike_sa, FALSE);
528 while (e1->enumerate(e1, &auth))
529 {
530 e2 = auth->create_enumerator(auth);
531 while (e2->enumerate(e2, &type, &group))
532 {
533 /* look for group memberships */
534 if (type == AUTH_RULE_GROUP)
535 {
536 if (first)
537 {
538 first = FALSE;
539
540 if (up)
541 {
542 el = axiom_element_create(this->env, NULL, "update",
543 NULL, &node);
544 }
545 else
546 {
547 node = create_delete_filter(this, "capability");
548 }
549 axiom_node_add_child(request, this->env, node);
550
551 /* add access-request */
552 axiom_node_add_child(node, this->env,
553 create_access_request(this, ike_sa_id));
554 if (!up)
555 {
556 break;
557 }
558 el = axiom_element_create(this->env, NULL, "metadata", NULL,
559 &node2);
560 axiom_node_add_child(node, this->env, node2);
561 }
562 axiom_node_add_child(node2, this->env,
563 create_capability(this, group));
564 }
565 if (!first && !up)
566 {
567 break;
568 }
569 }
570 e2->destroy(e2);
571 }
572 e1->destroy(e1);
573
574 /* send publish request and receive publishReceived */
575 return send_receive(this, "publish", request, "publishReceived", NULL);
576 }
577
578 METHOD(tnc_ifmap_soap_t, publish_device_ip, bool,
579 private_tnc_ifmap_soap_t *this, host_t *host)
580 {
581 axiom_node_t *request, *node;
582 axiom_element_t *el;
583 axiom_namespace_t *ns, *ns_meta;
584 axiom_attribute_t *attr;
585
586 /* build publish request */
587 ns = axiom_namespace_create(this->env, IFMAP_NS, "ifmap");
588 el = axiom_element_create(this->env, NULL, "publish", ns, &request);
589 ns_meta = axiom_namespace_create(this->env, IFMAP_META_NS, "meta");
590 axiom_element_declare_namespace(el, this->env, request, ns_meta);
591 attr = axiom_attribute_create(this->env, "session-id", this->session_id,
592 NULL);
593 axiom_element_add_attribute(el, this->env, attr, request);
594 el = axiom_element_create(this->env, NULL, "update", NULL, &node);
595 axiom_node_add_child(request, this->env, node);
596
597 /* add device, ip-address and metadata */
598 axiom_node_add_child(node, this->env,
599 create_device(this));
600 axiom_node_add_child(node, this->env,
601 create_ip_address(this, host));
602 axiom_node_add_child(node, this->env,
603 create_metadata(this, "device-ip"));
604
605 /* send publish request and receive publishReceived */
606 return send_receive(this, "publish", request, "publishReceived", NULL);
607 }
608
609 METHOD(tnc_ifmap_soap_t, endSession, bool,
610 private_tnc_ifmap_soap_t *this)
611 {
612 axiom_node_t *request;
613 axiom_element_t *el;
614 axiom_namespace_t *ns;
615 axiom_attribute_t *attr;
616
617 /* build endSession request */
618 ns = axiom_namespace_create(this->env, IFMAP_NS, "ifmap");
619 el = axiom_element_create(this->env, NULL, "endSession", ns, &request);
620 attr = axiom_attribute_create(this->env, "session-id", this->session_id, NULL);
621 axiom_element_add_attribute(el, this->env, attr, request);
622
623 /* send endSession request and receive end SessionResult */
624 return send_receive(this, "endSession", request, "endSessionResult", NULL);
625 }
626
627 METHOD(tnc_ifmap_soap_t, destroy, void,
628 private_tnc_ifmap_soap_t *this)
629 {
630 if (this->session_id)
631 {
632 endSession(this);
633 free(this->session_id);
634 free(this->ifmap_publisher_id);
635 free(this->device_name);
636 }
637 if (this->svc_client)
638 {
639 axis2_svc_client_free(this->svc_client, this->env);
640 }
641 if (this->env)
642 {
643 axutil_env_free(this->env);
644 }
645 free(this);
646 }
647
648 static bool axis2c_init(private_tnc_ifmap_soap_t *this)
649 {
650 axis2_char_t *server, *server_cert, *client_home;
651 axis2_char_t *username, *password, *auth_type;
652 axis2_endpoint_ref_t* endpoint_ref = NULL;
653 axis2_options_t *options = NULL;
654 axis2_transport_in_desc_t *transport_in;
655 axis2_transport_out_desc_t *transport_out;
656 axis2_transport_sender_t *transport_sender;
657 axutil_property_t* property;
658
659 /* Getting configuration parameters from strongswan.conf */
660 client_home = lib->settings->get_str(lib->settings,
661 "charon.plugins.tnc-ifmap.client_home",
662 AXIS2_GETENV("AXIS2C_HOME"));
663 server = lib->settings->get_str(lib->settings,
664 "charon.plugins.tnc-ifmap.server", IFMAP_SERVER);
665 server_cert = lib->settings->get_str(lib->settings,
666 "charon.plugins.tnc-ifmap.server_cert", NULL);
667 auth_type = lib->settings->get_str(lib->settings,
668 "charon.plugins.tnc-ifmap.auth_type", "Basic");
669 username = lib->settings->get_str(lib->settings,
670 "charon.plugins.tnc-ifmap.username", NULL);
671 password = lib->settings->get_str(lib->settings,
672 "charon.plugins.tnc-ifmap.password", NULL);
673
674 if (!server_cert)
675 {
676 DBG1(DBG_TNC, "MAP server certificate not defined");
677 return FALSE;
678 }
679 if (!username || !password)
680 {
681 DBG1(DBG_TNC, "MAP client %s%s%s not defined",
682 (!username) ? "username" : "",
683 (!username && ! password) ? " and " : "",
684 (!password) ? "password" : "");
685 return FALSE;
686 }
687
688 /* Create Axis2/C environment and options */
689 this->env = axutil_env_create_all(IFMAP_LOGFILE, AXIS2_LOG_LEVEL_TRACE);
690 options = axis2_options_create(this->env);
691
692 /* Path to the MAP server certificate */
693 property =axutil_property_create_with_args(this->env, 0, 0, 0, server_cert);
694 axis2_options_set_property(options, this->env, AXIS2_SSL_SERVER_CERT, property);
695
696 /* Define the MAP server as the to endpoint reference */
697 endpoint_ref = axis2_endpoint_ref_create(this->env, server);
698 axis2_options_set_to(options, this->env, endpoint_ref);
699
700 /* Set up HTTP Basic or Digest MAP client authentication */
701 axis2_options_set_http_auth_info(options, this->env, username, password,
702 auth_type);
703
704 /* Set up https transport */
705 transport_in = axis2_transport_in_desc_create(this->env,
706 AXIS2_TRANSPORT_ENUM_HTTPS);
707 transport_out = axis2_transport_out_desc_create(this->env,
708 AXIS2_TRANSPORT_ENUM_HTTPS);
709 transport_sender = axis2_http_transport_sender_create(this->env);
710 axis2_transport_out_desc_set_sender(transport_out, this->env,
711 transport_sender);
712 axis2_options_set_transport_in(options, this->env, transport_in);
713 axis2_options_set_transport_out(options, this->env, transport_out);
714
715 /* Create the axis2 service client */
716 this->svc_client = axis2_svc_client_create(this->env, client_home);
717 if (!this->svc_client)
718 {
719 DBG1(DBG_TNC, "could not create axis2 service client");
720 AXIS2_LOG_ERROR(this->env->log, AXIS2_LOG_SI,
721 "Stub invoke FAILED: Error code: %d :: %s",
722 this->env->error->error_number,
723 AXIS2_ERROR_GET_MESSAGE(this->env->error));
724 destroy(this);
725 return FALSE;
726 }
727
728 axis2_svc_client_set_options(this->svc_client, this->env, options);
729 DBG1(DBG_TNC, "connecting as MAP client '%s' to MAP server at '%s'",
730 username, server);
731
732 return TRUE;
733 }
734
735 /**
736 * See header
737 */
738 tnc_ifmap_soap_t *tnc_ifmap_soap_create()
739 {
740 private_tnc_ifmap_soap_t *this;
741
742 INIT(this,
743 .public = {
744 .newSession = _newSession,
745 .purgePublisher = _purgePublisher,
746 .publish_ike_sa = _publish_ike_sa,
747 .publish_device_ip = _publish_device_ip,
748 .endSession = _endSession,
749 .destroy = _destroy,
750 },
751 );
752
753 if (!axis2c_init(this))
754 {
755 destroy(this);
756 return NULL;
757 }
758
759 return &this->public;
760 }
761