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 #include "private.h"
25 #include "sa_sasl_request.h"
26 #include "idwsf_strings.h"
27
28 /**
29 * SECTION:sa_sasl_request
30 * @short_description: <sa:SASLRequest>
31 *
32 * <figure><title>Schema fragment for sa:SASLRequest</title>
33 * <programlisting><![CDATA[
34 *
35 * <xs:element name="SASLRequest">
36 * <xs:complexType>
37 * <xs:sequence>
38 * <xs:element name="Data" minOccurs="0">
39 * <xs:complexType>
40 * <xs:simpleContent>
41 * <xs:extension base="xs:base64Binary"/>
42 * </xs:simpleContent>
43 * </xs:complexType>
44 * </xs:element>
45 * <xs:element ref="lib:RequestAuthnContext" minOccurs="0"/>
46 * </xs:sequence>
47 * <xs:attribute name="mechanism"type="xs:string" use="required"/>
48 * <xs:attribute name="authzID" type="xs:string" use="optional"/>
49 * <xs:attribute name="advisoryAuthnID" type="xs:string" use="optional"/>
50 * <xs:attribute name="id" type="xs:ID"use="optional"/>
51 * </xs:complexType>
52 * </xs:element>
53 * ]]></programlisting>
54 * </figure>
55 */
56
57 /*****************************************************************************/
58 /* private methods */
59 /*****************************************************************************/
60
61 static struct XmlSnippet schema_snippets[] = {
62 { "Data", SNIPPET_LIST_CONTENT,
63 G_STRUCT_OFFSET(LassoSaSASLRequest, Data), NULL, NULL, NULL},
64 { "RequestAuthnContext", SNIPPET_NODE,
65 G_STRUCT_OFFSET(LassoSaSASLRequest, RequestAuthnContext), NULL, LASSO_LIB_PREFIX,
66 LASSO_LIB_HREF},
67 { "mechanism", SNIPPET_ATTRIBUTE,
68 G_STRUCT_OFFSET(LassoSaSASLRequest, mechanism), NULL, NULL, NULL},
69 { "authzID", SNIPPET_ATTRIBUTE,
70 G_STRUCT_OFFSET(LassoSaSASLRequest, authzID), NULL, NULL, NULL},
71 { "advisoryAuthnID", SNIPPET_ATTRIBUTE,
72 G_STRUCT_OFFSET(LassoSaSASLRequest, advisoryAuthnID), NULL, NULL, NULL},
73 { "id", SNIPPET_ATTRIBUTE,
74 G_STRUCT_OFFSET(LassoSaSASLRequest, id), NULL, NULL, NULL},
75 {NULL, 0, 0, NULL, NULL, NULL}
76 };
77
78 /*****************************************************************************/
79 /* instance and class init functions */
80 /*****************************************************************************/
81
82
83 static void
class_init(LassoSaSASLRequestClass * klass,void * unused G_GNUC_UNUSED)84 class_init(LassoSaSASLRequestClass *klass, void *unused G_GNUC_UNUSED)
85 {
86 LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
87
88 nclass->node_data = g_new0(LassoNodeClassData, 1);
89 lasso_node_class_set_nodename(nclass, "SASLRequest");
90 lasso_node_class_set_ns(nclass, LASSO_SA_HREF, LASSO_SA_PREFIX);
91 lasso_node_class_add_snippets(nclass, schema_snippets);
92 }
93
94 GType
lasso_sa_sasl_request_get_type()95 lasso_sa_sasl_request_get_type()
96 {
97 static GType this_type = 0;
98
99 if (!this_type) {
100 static const GTypeInfo this_info = {
101 sizeof (LassoSaSASLRequestClass),
102 NULL,
103 NULL,
104 (GClassInitFunc) class_init,
105 NULL,
106 NULL,
107 sizeof(LassoSaSASLRequest),
108 0,
109 NULL,
110 NULL
111 };
112
113 this_type = g_type_register_static(LASSO_TYPE_NODE,
114 "LassoSaSASLRequest", &this_info, 0);
115 }
116 return this_type;
117 }
118
119 LassoSaSASLRequest*
lasso_sa_sasl_request_new(const gchar * mechanism)120 lasso_sa_sasl_request_new(const gchar *mechanism)
121 {
122 LassoSaSASLRequest *node;
123
124 g_return_val_if_fail(mechanism != NULL, NULL);
125
126 node = g_object_new(LASSO_TYPE_SA_SASL_REQUEST, NULL);
127 node->mechanism = g_strdup(mechanism);
128
129 return node;
130 }
131