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

« back to all changes in this revision

Viewing changes to lasso/xml/lib_assertion.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_assertion.c,v 1.6 2004/09/01 09:59:53 fpeters Exp $
 
2
 *
 
3
 * Lasso - A free implementation of the Liberty 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_assertion.h>
 
27
 
 
28
/*
 
29
Authentication assertions provided in an <AuthnResponse> element MUST be of
 
30
type AssertionType, which is an extension of saml:AssertionType, so that the
 
31
RequestID attribute from the original <AuthnRequest> MAY be included in the
 
32
InResponseTo attribute in the <Assertion> element. This is done because it is
 
33
not required that the <AuthnResponse> element itself be signed. Instead, the
 
34
individual <Assertion> elements contained MUST each be signed. Note that it is
 
35
optional for the InResponseTo to be present. Its absence indicates that the
 
36
<AuthnResponse> has been unilaterally sent by the identity provider without a
 
37
corresponding <AuthnRequest> message from the service provider. If the
 
38
attribute is present, it MUST be set to the RequestID of the original
 
39
<AuthnRequest>.
 
40
 
 
41
The schema fragment is as follows:
 
42
 
 
43
<xs:element name="Assertion" type="AssertionType" substitutionGroup="saml:Assertion" />
 
44
<xs:complexType name="AssertionType">
 
45
  <xs:complexContent>
 
46
    <xs:extension base="saml:AssertionType">
 
47
      <xs:attribute name="InResponseTo" type="xs:NCName" use="optional"/>
 
48
    </xs:extension>
 
49
  </xs:complexContent>
 
50
</xs:complexType>
 
51
 
 
52
*/
 
53
 
 
54
/*****************************************************************************/
 
55
/* public methods                                                            */
 
56
/*****************************************************************************/
 
57
 
 
58
void
 
59
lasso_lib_assertion_set_inResponseTo(LassoLibAssertion *node,
 
60
                                     const xmlChar *inResponseTo)
 
61
{
 
62
  LassoNodeClass *class;
 
63
  g_assert(LASSO_IS_LIB_ASSERTION(node));
 
64
  g_assert(inResponseTo != NULL);
 
65
 
 
66
  class = LASSO_NODE_GET_CLASS(node);
 
67
  class->set_prop(LASSO_NODE (node), "InResponseTo", inResponseTo);
 
68
}
 
69
 
 
70
/*****************************************************************************/
 
71
/* instance and class init functions                                         */
 
72
/*****************************************************************************/
 
73
 
 
74
enum {
 
75
  LASSO_LIB_ASSERTION_USE_XSITYPE = 1
 
76
};
 
77
 
 
78
static void
 
79
lasso_lib_assertion_set_property (GObject      *object,
 
80
                                  guint         property_id,
 
81
                                  const GValue *value,
 
82
                                  GParamSpec   *pspec)
 
83
{
 
84
  LassoLibAssertion *self = LASSO_LIB_ASSERTION(object);
 
85
  LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(object));
 
86
 
 
87
  switch (property_id) {
 
88
  case LASSO_LIB_ASSERTION_USE_XSITYPE:
 
89
    self->use_xsitype = g_value_get_boolean (value);
 
90
    if (self->use_xsitype == TRUE) {
 
91
      /* namespace and name were already set in parent class
 
92
         LassoSamlAssertion */
 
93
      class->new_ns_prop(LASSO_NODE(object),
 
94
                         "type", "lib:AssertionType",
 
95
                         lassoXsiHRef, lassoXsiPrefix);
 
96
    }
 
97
    else {
 
98
      /* node name was already set in parent class LassoSamlAssertion
 
99
         just change ns */
 
100
      class->set_ns(LASSO_NODE(object), lassoLibHRef, lassoLibPrefix);
 
101
    }
 
102
    break;
 
103
  default:
 
104
    /* We don't have any other property... */
 
105
    g_assert (FALSE);
 
106
    break;
 
107
  }
 
108
}
 
109
 
 
110
static void
 
111
lasso_lib_assertion_instance_init(LassoLibAssertion *node)
 
112
{
 
113
}
 
114
 
 
115
static void
 
116
lasso_lib_assertion_class_init(LassoLibAssertionClass *g_class,
 
117
                               gpointer                g_class_data)
 
118
{
 
119
  GObjectClass *gobject_class = G_OBJECT_CLASS (g_class);
 
120
  GParamSpec *pspec;
 
121
 
 
122
  /* override parent class methods */
 
123
  gobject_class->set_property = lasso_lib_assertion_set_property;
 
124
 
 
125
  pspec = g_param_spec_boolean ("use_xsitype",
 
126
                                "use_xsitype",
 
127
                                "using xsi:type",
 
128
                                FALSE,
 
129
                                G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE);
 
130
  g_object_class_install_property (gobject_class,
 
131
                                   LASSO_LIB_ASSERTION_USE_XSITYPE,
 
132
                                   pspec);
 
133
}
 
134
 
 
135
GType lasso_lib_assertion_get_type() {
 
136
  static GType this_type = 0;
 
137
 
 
138
  if (!this_type) {
 
139
    static const GTypeInfo this_info = {
 
140
      sizeof (LassoLibAssertionClass),
 
141
      NULL,
 
142
      NULL,
 
143
      (GClassInitFunc) lasso_lib_assertion_class_init,
 
144
      NULL,
 
145
      NULL,
 
146
      sizeof(LassoLibAssertion),
 
147
      0,
 
148
      (GInstanceInitFunc) lasso_lib_assertion_instance_init,
 
149
    };
 
150
    
 
151
    this_type = g_type_register_static(LASSO_TYPE_SAML_ASSERTION,
 
152
                                       "LassoLibAssertion",
 
153
                                       &this_info, 0);
 
154
  }
 
155
  return this_type;
 
156
}
 
157
 
 
158
LassoNode*
 
159
lasso_lib_assertion_new(gboolean use_xsitype)
 
160
{
 
161
  LassoNode *node;
 
162
 
 
163
  node = LASSO_NODE(g_object_new(LASSO_TYPE_LIB_ASSERTION,
 
164
                                 "use_xsitype", use_xsitype,
 
165
                                 NULL));
 
166
 
 
167
  return node;
 
168
}