1
/* $Id: authentication_statement.c,v 1.15 2004/09/01 09:59:53 fpeters Exp $
3
* Lasso - A free implementation of the Liberty Alliance specifications.
5
* Copyright (C) 2004 Entr'ouvert
6
* http://lasso.entrouvert.org
8
* Authors: Valery Febvre <vfebvre@easter-eggs.com>
9
* Nicolas Clapies <nclapies@entrouvert.com>
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.
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.
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
26
#include <lasso/protocols/elements/authentication_statement.h>
28
/*****************************************************************************/
30
/*****************************************************************************/
32
/*****************************************************************************/
33
/* instance and class init functions */
34
/*****************************************************************************/
37
lasso_authentication_statement_instance_init(LassoAuthenticationStatement *authentication_statement)
42
lasso_authentication_statement_class_init(LassoAuthenticationStatementClass *class)
46
GType lasso_authentication_statement_get_type() {
47
static GType this_type = 0;
50
static const GTypeInfo this_info = {
51
sizeof (LassoAuthenticationStatementClass),
54
(GClassInitFunc) lasso_authentication_statement_class_init,
57
sizeof(LassoAuthenticationStatement),
59
(GInstanceInitFunc) lasso_authentication_statement_instance_init,
62
this_type = g_type_register_static(LASSO_TYPE_LIB_AUTHENTICATION_STATEMENT,
63
"LassoAuthenticationStatement",
70
lasso_authentication_statement_new(const xmlChar *authenticationMethod,
71
const xmlChar *reauthenticateOnOrAfter,
72
LassoSamlNameIdentifier *sp_identifier,
73
LassoSamlNameIdentifier *idp_identifier)
76
LassoNode *new_identifier, *new_idp_identifier;
77
LassoNode *subject, *subject_confirmation;
81
g_return_val_if_fail(LASSO_IS_SAML_NAME_IDENTIFIER(idp_identifier), NULL);
83
statement = LASSO_NODE(g_object_new(LASSO_TYPE_AUTHENTICATION_STATEMENT,
87
lasso_saml_authentication_statement_set_authenticationMethod(LASSO_SAML_AUTHENTICATION_STATEMENT(statement),
88
authenticationMethod);
89
time = lasso_get_current_time();
90
lasso_saml_authentication_statement_set_authenticationInstant(LASSO_SAML_AUTHENTICATION_STATEMENT(statement),
91
(const xmlChar *)time);
93
lasso_lib_authentication_statement_set_reauthenticateOnOrAfter(LASSO_LIB_AUTHENTICATION_STATEMENT(statement),
94
reauthenticateOnOrAfter);
96
/* use_xsitype = TRUE */
97
subject = lasso_lib_subject_new(TRUE);
98
if (sp_identifier == NULL) {
99
if (idp_identifier != NULL) {
100
new_identifier = lasso_node_copy(LASSO_NODE(idp_identifier));
103
message(G_LOG_LEVEL_CRITICAL, "Failed to create the authentication statement, both name identifiers are NULL\n");
104
lasso_node_destroy(statement);
109
new_identifier = lasso_node_copy(LASSO_NODE(sp_identifier));
111
lasso_saml_subject_set_nameIdentifier(LASSO_SAML_SUBJECT(subject),
112
LASSO_SAML_NAME_IDENTIFIER(new_identifier));
113
lasso_node_destroy(new_identifier);
115
if (sp_identifier != NULL) {
116
/* create a new IdpProvidedNameIdentifier and use idp_identifier data to fill it */
117
str = lasso_node_get_content(LASSO_NODE(idp_identifier), NULL);
118
new_idp_identifier = lasso_lib_idp_provided_name_identifier_new(str);
120
str = lasso_node_get_attr_value(LASSO_NODE(idp_identifier), "NameQualifier", NULL);
122
lasso_saml_name_identifier_set_nameQualifier(LASSO_SAML_NAME_IDENTIFIER(new_idp_identifier), str);
125
str = lasso_node_get_attr_value(LASSO_NODE(idp_identifier), "Format", NULL);
127
lasso_saml_name_identifier_set_format(LASSO_SAML_NAME_IDENTIFIER(new_idp_identifier), str);
130
lasso_lib_subject_set_idpProvidedNameIdentifier(LASSO_LIB_SUBJECT(subject),
131
LASSO_LIB_IDP_PROVIDED_NAME_IDENTIFIER(new_idp_identifier));
132
lasso_node_destroy(new_idp_identifier);
135
/* SubjectConfirmation & Subject */
136
subject_confirmation = lasso_saml_subject_confirmation_new();
137
lasso_saml_subject_confirmation_set_subjectConfirmationMethod(LASSO_SAML_SUBJECT_CONFIRMATION(subject_confirmation),
138
lassoSamlConfirmationMethodBearer);
139
lasso_saml_subject_set_subjectConfirmation(LASSO_SAML_SUBJECT(subject),
140
LASSO_SAML_SUBJECT_CONFIRMATION(subject_confirmation));
142
lasso_saml_subject_statement_abstract_set_subject(LASSO_SAML_SUBJECT_STATEMENT_ABSTRACT(statement),
143
LASSO_SAML_SUBJECT(subject));
145
lasso_node_destroy(subject);
146
lasso_node_destroy(subject_confirmation);