~ubuntu-branches/ubuntu/utopic/lasso/utopic-proposed

« back to all changes in this revision

Viewing changes to lasso/xml/lib_subject.c

  • Committer: Bazaar Package Importer
  • Author(s): Frederic Peters
  • Date: 2004-09-13 09:26:34 UTC
  • Revision ID: james.westby@ubuntu.com-20040913092634-01vdfl8j9cp94exa
Tags: upstream-0.4.1
ImportĀ upstreamĀ versionĀ 0.4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: lib_subject.c,v 1.7 2004/09/01 09:59:53 fpeters Exp $
 
2
 *
 
3
 * Lasso - A free implementation of the Samlerty Alliance specifications.
 
4
 *
 
5
 * Copyright (C) 2004 Entr'ouvert
 
6
 * http://lasso.entrouvert.org
 
7
 * 
 
8
 * Authors: Nicolas Clapies <nclapies@entrouvert.com>
 
9
 *          Valery Febvre <vfebvre@easter-eggs.com>
 
10
 *
 
11
 * This program is free software; you can redistribute it and/or modify
 
12
 * it under the terms of the GNU General Public License as published by
 
13
 * the Free Software Foundation; either version 2 of the License, or
 
14
 * (at your option) any later version.
 
15
 * 
 
16
 * This program is distributed in the hope that it will be useful,
 
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
19
 * GNU General Public License for more details.
 
20
 * 
 
21
 * You should have received a copy of the GNU General Public License
 
22
 * along with this program; if not, write to the Free Software
 
23
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
24
 */
 
25
 
 
26
#include <lasso/xml/lib_subject.h>
 
27
 
 
28
/*
 
29
The schema fragment (liberty-idff-protocols-schema-v1.2.xsd):
 
30
 
 
31
<xs:complexType name="SubjectType">
 
32
  <xs:complexContent>
 
33
    <xs:extension base="saml:SubjectType">
 
34
      <xs:sequence>
 
35
        <xs:element ref="IDPProvidedNameIdentifier"/>
 
36
      </xs:sequence>
 
37
    </xs:extension>
 
38
  </xs:complexContent>
 
39
</xs:complexType>
 
40
<xs:element name="Subject" type="SubjectType" substitutionGroup="saml:Subject"/>
 
41
 
 
42
*/
 
43
 
 
44
/*****************************************************************************/
 
45
/* public methods                                                            */
 
46
/*****************************************************************************/
 
47
 
 
48
void
 
49
lasso_lib_subject_set_idpProvidedNameIdentifier(LassoLibSubject *node,
 
50
                                                LassoLibIDPProvidedNameIdentifier *idpProvidedNameIdentifier)
 
51
{
 
52
  LassoNodeClass *class;
 
53
  g_assert(LASSO_IS_LIB_SUBJECT(node));
 
54
  g_assert(LASSO_IS_LIB_IDP_PROVIDED_NAME_IDENTIFIER(idpProvidedNameIdentifier));
 
55
 
 
56
  class = LASSO_NODE_GET_CLASS(node);
 
57
  class->add_child(LASSO_NODE (node), LASSO_NODE(idpProvidedNameIdentifier), FALSE);
 
58
}
 
59
 
 
60
/*****************************************************************************/
 
61
/* instance and class init functions                                         */
 
62
/*****************************************************************************/
 
63
 
 
64
enum {
 
65
  LASSO_LIB_SUBJECT_USE_XSITYPE = 1
 
66
};
 
67
 
 
68
static void
 
69
lasso_lib_subject_set_property (GObject      *object,
 
70
                                guint         property_id,
 
71
                                const GValue *value,
 
72
                                GParamSpec   *pspec)
 
73
{
 
74
  LassoLibSubject *self = LASSO_LIB_SUBJECT(object);
 
75
  LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(object));
 
76
 
 
77
  switch (property_id) {
 
78
  case LASSO_LIB_SUBJECT_USE_XSITYPE:
 
79
    self->use_xsitype = g_value_get_boolean (value);
 
80
    if (self->use_xsitype == TRUE) {
 
81
      /* namespace and name were already set in parent class
 
82
         LassoSamlAssertion */
 
83
      class->new_ns_prop(LASSO_NODE(object),
 
84
                         "type", "lib:SubjectType",
 
85
                         lassoXsiHRef, lassoXsiPrefix);
 
86
    }
 
87
    else {
 
88
      /* node name was already set in parent class LassoSamlAssertion
 
89
         just change ns */
 
90
      class->set_ns(LASSO_NODE(object), lassoLibHRef, lassoLibPrefix);
 
91
    }
 
92
    break;
 
93
  default:
 
94
    /* We don't have any other property... */
 
95
    g_assert (FALSE);
 
96
    break;
 
97
  }
 
98
}
 
99
 
 
100
static void
 
101
lasso_lib_subject_instance_init(LassoLibSubject *node)
 
102
{
 
103
}
 
104
 
 
105
static void
 
106
lasso_lib_subject_class_init(LassoLibSubjectClass *g_class,
 
107
                             gpointer              g_class_data)
 
108
{
 
109
  GObjectClass *gobject_class = G_OBJECT_CLASS (g_class);
 
110
  GParamSpec *pspec;
 
111
 
 
112
  /* override parent class methods */
 
113
  gobject_class->set_property = lasso_lib_subject_set_property;
 
114
 
 
115
  pspec = g_param_spec_boolean ("use_xsitype",
 
116
                                "use_xsitype",
 
117
                                "using xsi:type",
 
118
                                FALSE,
 
119
                                G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE);
 
120
  g_object_class_install_property (gobject_class,
 
121
                                   LASSO_LIB_SUBJECT_USE_XSITYPE,
 
122
                                   pspec);
 
123
}
 
124
 
 
125
GType lasso_lib_subject_get_type() {
 
126
  static GType this_type = 0;
 
127
 
 
128
  if (!this_type) {
 
129
    static const GTypeInfo this_info = {
 
130
      sizeof (LassoLibSubjectClass),
 
131
      NULL,
 
132
      NULL,
 
133
      (GClassInitFunc) lasso_lib_subject_class_init,
 
134
      NULL,
 
135
      NULL,
 
136
      sizeof(LassoLibSubject),
 
137
      0,
 
138
      (GInstanceInitFunc) lasso_lib_subject_instance_init,
 
139
    };
 
140
    
 
141
    this_type = g_type_register_static(LASSO_TYPE_SAML_SUBJECT,
 
142
                                       "LassoLibSubject",
 
143
                                       &this_info, 0);
 
144
  }
 
145
  return this_type;
 
146
}
 
147
 
 
148
LassoNode*
 
149
lasso_lib_subject_new(gboolean use_xsitype)
 
150
{
 
151
  LassoNode *node;
 
152
 
 
153
  node = LASSO_NODE(g_object_new(LASSO_TYPE_LIB_SUBJECT,
 
154
                                 "use_xsitype", use_xsitype,
 
155
                                 NULL));
 
156
 
 
157
  return node;
 
158
}