|
1 |
/* $Id$
|
|
2 |
*
|
|
3 |
* Lasso - A free implementation of the Liberty Alliance specifications.
|
|
4 |
*
|
|
5 |
* Copyright (C) 2004-2007 Entr'ouvert
|
|
6 |
* http://lasso.entrouvert.org
|
|
7 |
*
|
|
8 |
* Authors: See AUTHORS file in top-level directory.
|
|
9 |
*
|
|
10 |
* This program is free software; you can redistribute it and/or modify
|
|
11 |
* it under the terms of the GNU General Public License as published by
|
|
12 |
* the Free Software Foundation; either version 2 of the License, or
|
|
13 |
* (at your option) any later version.
|
|
14 |
*
|
|
15 |
* This program is distributed in the hope that it will be useful,
|
|
16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
18 |
* GNU General Public License for more details.
|
|
19 |
*
|
|
20 |
* You should have received a copy of the GNU General Public License
|
|
21 |
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
22 |
*/
|
|
23 |
|
|
24 |
#ifndef __LASSO_XMLSEC_SOAP_H__
|
|
25 |
#define __LASSO_XMLSEC_SOAP_H__
|
|
26 |
|
|
27 |
#ifdef __cplusplus
|
|
28 |
extern "C" {
|
|
29 |
#endif /* __cplusplus */
|
|
30 |
|
|
31 |
#include <libxml/tree.h>
|
|
32 |
|
|
33 |
#include <xmlsec/xmlsec.h>
|
|
34 |
#include <xmlsec/xmltree.h>
|
|
35 |
#include <xmlsec/errors.h>
|
|
36 |
|
|
37 |
|
|
38 |
/** Replacement for xmlsec/soap.h */
|
|
39 |
|
|
40 |
#define xmlSecSoap11Ns ((xmlChar*)"http://schemas.xmlsoap.org/soap/envelope/")
|
|
41 |
#define xmlSecSoap12Ns ((xmlChar*)"http://www.w3.org/2003/05/soap-envelope")
|
|
42 |
|
|
43 |
static inline xmlNodePtr
|
|
44 |
xmlSecSoap11GetHeader(xmlNodePtr envNode) {
|
|
45 |
xmlNodePtr cur;
|
|
46 |
|
|
47 |
xmlSecAssert2(envNode != NULL, NULL);
|
|
48 |
|
|
49 |
/* optional Header node is first */
|
|
50 |
cur = xmlSecGetNextElementNode(envNode->children);
|
|
51 |
if((cur != NULL) && xmlSecCheckNodeName(cur, xmlSecNodeHeader, xmlSecSoap11Ns)) {
|
|
52 |
return(cur);
|
|
53 |
}
|
|
54 |
|
|
55 |
return(NULL);
|
|
56 |
}
|
|
57 |
|
|
58 |
static inline xmlNodePtr
|
|
59 |
xmlSecSoap11GetBody(xmlNodePtr envNode) {
|
|
60 |
xmlNodePtr cur;
|
|
61 |
|
|
62 |
xmlSecAssert2(envNode != NULL, NULL);
|
|
63 |
|
|
64 |
/* optional Header node first */
|
|
65 |
cur = xmlSecGetNextElementNode(envNode->children);
|
|
66 |
if((cur != NULL) && xmlSecCheckNodeName(cur, xmlSecNodeHeader, xmlSecSoap11Ns)) {
|
|
67 |
cur = xmlSecGetNextElementNode(cur->next);
|
|
68 |
}
|
|
69 |
|
|
70 |
/* Body node is next */
|
|
71 |
if((cur == NULL) || !xmlSecCheckNodeName(cur, xmlSecNodeBody, xmlSecSoap11Ns)) {
|
|
72 |
xmlSecError(XMLSEC_ERRORS_HERE,
|
|
73 |
NULL,
|
|
74 |
xmlSecErrorsSafeString(xmlSecNodeBody),
|
|
75 |
XMLSEC_ERRORS_R_NODE_NOT_FOUND,
|
|
76 |
XMLSEC_ERRORS_NO_MESSAGE);
|
|
77 |
return(NULL);
|
|
78 |
}
|
|
79 |
|
|
80 |
return(cur);
|
|
81 |
}
|
|
82 |
|
|
83 |
static inline xmlNodePtr
|
|
84 |
xmlSecSoap12GetBody(xmlNodePtr envNode) {
|
|
85 |
xmlNodePtr cur;
|
|
86 |
|
|
87 |
xmlSecAssert2(envNode != NULL, NULL);
|
|
88 |
|
|
89 |
/* optional Header node first */
|
|
90 |
cur = xmlSecGetNextElementNode(envNode->children);
|
|
91 |
if((cur != NULL) && xmlSecCheckNodeName(cur, xmlSecNodeHeader, xmlSecSoap12Ns)) {
|
|
92 |
cur = xmlSecGetNextElementNode(cur->next);
|
|
93 |
}
|
|
94 |
|
|
95 |
/* Body node is next */
|
|
96 |
if((cur == NULL) || !xmlSecCheckNodeName(cur, xmlSecNodeBody, xmlSecSoap12Ns)) {
|
|
97 |
xmlSecError(XMLSEC_ERRORS_HERE,
|
|
98 |
NULL,
|
|
99 |
xmlSecErrorsSafeString(xmlSecNodeBody),
|
|
100 |
XMLSEC_ERRORS_R_NODE_NOT_FOUND,
|
|
101 |
XMLSEC_ERRORS_NO_MESSAGE);
|
|
102 |
return(NULL);
|
|
103 |
}
|
|
104 |
|
|
105 |
return(cur);
|
|
106 |
}
|
|
107 |
|
|
108 |
#ifdef __cplusplus
|
|
109 |
}
|
|
110 |
#endif /* __cplusplus */
|
|
111 |
|
|
112 |
#endif /* __LASSO_XMLSEC_SOAP_H__ */
|
0 |
|
-
|