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

« back to all changes in this revision

Viewing changes to lasso/protocols/request.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: request.c,v 1.13 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: Valery Febvre   <vfebvre@easter-eggs.com>
 
9
 *          Nicolas Clapies <nclapies@entrouvert.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/samlp_request.h>
 
27
#include <lasso/protocols/request.h>
 
28
 
 
29
/*****************************************************************************/
 
30
/* functions                                                                 */
 
31
/*****************************************************************************/
 
32
 
 
33
/*****************************************************************************/
 
34
/* public methods                                                            */
 
35
/*****************************************************************************/
 
36
 
 
37
/*****************************************************************************/
 
38
/* instance and class init functions                                         */
 
39
/*****************************************************************************/
 
40
 
 
41
static void
 
42
lasso_request_instance_init(LassoRequest *request)
 
43
{
 
44
}
 
45
 
 
46
static void
 
47
lasso_request_class_init(LassoRequestClass *class)
 
48
{
 
49
}
 
50
 
 
51
GType lasso_request_get_type() {
 
52
  static GType this_type = 0;
 
53
 
 
54
  if (!this_type) {
 
55
    static const GTypeInfo this_info = {
 
56
      sizeof (LassoRequestClass),
 
57
      NULL,
 
58
      NULL,
 
59
      (GClassInitFunc) lasso_request_class_init,
 
60
      NULL,
 
61
      NULL,
 
62
      sizeof(LassoRequest),
 
63
      0,
 
64
      (GInstanceInitFunc) lasso_request_instance_init,
 
65
    };
 
66
    
 
67
    this_type = g_type_register_static(LASSO_TYPE_SAMLP_REQUEST,
 
68
                                       "LassoRequest",
 
69
                                       &this_info, 0);
 
70
  }
 
71
  return this_type;
 
72
}
 
73
 
 
74
LassoNode*
 
75
lasso_request_new(const xmlChar *assertionArtifact)
 
76
{
 
77
  LassoNode *request;
 
78
  xmlChar   *id, *time;
 
79
 
 
80
  request = LASSO_NODE(g_object_new(LASSO_TYPE_REQUEST, NULL));
 
81
  
 
82
  /* Set ONLY required elements/attributes */
 
83
  /* RequestID */
 
84
  id = lasso_build_unique_id(32);
 
85
  lasso_samlp_request_abstract_set_requestID(LASSO_SAMLP_REQUEST_ABSTRACT(request),
 
86
                                             (const xmlChar *)id);
 
87
  xmlFree(id);
 
88
  /* MajorVersion */
 
89
  lasso_samlp_request_abstract_set_majorVersion(LASSO_SAMLP_REQUEST_ABSTRACT(request),
 
90
                                                lassoLibMajorVersion);
 
91
  /* MinorVersion */
 
92
  lasso_samlp_request_abstract_set_minorVersion(LASSO_SAMLP_REQUEST_ABSTRACT(request), 
 
93
                                                lassoLibMinorVersion);
 
94
  /* IssueInstant */
 
95
  time = lasso_get_current_time();
 
96
  lasso_samlp_request_abstract_set_issueInstant(LASSO_SAMLP_REQUEST_ABSTRACT(request),
 
97
                                                (const xmlChar *)time);
 
98
  xmlFree(time);
 
99
 
 
100
  /* Signature template with X509
 
101
     FIXME: signature method */
 
102
  lasso_samlp_request_abstract_set_signature_tmpl(LASSO_SAMLP_REQUEST_ABSTRACT(request),
 
103
                                                  lassoSignatureTypeWithX509,
 
104
                                                  lassoSignatureMethodRsaSha1,
 
105
                                                  NULL);
 
106
 
 
107
  /* AssertionArtifact */
 
108
  lasso_samlp_request_set_assertionArtifact(LASSO_SAMLP_REQUEST(request),
 
109
                                            assertionArtifact);
 
110
  
 
111
  return request;
 
112
}
 
113
 
 
114
LassoNode*
 
115
lasso_request_new_from_export(gchar               *buffer,
 
116
                              lassoNodeExportType  export_type)
 
117
{
 
118
  LassoNode *request=NULL, *soap_node, *request_node;
 
119
  gchar *export;
 
120
 
 
121
  g_return_val_if_fail(buffer != NULL, NULL);
 
122
 
 
123
  request = LASSO_NODE(g_object_new(LASSO_TYPE_REQUEST, NULL));
 
124
 
 
125
  switch (export_type) {
 
126
  case lassoNodeExportTypeXml:
 
127
    lasso_node_import(request, buffer);
 
128
    break;
 
129
  case lassoNodeExportTypeQuery:
 
130
  case lassoNodeExportTypeBase64:
 
131
    break;
 
132
  case lassoNodeExportTypeSoap:
 
133
    soap_node = lasso_node_new_from_dump(buffer);
 
134
    request_node = lasso_node_get_child(soap_node, "Request",
 
135
                                        lassoSamlProtocolHRef, NULL);
 
136
    export = lasso_node_export(request_node);
 
137
    lasso_node_import(request, export);
 
138
    g_free(export);
 
139
    lasso_node_destroy(request_node);
 
140
    lasso_node_destroy(soap_node);
 
141
    break;
 
142
  }
 
143
 
 
144
  return request;
 
145
}