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 "saml_subject.h"
26 
27 /**
28  * SECTION:saml_subject
29  * @short_description: &lt;saml:Subject&gt;
30  *
31  * <figure><title>Schema fragment for saml:Subject</title>
32  * <programlisting><![CDATA[
33  *
34  * <element name="Subject" type="saml:SubjectType"/>
35  * <complexType name="SubjectType">
36  *   <choice>
37  *     <sequence>
38  *       <element ref="saml:NameIdentifier"/>
39  *       <element ref="saml:SubjectConfirmation" minOccurs="0"/>
40  *     </sequence>
41  *     <element ref="saml:SubjectConfirmation"/>
42  *   </choice>
43  * </complexType>
44  * ]]></programlisting>
45  * </figure>
46  */
47 
48 /*****************************************************************************/
49 /* private methods                                                           */
50 /*****************************************************************************/
51 
52 static struct XmlSnippet schema_snippets[] = {
53 	{ "NameIdentifier", SNIPPET_NODE | SNIPPET_JUMP_ON_MISS | SNIPPET_JUMP_2,
54 		G_STRUCT_OFFSET(LassoSamlSubject, NameIdentifier), NULL, NULL, NULL},
55 	{ "EncryptedNameIdentifier", SNIPPET_NODE,
56 		G_STRUCT_OFFSET(LassoSamlSubject, EncryptedNameIdentifier),
57 		"LassoSaml2EncryptedElement", NULL, NULL },
58 	{ "SubjectConfirmation", SNIPPET_NODE,
59 		G_STRUCT_OFFSET(LassoSamlSubject, SubjectConfirmation), NULL, NULL, NULL},
60 	{NULL, 0, 0, NULL, NULL, NULL}
61 };
62 
63 /*****************************************************************************/
64 /* instance and class init functions                                         */
65 /*****************************************************************************/
66 
67 
68 static void
class_init(LassoSamlSubjectClass * klass,void * unused G_GNUC_UNUSED)69 class_init(LassoSamlSubjectClass *klass, void *unused G_GNUC_UNUSED)
70 {
71 	LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
72 
73 	nclass->node_data = g_new0(LassoNodeClassData, 1);
74 	lasso_node_class_set_nodename(nclass, "Subject");
75 	lasso_node_class_set_ns(nclass, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX);
76 	lasso_node_class_add_snippets(nclass, schema_snippets);
77 }
78 
79 GType
lasso_saml_subject_get_type()80 lasso_saml_subject_get_type()
81 {
82 	static GType this_type = 0;
83 
84 	if (!this_type) {
85 		static const GTypeInfo this_info = {
86 			sizeof (LassoSamlSubjectClass),
87 			NULL,
88 			NULL,
89 			(GClassInitFunc) class_init,
90 			NULL,
91 			NULL,
92 			sizeof(LassoSamlSubject),
93 			0,
94 			NULL,
95 			NULL
96 		};
97 
98 		this_type = g_type_register_static(LASSO_TYPE_NODE,
99 				"LassoSamlSubject", &this_info, 0);
100 	}
101 	return this_type;
102 }
103 
104 /**
105  * lasso_saml_subject_new:
106  *
107  * Creates a new #LassoSamlSubject object.
108  *
109  * Return value: a newly created #LassoSamlSubject object
110  **/
lasso_saml_subject_new()111 LassoNode* lasso_saml_subject_new()
112 {
113 	return g_object_new(LASSO_TYPE_SAML_SUBJECT, NULL);
114 }
115