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

« back to all changes in this revision

Viewing changes to lasso/xml/samlp_request_abstract.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: samlp_request_abstract.c,v 1.14 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 "errors.h"
 
27
 
 
28
#include <lasso/xml/samlp_request_abstract.h>
 
29
 
 
30
/*
 
31
The schema fragment (oasis-sstc-saml-schema-protocol-1.0.xsd):
 
32
 
 
33
<complexType name="RequestAbstractType" abstract="true">
 
34
  <sequence>
 
35
    <element ref="samlp:RespondWith" minOccurs="0" maxOccurs="unbounded"/>
 
36
    <element ref="ds:Signature" minOccurs="0"/>
 
37
  </sequence>
 
38
  <attribute name="RequestID" type="saml:IDType" use="required"/>
 
39
  <attribute name="MajorVersion" type="integer" use="required"/>
 
40
  <attribute name="MinorVersion" type="integer" use="required"/>
 
41
  <attribute name="IssueInstant" type="dateTime" use="required"/>
 
42
</complexType>
 
43
 
 
44
<element name="RespondWith" type="QName"/>
 
45
 
 
46
From oasis-sstc-saml-schema-assertion-1.0.xsd:
 
47
<simpleType name="IDType">
 
48
  <restriction base="string"/>
 
49
</simpleType>
 
50
 
 
51
*/
 
52
 
 
53
/*****************************************************************************/
 
54
/* public methods                                                            */
 
55
/*****************************************************************************/
 
56
 
 
57
void
 
58
lasso_samlp_request_abstract_add_respondWith(LassoSamlpRequestAbstract *node,
 
59
                                             const xmlChar *respondWith)
 
60
{
 
61
  LassoNodeClass *class;
 
62
 
 
63
  if (LASSO_IS_SAMLP_REQUEST_ABSTRACT(node) && respondWith != NULL) {
 
64
    class = LASSO_NODE_GET_CLASS(node);
 
65
    class->new_child(LASSO_NODE (node), "RespondWith", respondWith, TRUE);
 
66
  }
 
67
}
 
68
 
 
69
void
 
70
lasso_samlp_request_abstract_set_issueInstant(LassoSamlpRequestAbstract *node,
 
71
                                              const xmlChar *issueInstant)
 
72
{
 
73
  LassoNodeClass *class;
 
74
 
 
75
  if (LASSO_IS_SAMLP_REQUEST_ABSTRACT(node) && issueInstant != NULL) {
 
76
    class = LASSO_NODE_GET_CLASS(node);
 
77
    class->set_prop(LASSO_NODE (node), "IssueInstant", issueInstant);
 
78
  }
 
79
}
 
80
 
 
81
void
 
82
lasso_samlp_request_abstract_set_majorVersion(LassoSamlpRequestAbstract *node,
 
83
                                              const xmlChar *majorVersion)
 
84
{
 
85
  LassoNodeClass *class;
 
86
 
 
87
  if (LASSO_IS_SAMLP_REQUEST_ABSTRACT(node) && majorVersion != NULL) {
 
88
    class = LASSO_NODE_GET_CLASS(node);
 
89
    class->set_prop(LASSO_NODE (node), "MajorVersion", majorVersion);
 
90
  }
 
91
}
 
92
 
 
93
void
 
94
lasso_samlp_request_abstract_set_minorVersion(LassoSamlpRequestAbstract *node,
 
95
                                              const xmlChar *minorVersion)
 
96
{
 
97
  LassoNodeClass *class;
 
98
 
 
99
  if (LASSO_IS_SAMLP_REQUEST_ABSTRACT(node) && minorVersion != NULL) {
 
100
    class = LASSO_NODE_GET_CLASS(node);
 
101
    class->set_prop(LASSO_NODE (node), "MinorVersion", minorVersion);
 
102
  }
 
103
}
 
104
 
 
105
/**
 
106
 * lasso_samlp_request_abstract_impl_set_requestID:
 
107
 * @node: the pointer to <Samlp:RequestAbstract/> node
 
108
 * @requestID: the RequestID attribute
 
109
 * 
 
110
 * Sets the RequestID attribute (unique)
 
111
 **/
 
112
void
 
113
lasso_samlp_request_abstract_set_requestID(LassoSamlpRequestAbstract *node,
 
114
                                           const xmlChar *requestID)
 
