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

« back to all changes in this revision

Viewing changes to lasso/xml/lib_scoping.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_scoping.c,v 1.5 2004/08/13 15:16:13 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 <glib.h>
 
27
#include <glib/gprintf.h>
 
28
 
 
29
#include <lasso/xml/lib_scoping.h>
 
30
 
 
31
/*
 
32
Schema fragment (liberty-idff-protocols-schema-v1.2.xsd):
 
33
 
 
34
<xs:complexType name="ScopingType">
 
35
  <xs:sequence>
 
36
    <xs:element name="ProxyCount" type="xs:nonNegativeInteger" minOccurs="0"/>
 
37
    <xs:element ref="IDPList" minOccurs="0"/>
 
38
  </xs:sequence>
 
39
</xs:complexType>
 
40
<xs:element name="Scoping" type="ScopingType"/>
 
41
*/
 
42
 
 
43
/*****************************************************************************/
 
44
/* public methods                                                            */
 
45
/*****************************************************************************/
 
46
 
 
47
/**
 
48
 * lasso_lib_scoping_set_proxyCount:
 
49
 * @node      : the pointer to <lib:Scoping/> node object
 
50
 * @proxyCount: the value of "ProxyCount" element (should be superior or equal
 
51
 * to 0).
 
52
 * 
 
53
 * Sets the "ProxyCount" element [optional].
 
54
 *
 
55
 * It's the upper limit on the number of proxying steps the requester wishes to
 
56
 * specify for the authentication request.
 
57
 **/
 
58
void
 
59
lasso_lib_scoping_set_proxyCount(LassoLibScoping *node,
 
60
                                 gint proxyCount)
 
61
{
 
62
  gchar str[6];
 
63
  LassoNodeClass *class;
 
64
 
 
65
  g_assert(LASSO_IS_LIB_SCOPING(node));
 
66
  g_assert(proxyCount >= 0);
 
67
 
 
68
  g_sprintf(str, "%d", proxyCount);
 
69
  class = LASSO_NODE_GET_CLASS(node);
 
70
  class->new_child(LASSO_NODE (node), "ProxyCount", str, FALSE);
 
71
}
 
72
 
 
73
/**
 
74
 * lasso_lib_scoping_set_idpList:
 
75
 * @node   : the pointer to <lib:Scoping/> node object
 
76
 * @idpList: the value of "IDPList" element
 
77
 * 
 
78
 * Sets the "IDPList" element [optional].
 
79
 *
 
80
 * It's an ordered list of identity providers which the requester prefers to
 
81
 * use in authenticating the Principal. This list is a suggestion only, and may
 
82
 * be ignored or added to by the recipient of the message.
 
83
 **/
 
84
void
 
85
lasso_lib_scoping_set_idpList(LassoLibScoping *node,
 
86
                              LassoLibIDPList *idpList)
 
87
{
 
88
  LassoNodeClass *class;
 
89
  g_assert(LASSO_IS_LIB_SCOPING(node));
 
90
  g_assert(LASSO_IS_LIB_IDP_LIST(idpList));
 
91
 
 
92
  class = LASSO_NODE_GET_CLASS(node);
 
93
  class->add_child(LASSO_NODE (node), LASSO_NODE(idpList), FALSE);
 
94
}
 
95
 
 
96
/*****************************************************************************/
 
97
/* instance and class init functions                                         */
 
98
/*****************************************************************************/
 
99
 
 
100
static void
 
101
lasso_lib_scoping_instance_init(LassoLibScoping *node)
 
102
{
 
103
  LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
 
104
 
 
105
  class->set_ns(LASSO_NODE(node), lassoLibHRef, lassoLibPrefix);
 
106
  class->set_name(LASSO_NODE(node), "Scoping");
 
107
}
 
108
 
 
109
static void
 
110
lasso_lib_scoping_class_init(LassoLibScopingClass *klass)
 
111
{
 
112
}
 
113
 
 
114
GType lasso_lib_scoping_get_type() {
 
115
  static GType this_type = 0;
 
116
 
 
117
  if (!this_type) {
 
118
    static const GTypeInfo this_info = {
 
119
      sizeof (LassoLibScopingClass),
 
120
      NULL,
 
121
      NULL,
 
122
      (GClassInitFunc) lasso_lib_scoping_class_init,
 
123
      NULL,
 
124
      NULL,
 
125
      sizeof(LassoLibScoping),
 
126
      0,
 
127
      (GInstanceInitFunc) lasso_lib_scoping_instance_init,
 
128
    };
 
129
    
 
130
    this_type = g_type_register_static(LASSO_TYPE_NODE,
 
131
                                       "LassoLibScoping",
 
132
                                       &this_info, 0);
 
133
  }
 
134
  return this_type;
 
135
}
 
136
 
 
137
/**
 
138
 * lasso_lib_scoping_new:
 
139
 *
 
140
 * Creates a new <lib:Scoping/> node object.
 
141
 *
 
142
 * Specifies any preferences on the number and specific identifiers of
 
143
 * additional identity providers through which the authentication request may
 
144
 * be proxied. The requester may also choose not to include this element, in
 
145
 * which case, the recipient of the message MAY act as a proxy.
 
146
 * 
 
147
 * Return value: a new @LassoLibScoping
 
148
 **/
 
149
LassoNode* lasso_lib_scoping_new()
 
150
{
 
151
  return LASSO_NODE(g_object_new(LASSO_TYPE_LIB_SCOPING, NULL));
 
152
}