1 /* $Id: wsse_reference.c,v 1.0 2005/10/14 15:17:55 fpeters Exp $
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 #include "../private.h"
25 #include "wsse_reference.h"
26 #include "../idwsf_strings.h"
27
28 /*
29 * Schema fragment (oasis-200401-wss-wssecurity-secext-1.0.xsd):
30 *
31 * <xs:complexType name="ReferenceType">
32 * <xs:annotation>
33 * <xs:documentation>This type represents a reference to an external security
34 * token.</xs:documentation>
35 * </xs:annotation>
36 * <xs:attribute name="URI" type="xs:anyURI"/>
37 * <xs:attribute name="ValueType" type="xs:anyURI"/>
38 * <xs:anyAttribute namespace="##other" processContents="lax"/>
39 * </xs:complexType>
40 */
41
42 /*****************************************************************************/
43 /* private methods */
44 /*****************************************************************************/
45
46
47 static struct XmlSnippet schema_snippets[] = {
48 { "URI", SNIPPET_ATTRIBUTE,
49 G_STRUCT_OFFSET(LassoWsSec1Reference, URI), NULL, NULL, NULL},
50 { "ValueType", SNIPPET_ATTRIBUTE,
51 G_STRUCT_OFFSET(LassoWsSec1Reference, ValueType), NULL, NULL, NULL},
52 { "attributes", SNIPPET_ATTRIBUTE | SNIPPET_ANY,
53 G_STRUCT_OFFSET(LassoWsSec1Reference, attributes), NULL, NULL, NULL},
54 {NULL, 0, 0, NULL, NULL, NULL}
55 };
56
57 static LassoNodeClass *parent_class = NULL;
58
59
60 /*****************************************************************************/
61 /* instance and class init functions */
62 /*****************************************************************************/
63
64 static void
instance_init(LassoWsSec1Reference * node)65 instance_init(LassoWsSec1Reference *node)
66 {
67 node->attributes = g_hash_table_new_full(
68 g_str_hash, g_str_equal, g_free, g_free);
69 }
70
71 static void
class_init(LassoWsSec1ReferenceClass * klass,void * unused G_GNUC_UNUSED)72 class_init(LassoWsSec1ReferenceClass *klass, void *unused G_GNUC_UNUSED)
73 {
74 LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
75
76 parent_class = g_type_class_peek_parent(klass);
77 nclass->node_data = g_new0(LassoNodeClassData, 1);
78 lasso_node_class_set_nodename(nclass, "Reference");
79 lasso_node_class_set_ns(nclass, LASSO_WSSE1_HREF, LASSO_WSSE1_PREFIX);
80 lasso_node_class_add_snippets(nclass, schema_snippets);
81 }
82
83 GType
lasso_wsse_reference_get_type()84 lasso_wsse_reference_get_type()
85 {
86 static GType this_type = 0;
87
88 if (!this_type) {
89 static const GTypeInfo this_info = {
90 sizeof (LassoWsSec1ReferenceClass),
91 NULL,
92 NULL,
93 (GClassInitFunc) class_init,
94 NULL,
95 NULL,
96 sizeof(LassoWsSec1Reference),
97 0,
98 (GInstanceInitFunc) instance_init,
99 NULL
100 };
101
102 this_type = g_type_register_static(LASSO_TYPE_NODE,
103 "LassoWsSec1Reference", &this_info, 0);
104 }
105 return this_type;
106 }
107
108 /**
109 * lasso_wsse_reference_new:
110 *
111 * Creates a new #LassoWsSec1Reference object.
112 *
113 * Return value: a newly created #LassoWsSec1Reference object
114 **/
115 LassoWsSec1Reference*
lasso_wsse_reference_new()116 lasso_wsse_reference_new()
117 {
118 return g_object_new(LASSO_TYPE_WSSE_REFERENCE, NULL);
119 }
120