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

« back to all changes in this revision

Viewing changes to lasso/xml/saml_conditions.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: saml_conditions.c,v 1.4 2004/08/13 15:16:13 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/saml_conditions.h>
 
27
 
 
28
/*
 
29
The schema fragment (oasis-sstc-saml-schema-assertion-1.0.xsd):
 
30
 
 
31
<element name="Conditions" type="saml:ConditionsType"/>
 
32
<complexType name="ConditionsType">
 
33
  <choice minOccurs="0" maxOccurs="unbounded">
 
34
    <element ref="saml:AudienceRestrictionCondition"/>
 
35
    <element ref="saml:Condition"/>
 
36
  </choice>
 
37
  <attribute name="NotBefore" type="dateTime" use="optional"/>
 
38
  <attribute name="NotOnOrAfter" type="dateTime" use="optional"/>
 
39
</complexType>
 
40
*/
 
41
 
 
42
/*****************************************************************************/
 
43
/* public methods                                                            */
 
44
/*****************************************************************************/
 
45
 
 
46
/**
 
47
 * lasso_saml_conditions_add_condition:
 
48
 * @node: the <saml:Conditions> node object
 
49
 * @condition: 
 
50
 * 
 
51
 * 
 
52
 **/
 
53
void
 
54
lasso_saml_conditions_add_condition(LassoSamlConditions *node,
 
55
                                    LassoSamlConditionAbstract *condition)
 
56
{
 
57
  LassoNodeClass *class;
 
58
  g_assert(LASSO_IS_SAML_CONDITIONS(node));
 
59
  g_assert(LASSO_IS_SAML_CONDITION_ABSTRACT(condition));
 
60
 
 
61
  class = LASSO_NODE_GET_CLASS(node);
 
62
  class->add_child(LASSO_NODE (node), LASSO_NODE(condition), TRUE);
 
63
}
 
64
 
 
65
/**
 
66
 * lasso_saml_conditions_add_audienceRestrictionCondition:
 
67
 * @node: the <saml:Conditions> node object
 
68
 * @audienceRestrictionCondition: 
 
69
 * 
 
70
 * 
 
71
 **/
 
72
void
 
73
lasso_saml_conditions_add_audienceRestrictionCondition(LassoSamlConditions *node,
 
74
                                                       LassoSamlAudienceRestrictionCondition *audienceRestrictionCondition)
 
75
{
 
76
  LassoNodeClass *class;
 
77
  g_assert(LASSO_IS_SAML_CONDITIONS(node));
 
78
  g_assert(LASSO_IS_SAML_AUDIENCE_RESTRICTION_CONDITION(audienceRestrictionCondition));
 
79
 
 
80
  class = LASSO_NODE_GET_CLASS(node);
 
81
  class->add_child(LASSO_NODE (node), LASSO_NODE(audienceRestrictionCondition), TRUE);
 
82
}
 
83
 
 
84
/**
 
85
 * lasso_saml_conditions_set_notBefore:
 
86
 * @node: the <saml:Conditions> node object
 
87
 * @notBefore: the value of "NotBefore" attribute
 
88
 * 
 
89
 * Sets the "NotBefore" attribute.
 
90
 *
 
91
 * Specifies the earliest time instant at which the assertion is valid. The
 
92
 * time value is encoded in UTC as described in Section 1.2.2
 
93
 * (oasis-sstc-saml-core-1.0.pdf).
 
94
 **/
 
95
void
 
96
lasso_saml_conditions_set_notBefore(LassoSamlConditions *node,
 
97
                                    const xmlChar *notBefore)
 
98
{
 
99
  LassoNodeClass *class;
 
100
  g_assert(LASSO_IS_SAML_CONDITIONS(node));
 
101
  g_assert(notBefore != NULL);
 
102
 
 
103
  class = LASSO_NODE_GET_CLASS(node);
 
104
  class->set_prop(LASSO_NODE (node), "NotBefore", notBefore);
 
105
}
 
106
 
 
107
/**
 
108
 * lasso_saml_conditions_set_notOnOrAfter:
 
109
 * @node: the <saml:Conditions> node object
 
110
 * @notOnOrAfter: the value of "NotOnOrAfter" attribute.
 
111
 * 
 
112
 * Sets the "NotOnOrAfter" attribute.
 
113
 *
 
114
 * Specifies the time instant at which the assertion has expired. The time
 
115
 * value is encoded in UTC as described in Section 1.2.2
 
116
 * (oasis-sstc-saml-core-1.0.pdf).
 
117
 **/
 
118
void
 
119
lasso_saml_conditions_set_notOnOrAfter(LassoSamlConditions *node,
 
120
                                       const xmlChar *notOnOrAfter)
 
121
{
 
122
  LassoNodeClass *class;
 
123
  g_assert(LASSO_IS_SAML_CONDITIONS(node));
 
124
  g_assert(notOnOrAfter != NULL);
 
125
 
 
126
  class = LASSO_NODE_GET_CLASS(node);
 
127
  class->set_prop(LASSO_NODE (node), "NotOnOrAfter", notOnOrAfter);
 
128
}
 
129
 
 
130
/*****************************************************************************/
 
131
/* instance and class init functions                                         */
 
132
/*****************************************************************************/
 
133
 
 
134
static void
 
135
lasso_saml_conditions_instance_init(LassoSamlConditions *node)
 
136
{
 
137
  LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
 
138
 
 
139
  class->set_ns(LASSO_NODE(node), lassoSamlAssertionHRef,
 
140
                lassoSamlAssertionPrefix);
 
141
  class->set_name(LASSO_NODE(node), "Conditions");
 
142
}
 
143
 
 
144
static void
 
145
lasso_saml_conditions_class_init(LassoSamlConditionsClass *klass)
 
146
{
 
147
}
 
148
 
 
149
GType lasso_saml_conditions_get_type()
 
150
{
 
151
  static GType this_type = 0;
 
152
 
 
153
  if (!this_type) {
 
154
    static const GTypeInfo this_info = {
 
155
      sizeof (LassoSamlConditionsClass),
 
156
      NULL,
 
157
      NULL,
 
158
      (GClassInitFunc) lasso_saml_conditions_class_init,
 
159
      NULL,
 
160
      NULL,
 
161
      sizeof(LassoSamlConditions),
 
162
      0,
 
163
      (GInstanceInitFunc) lasso_saml_conditions_instance_init,
 
164
    };
 
165
    
 
166
    this_type = g_type_register_static(LASSO_TYPE_NODE,
 
167
                                       "LassoSamlConditions",
 
168
                                       &this_info, 0);
 
169
  }
 
170
  return this_type;
 
171
}
 
172
 
 
173
/**
 
174
 * lasso_saml_conditions_new:
 
175
 * 
 
176
 * Creates a new <saml:Conditions> node object.
 
177
 *
 
178
 * Return value: the new @LassoSamlConditions
 
179
 **/
 
180
LassoNode* lasso_saml_conditions_new()
 
181
{
 
182
  return LASSO_NODE(g_object_new(LASSO_TYPE_SAML_CONDITIONS, NULL));
 
183
}