115
{
 
116
  LassoNodeClass *class;
 
117
 
 
118
  if (LASSO_IS_SAMLP_REQUEST_ABSTRACT(node) && requestID != NULL) {
 
119
    class = LASSO_NODE_GET_CLASS(node);
 
120
    class->set_prop(LASSO_NODE (node), "RequestID", requestID);
 
121
  }
 
122
}
 
123
 
 
124
/* obsolete method */
 
125
gint
 
126
lasso_samlp_request_abstract_set_signature(LassoSamlpRequestAbstract *node,
 
127
                                           gint                       sign_method,
 
128
                                           const xmlChar             *private_key_file,
 
129
                                           const xmlChar             *certificate_file)
 
130
{
 
131
  gint ret;
 
132
  LassoNodeClass *class;
 
133
 
 
134
  g_return_val_if_fail(LASSO_IS_SAMLP_REQUEST_ABSTRACT(node),
 
135
                       LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
 
136
 
 
137
  class = LASSO_NODE_GET_CLASS(node);
 
138
 
 
139
  ret = class->add_signature(LASSO_NODE (node), sign_method,
 
140
                             private_key_file, certificate_file);
 
141
 
 
142
  return ret;
 
143
}
 
144
 
 
145
gint
 
146
lasso_samlp_request_abstract_set_signature_tmpl(LassoSamlpRequestAbstract *node,
 
147
                                                lassoSignatureType         sign_type,
 
148
                                                lassoSignatureMethod       sign_method,
 
149
                                                xmlChar                   *reference_id)
 
150
{
 
151
  LassoNodeClass *class;
 
152
 
 
153
  g_return_val_if_fail(LASSO_IS_SAMLP_REQUEST_ABSTRACT(node),
 
154
                       LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
 
155
 
 
156
  class = LASSO_NODE_GET_CLASS(node);
 
157
 
 
158
  return class->add_signature_tmpl(LASSO_NODE (node), sign_type, sign_method, reference_id);
 
159
}
 
160
 
 
161
gint
 
162
lasso_samlp_request_abstract_sign_signature_tmpl(LassoSamlpRequestAbstract *node,
 
163
                                                 const xmlChar             *private_key_file,
 
164
                                                 const xmlChar             *certificate_file)
 
165
{
 
166
  LassoNodeClass *class;
 
167
 
 
168
  g_return_val_if_fail(LASSO_IS_SAMLP_REQUEST_ABSTRACT(node),
 
169
                       LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
 
170
 
 
171
  class = LASSO_NODE_GET_CLASS(node);
 
172
 
 
173
  return(class->sign_signature_tmpl(LASSO_NODE (node), private_key_file,
 
174
                                    certificate_file));
 
175
}
 
176
 
 
177
/*****************************************************************************/
 
178
/* instance and class init functions                                         */
 
179
/*****************************************************************************/
 
180
 
 
181
static void
 
182
lasso_samlp_request_abstract_instance_init(LassoSamlpRequestAbstract *node)
 
183
{
 
184
  LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
 
185
 
 
186
  class->set_ns(LASSO_NODE(node), lassoSamlProtocolHRef,
 
187
                lassoSamlProtocolPrefix);
 
188
  class->set_name(LASSO_NODE(node), "RequestAbstract");
 
189
}
 
190
 
 
191
static void
 
192
lasso_samlp_request_abstract_class_init(LassoSamlpRequestAbstractClass *klass)
 
193
{
 
194
}
 
195
 
 
196
GType lasso_samlp_request_abstract_get_type() {
 
197
  static GType this_type = 0;
 
198
 
 
199
  if (!this_type) {
 
200
    static const GTypeInfo this_info = {
 
201
      sizeof (LassoSamlpRequestAbstractClass),
 
202
      NULL,
 
203
      NULL,
 
204
      (GClassInitFunc) lasso_samlp_request_abstract_class_init,
 
205
      NULL,
 
206
      NULL,
 
207
      sizeof(LassoSamlpRequestAbstract),
 
208
      0,
 
209
      (GInstanceInitFunc) lasso_samlp_request_abstract_instance_init,
 
210
    };
 
211
    
 
212
    this_type = g_type_register_static(LASSO_TYPE_NODE ,
 
213
                                       "LassoSamlpRequestAbstract",
 
214
                                       &this_info, 0);
 
215
  }
 
216
  return this_type;
 
217
}
 
218
 
 
219
LassoNode* lasso_samlp_request_abstract_new() {
 
220
  return LASSO_NODE(g_object_new(LASSO_TYPE_SAMLP_REQUEST_ABSTRACT,
 
221
                                 NULL));
 
222
}