Done with the move to structures and the removal of protocols/ (lasso branched

on October 2nd; occasional merges since then).

- Compatible with current souk test suites.
- Missing memory management for everything in xml/
- Missing xmlsec support for SOAP messages.
This commit is contained in:
Frédéric Péters 2004-10-27 09:49:13 +00:00
parent c411dbc31f
commit f13772d62d
134 changed files with 10655 additions and 12321 deletions

View File

@ -643,8 +643,6 @@ docs/tutorial/Makefile
java/Makefile
lasso/Makefile
lasso/environs/Makefile
lasso/protocols/elements/Makefile
lasso/protocols/Makefile
lasso/xml/Makefile
php/Makefile
php/examples/Makefile

View File

@ -1,4 +1,4 @@
SUBDIRS = xml protocols environs
SUBDIRS = xml environs
liblassoincludedir = $(includedir)/lasso
@ -23,7 +23,6 @@ liblasso_la_SOURCES = lasso.c
if MINGW
liblasso_la_LIBADD = \
$(top_builddir)/lasso/xml/liblasso-xml.la \
$(top_builddir)/lasso/protocols/liblasso-protocols.la \
$(top_builddir)/lasso/environs/liblasso-environs.la \
$(LASSO_LIBS) \
lasso.rc.lo
@ -35,7 +34,6 @@ liblasso_la_LDFLAGS = -no-undefined -version-info @LASSO_VERSION_INFO@ \
else
liblasso_la_LIBADD = \
$(top_builddir)/lasso/xml/liblasso-xml.la \
$(top_builddir)/lasso/protocols/liblasso-protocols.la \
$(top_builddir)/lasso/environs/liblasso-environs.la \
$(LASSO_LIBS)
# Just make damn sure the ABI stays the same between

View File

@ -11,6 +11,7 @@ noinst_LTLIBRARIES = liblasso-environs.la
liblasso_environs_la_SOURCES = \
defederation.c \
federation.c \
identity.c \
lecp.c \
login.c \
@ -18,11 +19,13 @@ liblasso_environs_la_SOURCES = \
name_identifier_mapping.c \
name_registration.c \
profile.c \
provider.c \
server.c \
session.c
liblassoinclude_HEADERS = \
defederation.h \
federation.h \
identity.h \
lecp.h \
login.h \
@ -30,5 +33,6 @@ liblassoinclude_HEADERS = \
name_identifier_mapping.h \
name_registration.h \
profile.h \
provider.h \
server.h \
session.h

View File

@ -30,11 +30,9 @@
#include <lasso/environs/defederation.h>
#include <lasso/xml/errors.h>
static GObjectClass *parent_class = NULL;
struct _LassoDefederationPrivate
{
gboolean dispose_has_run;
gboolean dispose_has_run;
};
/*****************************************************************************/
@ -47,116 +45,88 @@ struct _LassoDefederationPrivate
*
* This method builds the federation termination notification message.
*
* It gets the federation termination notification protocol profile and :
* if it is a SOAP method, then it builds the federation termination notification SOAP message,
* optionaly signs the notification node, set the msg_body attribute, gets the SoapEndpoint
* url and set the msg_url attribute of the federation termination object.
* It gets the federation termination notification protocol profile and:
*
* - if it is a SOAP method, then it builds the federation termination
* notification SOAP message, optionaly signs the notification node, set the
* msg_body attribute, gets the SoapEndpoint url and set the msg_url
* attribute of the federation termination object.
*
* if it is a HTTP-Redirect method, then it builds the federation termination notification QUERY message
* ( optionaly signs the notification message ), builds the federation termination notification url
* with federation termination service url, set the msg_url attribute of the federation termination object,
* set the msg_body to NULL
* - if it is a HTTP-Redirect method, then it builds the federation termination
* notification QUERY message (optionaly signs the notification message),
* builds the federation termination notification url with federation
* termination service url, set the msg_url attribute of the federation
* termination object, set the msg_body to NULL
*
* Return value: O of OK else < 0
**/
gint
lasso_defederation_build_notification_msg(LassoDefederation *defederation)
{
LassoProfile *profile;
LassoProvider *provider;
xmlChar *protocolProfile = NULL;
gchar *url = NULL, *query = NULL;
lassoProviderType remote_provider_type;
gint ret = 0;
LassoProfile *profile;
LassoProvider *remote_provider;
gchar *url = NULL, *query = NULL;
g_return_val_if_fail(LASSO_IS_DEFEDERATION(defederation), -1);
profile = LASSO_PROFILE(defederation);
g_return_val_if_fail(LASSO_IS_DEFEDERATION(defederation),
LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
/* set the remote provider type and get the remote provider object */
if (profile->provider_type == lassoProviderTypeSp) {
remote_provider_type = lassoProviderTypeIdp;
}
else if (profile->provider_type == lassoProviderTypeIdp) {
remote_provider_type = lassoProviderTypeSp;
}
else {
message(G_LOG_LEVEL_CRITICAL, "Invalid provider type\n");
ret = -1;
goto done;
}
provider = lasso_server_get_provider_ref(profile->server,
profile->remote_providerID,
NULL);
if (provider == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Provider %s not found\n", profile->remote_providerID);
ret = -1;
goto done;
}
profile = LASSO_PROFILE(defederation);
/* get the prototocol profile of the logout request */
protocolProfile = lasso_provider_get_singleLogoutProtocolProfile(provider,
remote_provider_type,
NULL);
if (protocolProfile == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Single logout protocol profile not found\n");
ret = -1;
goto done;
}
/* get the remote provider object */
remote_provider = g_hash_table_lookup(profile->server->providers,
profile->remote_providerID);
if (LASSO_IS_PROVIDER(remote_provider) == FALSE) {
message(G_LOG_LEVEL_CRITICAL, "Provider %s not found", profile->remote_providerID);
return -1;
}
/* build the federation termination notification message (SOAP or HTTP-Redirect) */
if (xmlStrEqual(protocolProfile, lassoLibProtocolProfileSloSpSoap) || \
xmlStrEqual(protocolProfile, lassoLibProtocolProfileSloIdpSoap)) {
/* optionaly sign the notification node */
if ( (profile->server->private_key != NULL) && (profile->server->signature_method && profile->server->certificate) ) {
lasso_samlp_request_abstract_set_signature(LASSO_SAMLP_REQUEST_ABSTRACT(profile->request),
profile->server->signature_method,
profile->server->private_key,
profile->server->certificate);
}
/* build the message */
profile->msg_url = lasso_provider_get_soapEndpoint(provider,
remote_provider_type,
NULL);
profile->msg_body = lasso_node_export_to_soap(profile->request);
}
else if (xmlStrEqual(protocolProfile,lassoLibProtocolProfileSloSpHttp) || \
xmlStrEqual(protocolProfile,lassoLibProtocolProfileSloIdpHttp)) {
/* build and optionaly sign the query message and build the federation termination notification url */
url = lasso_provider_get_federationTerminationServiceURL(provider,
remote_provider_type,
NULL);
query = lasso_node_export_to_query(profile->request,
profile->server->signature_method,
profile->server->private_key);
/* get the protocol profile type */
if ( (url == NULL) || (query == NULL) ) {
message(G_LOG_LEVEL_CRITICAL, "%d, Url %s or QUERY %s is NULL\n", remote_provider_type, url, query);
ret = -1;
goto done;
}
/* build the federation termination notification message (SOAP or HTTP-Redirect) */
if (profile->http_request_method == LASSO_HTTP_METHOD_SOAP) {
#if 0 /* XXX: signatures are done differently */
/* sign the request message */
lasso_samlp_request_abstract_sign_signature_tmpl(
LASSO_SAMLP_REQUEST_ABSTRACT(profile->request),
profile->server->private_key,
profile->server->certificate);
#endif
profile->msg_url = g_strdup_printf("%s?%s", url, query);
profile->msg_body = NULL;
}
else {
message(G_LOG_LEVEL_CRITICAL, "Invalid federation termination notification protocol profile\n");
ret = -1;
goto done;
}
/* build the logout request message */
profile->msg_url = lasso_provider_get_metadata_one(remote_provider, "SoapEndpoint");
profile->msg_body = lasso_node_export_to_soap(profile->request);
}
if (profile->http_request_method == LASSO_HTTP_METHOD_REDIRECT) {
/* build and optionaly sign the query message and build the
* federation termination notification url */
url = lasso_provider_get_metadata_one(remote_provider,
"FederationTerminationServiceURL");
if (url == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Unknown profile service URL");
return -1;
}
query = lasso_node_export_to_query(profile->request,
profile->server->signature_method,
profile->server->private_key);
done:
if (protocolProfile != NULL) {
xmlFree(protocolProfile);
}
if (url != NULL) {
xmlFree(url);
}
if (query != NULL) {
xmlFree(query);
}
if (query == NULL) {
g_free(url);
message(G_LOG_LEVEL_CRITICAL, "Error while building request QUERY url");
return -1;
}
return ret;
profile->msg_url = g_strdup_printf("%s?%s", url, query);
g_free(url);
g_free(query);
profile->msg_body = NULL;
}
if (profile->msg_url == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Invalid http method\n");
return LASSO_PROFILE_ERROR_INVALID_HTTP_METHOD;
}
return 0;
}
/**
@ -169,14 +139,14 @@ lasso_defederation_build_notification_msg(LassoDefederation *defederation)
void
lasso_defederation_destroy(LassoDefederation *defederation)
{
g_object_unref(G_OBJECT(defederation));
g_object_unref(G_OBJECT(defederation));
}
/**
* lasso_defederation_init_notification:
* @defederation: the federation termination object
* @remote_providerID: the provider id of the federation termination notified provider.
* If it is set to NULL, then gets the default first remote provider id.
* @remote_providerID: the provider id of the federation termination notified
* provider.
*
* It sets a new federation termination notification to the remote provider id
* with the provider id of the requester (from the server object )
@ -185,250 +155,180 @@ lasso_defederation_destroy(LassoDefederation *defederation)
* Return value: 0 if OK else < 0
**/
gint
lasso_defederation_init_notification(LassoDefederation *defederation,
gchar *remote_providerID,
lassoHttpMethod notification_method)
lasso_defederation_init_notification(LassoDefederation *defederation, gchar *remote_providerID,
lassoHttpMethod http_method)
{
LassoProfile *profile;
LassoProvider *provider;
LassoFederation *federation = NULL;
LassoNode *nameIdentifier = NULL;
xmlChar *content = NULL, *nameQualifier = NULL, *format = NULL;
xmlChar *federationTerminationProtocolProfile;
gint ret = 0;
LassoProfile*profile;
LassoProvider *remote_provider;
LassoFederation *federation;
LassoSamlNameIdentifier *nameIdentifier = NULL;
g_return_val_if_fail(LASSO_IS_DEFEDERATION(defederation), -1);
g_return_val_if_fail(LASSO_IS_DEFEDERATION(defederation),
LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
profile = LASSO_PROFILE(defederation);
profile = LASSO_PROFILE(defederation);
/* set the remote provider id */
if (remote_providerID == NULL) {
profile->remote_providerID = lasso_identity_get_first_providerID(profile->identity);
}
else {
profile->remote_providerID = g_strdup(remote_providerID);
}
if (profile->remote_providerID == NULL) {
message(G_LOG_LEVEL_CRITICAL, "No remote provider id to build the federation termination notification\n");
ret = -1;
goto done;
}
/* set the remote provider id */
profile->remote_providerID = g_strdup(remote_providerID);
/* get federation */
federation = lasso_identity_get_federation(profile->identity, profile->remote_providerID);
if (federation == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Federation not found for %s\n", profile->remote_providerID);
ret = -1;
goto done;
}
if (profile->remote_providerID == NULL) {
message(G_LOG_LEVEL_CRITICAL,
"No remote provider id to send the defederation request");
return -1;
}
/* get the name identifier (!!! depend on the provider type : SP or IDP !!!) */
switch (profile->provider_type) {
case lassoProviderTypeSp:
nameIdentifier = LASSO_NODE(lasso_federation_get_local_nameIdentifier(federation));
if (!nameIdentifier) {
nameIdentifier = LASSO_NODE(lasso_federation_get_remote_nameIdentifier(federation));
}
break;
case lassoProviderTypeIdp:
nameIdentifier = LASSO_NODE(lasso_federation_get_remote_nameIdentifier(federation));
if (!nameIdentifier) {
nameIdentifier = LASSO_NODE(lasso_federation_get_local_nameIdentifier(federation));
}
break;
default:
message(G_LOG_LEVEL_CRITICAL, "Invalid provider type\n");
}
if (!nameIdentifier) {
message(G_LOG_LEVEL_CRITICAL, "Name identifier not found for %s\n", profile->remote_providerID);
ret = -1;
goto done;
}
remote_provider = g_hash_table_lookup(
profile->server->providers, profile->remote_providerID);
if (remote_provider == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Remote provider not found");
return -1;
}
/* Get the content, name qualifier and the format of the name identifier */
/* WARNING : Don't free content, it will be backed up in nameIdentifier attribute of LassoDefederation object */
content = lasso_node_get_content(nameIdentifier, NULL);
nameQualifier = lasso_node_get_attr_value(nameIdentifier, "NameQualifier", NULL);
format = lasso_node_get_attr_value(nameIdentifier, "Format", NULL);
if (content == NULL) {
message(G_LOG_LEVEL_CRITICAL, "NameIdentifier has no content\n");
ret = -1;
goto done;
}
/* get federation */
federation = g_hash_table_lookup(profile->identity->federations,
profile->remote_providerID);
if (federation == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Federation not found for %s",
profile->remote_providerID);
return -1;
}
/* get the protocol profile and set a new federation termination notification object */
provider = lasso_server_get_provider_ref(profile->server, profile->remote_providerID, NULL);
if (provider == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Provider %s not found\n", profile->remote_providerID);
ret = -1;
goto done;
}
/* get the nameIdentifier to send the federation termination notification */
nameIdentifier = lasso_profile_get_nameIdentifier(profile);
if (nameIdentifier == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Name identifier not found for %s",
profile->remote_providerID);
return -1;
}
if (profile->provider_type == lassoProviderTypeIdp) {
federationTerminationProtocolProfile = lasso_provider_get_federationTerminationNotificationProtocolProfile(provider,
lassoProviderTypeSp,
NULL);
}
else if (profile->provider_type == lassoProviderTypeSp) {
federationTerminationProtocolProfile = lasso_provider_get_federationTerminationNotificationProtocolProfile(provider,
lassoProviderTypeIdp,
NULL);
}
else {
message(G_LOG_LEVEL_CRITICAL, "Invalid provider type\n");
ret = -1;
goto done;
}
/* get / verify http method */
if (http_method == LASSO_HTTP_METHOD_ANY) {
http_method = lasso_provider_get_first_http_method(
LASSO_PROVIDER(profile->server),
remote_provider,
LASSO_MD_PROTOCOL_TYPE_FEDERATION_TERMINATION);
} else {
if (lasso_provider_accept_http_method(LASSO_PROVIDER(profile->server),
remote_provider,
LASSO_MD_PROTOCOL_TYPE_FEDERATION_TERMINATION,
http_method,
TRUE) == FALSE) {
message(G_LOG_LEVEL_CRITICAL, "This provider can't initiate this profile");
return LASSO_PROFILE_ERROR_UNSUPPORTED_PROFILE;
}
}
if (federationTerminationProtocolProfile == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Federation termination notification protocol profile not found\n");
ret = -1;
goto done;
}
/* build the request */
if (http_method == LASSO_HTTP_METHOD_SOAP) {
profile->request = lasso_lib_federation_termination_notification_new_full(
LASSO_PROVIDER(profile->server)->ProviderID,
nameIdentifier,
LASSO_SIGNATURE_TYPE_WITHX509,
LASSO_SIGNATURE_METHOD_RSA_SHA1);
}
if (http_method == LASSO_HTTP_METHOD_REDIRECT) {
profile->request = lasso_lib_federation_termination_notification_new_full(
LASSO_PROVIDER(profile->server)->ProviderID,
nameIdentifier,
LASSO_SIGNATURE_TYPE_NONE,
0);
}
if (LASSO_IS_LIB_FEDERATION_TERMINATION_NOTIFICATION(profile->request) == FALSE) {
message(G_LOG_LEVEL_CRITICAL, "Error while building the request");
return -1;
}
/* build the request */
if (xmlStrEqual(federationTerminationProtocolProfile, lassoLibProtocolProfileFedTermSpSoap) || \
xmlStrEqual(federationTerminationProtocolProfile, lassoLibProtocolProfileFedTermIdpSoap)) {
profile->request = lasso_federation_termination_notification_new(profile->server->providerID,
content,
nameQualifier,
format,
lassoSignatureTypeWithX509,
lassoSignatureMethodRsaSha1);
}
else if (xmlStrEqual(federationTerminationProtocolProfile, lassoLibProtocolProfileFedTermSpHttp) || \
xmlStrEqual(federationTerminationProtocolProfile, lassoLibProtocolProfileFedTermIdpHttp)) {
profile->request = lasso_federation_termination_notification_new(profile->server->providerID,
content,
nameQualifier,
format,
lassoSignatureTypeNone,
0);
}
else {
message(G_LOG_LEVEL_CRITICAL, "Invalid federation termination notification protocol profile\n");
ret = -1;
goto done;
}
if (profile->request == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Error while creating the federation termination notification\n");
ret = -1;
goto done;
}
/* Set the nameIdentifier attribute from content local variable */
profile->nameIdentifier = g_strdup(nameIdentifier->content);
/* Set the nameIdentifier attribute from content local variable */
profile->nameIdentifier = content;
content = NULL;
/* remove federation with remote provider id */
if (profile->identity == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Identity not found");
return -1;
}
lasso_identity_remove_federation(profile->identity, profile->remote_providerID);
/* remove federation with remote provider id */
if (profile->identity == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Identity not found\n");
ret = -1;
goto done;
}
lasso_identity_remove_federation(profile->identity, profile->remote_providerID);
/* remove assertion from session */
if (profile->session)
lasso_session_remove_assertion(profile->session, profile->remote_providerID);
/* remove assertion from session */
if (profile->session != NULL) {
lasso_session_remove_assertion(profile->session, profile->remote_providerID);
}
/* Save notification method */
profile->http_request_method = http_method;
done:
if (nameIdentifier != NULL) {
lasso_node_destroy(nameIdentifier);
}
if (federation!=NULL) {
lasso_federation_destroy(federation);
}
if (content != NULL) {
xmlFree(content);
}
if (nameQualifier != NULL) {
xmlFree(nameQualifier);
}
if (format != NULL) {
xmlFree(format);
}
return ret;
return 0;
}
/**
* lasso_defederation_process_notification_msg:
* @defederation: the federation termination object
* @notification_msg: the federation termination notification message
* @notification_method: the federation termination notification method
*
* Process the federation termination notification.
* If it is a SOAP notification method then it builds the federation termination object
* from the SOAP message and optionaly verify the signature.
*
* if it is a HTTP-Redirect notification method then it builds the federation termination notication
* object from the QUERY message and optionaly verify the signature.
*
* Set the msg_nameIdentifier attribute with the NameIdentifier content of the notification object and
* optionaly set the msg_relayState attribute with the RelayState content of the notifcation object
* - if it is a SOAP notification method then it builds the federation
* termination object from the SOAP message and optionaly verify the
* signature.
*
* - if it is a HTTP-Redirect notification method then it builds the
* federation termination notication object from the QUERY message and
* optionaly verify the signature.
*
* Set the msg_nameIdentifier attribute with the NameIdentifier content of the
* notification object and optionaly set the msg_relayState attribute with the
* RelayState content of the notification object
*
* Return value: 0 on success or a negative value otherwise.
**/
gint
lasso_defederation_process_notification_msg(LassoDefederation *defederation,
gchar *notification_msg,
lassoHttpMethod notification_method)
lasso_defederation_process_notification_msg(LassoDefederation *defederation, char *request_msg)
{
LassoProfile *profile;
gint ret = 0;
LassoProfile *profile;
LassoProvider *remote_provider;
LassoMessageFormat format;
g_return_val_if_fail(LASSO_IS_DEFEDERATION(defederation), -1);
g_return_val_if_fail(notification_msg!=NULL, -1);
g_return_val_if_fail(LASSO_IS_DEFEDERATION(defederation),
LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
g_return_val_if_fail(request_msg != NULL, LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
profile = LASSO_PROFILE(defederation);
profile = LASSO_PROFILE(defederation);
switch (notification_method) {
case lassoHttpMethodSoap:
debug("Build a federation termination notification from soap msg\n");
profile->request = lasso_federation_termination_notification_new_from_export(notification_msg, lassoNodeExportTypeSoap);
if (LASSO_IS_FEDERATION_TERMINATION_NOTIFICATION(profile->request) == FALSE) {
message(G_LOG_LEVEL_CRITICAL, lasso_strerror(LASSO_PROFILE_ERROR_INVALID_SOAP_MSG));
ret = LASSO_PROFILE_ERROR_INVALID_SOAP_MSG;
goto done;
}
break;
case lassoHttpMethodRedirect:
debug("Build a federation termination notification from query msg\n");
profile->request = lasso_federation_termination_notification_new_from_export(notification_msg, lassoNodeExportTypeQuery);
if (LASSO_IS_FEDERATION_TERMINATION_NOTIFICATION(profile->request) == FALSE) {
message(G_LOG_LEVEL_CRITICAL, lasso_strerror(LASSO_PROFILE_ERROR_INVALID_QUERY));
ret = LASSO_PROFILE_ERROR_INVALID_QUERY;
goto done;
}
break;
default:
message(G_LOG_LEVEL_CRITICAL, lasso_strerror(LASSO_PROFILE_ERROR_INVALID_HTTP_METHOD));
ret = LASSO_PROFILE_ERROR_INVALID_HTTP_METHOD;
goto done;
}
profile->request = lasso_lib_federation_termination_notification_new();
format = lasso_node_init_from_message(profile->request, request_msg);
/* set the http request method */
profile->http_request_method = notification_method;
if (format == LASSO_MESSAGE_FORMAT_UNKNOWN) {
message(G_LOG_LEVEL_CRITICAL, "XXX");
return LASSO_PROFILE_ERROR_INVALID_MSG;
}
/* get the NameIdentifier */
profile->nameIdentifier = lasso_node_get_child_content(profile->request,
"NameIdentifier", NULL, NULL);
if (profile->nameIdentifier==NULL) {
message(G_LOG_LEVEL_CRITICAL, "NameIdentifier not found\n");
ret = -1;
goto done;
}
profile->remote_providerID = g_strdup(LASSO_LIB_FEDERATION_TERMINATION_NOTIFICATION(
profile->request)->ProviderID);
remote_provider = g_hash_table_lookup(profile->server->providers,
profile->remote_providerID);
if (LASSO_IS_PROVIDER(remote_provider) == FALSE) {
message(G_LOG_LEVEL_CRITICAL, "Unknown provider");
return -1;
}
/* get the RelayState */
profile->msg_relayState = lasso_node_get_child_content(profile->request,
"RelayState", NULL, NULL);
profile->signature_status = lasso_provider_verify_signature(
remote_provider, request_msg, "RequestID");
done:
/* set the http request method */
if (format == LASSO_MESSAGE_FORMAT_SOAP)
profile->http_request_method = LASSO_HTTP_METHOD_SOAP;
if (format == LASSO_MESSAGE_FORMAT_QUERY)
profile->http_request_method = LASSO_HTTP_METHOD_REDIRECT;
return ret;
profile->nameIdentifier = g_strdup(LASSO_LIB_FEDERATION_TERMINATION_NOTIFICATION(
profile->request)->NameIdentifier->content);
/* get the RelayState */
/* XXX: not in schema; some mention in 3.4.1.1.5 (Step 5: Redirecting
* to the Identity Provider Return URL)
*/
return profile->signature_status;
}
/**
@ -436,165 +336,132 @@ lasso_defederation_process_notification_msg(LassoDefederation *defederation,
* @defederation: the federation termination object
*
* Validate the federation termination notification :
* verifies the ProviderID
* if HTTP-Redirect method, set msg_url with the federation termination service return url
* verifies the federation
* verifies the authentication
* - verifies the ProviderID
* - if HTTP-Redirect method, set msg_url with the federation termination
* service return url
* - verifies the federation
* - verifies the authentication
*
* Return value: O if OK else < 0
**/
gint
lasso_defederation_validate_notification(LassoDefederation *defederation)
{
LassoProfile *profile;
LassoProvider *provider;
LassoFederation *federation = NULL;
LassoNode *nameIdentifier = NULL;
gint ret = 0;
gint remote_provider_type;
LassoProfile *profile;
LassoProvider *remote_provider;
LassoFederation *federation = NULL;
LassoSamlNameIdentifier *nameIdentifier;
profile = LASSO_PROFILE(defederation);
g_return_val_if_fail(LASSO_IS_DEFEDERATION(defederation),
LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
/* verify the federation termination notification */
if (profile->request == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Request not found\n");
ret = -1;
goto done;
}
profile = LASSO_PROFILE(defederation);
/* set the remote provider id from the request */
profile->remote_providerID = lasso_node_get_child_content(profile->request,
"ProviderID",
NULL,
NULL);
if (profile->remote_providerID == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Remote provider id not found\n");
ret = -1;
goto done;
}
/* verify the federation termination notification */
if (LASSO_IS_LIB_FEDERATION_TERMINATION_NOTIFICATION(profile->request) == FALSE)
return LASSO_PROFILE_ERROR_MISSING_REQUEST;
/* get the remote provider type */
if (profile->provider_type == lassoProviderTypeSp) {
remote_provider_type = lassoProviderTypeIdp;
}
else if (profile->provider_type == lassoProviderTypeIdp) {
remote_provider_type = lassoProviderTypeSp;
}
else {
message(G_LOG_LEVEL_CRITICAL, "invalid provider type\n");
ret = -1;
goto done;
}
/* If SOAP notification, then msg_url and msg_body are NULL */
/* if HTTP-Redirect notification, set msg_url with the federation
* termination service return url, and set msg_body to NULL */
profile->msg_url = NULL;
profile->msg_body = NULL;
/* If SOAP notification, then msg_url and msg_body are NULL */
/* if HTTP-Redirect notification, set msg_url with the federation termination service return url,
and set msg_body to NULL */
profile->msg_url = NULL;
profile->msg_body = NULL;
if (profile->http_request_method == lassoHttpMethodRedirect) {
provider = lasso_server_get_provider_ref(profile->server, profile->remote_providerID, NULL);
if (provider == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Provider not found\n");
ret = -1;
goto done;
}
if (profile->http_request_method == LASSO_HTTP_METHOD_REDIRECT) {
remote_provider = g_hash_table_lookup(profile->server->providers,
profile->remote_providerID);
if (remote_provider == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Provider not found\n");
return -1;
}
/* build the QUERY and the url. Dont need to sign the query, only the relay state is optinaly added and it is crypted by the notifier */
profile->msg_url = lasso_provider_get_federationTerminationServiceReturnURL(provider,
remote_provider_type,
NULL);
/* build the QUERY and the url. Dont need to sign the query,
* only the relay state is optinaly added and it is crypted
* by the notifier */
profile->msg_url = lasso_provider_get_metadata_one(remote_provider,
"FederationTerminationServiceReturnURL");
if (profile->msg_url == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Unknown profile service return URL");
return -1;
}
if (profile->msg_url == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Federation termination service return url not found\n");
ret = -1;
goto done;
}
/* if a relay state, then build the query part */
if (profile->msg_relayState) {
gchar *url;
url = g_strdup_printf("%s?RelayState=%s",
profile->msg_url, profile->msg_relayState);
g_free(profile->msg_url);
profile->msg_url = url;
}
}
/* if a relay state, then build the query part */
if (profile->msg_relayState != NULL) {
gchar *url;
url = g_strdup_printf("%s?RelayState=%s", profile->msg_url, profile->msg_relayState);
xmlFree(profile->msg_url);
profile->msg_url = url;
}
}
/* get the name identifier */
nameIdentifier = LASSO_LIB_FEDERATION_TERMINATION_NOTIFICATION(
profile->request)->NameIdentifier;
if (nameIdentifier == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Name identifier not found in request");
return -1;
}
/* get the name identifier */
nameIdentifier = lasso_node_get_child(profile->request,
"NameIdentifier",
NULL,
NULL);
if (nameIdentifier == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Name identifier not found in request\n");
ret = -1;
goto done;
}
/* Verify federation */
if (profile->identity == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Identity not found");
return -1;
}
/* Verify federation */
if (profile->identity == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Identity not found\n");
ret = -1;
goto done;
}
federation = g_hash_table_lookup(profile->identity->federations,
profile->remote_providerID);
if (federation == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Federation not found");
return -1;
}
federation = lasso_identity_get_federation(profile->identity, profile->remote_providerID);
if (federation == NULL) {
message(G_LOG_LEVEL_CRITICAL, "No federation for %s\n", profile->remote_providerID);
ret = -1;
goto done;
}
if (lasso_federation_verify_nameIdentifier(federation, nameIdentifier) == FALSE) {
message(G_LOG_LEVEL_CRITICAL, "No name identifier for %s\n",
profile->remote_providerID);
return -1;
}
if (lasso_federation_verify_nameIdentifier(federation, nameIdentifier) == FALSE) {
message(G_LOG_LEVEL_CRITICAL, "No name identifier for %s\n", profile->remote_providerID);
ret = -1;
goto done;
}
/* remove federation of the remote provider */
lasso_identity_remove_federation(profile->identity, profile->remote_providerID);
/* remove federation of the remote provider */
lasso_identity_remove_federation(profile->identity, profile->remote_providerID);
/* if defederation has a session and if there is an assertion for remote provider id,
then remove assertion too */
if (profile->session != NULL) {
lasso_session_remove_assertion(profile->session, profile->remote_providerID);
}
/* if defederation has a session and if there is an assertion for remote provider id, then remove assertion too */
if (profile->session != NULL) {
lasso_session_remove_assertion(profile->session, profile->remote_providerID);
}
done:
if (federation != NULL) {
lasso_federation_destroy(federation);
}
if (nameIdentifier != NULL) {
lasso_node_destroy(nameIdentifier);
}
return ret;
return 0;
}
/*****************************************************************************/
/* overrided parent class methods */
/*****************************************************************************/
static LassoNodeClass *parent_class = NULL;
static void
lasso_defederation_dispose(LassoDefederation *defederation)
dispose(GObject *object)
{
if (defederation->private->dispose_has_run == TRUE) {
return;
}
defederation->private->dispose_has_run = TRUE;
LassoDefederation *defederation = LASSO_DEFEDERATION(object);
if (defederation->private->dispose_has_run == TRUE) {
return;
}
defederation->private->dispose_has_run = TRUE;
debug("Defederation object 0x%x disposed ...\n", defederation);
/* unref reference counted objects */
parent_class->dispose(G_OBJECT(defederation));
debug("Defederation object 0x%x disposed ...\n", defederation);
G_OBJECT_CLASS(parent_class)->dispose(object);
}
static void
lasso_defederation_finalize(LassoDefederation *defederation)
finalize(GObject *object)
{
g_free (defederation->private);
parent_class->finalize(G_OBJECT(defederation));
debug("Defederation object 0x%x finalized ...\n", defederation);
LassoDefederation *defederation = LASSO_DEFEDERATION(object);
debug("Defederation object 0x%x finalized ...\n", defederation);
g_free (defederation->private);
G_OBJECT_CLASS(parent_class)->finalize(object);
}
/*****************************************************************************/
@ -602,47 +469,48 @@ lasso_defederation_finalize(LassoDefederation *defederation)
/*****************************************************************************/
static void
lasso_defederation_instance_init(GTypeInstance *instance,
gpointer g_class)
instance_init(LassoDefederation *defederation)
{
LassoDefederation *defederation = LASSO_DEFEDERATION(instance);
defederation->private = g_new (LassoDefederationPrivate, 1);
defederation->private->dispose_has_run = FALSE;
defederation->private = g_new (LassoDefederationPrivate, 1);
defederation->private->dispose_has_run = FALSE;
}
static void
lasso_defederation_class_init(LassoDefederationClass *class)
class_init(LassoDefederationClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS(class);
parent_class = g_type_class_peek_parent(klass);
parent_class = g_type_class_peek_parent(class);
/* override parent class methods */
gobject_class->dispose = (void *)lasso_defederation_dispose;
gobject_class->finalize = (void *)lasso_defederation_finalize;
/* no dump needed
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
*/
G_OBJECT_CLASS(klass)->dispose = dispose;
G_OBJECT_CLASS(klass)->finalize = finalize;
}
GType lasso_defederation_get_type() {
static GType this_type = 0;
GType
lasso_defederation_get_type()
{
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoDefederationClass),
NULL,
NULL,
(GClassInitFunc) lasso_defederation_class_init,
NULL,
NULL,
sizeof(LassoDefederation),
0,
(GInstanceInitFunc) lasso_defederation_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_PROFILE,
"LassoDefederation",
&this_info, 0);
}
return this_type;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoDefederationClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoDefederation),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_PROFILE,
"LassoDefederation", &this_info, 0);
}
return this_type;
}
/**
@ -666,18 +534,15 @@ GType lasso_defederation_get_type() {
* Return value: a new instance of federation termination object or NULL
**/
LassoDefederation*
lasso_defederation_new(LassoServer *server,
lassoProviderType provider_type)
lasso_defederation_new(LassoServer *server)
{
LassoDefederation *defederation;
LassoDefederation *defederation;
g_return_val_if_fail(LASSO_IS_SERVER(server), NULL);
g_return_val_if_fail(LASSO_IS_SERVER(server), NULL);
/* set the defederation object */
defederation = g_object_new(LASSO_TYPE_DEFEDERATION,
"server", lasso_server_copy(server),
"provider_type", provider_type,
NULL);
defederation = g_object_new(LASSO_TYPE_DEFEDERATION, NULL);
LASSO_PROFILE(defederation)->server = server;
return defederation;
return defederation;
}

View File

@ -31,7 +31,7 @@ extern "C" {
#endif /* __cplusplus */
#include <lasso/environs/profile.h>
#include <lasso/protocols/federation_termination_notification.h>
#include <lasso/xml/lib_federation_termination_notification.h>
#define LASSO_TYPE_DEFEDERATION (lasso_defederation_get_type())
#define LASSO_DEFEDERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_DEFEDERATION, LassoDefederation))
@ -45,22 +45,18 @@ typedef struct _LassoDefederationClass LassoDefederationClass;
typedef struct _LassoDefederationPrivate LassoDefederationPrivate;
struct _LassoDefederation {
LassoProfile parent;
/*< private >*/
LassoDefederationPrivate *private;
LassoProfile parent;
/*< private >*/
LassoDefederationPrivate *private;
};
struct _LassoDefederationClass {
LassoProfileClass parent;
LassoProfileClass parent;
};
LASSO_EXPORT GType lasso_defederation_get_type (void);
LASSO_EXPORT LassoDefederation *lasso_defederation_new (LassoServer *server,
lassoProviderType provider_type);
LASSO_EXPORT LassoDefederation *lasso_defederation_new (LassoServer *server);
LASSO_EXPORT gint lasso_defederation_build_notification_msg (LassoDefederation *defederation);
@ -72,8 +68,7 @@ LASSO_EXPORT gint lasso_defederation_init_notification (LassoDefederation
lassoHttpMethod notification_method);
LASSO_EXPORT gint lasso_defederation_process_notification_msg (LassoDefederation *defederation,
gchar *notification_msg,
lassoHttpMethod notification_method);
gchar *notification_msg);
LASSO_EXPORT gint lasso_defederation_validate_notification (LassoDefederation *defederation);

306
lasso/id-ff/federation.c Normal file
View File

@ -0,0 +1,306 @@
/* $Id$
*
* Lasso - A free implementation of the Liberty Alliance specifications.
*
* Copyright (C) 2004 Entr'ouvert
* http://lasso.entrouvert.org
*
* Authors: Nicolas Clapies <nclapies@entrouvert.com>
* Valery Febvre <vfebvre@easter-eggs.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <lasso/environs/federation.h>
struct _LassoFederationPrivate
{
gboolean dispose_has_run;
};
/*****************************************************************************/
/* static methods/functions */
/*****************************************************************************/
static LassoSamlNameIdentifier*
lasso_federation_build_nameIdentifier(const gchar *nameQualifier,
const gchar *format,
const gchar *content)
{
LassoSamlNameIdentifier *nameIdentifier;
if (content == NULL) {
nameIdentifier = LASSO_SAML_NAME_IDENTIFIER(lasso_saml_name_identifier_new());
nameIdentifier->content = lasso_build_unique_id(32);
} else {
nameIdentifier = LASSO_SAML_NAME_IDENTIFIER(lasso_saml_name_identifier_new());
nameIdentifier->content = g_strdup(content);
}
nameIdentifier->NameQualifier = g_strdup(nameQualifier);
nameIdentifier->Format = g_strdup(format);
return nameIdentifier;
}
/*****************************************************************************/
/* public methods */
/*****************************************************************************/
void
lasso_federation_build_local_nameIdentifier(LassoFederation *federation,
const gchar *nameQualifier,
const gchar *format,
const gchar *content)
{
federation->local_nameIdentifier = lasso_federation_build_nameIdentifier(
nameQualifier, format, content);
}
void
lasso_federation_set_local_name_identifier(LassoFederation *federation,
LassoSamlNameIdentifier *name_identifier)
{
if (federation->local_nameIdentifier)
g_object_unref(federation->local_nameIdentifier);
federation->local_nameIdentifier = g_object_ref(name_identifier);
}
void
lasso_federation_set_remote_name_identifier(LassoFederation *federation,
LassoSamlNameIdentifier *name_identifier)
{
if (federation->remote_nameIdentifier)
g_object_unref(federation->remote_nameIdentifier);
federation->remote_nameIdentifier = g_object_ref(name_identifier);
}
void
lasso_federation_destroy(LassoFederation *federation)
{
g_object_unref(G_OBJECT(federation));
}
gboolean
lasso_federation_verify_nameIdentifier(LassoFederation *federation,
LassoSamlNameIdentifier *nameIdentifier)
{
char *s;
/* XXX: verify_nameIdentifier only checks content; what about Format
* and NameQualifier ? */
g_return_val_if_fail(LASSO_IS_FEDERATION(federation), FALSE);
g_return_val_if_fail(LASSO_IS_NODE(nameIdentifier), FALSE);
/* verify local name identifier */
if (federation->local_nameIdentifier != NULL) {
s = federation->local_nameIdentifier->content;
if (strcmp(s, nameIdentifier->content) == 0) {
return TRUE;
}
}
/* verify remote name identifier */
if (federation->remote_nameIdentifier != NULL) {
s = federation->remote_nameIdentifier->content;
if (strcmp(s, nameIdentifier->content) == 0) {
return TRUE;
}
}
return FALSE;
}
/*****************************************************************************/
/* private methods */
/*****************************************************************************/
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode, *t;
LassoFederation *federation = LASSO_FEDERATION(node);
xmlnode = xmlNewNode(NULL, "Federation");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LASSO_HREF, NULL));
xmlSetProp(xmlnode, "Version", "2");
if (federation->remote_providerID)
xmlNewTextChild(xmlnode, NULL, "RemoteProviderID", federation->remote_providerID);
if (federation->local_nameIdentifier) {
t = xmlNewTextChild(xmlnode, NULL, "LocalNameIdentifier", NULL);
xmlAddChild(t, lasso_node_get_xmlNode(
LASSO_NODE(federation->local_nameIdentifier)));
}
if (federation->remote_nameIdentifier) {
t = xmlNewTextChild(xmlnode, NULL, "RemoteNameIdentifier", NULL);
xmlAddChild(t, lasso_node_get_xmlNode(
LASSO_NODE(federation->remote_nameIdentifier)));
}
return xmlnode;
}
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoFederation *federation = LASSO_FEDERATION(node);
xmlNode *t, *n;
t = xmlnode->children;
while (t) {
if (t->type != XML_ELEMENT_NODE) {
t = t->next;
continue;
}
if (strcmp(t->name, "RemoteProviderID") == 0)
federation->remote_providerID = xmlNodeGetContent(t);
if (strcmp(t->name, "LocalNameIdentifier") == 0) {
n = t->children;
while (n && n->type != XML_ELEMENT_NODE) n = n->next;
if (n) {
federation->local_nameIdentifier = LASSO_SAML_NAME_IDENTIFIER(
lasso_node_new_from_xmlNode(n));
}
}
if (strcmp(t->name, "RemoteNameIdentifier") == 0) {
n = t->children;
while (n && n->type != XML_ELEMENT_NODE) n = n->next;
if (n) {
federation->remote_nameIdentifier = LASSO_SAML_NAME_IDENTIFIER(
lasso_node_new_from_xmlNode(n));
}
}
t = t->next;
}
}
/*****************************************************************************/
/* overrided parent class methods */
/*****************************************************************************/
static void
dispose(GObject *object)
{
LassoFederation *federation = LASSO_FEDERATION(object);
if (federation->private->dispose_has_run) {
return;
}
federation->private->dispose_has_run = TRUE;
debug("Federation object 0x%x disposed ...\n", federation);
/* unref reference counted objects */
lasso_node_destroy(LASSO_NODE(federation->local_nameIdentifier));
lasso_node_destroy(LASSO_NODE(federation->remote_nameIdentifier));
G_OBJECT_CLASS(parent_class)->dispose(object);
}
static void
finalize(GObject *object)
{
LassoFederation *federation = LASSO_FEDERATION(object);
debug("Federation object 0x%x finalized ...\n", federation);
g_free(federation->remote_providerID);
g_free(federation->private);
G_OBJECT_CLASS(parent_class)->finalize(object);
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
instance_init(LassoFederation *federation)
{
federation->private = g_new (LassoFederationPrivate, 1);
federation->private->dispose_has_run = FALSE;
federation->remote_providerID = NULL;
federation->local_nameIdentifier = NULL;
federation->remote_nameIdentifier = NULL;
}
static void
class_init(LassoFederationClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
G_OBJECT_CLASS(klass)->dispose = dispose;
G_OBJECT_CLASS(klass)->finalize = finalize;
}
GType
lasso_federation_get_type()
{
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoFederationClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoFederation),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoFederation", &this_info, 0);
}
return this_type;
}
LassoFederation*
lasso_federation_new(gchar *remote_providerID)
{
LassoFederation *federation;
g_return_val_if_fail(remote_providerID != NULL, NULL);
federation = LASSO_FEDERATION(g_object_new(LASSO_TYPE_FEDERATION, NULL));
federation->remote_providerID = g_strdup(remote_providerID);
return federation;
}
LassoFederation*
lasso_federation_new_from_dump(gchar *dump)
{
LassoFederation *federation;
g_return_val_if_fail(dump != NULL, NULL);
federation = LASSO_FEDERATION(g_object_new(LASSO_TYPE_FEDERATION, NULL));
return federation;
}

89
lasso/id-ff/federation.h Normal file
View File

@ -0,0 +1,89 @@
/* $Id$
*
* Lasso - A free implementation of the Liberty Alliance specifications.
*
* Copyright (C) 2004 Entr'ouvert
* http://lasso.entrouvert.org
*
* Authors: Nicolas Clapies <nclapies@entrouvert.com>
* Valery Febvre <vfebvre@easter-eggs.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __LASSO_FEDERATION_H__
#define __LASSO_FEDERATION_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <lasso/xml/xml.h>
#include <lasso/xml/saml_name_identifier.h>
#define LASSO_TYPE_FEDERATION (lasso_federation_get_type())
#define LASSO_FEDERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_FEDERATION, LassoFederation))
#define LASSO_FEDERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), LASSO_TYPE_FEDERATION, LassoFederationClass))
#define LASSO_IS_FEDERATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), LASSO_TYPE_FEDERATION))
#define LASSO_IS_FEDERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LASSO_TYPE_FEDERATION))
#define LASSO_FEDERATION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), LASSO_TYPE_FEDERATION, LassoFederationClass))
#define LASSO_FEDERATION_NODE "Federation"
#define LASSO_FEDERATION_REMOTE_PROVIDERID_NODE "RemoteProviderID"
#define LASSO_FEDERATION_LOCAL_NAME_IDENTIFIER_NODE "LocalNameIdentifier"
#define LASSO_FEDERATION_REMOTE_NAME_IDENTIFIER_NODE "RemoteNameIdentifier"
typedef struct _LassoFederation LassoFederation;
typedef struct _LassoFederationClass LassoFederationClass;
typedef struct _LassoFederationPrivate LassoFederationPrivate;
struct _LassoFederation {
LassoNode parent;
gchar *remote_providerID;
LassoSamlNameIdentifier *local_nameIdentifier;
LassoSamlNameIdentifier *remote_nameIdentifier;
/*< private >*/
LassoFederationPrivate *private;
};
struct _LassoFederationClass {
LassoNodeClass parent;
};
LASSO_EXPORT GType lasso_federation_get_type(void);
LASSO_EXPORT LassoFederation* lasso_federation_new(gchar *remote_providerID);
LASSO_EXPORT void lasso_federation_build_local_nameIdentifier(LassoFederation *federation,
const gchar *nameQualifier, const gchar *format, const gchar *content);
LASSO_EXPORT void lasso_federation_set_local_name_identifier(LassoFederation *federation,
LassoSamlNameIdentifier *name_identifier);
LASSO_EXPORT void lasso_federation_set_remote_name_identifier(LassoFederation *federation,
LassoSamlNameIdentifier *name_identifier);
LASSO_EXPORT void lasso_federation_destroy(LassoFederation *federation);
LASSO_EXPORT gboolean lasso_federation_verify_nameIdentifier(
LassoFederation *federation, LassoSamlNameIdentifier *nameIdentifier);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __LASSO_FEDERATION_H__ */

View File

@ -25,292 +25,133 @@
#include <lasso/environs/identity.h>
#include <lasso/lasso_config.h>
#define LASSO_IDENTITY_NODE "Identity"
#define LASSO_IDENTITY_FEDERATIONS_NODE "Federations"
#define LASSO_IDENTITY_FEDERATION_NODE "Federation"
#define LASSO_IDENTITY_REMOTE_PROVIDERID_ATTR "RemoteProviderID"
struct _LassoIdentityPrivate
{
gboolean dispose_has_run;
gboolean dispose_has_run;
};
static GObjectClass *parent_class = NULL;
/*****************************************************************************/
/* private functions */
/*****************************************************************************/
static void
lasso_identity_copy_federation(gpointer key,
gpointer value,
gpointer federations)
{
g_hash_table_insert((GHashTable *)federations, g_strdup((gchar *)key),
lasso_federation_copy(LASSO_FEDERATION(value)));
}
static void
lasso_identity_dump_federation(gpointer key,
gpointer value,
LassoNode *federations)
{
LassoNode *federation_node;
LassoNodeClass *federation_class;
xmlChar *dump;
dump = lasso_federation_dump(LASSO_FEDERATION(value));
federation_node = lasso_node_new_from_dump(dump);
xmlFree(dump);
federation_class = LASSO_NODE_GET_CLASS(federation_node);
federation_class->add_child(federations, federation_node, TRUE);
lasso_node_destroy(federation_node);
}
/*****************************************************************************/
/* public methods */
/*****************************************************************************/
gint
lasso_identity_add_federation(LassoIdentity *identity,
gchar *remote_providerID,
LassoFederation *federation)
lasso_identity_add_federation(LassoIdentity *identity, LassoFederation *federation)
{
gboolean found = FALSE;
int i;
g_return_val_if_fail(LASSO_IS_IDENTITY(identity), -1);
g_return_val_if_fail(LASSO_IS_FEDERATION(federation), -3);
g_return_val_if_fail(LASSO_IS_IDENTITY(identity), -1);
g_return_val_if_fail(remote_providerID != NULL, -2);
g_return_val_if_fail(LASSO_IS_FEDERATION(federation), -3);
/* add the federation, replace if one already exists */
g_hash_table_insert(identity->federations,
g_strdup(federation->remote_providerID), federation);
identity->is_dirty = TRUE;
/* add the remote provider id if not already saved */
for (i = 0; i<identity->providerIDs->len; i++) {
if(xmlStrEqual(remote_providerID, g_ptr_array_index(identity->providerIDs, i))) {
found = TRUE;
break;
}
}
if (found == TRUE) {
debug("A federation existed already for this providerID, it was replaced by the new one.\n");
}
else {
g_ptr_array_add(identity->providerIDs, g_strdup(remote_providerID));
}
/* add the federation, replace if one already exists */
g_hash_table_insert(identity->federations, g_strdup(remote_providerID),
lasso_federation_copy(federation));
identity->is_dirty = TRUE;
return 0;
return 0;
}
LassoIdentity*
lasso_identity_copy(LassoIdentity *identity)
gint
lasso_identity_remove_federation(LassoIdentity *identity, char *remote_providerID)
{
LassoIdentity *copy;
guint i;
if (identity == NULL) {
return NULL;
}
copy = LASSO_IDENTITY(g_object_new(LASSO_TYPE_IDENTITY, NULL));
copy->providerIDs = g_ptr_array_new();
for(i=0; i<identity->providerIDs->len; i++) {
g_ptr_array_add(copy->providerIDs,
g_strdup(g_ptr_array_index(identity->providerIDs, i)));
}
copy->federations = g_hash_table_new_full(g_str_hash, g_str_equal,
(GDestroyNotify)g_free,
(GDestroyNotify)lasso_node_destroy);
g_hash_table_foreach(identity->federations, (GHFunc)lasso_identity_copy_federation,
(gpointer)copy->federations);
copy->is_dirty = identity->is_dirty;
return copy;
if (g_hash_table_remove(identity->federations, remote_providerID) == FALSE) {
debug("Failed to remove federation for remote Provider %s", remote_providerID);
return -1;
}
identity->is_dirty = TRUE;
return 0;
}
void
lasso_identity_destroy(LassoIdentity *identity)
{
if (LASSO_IS_IDENTITY(identity)) {
g_object_unref(G_OBJECT(identity));
}
if (LASSO_IS_IDENTITY(identity)) {
g_object_unref(G_OBJECT(identity));
}
}
gchar*
lasso_identity_dump(LassoIdentity *identity)
/*****************************************************************************/
/* private methods */
/*****************************************************************************/
static LassoNodeClass *parent_class = NULL;
static void
add_federation_childnode(gchar *key, LassoFederation *value, xmlNode *xmlnode)
{
LassoNode *identity_node, *federations_node;
int table_size;
gchar *dump;
g_return_val_if_fail(identity != NULL, NULL);
identity_node = lasso_node_new();
LASSO_NODE_GET_CLASS(identity_node)->set_name(identity_node, LASSO_IDENTITY_NODE);
LASSO_NODE_GET_CLASS(identity_node)->set_ns(identity_node, lassoLassoHRef, NULL);
/* Add lasso version in the xml node */
LASSO_NODE_GET_CLASS(identity_node)->set_prop(LASSO_NODE(identity_node), "version", PACKAGE_VERSION);
/* dump the federations */
table_size = g_hash_table_size(identity->federations);
if (table_size > 0) {
federations_node = lasso_node_new();
LASSO_NODE_GET_CLASS(federations_node)->set_name(federations_node,
LASSO_IDENTITY_FEDERATIONS_NODE);
g_hash_table_foreach(identity->federations, (GHFunc)lasso_identity_dump_federation,
federations_node);
LASSO_NODE_GET_CLASS(identity_node)->add_child(identity_node, federations_node, FALSE);
lasso_node_destroy(federations_node);
}
dump = lasso_node_export(identity_node);
lasso_node_destroy(identity_node);
return dump;
xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(value)));
}
LassoFederation*
lasso_identity_get_federation(LassoIdentity *identity,
gchar *remote_providerID)
static xmlNode*
get_xmlNode(LassoNode *node)
{
LassoFederation *federation;
xmlNode *xmlnode;
LassoIdentity *identity = LASSO_IDENTITY(node);
g_return_val_if_fail(identity != NULL, NULL);
g_return_val_if_fail(remote_providerID != NULL, NULL);
xmlnode = xmlNewNode(NULL, "Identity");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LASSO_HREF, NULL));
xmlSetProp(xmlnode, "Version", "2");
federation = lasso_identity_get_federation_ref(identity, remote_providerID);
if (federation != NULL) {
return lasso_federation_copy(federation);
}
if (g_hash_table_size(identity->federations))
g_hash_table_foreach(identity->federations,
(GHFunc)add_federation_childnode, xmlnode);
return NULL;
return xmlnode;
}
LassoFederation*
lasso_identity_get_federation_ref(LassoIdentity *identity,
gchar *remote_providerID)
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoFederation *federation;
LassoIdentity *identity = LASSO_IDENTITY(node);
xmlNode *t;
g_return_val_if_fail(identity != NULL, NULL);
g_return_val_if_fail(remote_providerID != NULL, NULL);
t = xmlnode->children;
while (t) {
if (t->type != XML_ELEMENT_NODE) {
t = t->next;
continue;
}
federation = (LassoFederation *)g_hash_table_lookup(identity->federations,
remote_providerID);
if (federation == NULL) {
debug("No Federation found with remote ProviderID = %s\n", remote_providerID);
return NULL;
}
if (strcmp(t->name, "Federation") == 0) {
LassoFederation *federation;
federation = LASSO_FEDERATION(lasso_node_new_from_xmlNode(t));
g_hash_table_insert(
identity->federations,
g_strdup(federation->remote_providerID), federation);
}
return federation;
t = t->next;
}
}
gchar*
lasso_identity_get_first_providerID(LassoIdentity *identity)
{
gchar *remote_providerID;
g_return_val_if_fail(identity!=NULL, NULL);
if (identity->providerIDs->len == 0) {
return NULL;
}
remote_providerID = g_strdup(g_ptr_array_index(identity->providerIDs, 0));
return remote_providerID;
}
gchar*
lasso_identity_get_next_federation_remote_providerID(LassoIdentity *identity)
{
/* FIXME ABI : lasso_identity_get_next_federation_remote_providerID method is obsolete, use lasso_identity_get_first_providerID instead */
return lasso_identity_get_first_providerID(identity);
}
gint
lasso_identity_remove_federation(LassoIdentity *identity,
gchar *remote_providerID)
{
LassoFederation *federation;
int i;
g_return_val_if_fail(identity != NULL, -1);
g_return_val_if_fail(remote_providerID != NULL, -2);
/* remove the federation */
federation = lasso_identity_get_federation(identity, remote_providerID);
if (federation != NULL) {
g_hash_table_remove(identity->federations, remote_providerID);
lasso_federation_destroy(federation);
}
else {
debug("Failed to remove federation for remote Provider %s\n", remote_providerID);
}
/* remove the federation remote provider id */
for (i = 0; i<identity->providerIDs->len; i++) {
if (xmlStrEqual(remote_providerID, g_ptr_array_index(identity->providerIDs, i))) {
debug("Remove federation of %s\n", remote_providerID);
g_ptr_array_remove_index(identity->providerIDs, i);
break;
}
}
identity->is_dirty = TRUE;
return 0;
}
/*****************************************************************************/
/* overrided parent class methods */
/*****************************************************************************/
static void
lasso_identity_dispose(LassoIdentity *identity)
dispose(GObject *object)
{
if (identity->private->dispose_has_run == TRUE) {
return;
}
identity->private->dispose_has_run = TRUE;
LassoIdentity *identity = LASSO_IDENTITY(object);
debug("Identity object 0x%x disposed ...\n", identity);
if (identity->private->dispose_has_run == TRUE) {
return;
}
identity->private->dispose_has_run = TRUE;
g_hash_table_destroy(identity->federations);
identity->federations = NULL;
debug("Identity object 0x%x disposed ...\n", identity);
parent_class->dispose(G_OBJECT(identity));
/* XXX: here or in finalize ?
* g_hash_table_destroy(identity->federations); */
G_OBJECT_CLASS(parent_class)->dispose(object);
}
static void
lasso_identity_finalize(LassoIdentity *identity)
finalize(GObject *object)
{
gint i;
LassoIdentity *identity = LASSO_IDENTITY(object);
debug("Identity object 0x%x finalized ...\n", identity);
/* free allocated memory for providerIDs array */
for (i=0; i<identity->providerIDs->len; i++) {
g_free(identity->providerIDs->pdata[i]);
identity->providerIDs->pdata[i] = NULL;
}
g_ptr_array_free(identity->providerIDs, TRUE);
identity->providerIDs = NULL;
g_free(identity->private);
identity->private = NULL;
parent_class->finalize(G_OBJECT(identity));
debug("Identity object 0x%x finalized ...\n", identity);
identity->private = NULL;
G_OBJECT_CLASS(parent_class)->finalize(object);
}
/*****************************************************************************/
@ -318,191 +159,79 @@ lasso_identity_finalize(LassoIdentity *identity)
/*****************************************************************************/
static void
lasso_identity_instance_init(LassoIdentity *identity)
instance_init(LassoIdentity *identity)
{
identity->private = g_new (LassoIdentityPrivate, 1);
identity->private->dispose_has_run = FALSE;
identity->private = g_new (LassoIdentityPrivate, 1);
identity->private->dispose_has_run = FALSE;
identity->providerIDs = g_ptr_array_new();
identity->federations = g_hash_table_new_full(g_str_hash, g_str_equal,
(GDestroyNotify)g_free,
(GDestroyNotify)lasso_federation_destroy);
identity->is_dirty = FALSE;
identity->federations = g_hash_table_new_full(g_str_hash, g_str_equal,
(GDestroyNotify)g_free,
(GDestroyNotify)lasso_federation_destroy);
identity->is_dirty = FALSE;
}
static void
lasso_identity_class_init(LassoIdentityClass *class)
class_init(LassoIdentityClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS(class);
parent_class = g_type_class_peek_parent(class);
/* override parent class methods */
gobject_class->dispose = (void *)lasso_identity_dispose;
gobject_class->finalize = (void *)lasso_identity_finalize;
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
G_OBJECT_CLASS(klass)->dispose = dispose;
G_OBJECT_CLASS(klass)->finalize = finalize;
}
GType lasso_identity_get_type() {
static GType this_type = 0;
GType
lasso_identity_get_type()
{
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoIdentityClass),
NULL,
NULL,
(GClassInitFunc) lasso_identity_class_init,
NULL,
NULL,
sizeof(LassoIdentity),
0,
(GInstanceInitFunc) lasso_identity_instance_init,
};
this_type = g_type_register_static(G_TYPE_OBJECT,
"LassoIdentity",
&this_info, 0);
}
return this_type;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoIdentityClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoIdentity),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoIdentity", &this_info, 0);
}
return this_type;
}
LassoIdentity*
lasso_identity_new()
{
LassoIdentity *identity;
identity = LASSO_IDENTITY(g_object_new(LASSO_TYPE_IDENTITY, NULL));
return identity;
return g_object_new(LASSO_TYPE_IDENTITY, NULL);
}
LassoIdentity*
lasso_identity_new_from_dump(gchar *dump)
lasso_identity_new_from_dump(const gchar *dump)
{
LassoNode *identity_node;
LassoNode *federations_node, *federation_node;
LassoNode *nis, *ni, *nameIdentifier;
LassoIdentity *identity;
xmlDoc *doc;
LassoNodeClass *federations_class;
identity = lasso_identity_new();
doc = xmlParseMemory(dump, strlen(dump));
init_from_xml(LASSO_NODE(identity), xmlDocGetRootElement(doc));
xmlFreeDoc(doc);
xmlNodePtr federations_xmlNode, federation_xmlNode;
LassoIdentity *identity;
LassoFederation *federation;
xmlChar *str, *remote_providerID;
GError *err = NULL;
g_return_val_if_fail(dump != NULL, NULL);
/* new object */
identity = LASSO_IDENTITY(g_object_new(LASSO_TYPE_IDENTITY, NULL));
/* get identity */
identity_node = lasso_node_new_from_dump(dump);
if (identity_node == NULL) {
message(G_LOG_LEVEL_WARNING, "Can't create a identity from dump\n");
return NULL;
}
/* federations */
federations_node = lasso_node_get_child(identity_node,
LASSO_IDENTITY_FEDERATIONS_NODE,
lassoLassoHRef, NULL);
if (federations_node != NULL) {
federations_class = LASSO_NODE_GET_CLASS(federations_node);
federations_xmlNode = federations_class->get_xmlNode(federations_node);
federation_xmlNode = federations_xmlNode->children;
while (federation_xmlNode != NULL) {
if (federation_xmlNode->type==XML_ELEMENT_NODE && \
xmlStrEqual(federation_xmlNode->name, LASSO_IDENTITY_FEDERATION_NODE)) {
federation_node = lasso_node_new_from_xmlNode(federation_xmlNode);
remote_providerID = lasso_node_get_attr_value(federation_node,
LASSO_FEDERATION_REMOTE_PROVIDERID_NODE, &err);
if (remote_providerID == NULL) {
message(G_LOG_LEVEL_WARNING, err->message);
g_error_free(err);
lasso_node_destroy(federation_node);
federation_xmlNode = federation_xmlNode->next;
continue;
}
/* new federation */
federation = lasso_federation_new(remote_providerID);
/* local name identifier */
nis = lasso_node_get_child(federation_node,
LASSO_FEDERATION_LOCAL_NAME_IDENTIFIER_NODE,
lassoLassoHRef, NULL);
if (nis != NULL) {
ni = lasso_node_get_child(nis, "NameIdentifier", NULL, NULL);
if (ni != NULL) {
/* content */
str = lasso_node_get_content(ni, NULL);
nameIdentifier = lasso_saml_name_identifier_new(str);
xmlFree(str);
/* NameQualifier */
str = lasso_node_get_attr_value(ni, "NameQualifier", NULL);
if (str != NULL) {
lasso_saml_name_identifier_set_nameQualifier(LASSO_SAML_NAME_IDENTIFIER(nameIdentifier), str);
xmlFree(str);
}
/* format */
str = lasso_node_get_attr_value(ni, "Format", NULL);
if (str != NULL) {
lasso_saml_name_identifier_set_format(LASSO_SAML_NAME_IDENTIFIER(nameIdentifier), str);
xmlFree(str);
}
lasso_federation_set_local_nameIdentifier(federation, nameIdentifier);
lasso_node_destroy(ni);
lasso_node_destroy(nameIdentifier);
}
lasso_node_destroy(nis);
}
/* remote name identifier */
nis = lasso_node_get_child(federation_node,
LASSO_FEDERATION_REMOTE_NAME_IDENTIFIER_NODE,
lassoLassoHRef, NULL);
if (nis != NULL) {
ni = lasso_node_get_child(nis, "NameIdentifier", NULL, NULL);
if (ni != NULL) {
/* content */
str = lasso_node_get_content(ni, NULL);
nameIdentifier = lasso_saml_name_identifier_new(str);
xmlFree(str);
/* NameQualifier */
str = lasso_node_get_attr_value(ni, "NameQualifier", NULL);
if (str != NULL) {
lasso_saml_name_identifier_set_nameQualifier(LASSO_SAML_NAME_IDENTIFIER(nameIdentifier), str);
xmlFree(str);
}
/* format */
str = lasso_node_get_attr_value(ni, "Format", NULL);
if (str != NULL) {
lasso_saml_name_identifier_set_format(LASSO_SAML_NAME_IDENTIFIER(nameIdentifier), str);
xmlFree(str);
}
lasso_federation_set_remote_nameIdentifier(federation, nameIdentifier);
lasso_node_destroy(ni);
lasso_node_destroy(nameIdentifier);
}
lasso_node_destroy(nis);
}
debug("Add federation for %s\n", remote_providerID);
lasso_identity_add_federation(identity, remote_providerID, federation);
xmlFree(remote_providerID);
lasso_node_destroy(federation_node);
lasso_federation_destroy(federation);
}
federation_xmlNode = federation_xmlNode->next;
}
lasso_node_destroy(federations_node);
}
lasso_node_destroy(identity_node);
return identity;
return identity;
}
gchar*
lasso_identity_dump(LassoIdentity *identity)
{
if (g_hash_table_size(identity->federations) == 0)
return g_strdup("");
return lasso_node_dump(LASSO_NODE(identity), NULL, 1);
}

View File

@ -31,7 +31,7 @@ extern "C" {
#endif /* __cplusplus */
#include <lasso/xml/xml.h>
#include <lasso/protocols/federation.h>
#include <lasso/environs/federation.h>
#define LASSO_TYPE_IDENTITY (lasso_identity_get_type())
#define LASSO_IDENTITY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_IDENTITY, LassoIdentity))
@ -45,50 +45,32 @@ typedef struct _LassoIdentityClass LassoIdentityClass;
typedef struct _LassoIdentityPrivate LassoIdentityPrivate;
struct _LassoIdentity {
GObject parent;
LassoNode parent;
/*< public >*/
GPtrArray *providerIDs; /* list of the remote provider ids for federations hash table */
GHashTable *federations; /* hash for federations with remote ProviderID as key */
/*< public >*/
GHashTable *federations; /* hash for federations with remote ProviderID as key */
gboolean is_dirty;
gboolean is_dirty;
/*< private >*/
LassoIdentityPrivate *private;
/*< private >*/
LassoIdentityPrivate *private;
};
struct _LassoIdentityClass {
GObjectClass parent;
LassoNodeClass parent;
};
LASSO_EXPORT GType lasso_identity_get_type (void);
LASSO_EXPORT GType lasso_identity_get_type(void);
LASSO_EXPORT LassoIdentity* lasso_identity_new(void);
LASSO_EXPORT LassoIdentity* lasso_identity_new (void);
LASSO_EXPORT gint lasso_identity_add_federation(LassoIdentity *identity,
LassoFederation *federation);
LASSO_EXPORT gint lasso_identity_remove_federation(LassoIdentity *identity,
char *remote_providerID);
LASSO_EXPORT LassoIdentity* lasso_identity_new_from_dump (gchar *dump);
LASSO_EXPORT void lasso_identity_destroy(LassoIdentity *identity);
LASSO_EXPORT gint lasso_identity_add_federation (LassoIdentity *identity,
gchar *remote_providerID,
LassoFederation *federation);
LASSO_EXPORT LassoIdentity* lasso_identity_copy (LassoIdentity *identity);
LASSO_EXPORT void lasso_identity_destroy (LassoIdentity *identity);
LASSO_EXPORT gchar* lasso_identity_dump (LassoIdentity *identity);
LASSO_EXPORT LassoFederation* lasso_identity_get_federation (LassoIdentity *identity,
gchar *remote_providerID);
LASSO_EXPORT LassoFederation* lasso_identity_get_federation_ref (LassoIdentity *identity,
gchar *remote_providerID);
LASSO_EXPORT gchar* lasso_identity_get_first_providerID (LassoIdentity *identity);
LASSO_EXPORT gchar* lasso_identity_get_next_federation_remote_providerID (LassoIdentity *identity);
LASSO_EXPORT gint lasso_identity_remove_federation (LassoIdentity *identity,
gchar *remote_providerID);
LASSO_EXPORT gchar* lasso_identity_dump(LassoIdentity *identity);
LASSO_EXPORT LassoIdentity* lasso_identity_new_from_dump(const gchar *dump);
#ifdef __cplusplus
}

View File

@ -41,9 +41,8 @@ lasso_lecp_build_authn_request_envelope_msg(LassoLecp *lecp)
profile = LASSO_PROFILE(lecp);
assertionConsumerServiceURL = lasso_provider_get_assertionConsumerServiceURL(LASSO_PROVIDER(profile->server),
lassoProviderTypeSp,
NULL);
assertionConsumerServiceURL = lasso_provider_get_metadata_one(
LASSO_PROVIDER(profile->server), "AssertionConsumerServiceURL");
if (assertionConsumerServiceURL == NULL) {
message(G_LOG_LEVEL_CRITICAL, "AssertionConsumerServiceURL not found\n");
return -1;
@ -54,15 +53,20 @@ lasso_lecp_build_authn_request_envelope_msg(LassoLecp *lecp)
return -1;
}
lecp->authnRequestEnvelope = lasso_authn_request_envelope_new(LASSO_AUTHN_REQUEST(profile->request),
profile->server->providerID,
assertionConsumerServiceURL);
#if 0
lecp->authnRequestEnvelope = lasso_authn_request_envelope_new(
LASSO_LIB_AUTHN_REQUEST(profile->request),
LASSO_PROVIDER(profile->server)->ProviderID,
assertionConsumerServiceURL);
#endif
if (lecp->authnRequestEnvelope == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Error while building AuthnRequestEnvelope\n");
return -1;
}
#if 0 /* XXX: dump to xml ? */
profile->msg_body = lasso_node_export(lecp->authnRequestEnvelope);
#endif
if (profile->msg_body == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Error while exporting the AuthnRequestEnvelope to POST msg\n");
return -1;
@ -99,11 +103,9 @@ lasso_lecp_build_authn_request_msg(LassoLecp *lecp,
profile->remote_providerID = g_strdup(remote_providerID);
}
remote_provider = lasso_server_get_provider_ref(profile->server,
profile->remote_providerID,
NULL);
remote_provider = g_hash_table_lookup(profile->server->providers, profile->remote_providerID);
profile->msg_url = lasso_provider_get_singleSignOnServiceURL(remote_provider, NULL);
profile->msg_url = lasso_provider_get_metadata_one(remote_provider, "SingleSignOnServiceURL");
profile->msg_body = lasso_node_export_to_soap(profile->request);
if (profile->msg_body == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Error while building the AuthnRequest SOAP message\n");
@ -136,11 +138,14 @@ lasso_lecp_build_authn_response_msg(LassoLecp *lecp)
}
gint
lasso_lecp_build_authn_response_envelope_msg(LassoLecp *lecp,
gint authentication_result,
gboolean is_consent_obtained,
const gchar *authenticationMethod,
const gchar *reauthenticateOnOrAfter)
lasso_lecp_build_authn_response_envelope_msg(LassoLecp *lecp,
gint authentication_result,
gboolean is_consent_obtained,
const char *authenticationMethod,
const char *authenticationInstant,
const char *reauthenticateOnOrAfter,
const char *notBefore,
const char *notOnOrAfter)
{
LassoProfile *profile;
LassoProvider *provider;
@ -150,14 +155,12 @@ lasso_lecp_build_authn_response_envelope_msg(LassoLecp *lecp,
profile = LASSO_PROFILE(lecp);
if (LASSO_IS_AUTHN_RESPONSE(profile->response) == FALSE) {
if (LASSO_IS_LIB_AUTHN_RESPONSE(profile->response) == FALSE) {
message(G_LOG_LEVEL_CRITICAL, "AuthnResponse not found\n");
return -1;
}
provider = lasso_server_get_provider_ref(profile->server,
profile->remote_providerID,
NULL);
provider = g_hash_table_lookup(profile->server->providers, profile->remote_providerID);
if (provider == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Provider %s not found\n", profile->remote_providerID);
return -1;
@ -168,11 +171,13 @@ lasso_lecp_build_authn_response_envelope_msg(LassoLecp *lecp,
authentication_result,
is_consent_obtained,
authenticationMethod,
reauthenticateOnOrAfter);
authenticationInstant,
reauthenticateOnOrAfter,
notBefore,
notOnOrAfter);
assertionConsumerServiceURL = lasso_provider_get_assertionConsumerServiceURL(provider,
lassoProviderTypeSp,
NULL);
assertionConsumerServiceURL = lasso_provider_get_metadata_one(
provider, "AssertionConsumerServiceURL");
if (assertionConsumerServiceURL == NULL) {
message(G_LOG_LEVEL_CRITICAL, "AssertionConsumerServiceURL not found\n");
return -1;
@ -182,8 +187,9 @@ lasso_lecp_build_authn_response_envelope_msg(LassoLecp *lecp,
LASSO_PROFILE(lecp)->msg_body = NULL;
xmlFree(LASSO_PROFILE(lecp)->msg_url);
LASSO_PROFILE(lecp)->msg_url = NULL;
lecp->authnResponseEnvelope = lasso_authn_response_envelope_new(LASSO_AUTHN_RESPONSE(profile->response),
assertionConsumerServiceURL);
lecp->authnResponseEnvelope = lasso_lib_authn_response_envelope_new(
LASSO_LIB_AUTHN_RESPONSE(profile->response),
assertionConsumerServiceURL);
LASSO_PROFILE(lecp)->msg_body = lasso_node_export_to_soap(lecp->authnResponseEnvelope);
if (LASSO_PROFILE(lecp)->msg_body == NULL) {
@ -204,26 +210,26 @@ lasso_lecp_init_authn_request(LassoLecp *lecp)
/* FIXME : BAD usage of http_method
using POST method so that the lib:AuthnRequest is initialize with
a signature template */
res = lasso_login_init_authn_request(LASSO_LOGIN(lecp), lassoHttpMethodPost);
res = lasso_login_init_authn_request(LASSO_LOGIN(lecp), LASSO_HTTP_METHOD_POST);
return res;
}
gint
lasso_lecp_process_authn_request_msg(LassoLecp *lecp,
gchar *authn_request_msg,
lassoHttpMethod authn_request_method)
gchar *authn_request_msg)
{
lassoHttpMethod authn_request_method = 0; /* XXX: update to CVS */
gint res;
g_return_val_if_fail(LASSO_IS_LECP(lecp), -1);
g_return_val_if_fail(authn_request_msg!=NULL, -1);
if (authn_request_method != lassoHttpMethodSoap) {
if (authn_request_method != LASSO_HTTP_METHOD_SOAP) {
message(G_LOG_LEVEL_CRITICAL, "Invalid authentication request method\n");
return -1;
}
res = lasso_login_process_authn_request_msg(LASSO_LOGIN(lecp), authn_request_msg, authn_request_method);
res = lasso_login_process_authn_request_msg(LASSO_LOGIN(lecp), authn_request_msg);
return res;
}
@ -234,13 +240,17 @@ lasso_lecp_process_authn_request_envelope_msg(LassoLecp *lecp,
g_return_val_if_fail(LASSO_IS_LECP(lecp), -1);
g_return_val_if_fail(request_msg!=NULL, -1);
lecp->authnRequestEnvelope = lasso_authn_request_envelope_new_from_export(request_msg, lassoNodeExportTypeXml);
#if 0 /* XXX */
lecp->authnRequestEnvelope = lasso_authn_request_envelope_new_from_export(request_msg, LASSO_NODE_EXPORT_TYPE_XML);
#endif
if (lecp->authnRequestEnvelope == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Error while building the authentication request envelope\n");
return -1;
}
#if 0
LASSO_PROFILE(lecp)->request = lasso_authn_request_envelope_get_authnRequest(LASSO_AUTHN_REQUEST_ENVELOPE(lecp->authnRequestEnvelope));
#endif
if (LASSO_PROFILE(lecp)->request == NULL) {
message(G_LOG_LEVEL_CRITICAL, "AuthnRequest not found\n");
return -1;
@ -260,24 +270,29 @@ lasso_lecp_process_authn_response_envelope_msg(LassoLecp *lecp,
profile = LASSO_PROFILE(lecp);
lecp->authnResponseEnvelope = lasso_authn_response_envelope_new_from_export(response_msg, lassoNodeExportTypeSoap);
lecp->authnResponseEnvelope = lasso_lib_authn_response_envelope_new(NULL, NULL);
lasso_node_init_from_message(lecp->authnResponseEnvelope, response_msg);
if (lecp->authnResponseEnvelope == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Error while building AuthnResponseEnvelope\n");
return -1;
}
#if 0 /* XXX */
profile->response = lasso_authn_response_envelope_get_authnResponse(LASSO_AUTHN_RESPONSE_ENVELOPE(lecp->authnResponseEnvelope));
if (profile->response == NULL) {
message(G_LOG_LEVEL_CRITICAL, "AuthnResponse not found\n");
return -1;
}
#endif
#if 0 /* XXX */
lecp->assertionConsumerServiceURL = lasso_authn_response_envelope_get_assertionConsumerServiceURL(
LASSO_AUTHN_RESPONSE_ENVELOPE(lecp->authnResponseEnvelope));
if (lecp->assertionConsumerServiceURL == NULL){
message(G_LOG_LEVEL_CRITICAL, "AssertionConsumerServiceURL not found\n");
return -1;
}
#endif
return 0;
}
@ -355,7 +370,7 @@ lasso_lecp_new(LassoServer *server)
if (LASSO_IS_SERVER(server)) {
debug("Add server to lecp object\n");
LASSO_PROFILE(lecp)->server = lasso_server_copy(server);
/* XXX LASSO_PROFILE(lecp)->server = lasso_server_copy(server); */
}

View File

@ -32,8 +32,8 @@ extern "C" {
#include <lasso/xml/xml.h>
#include <lasso/protocols/authn_request_envelope.h>
#include <lasso/protocols/authn_response_envelope.h>
#include <lasso/xml/lib_authn_request_envelope.h>
#include <lasso/xml/lib_authn_response_envelope.h>
#include <lasso/environs/login.h>
@ -74,19 +74,21 @@ LASSO_EXPORT gint lasso_lecp_build_authn_request_msg (LassoLec
LASSO_EXPORT gint lasso_lecp_build_authn_response_msg (LassoLecp *lecp);
LASSO_EXPORT gint lasso_lecp_build_authn_response_envelope_msg (LassoLecp *lecp,
gint authentication_result,
gboolean is_consent_obtained,
const gchar *authenticationMethod,
const gchar *reauthenticateOnOrAfter);
LASSO_EXPORT gint lasso_lecp_build_authn_response_envelope_msg(LassoLecp *lecp,
gint authentication_result,
gboolean is_consent_obtained,
const char *authenticationMethod,
const char *authenticationInstant,
const char *reauthenticateOnOrAfter,
const char *notBefore,
const char *notOnOrAfter);
LASSO_EXPORT void lasso_lecp_destroy (LassoLecp *lecp);
LASSO_EXPORT gint lasso_lecp_init_authn_request (LassoLecp *lecp);
LASSO_EXPORT gint lasso_lecp_process_authn_request_msg (LassoLecp *lecp,
gchar *authn_request_msg,
lassoHttpMethod authn_request_method);
gchar *authn_request_msg);
LASSO_EXPORT gint lasso_lecp_process_authn_request_envelope_msg (LassoLecp *lecp,
gchar *request_msg);

File diff suppressed because it is too large Load Diff

View File

@ -33,10 +33,10 @@ extern "C" {
#include <lasso/environs/profile.h>
#include <lasso/protocols/authn_request.h>
#include <lasso/protocols/authn_response.h>
#include <lasso/protocols/request.h>
#include <lasso/protocols/response.h>
#include <lasso/xml/lib_authn_request.h>
#include <lasso/xml/lib_authn_response.h>
#include <lasso/xml/samlp_request.h>
#include <lasso/xml/samlp_response.h>
#define LASSO_TYPE_LOGIN (lasso_login_get_type())
#define LASSO_LOGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_LOGIN, LassoLogin))
@ -50,24 +50,25 @@ typedef struct _LassoLoginClass LassoLoginClass;
typedef struct _LassoLoginPrivate LassoLoginPrivate;
typedef enum {
lassoLoginProtocolProfileBrwsArt = 1,
lassoLoginProtocolProfileBrwsPost,
LASSO_LOGIN_PROTOCOL_PROFILE_BRWS_ART = 1,
LASSO_LOGIN_PROTOCOL_PROFILE_BRWS_POST,
} lassoLoginProtocolProfile;
struct _LassoLogin {
LassoProfile parent;
/*< public >*/
lassoLoginProtocolProfile protocolProfile;
gchar *assertionArtifact;
LassoProfile parent;
/*< private >*/
gchar *nameIDPolicy;
lassoHttpMethod http_method;
LassoLoginPrivate *private;
/*< public >*/
lassoLoginProtocolProfile protocolProfile;
gchar *assertionArtifact;
/*< private >*/
gchar *nameIDPolicy;
lassoHttpMethod http_method;
LassoLoginPrivate *private;
};
struct _LassoLoginClass {
LassoProfileClass parent;
LassoProfileClass parent;
};
LASSO_EXPORT GType lasso_login_get_type (void);
@ -75,25 +76,31 @@ LASSO_EXPORT GType lasso_login_get_type (void);
LASSO_EXPORT LassoLogin* lasso_login_new (LassoServer *server);
LASSO_EXPORT LassoLogin* lasso_login_new_from_dump (LassoServer *server,
gchar *dump);
const gchar *dump);
LASSO_EXPORT gint lasso_login_accept_sso (LassoLogin *login);
LASSO_EXPORT gint lasso_login_build_artifact_msg (LassoLogin *login,
gboolean authentication_result,
gboolean is_consent_obtained,
const gchar *authenticationMethod,
const gchar *reauthenticateOnOrAfter,
lassoHttpMethod http_method);
gboolean authentication_result,
gboolean is_consent_obtained,
const char *authenticationMethod,
const char *authenticationInstant,
const char *reauthenticateOnOrAfter,
const char *notBefore,
const char *notOnOrAfter,
lassoHttpMethod http_method);
LASSO_EXPORT gint lasso_login_build_authn_request_msg (LassoLogin *login,
const gchar *remote_providerID);
LASSO_EXPORT gint lasso_login_build_authn_response_msg (LassoLogin *login,
gboolean authentication_result,
gboolean is_consent_obtained,
const gchar *authenticationMethod,
const gchar *reauthenticateOnOrAfter);
gboolean authentication_result,
gboolean is_consent_obtained,
const char *authenticationMethod,
const char *authenticationInstant,
const char *reauthenticateOnOrAfter,
const char *notBefore,
const char *notOnOrAfter);
LASSO_EXPORT gint lasso_login_build_request_msg (LassoLogin *login);
@ -110,7 +117,7 @@ LASSO_EXPORT gint lasso_login_init_authn_request (LassoLogin
LASSO_EXPORT gint lasso_login_init_request (LassoLogin *login,
gchar *response_msg,
lassoHttpMethod response_http_method);
LASSO_EXPORT gint lasso_login_init_self_addressed_authn_request (LassoLogin *login,
LASSO_EXPORT gint lasso_login_init_idp_initiated_authn_request (LassoLogin *login,
const gchar *remote_providerID);
LASSO_EXPORT gboolean lasso_login_must_ask_for_consent (LassoLogin *login);
@ -118,8 +125,7 @@ LASSO_EXPORT gboolean lasso_login_must_ask_for_consent (LassoLogin *log
LASSO_EXPORT gboolean lasso_login_must_authenticate (LassoLogin *login);
LASSO_EXPORT gint lasso_login_process_authn_request_msg (LassoLogin *login,
gchar *authn_request_msg,
lassoHttpMethod authn_request_http_method);
gchar *authn_request_msg);
LASSO_EXPORT gint lasso_login_process_authn_response_msg (LassoLogin *login,
gchar *authn_response_msg);

File diff suppressed because it is too large Load Diff

View File

@ -31,8 +31,8 @@ extern "C" {
#endif /* __cplusplus */
#include <lasso/environs/profile.h>
#include <lasso/protocols/logout_request.h>
#include <lasso/protocols/logout_response.h>
#include <lasso/xml/lib_logout_request.h>
#include <lasso/xml/lib_logout_response.h>
#define LASSO_TYPE_LOGOUT (lasso_logout_get_type())
#define LASSO_LOGOUT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_LOGOUT, LassoLogout))
@ -46,31 +46,28 @@ typedef struct _LassoLogoutClass LassoLogoutClass;
typedef struct _LassoLogoutPrivate LassoLogoutPrivate;
struct _LassoLogout {
LassoProfile parent;
LassoProfile parent;
/*< public >*/
/*< private >*/
LassoNode *initial_request;
LassoNode *initial_response;
gchar *initial_remote_providerID;
gint providerID_index;
lassoHttpMethod initial_http_request_method;
/*< private >*/
LassoNode *initial_request;
LassoNode *initial_response;
gchar *initial_remote_providerID;
gint providerID_index;
LassoLogoutPrivate *private;
LassoLogoutPrivate *private;
};
struct _LassoLogoutClass {
LassoProfileClass parent;
LassoProfileClass parent;
};
LASSO_EXPORT GType lasso_logout_get_type (void);
LASSO_EXPORT LassoLogout* lasso_logout_new (LassoServer *server,
lassoProviderType provider_type);
LASSO_EXPORT LassoLogout* lasso_logout_new (LassoServer *server);
LASSO_EXPORT LassoLogout* lasso_logout_new_from_dump (LassoServer *server, gchar *dump);
LASSO_EXPORT LassoLogout* lasso_logout_new_from_dump(LassoServer *server, const gchar *dump);
LASSO_EXPORT gint lasso_logout_build_request_msg (LassoLogout *logout);
@ -87,12 +84,10 @@ LASSO_EXPORT gint lasso_logout_init_request (LassoLogout *l
lassoHttpMethod request_method);
LASSO_EXPORT gint lasso_logout_process_request_msg (LassoLogout *logout,
gchar *request_msg,
lassoHttpMethod request_method);
gchar *request_msg);
LASSO_EXPORT gint lasso_logout_process_response_msg (LassoLogout *logout,
gchar *response_msg,
lassoHttpMethod response_method);
gchar *response_msg);
LASSO_EXPORT gint lasso_logout_reset_providerID_index (LassoLogout *logout);

View File

@ -31,555 +31,442 @@
/* public methods */
/*****************************************************************************/
gchar *
lasso_name_identifier_mapping_dump(LassoNameIdentifierMapping *mapping)
{
gchar *dump = NULL;
g_return_val_if_fail(LASSO_IS_NAME_IDENTIFIER_MAPPING(mapping), NULL);
return dump;
}
gint
lasso_name_identifier_mapping_build_request_msg(LassoNameIdentifierMapping *mapping)
{
LassoProfile *profile;
LassoProvider *provider;
xmlChar *protocolProfile;
GError *err = NULL;
gint ret = 0;
LassoProfile *profile;
LassoProvider *remote_provider;
g_return_val_if_fail(LASSO_IS_NAME_IDENTIFIER_MAPPING(mapping), -1);
profile = LASSO_PROFILE(mapping);
g_return_val_if_fail(LASSO_IS_NAME_IDENTIFIER_MAPPING(mapping), -1);
/* verify the provider type is a service provider type */
if (profile->provider_type != lassoProviderTypeSp) {
message(G_LOG_LEVEL_CRITICAL, "Build request msg method is forbidden for an IDP\n");
ret = -1;
goto done;
}
profile = LASSO_PROFILE(mapping);
/* get provider object */
provider = lasso_server_get_provider_ref(profile->server,
profile->remote_providerID,
NULL);
if (provider == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Provider %s not found\n", profile->remote_providerID);
ret = -1;
goto done;
}
/* get provider object */
remote_provider = g_hash_table_lookup(profile->server->providers,
profile->remote_providerID);
if (remote_provider == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Provider %s not found", profile->remote_providerID);
return -1;
}
/* get the prototocol profile of the name identifier mapping request */
protocolProfile = lasso_provider_get_nameIdentifierMappingProtocolProfile(provider,
lassoProviderTypeIdp,
NULL);
if (protocolProfile == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Name identifier mapping protocol profile not found\n");
ret = -1;
goto done;
}
if (remote_provider->role != LASSO_PROVIDER_ROLE_IDP) {
message(G_LOG_LEVEL_CRITICAL, "Build request msg method is forbidden at IDP");
return -1;
}
/* Build the name identifier mapping request message (SOAP or QUERY type) */
if(xmlStrEqual(protocolProfile, lassoLibProtocolProfileNimSpHttp)) {
profile->msg_url = lasso_provider_get_soapEndpoint(provider,
lassoProviderTypeIdp,
NULL);
if (profile->msg_url == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Name identifier mapping url not found\n");
ret = -1;
goto done;
}
profile->msg_url = lasso_provider_get_metadata_one(remote_provider, "SoapEndpoint");
if (profile->msg_url == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Name identifier mapping url not found");
return -1;
}
profile->msg_body = lasso_node_export_to_soap(profile->request);
if (profile->msg_body == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Error while building name identifier mapping request SOAP message\n");
ret = -1;
goto done;
}
}
else {
message(G_LOG_LEVEL_CRITICAL, "Invalid protocol profile\n");
ret = -1;
goto done;
}
profile->msg_body = lasso_node_export_to_soap(profile->request);
if (profile->msg_body == NULL) {
message(G_LOG_LEVEL_CRITICAL,
"Error building name identifier mapping request SOAP message");
return -1;
}
done:
return ret;
return 0;
}
gint
lasso_name_identifier_mapping_build_response_msg(LassoNameIdentifierMapping *mapping)
{
LassoProfile *profile;
LassoProvider *provider;
xmlChar *protocolProfile;
GError *err = NULL;
gint ret = 0;
LassoProfile *profile;
LassoProvider *remote_provider;
g_return_val_if_fail(LASSO_IS_NAME_IDENTIFIER_MAPPING(mapping), -1);
g_return_val_if_fail(LASSO_IS_NAME_IDENTIFIER_MAPPING(mapping), -1);
profile = LASSO_PROFILE(mapping);
profile = LASSO_PROFILE(mapping);
/* verify the provider type is a service provider type */
if (profile->provider_type != lassoProviderTypeIdp) {
message(G_LOG_LEVEL_CRITICAL, "Build request msg method is forbidden for an SP\n");
ret = -1;
goto done;
}
remote_provider = g_hash_table_lookup(profile->server->providers,
profile->remote_providerID);
if (remote_provider == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Provider %s not found", profile->remote_providerID);
return -1;
}
/* build name identifier mapping response msg */
switch (profile->http_request_method) {
case lassoHttpMethodSoap:
profile->msg_url = NULL;
profile->msg_body = lasso_node_export_to_soap(profile->response);
break;
case lassoHttpMethodRedirect:
profile->msg_url = lasso_node_export_to_query(profile->response,
profile->server->signature_method,
profile->server->private_key);
profile->msg_body = NULL;
break;
default:
message(G_LOG_LEVEL_CRITICAL, "Invalid http request method\n");
ret = -1;
goto done;
}
if (remote_provider->role != LASSO_PROVIDER_ROLE_SP) {
message(G_LOG_LEVEL_CRITICAL, "Build response msg method is forbidden at SP");
return -1;
}
done:
/* verify the provider type is a service provider type */
/* build name identifier mapping response msg */
if (profile->http_request_method != LASSO_HTTP_METHOD_SOAP) {
message(G_LOG_LEVEL_CRITICAL, "Invalid http request method");
return -1;
}
return ret;
profile->msg_url = NULL;
profile->msg_body = lasso_node_export_to_soap(profile->response);
return 0;
}
void
lasso_name_identifier_mapping_destroy(LassoNameIdentifierMapping *mapping)
{
g_object_unref(G_OBJECT(mapping));
g_object_unref(G_OBJECT(mapping));
}
gint
lasso_name_identifier_mapping_init_request(LassoNameIdentifierMapping *mapping,
gchar *targetNameSpace,
gchar *remote_providerID)
char *targetNamespace, char *remote_providerID)
{
LassoProfile *profile;
LassoNode *nameIdentifier;
LassoProvider *provider;
LassoFederation *federation;
xmlChar *content, *nameQualifier, *format, *nameIdentifierMappingProtocolProfile;
gint ret = 0;
LassoProfile *profile;
LassoProvider *remote_provider;
LassoFederation *federation;
LassoSamlNameIdentifier *nameIdentifier;
g_return_val_if_fail(LASSO_IS_NAME_IDENTIFIER_MAPPING(mapping), -1);
g_return_val_if_fail(targetNameSpace != NULL, -1);
g_return_val_if_fail(LASSO_IS_NAME_IDENTIFIER_MAPPING(mapping),
LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
g_return_val_if_fail(targetNamespace != NULL, LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
profile = LASSO_PROFILE(mapping);
profile = LASSO_PROFILE(mapping);
/* verify the provider type is a service provider type */
if (profile->provider_type != lassoProviderTypeSp) {
message(G_LOG_LEVEL_CRITICAL, "Init request method is forbidden for an IDP\n");
ret = -1;
goto done;
}
/* verify if the identity exists */
if (profile->identity == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Identity not found");
return -1;
}
/* verify if the identity exists */
if (profile->identity == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Identity not found\n");
ret = -1;
goto done;
}
/* set the remote provider id */
if (remote_providerID == NULL)
g_assert_not_reached(); /* was default; didn't make sense */
profile->remote_providerID = g_strdup(remote_providerID);
/* set the remote provider id */
if (remote_providerID == NULL) {
profile->remote_providerID = lasso_identity_get_first_providerID(profile->identity);
}
else {
profile->remote_providerID = g_strdup(remote_providerID);
}
if (profile->remote_providerID == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Remote provider id not found\n");
ret = -1;
goto done;
}
/* get federation */
federation = lasso_identity_get_federation(profile->identity, profile->remote_providerID);
if(federation == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Federation not found\n");
ret = -1;
goto done;
}
/* get the name identifier */
nameIdentifier = LASSO_NODE(lasso_federation_get_local_nameIdentifier(federation));
if(nameIdentifier == NULL) {
nameIdentifier = LASSO_NODE(lasso_federation_get_remote_nameIdentifier(federation));
}
if (nameIdentifier == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Name identifier not found\n");
ret = -1;
goto done;
}
lasso_federation_destroy(federation);
/* verify the provider type is a service provider type */
remote_provider = g_hash_table_lookup(profile->server->providers,
profile->remote_providerID);
if (remote_provider == NULL) {
message(G_LOG_LEVEL_CRITICAL, "XXX");
return -1;
}
if (remote_provider->role != LASSO_PROVIDER_ROLE_IDP) {
message(G_LOG_LEVEL_CRITICAL, "Init request method is forbidden for an IDP");
return -1;
}
/* get content and attributes of name identifier */
content = lasso_node_get_content(nameIdentifier, NULL);
nameQualifier = lasso_node_get_attr_value(nameIdentifier, "NameQualifier", NULL);
format = lasso_node_get_attr_value(nameIdentifier, "Format", NULL);
if (content == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Content of name identifier not found\n");
ret = -1;
goto done;
}
/* get federation */
federation = g_hash_table_lookup(profile->identity->federations,
profile->remote_providerID);
if(federation == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Federation not found");
return -1;
}
/* get protocol profile */
provider = lasso_server_get_provider_ref(profile->server, profile->remote_providerID, NULL);
if (provider == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Provider %s not found\n", profile->remote_providerID);
ret = -1;
goto done;
}
/* name identifier */
nameIdentifier = federation->local_nameIdentifier;
if (nameIdentifier == NULL)
nameIdentifier = federation->remote_nameIdentifier;
if (nameIdentifier == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Name identifier not found");
return -1;
}
nameIdentifierMappingProtocolProfile = lasso_provider_get_nameIdentifierMappingProtocolProfile(provider,
lassoProviderTypeIdp,
NULL);
if (nameIdentifierMappingProtocolProfile == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Name identifier mapping protocol profile not found\n");
ret = -1;
goto done;
}
/* get / verify http method */
profile->http_request_method = LASSO_HTTP_METHOD_NONE;
if (lasso_provider_accept_http_method(LASSO_PROVIDER(profile->server),
remote_provider,
LASSO_MD_PROTOCOL_TYPE_NAME_IDENTIFIER_MAPPING,
LASSO_HTTP_METHOD_REDIRECT, TRUE) == FALSE) {
message(G_LOG_LEVEL_CRITICAL, "unsupported profile!");
return LASSO_PROFILE_ERROR_UNSUPPORTED_PROFILE;
}
/* build the request */
if (xmlStrEqual(nameIdentifierMappingProtocolProfile, lassoLibProtocolProfileNimSpHttp)) {
profile->request = lasso_name_identifier_mapping_request_new(profile->server->providerID,
content,
nameQualifier,
format,
targetNameSpace,
lassoSignatureTypeWithX509,
lassoSignatureMethodRsaSha1);
}
else {
message(G_LOG_LEVEL_CRITICAL, "Invalid name identifier mapping protocol profile\n");
ret = -1;
goto done;
}
profile->request = lasso_lib_name_identifier_mapping_request_new_full(
LASSO_PROVIDER(profile->server)->ProviderID,
nameIdentifier,
targetNamespace,
LASSO_SIGNATURE_TYPE_WITHX509,
LASSO_SIGNATURE_METHOD_RSA_SHA1);
if (LASSO_IS_LIB_NAME_IDENTIFIER_MAPPING_REQUEST(profile->request) == FALSE) {
message(G_LOG_LEVEL_CRITICAL, "Invalid request");
return -1;
}
done:
profile->http_request_method = LASSO_HTTP_METHOD_SOAP;
return ret;
return 0;
}
gint
lasso_name_identifier_mapping_process_request_msg(LassoNameIdentifierMapping *mapping,
gchar *request_msg,
lassoHttpMethod request_method)
char *request_msg)
{
LassoProfile *profile;
LassoFederation *federation;
LassoNode *nameIdentifier;
LassoNode *statusCode;
LassoNodeClass *statusCode_class;
xmlChar *remote_providerID;
gint ret = 0;
LassoProfile *profile;
LassoProvider *remote_provider;
LassoMessageFormat format;
g_return_val_if_fail(LASSO_IS_NAME_IDENTIFIER_MAPPING(mapping), -1);
g_return_val_if_fail(request_msg != NULL, -1);
g_return_val_if_fail(LASSO_IS_NAME_IDENTIFIER_MAPPING(mapping),
LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
g_return_val_if_fail(request_msg != NULL, LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
profile = LASSO_PROFILE(mapping);
profile = LASSO_PROFILE(mapping);
switch(request_method){
case lassoHttpMethodRedirect:
message(G_LOG_LEVEL_CRITICAL, lasso_strerror(LASSO_PROFILE_ERROR_INVALID_QUERY));
ret = LASSO_PROFILE_ERROR_INVALID_QUERY;
goto done;
break;
case lassoHttpMethodSoap:
profile->request = lasso_name_identifier_mapping_request_new_from_export(request_msg, lassoNodeExportTypeSoap);
if (LASSO_IS_NAME_IDENTIFIER_MAPPING_REQUEST(profile->request) == FALSE) {
message(G_LOG_LEVEL_CRITICAL, lasso_strerror(LASSO_PROFILE_ERROR_INVALID_SOAP_MSG));
ret = LASSO_PROFILE_ERROR_INVALID_SOAP_MSG;
goto done;
}
break;
default:
message(G_LOG_LEVEL_CRITICAL, lasso_strerror(LASSO_PROFILE_ERROR_INVALID_HTTP_METHOD));
ret = LASSO_PROFILE_ERROR_INVALID_HTTP_METHOD;
goto done;
}
/* build name identifier mapping from message */
profile->request = lasso_lib_name_identifier_mapping_request_new();
format = lasso_node_init_from_message(profile->request, request_msg);
if (format == LASSO_MESSAGE_FORMAT_UNKNOWN) {
message(G_LOG_LEVEL_CRITICAL, "XXX");
return LASSO_PROFILE_ERROR_INVALID_MSG;
}
/* set the http request method */
profile->http_request_method = request_method;
remote_provider = g_hash_table_lookup(profile->server->providers,
LASSO_LIB_NAME_IDENTIFIER_MAPPING_REQUEST(profile->request)->ProviderID);
if (LASSO_IS_PROVIDER(remote_provider) == FALSE) {
message(G_LOG_LEVEL_CRITICAL, "Unknown provider");
return -1;
}
profile->remote_providerID = g_strdup(remote_provider->ProviderID);
/* NameIdentifier */
profile->nameIdentifier = lasso_node_get_child_content(profile->request,
"NameIdentifier", NULL, NULL);
/* verify http method is supported */
if (lasso_provider_accept_http_method(LASSO_PROVIDER(profile->server),
remote_provider,
LASSO_MD_PROTOCOL_TYPE_NAME_IDENTIFIER_MAPPING,
LASSO_HTTP_METHOD_REDIRECT, FALSE) == FALSE ) {
message(G_LOG_LEVEL_CRITICAL, "unsupported profile!");
return LASSO_PROFILE_ERROR_UNSUPPORTED_PROFILE;
}
done:
/* verify signature */
profile->signature_status = lasso_provider_verify_signature(
remote_provider, request_msg, "RequestID");
return ret;
profile->http_request_method = LASSO_HTTP_METHOD_SOAP;
profile->nameIdentifier = g_strdup(LASSO_LIB_NAME_IDENTIFIER_MAPPING_REQUEST(
profile->request)->NameIdentifier->content);
return profile->signature_status;
}
gint
lasso_name_identifier_mapping_process_response_msg(LassoNameIdentifierMapping *mapping,
gchar *response_msg,
lassoHttpMethod response_method)
char *response_msg)
{
LassoProfile *profile;
xmlChar *statusCodeValue;
LassoNode *statusCode;
GError *err = NULL;
gint ret = 0;
LassoProfile *profile;
LassoProvider *remote_provider;
LassoMessageFormat format;
int rc;
char *statusCodeValue;
g_return_val_if_fail(LASSO_IS_NAME_IDENTIFIER_MAPPING(mapping), -1);
g_return_val_if_fail(response_msg != NULL, -1);
g_return_val_if_fail(LASSO_IS_NAME_IDENTIFIER_MAPPING(mapping),
LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
g_return_val_if_fail(response_msg != NULL, LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
profile = LASSO_PROFILE(mapping);
profile = LASSO_PROFILE(mapping);
switch(response_method){
case lassoHttpMethodSoap:
profile->response = lasso_name_identifier_mapping_response_new_from_export(response_msg, lassoNodeExportTypeSoap);
break;
default:
message(G_LOG_LEVEL_CRITICAL, "Invalid response method\n");
ret = -1;
goto done;
}
if (LASSO_IS_NAME_IDENTIFIER_MAPPING_RESPONSE(profile->response) == FALSE) {
message(G_LOG_LEVEL_CRITICAL, "Error while building NameIdentifierMappingResponse message\n");
ret = -1;
goto done;
}
profile->response = lasso_lib_name_identifier_mapping_response_new();
format = lasso_node_init_from_message(profile->response, response_msg);
if (format == LASSO_MESSAGE_FORMAT_UNKNOWN) {
message(G_LOG_LEVEL_CRITICAL, "XXX");
return LASSO_PROFILE_ERROR_INVALID_MSG;
}
/* Verify the status code value */
statusCode = lasso_node_get_child(profile->response, "StatusCode", NULL, NULL);
if (statusCode == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Status code not found\n");
ret = -1;
goto done;
}
statusCodeValue = lasso_node_get_attr_value(statusCode, "Value", NULL);
if (statusCodeValue == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Status code value not found\n");
ret = -1;
goto done;
}
if (xmlStrEqual(statusCodeValue, lassoLibStatusCodeFederationDoesNotExist)) {
message(G_LOG_LEVEL_CRITICAL, "Status code : Federation does not exists\n");
ret = -1;
goto done;
}
else if (xmlStrEqual(statusCodeValue, lassoLibStatusCodeUnknownPrincipal)) {
message(G_LOG_LEVEL_CRITICAL, "Status code : Unknown Principal\n");
ret = -1;
goto done;
}
remote_provider = g_hash_table_lookup(profile->server->providers,
LASSO_LIB_NAME_IDENTIFIER_MAPPING_RESPONSE(profile->response)->ProviderID);
if (remote_provider == NULL) {
message(G_LOG_LEVEL_CRITICAL, "XXX");
return -1;
}
/* Set the target name identifier */
mapping->targetNameIdentifier = lasso_node_get_child_content(profile->response, "NameIdentifier", NULL, NULL);
/* verify signature */
rc = lasso_provider_verify_signature(remote_provider, response_msg, "ResponseID");
done:
statusCodeValue = LASSO_LIB_NAME_IDENTIFIER_MAPPING_RESPONSE(
profile->response)->Status->StatusCode->Value;
if (strcmp(statusCodeValue, LASSO_SAML_STATUS_CODE_SUCCESS) != 0) {
message(G_LOG_LEVEL_CRITICAL, "%s", statusCodeValue);
return -1;
}
return ret;
/* Set the target name identifier */
mapping->targetNameIdentifier = g_strdup(LASSO_LIB_NAME_IDENTIFIER_MAPPING_REQUEST(
profile->request)->NameIdentifier->content);
return 0;
}
gint
lasso_name_identifier_mapping_validate_request(LassoNameIdentifierMapping *mapping)
{
LassoProfile *profile = NULL;
LassoFederation *federation = NULL;
LassoNode *nameIdentifier = NULL, *targetNameIdentifier = NULL;
gchar *remote_providerID = NULL, *targetNameSpace = NULL;
gint ret = 0;
gint remote_provider_type;
LassoProfile *profile;
LassoProvider *remote_provider;
LassoFederation *federation;
LassoLibNameIdentifierMappingRequest *request;
LassoSamlNameIdentifier *nameIdentifier, *targetNameIdentifier;
g_return_val_if_fail(LASSO_IS_NAME_IDENTIFIER_MAPPING(mapping) == TRUE, -1);
g_return_val_if_fail(LASSO_IS_NAME_IDENTIFIER_MAPPING(mapping) == TRUE,
LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
profile = LASSO_PROFILE(mapping);
profile = LASSO_PROFILE(mapping);
/* verify the provider type is a service provider type */
if (profile->provider_type != lassoProviderTypeIdp) {
message(G_LOG_LEVEL_CRITICAL, "Build request msg method is forbidden for an SP\n");
ret = -1;
goto done;
}
/* verify the provider type is a service provider type */
if (profile->remote_providerID == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Remote provider id not found");
return -1;
}
remote_provider = g_hash_table_lookup(profile->server->providers,
profile->remote_providerID);
if (remote_provider->role != LASSO_PROVIDER_ROLE_SP) {
message(G_LOG_LEVEL_CRITICAL, "Build request msg method is forbidden at SP");
return -1;
}
/* verify request attribute of mapping is a name identifier mapping request */
if (LASSO_IS_NAME_IDENTIFIER_MAPPING_REQUEST(profile->request) == FALSE) {
message(G_LOG_LEVEL_CRITICAL, "Invalid NameIdentifierMappingRequest\n");
ret = -1;
goto done;
}
/* verify request attribute of mapping is a name identifier mapping request */
if (LASSO_IS_LIB_NAME_IDENTIFIER_MAPPING_REQUEST(profile->request) == FALSE) {
message(G_LOG_LEVEL_CRITICAL, "Invalid NameIdentifierMappingRequest");
return -1;
}
/* set the name identifier mapping response object */
switch (profile->http_request_method) {
case lassoHttpMethodSoap:
profile->response = lasso_name_identifier_mapping_response_new(profile->server->providerID,
(gchar *)lassoSamlStatusCodeSuccess,
profile->request,
lassoSignatureTypeWithX509,
lassoSignatureMethodRsaSha1);
break;
default:
message(G_LOG_LEVEL_CRITICAL, "Invalid HTTP request method\n");
ret = -1;
goto done;
}
if (LASSO_IS_NAME_IDENTIFIER_MAPPING_RESPONSE(profile->response) == FALSE) {
message(G_LOG_LEVEL_CRITICAL, "Error while building NameIdentifierMappingResponse\n");
ret = -1;
goto done;
}
if (profile->http_request_method != LASSO_HTTP_METHOD_SOAP) {
message(G_LOG_LEVEL_CRITICAL, "Invalid HTTP request method");
return -1;
}
/* set the remote provider id from the request */
profile->remote_providerID = lasso_node_get_child_content(profile->request,
"ProviderID",
NULL,
NULL);
if (profile->remote_providerID == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Remote provider id not found\n");
ret = -1;
goto done;
}
request = LASSO_LIB_NAME_IDENTIFIER_MAPPING_REQUEST(profile->request);
/* Verify identity attribute of mapping object */
if (LASSO_IS_IDENTITY(profile->identity) == FALSE) {
message(G_LOG_LEVEL_CRITICAL, "Identity not found\n");
ret = -1;
goto done;
}
profile->response = lasso_lib_name_identifier_mapping_response_new_full(
LASSO_PROVIDER(profile->server)->ProviderID,
LASSO_SAML_STATUS_CODE_SUCCESS,
request,
LASSO_SIGNATURE_TYPE_WITHX509,
LASSO_SIGNATURE_METHOD_RSA_SHA1);
/* verify federation of the SP request */
federation = lasso_identity_get_federation_ref(profile->identity, profile->remote_providerID);
if (LASSO_IS_FEDERATION(federation) == FALSE) {
lasso_name_identifier_mapping_response_set_status_code_value(LASSO_NAME_IDENTIFIER_MAPPING_RESPONSE(profile->response),
lassoLibStatusCodeUnknownPrincipal);
message(G_LOG_LEVEL_CRITICAL, "Federation not found\n");
ret = -1;
goto done;
}
nameIdentifier = lasso_federation_get_remote_nameIdentifier(federation);
if (nameIdentifier == NULL) {
nameIdentifier = lasso_federation_get_local_nameIdentifier(federation);
}
if (nameIdentifier == NULL) {
lasso_name_identifier_mapping_response_set_status_code_value(LASSO_NAME_IDENTIFIER_MAPPING_RESPONSE(profile->response),
lassoLibStatusCodeUnknownPrincipal);
message(G_LOG_LEVEL_CRITICAL, "Name identifier of federation not found\n");
ret = -1;
goto done;
}
lasso_node_destroy(nameIdentifier);
if (LASSO_IS_LIB_NAME_IDENTIFIER_MAPPING_RESPONSE(profile->response) == FALSE) {
message(G_LOG_LEVEL_CRITICAL, "Error building NameIdentifierMappingResponse");
return -1;
}
/* get the federation of the target name space and his name identifier */
targetNameSpace = lasso_node_get_child_content(profile->request, "TargetNameSpace", NULL, NULL);
if (targetNameSpace == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Target name space not found\n");
ret = -1;
goto done;
}
federation = lasso_identity_get_federation_ref(profile->identity, targetNameSpace);
if (LASSO_IS_FEDERATION(federation) == FALSE) {
lasso_name_identifier_mapping_response_set_status_code_value(LASSO_NAME_IDENTIFIER_MAPPING_RESPONSE(profile->response),
lassoLibStatusCodeFederationDoesNotExist);
message(G_LOG_LEVEL_CRITICAL, "Target name space federation not found\n");
ret = -1;
goto done;
}
targetNameIdentifier = lasso_federation_get_remote_nameIdentifier(federation);
if (targetNameIdentifier == NULL) {
targetNameIdentifier = lasso_federation_get_local_nameIdentifier(federation);
}
if (targetNameIdentifier == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Name identifier for target name space federation not found\n");
lasso_name_identifier_mapping_response_set_status_code_value(LASSO_NAME_IDENTIFIER_MAPPING_RESPONSE(profile->response),
lassoLibStatusCodeFederationDoesNotExist);
ret = -1;
goto done;
}
lasso_lib_name_identifier_mapping_response_set_nameIdentifier(LASSO_LIB_NAME_IDENTIFIER_MAPPING_RESPONSE(profile->response),
LASSO_SAML_NAME_IDENTIFIER(targetNameIdentifier));
/* verify signature status */
if (profile->signature_status != 0) {
lasso_profile_set_response_status(profile, LASSO_LIB_STATUS_CODE_INVALID_SIGNATURE);
}
done:
if (nameIdentifier != NULL) {
lasso_node_destroy(nameIdentifier);
}
if (targetNameIdentifier != NULL) {
lasso_node_destroy(targetNameIdentifier);
}
/* Verify identity attribute of mapping object */
if (LASSO_IS_IDENTITY(profile->identity) == FALSE) {
message(G_LOG_LEVEL_CRITICAL, "Identity not found");
return -1;
}
return ret;
/* verify federation of the SP request */
federation = g_hash_table_lookup(profile->identity->federations, profile->remote_providerID);
if (LASSO_IS_FEDERATION(federation) == FALSE) {
lasso_profile_set_response_status(profile,
LASSO_LIB_STATUS_CODE_UNKNOWN_PRINCIPAL);
message(G_LOG_LEVEL_CRITICAL, "Federation not found");
return -1;
}
nameIdentifier = federation->remote_nameIdentifier;
if (nameIdentifier == NULL)
nameIdentifier = federation->local_nameIdentifier;
if (nameIdentifier == NULL) {
lasso_profile_set_response_status(profile,
LASSO_LIB_STATUS_CODE_UNKNOWN_PRINCIPAL);
message(G_LOG_LEVEL_CRITICAL, "Name identifier of federation not found");
return -1;
}
/* get the federation of the target name space and his name identifier */
if (request->TargetNamespace == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Target name space not found");
return -1;
}
federation = g_hash_table_lookup(profile->identity->federations, request->TargetNamespace);
if (LASSO_IS_FEDERATION(federation) == FALSE) {
lasso_profile_set_response_status(profile,
LASSO_LIB_STATUS_CODE_FEDERATION_DOES_NOT_EXIST);
message(G_LOG_LEVEL_CRITICAL, "Target name space federation not found");
return -1;
}
targetNameIdentifier = federation->remote_nameIdentifier;
if (targetNameIdentifier == NULL) {
targetNameIdentifier = federation->local_nameIdentifier;
}
if (targetNameIdentifier == NULL) {
message(G_LOG_LEVEL_CRITICAL,
"Name identifier for target name space federation not found");
lasso_profile_set_response_status(profile,
LASSO_LIB_STATUS_CODE_FEDERATION_DOES_NOT_EXIST);
return -1;
}
LASSO_LIB_NAME_IDENTIFIER_MAPPING_RESPONSE(profile->response)->NameIdentifier =
g_object_ref(targetNameIdentifier);
return 0;
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
lasso_name_identifier_mapping_instance_init(LassoNameIdentifierMapping *name_identifier_mapping)
instance_init(LassoNameIdentifierMapping *name_identifier_mapping)
{
}
static void
lasso_name_identifier_mapping_class_init(LassoNameIdentifierMappingClass *klass)
class_init(LassoNameIdentifierMappingClass *klass)
{
}
GType lasso_name_identifier_mapping_get_type() {
static GType this_type = 0;
GType
lasso_name_identifier_mapping_get_type()
{
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoNameIdentifierMappingClass),
NULL,
NULL,
(GClassInitFunc) lasso_name_identifier_mapping_class_init,
NULL,
NULL,
sizeof(LassoNameIdentifierMapping),
0,
(GInstanceInitFunc) lasso_name_identifier_mapping_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_PROFILE,
"LassoNameIdentifierMapping",
&this_info, 0);
}
return this_type;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoNameIdentifierMappingClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoNameIdentifierMapping),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_PROFILE,
"LassoNameIdentifierMapping", &this_info, 0);
}
return this_type;
}
LassoNameIdentifierMapping *
lasso_name_identifier_mapping_new(LassoServer *server,
lassoProviderType provider_type)
lasso_name_identifier_mapping_new(LassoServer *server)
{
LassoNameIdentifierMapping *mapping;
LassoNameIdentifierMapping *mapping = NULL;
g_return_val_if_fail(LASSO_IS_SERVER(server), NULL);
g_return_val_if_fail((provider_type == lassoProviderTypeSp) || (provider_type == lassoProviderTypeIdp), NULL);
g_return_val_if_fail(LASSO_IS_SERVER(server), NULL);
/* set the name_identifier_mapping object */
mapping = g_object_new(LASSO_TYPE_NAME_IDENTIFIER_MAPPING,
"server", lasso_server_copy(server),
"provider_type", provider_type,
NULL);
return mapping;
mapping = g_object_new(LASSO_TYPE_NAME_IDENTIFIER_MAPPING, NULL);
LASSO_PROFILE(mapping)->server = server;
return mapping;
}
LassoNameIdentifierMapping *
lasso_name_identifier_mapping_new_from_dump(LassoServer *server,
gchar *dump)
LassoNameIdentifierMapping*
lasso_name_identifier_mapping_new_from_dump(LassoServer *server, gchar *dump)
{
LassoNameIdentifierMapping *mapping;
LassoNode *node_dump;
g_return_val_if_fail(LASSO_IS_SERVER(server), NULL);
g_return_val_if_fail(dump != NULL, NULL);
mapping = g_object_new(LASSO_TYPE_NAME_IDENTIFIER_MAPPING,
"server", lasso_server_copy(server),
NULL);
node_dump = lasso_node_new_from_dump(dump);
return mapping;
g_assert_not_reached();
return NULL;
}
char*
lasso_name_identifier_mapping_dump(LassoNameIdentifierMapping *mapping)
{
g_assert_not_reached();
return lasso_node_dump(LASSO_NODE(mapping), NULL, 1);
}

View File

@ -32,8 +32,8 @@ extern "C" {
#include <lasso/environs/profile.h>
#include <lasso/protocols/name_identifier_mapping_request.h>
#include <lasso/protocols/name_identifier_mapping_response.h>
#include <lasso/xml/lib_name_identifier_mapping_request.h>
#include <lasso/xml/lib_name_identifier_mapping_response.h>
#define LASSO_TYPE_NAME_IDENTIFIER_MAPPING (lasso_name_identifier_mapping_get_type())
#define LASSO_NAME_IDENTIFIER_MAPPING(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_NAME_IDENTIFIER_MAPPING, LassoNameIdentifierMapping))
@ -46,22 +46,18 @@ typedef struct _LassoNameIdentifierMapping LassoNameIdentifierMapping;
typedef struct _LassoNameIdentifierMappingClass LassoNameIdentifierMappingClass;
struct _LassoNameIdentifierMapping {
LassoProfile parent;
gchar *targetNameIdentifier;
/*< private >*/
LassoProfile parent;
gchar *targetNameIdentifier;
};
struct _LassoNameIdentifierMappingClass {
LassoProfileClass parent;
LassoProfileClass parent;
};
LASSO_EXPORT GType lasso_name_identifier_mapping_get_type (void);
LASSO_EXPORT LassoNameIdentifierMapping* lasso_name_identifier_mapping_new (LassoServer *server,
lassoProviderType provider_type);
LASSO_EXPORT LassoNameIdentifierMapping* lasso_name_identifier_mapping_new(LassoServer *server);
LASSO_EXPORT gchar * lasso_name_identifier_mapping_dump(LassoNameIdentifierMapping*);
LASSO_EXPORT gint lasso_name_identifier_mapping_build_request_msg (LassoNameIdentifierMapping *mapping);
@ -74,12 +70,10 @@ LASSO_EXPORT gint lasso_name_identifier_mapping_init_requ
gchar *remote_providerID);
LASSO_EXPORT gint lasso_name_identifier_mapping_process_request_msg (LassoNameIdentifierMapping *mapping,
gchar *request_msg,
lassoHttpMethod request_method);
gchar *request_msg);
LASSO_EXPORT gint lasso_name_identifier_mapping_process_response_msg (LassoNameIdentifierMapping *mapping,
gchar *response_msg,
lassoHttpMethod response_method);
gchar *response_msg);
LASSO_EXPORT gint lasso_name_identifier_mapping_validate_request (LassoNameIdentifierMapping *mapping);

File diff suppressed because it is too large Load Diff

View File

@ -32,8 +32,8 @@ extern "C" {
#include <lasso/environs/profile.h>
#include <lasso/protocols/register_name_identifier_request.h>
#include <lasso/protocols/register_name_identifier_response.h>
#include <lasso/xml/lib_register_name_identifier_request.h>
#include <lasso/xml/lib_register_name_identifier_response.h>
#define LASSO_TYPE_NAME_REGISTRATION (lasso_name_registration_get_type())
#define LASSO_NAME_REGISTRATION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_NAME_REGISTRATION, LassoNameRegistration))
@ -46,25 +46,20 @@ typedef struct _LassoNameRegistration LassoNameRegistration;
typedef struct _LassoNameRegistrationClass LassoNameRegistrationClass;
struct _LassoNameRegistration {
LassoProfile parent;
gchar *oldNameIdentifier;
/*< private >*/
LassoProfile parent;
gchar *oldNameIdentifier;
};
struct _LassoNameRegistrationClass {
LassoProfileClass parent;
LassoProfileClass parent;
};
LASSO_EXPORT GType lasso_name_registration_get_type (void);
LASSO_EXPORT LassoNameRegistration* lasso_name_registration_new (LassoServer *server,
lassoProviderType provider_type);
LASSO_EXPORT LassoNameRegistration* lasso_name_registration_new(LassoServer *server);
LASSO_EXPORT LassoNameRegistration* lasso_name_registration_new_from_dump (LassoServer *server,
gchar *dump);
LASSO_EXPORT LassoNameRegistration* lasso_name_registration_new_from_dump(
LassoServer *server, const char *dump);
LASSO_EXPORT gint lasso_name_registration_build_request_msg (LassoNameRegistration *name_registration);
@ -74,16 +69,14 @@ LASSO_EXPORT void lasso_name_registration_destroy (Lasso
LASSO_EXPORT gchar* lasso_name_registration_dump (LassoNameRegistration *name_registration);
LASSO_EXPORT gint lasso_name_registration_init_request (LassoNameRegistration *name_registration,
gchar *remote_providerID);
LASSO_EXPORT gint lasso_name_registration_init_request(LassoNameRegistration *name_registration,
char *remote_providerID, lassoHttpMethod http_method);
LASSO_EXPORT gint lasso_name_registration_process_request_msg (LassoNameRegistration *name_registration,
gchar *request_msg,
lassoHttpMethod request_method);
gchar *request_msg);
LASSO_EXPORT gint lasso_name_registration_process_response_msg (LassoNameRegistration *name_registration,
gchar *response_msg,
lassoHttpMethod response_method);
gchar *response_msg);
LASSO_EXPORT gint lasso_name_registration_validate_request (LassoNameRegistration *name_registration);

View File

@ -26,76 +26,108 @@
#include <glib.h>
#include <glib/gprintf.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
#include <lasso/xml/errors.h>
#include <lasso/xml/samlp_response.h>
#include <lasso/protocols/request.h>
#include <lasso/protocols/response.h>
#include <lasso/protocols/authn_response.h>
#include <lasso/xml/samlp_request.h>
#include <lasso/xml/lib_authn_response.h>
#include <lasso/xml/lib_status_response.h>
#include <lasso/environs/profile.h>
#include <lasso/lasso_config.h>
struct _LassoProfilePrivate
{
gboolean dispose_has_run;
gboolean dispose_has_run;
};
static GObjectClass *parent_class = NULL;
/*****************************************************************************/
/* public functions */
/*****************************************************************************/
LassoSamlNameIdentifier*
lasso_profile_get_nameIdentifier(LassoProfile *ctx)
{
LassoProvider *remote_provider;
LassoFederation *federation;
g_return_val_if_fail(LASSO_IS_PROFILE(ctx), NULL);
g_return_val_if_fail(LASSO_IS_SERVER(ctx->server), NULL);
g_return_val_if_fail(LASSO_IS_IDENTITY(ctx->identity), NULL);
g_return_val_if_fail(ctx->remote_providerID != NULL, NULL);
remote_provider = g_hash_table_lookup(ctx->server->providers, ctx->remote_providerID);
if (remote_provider == NULL)
return NULL;
federation = g_hash_table_lookup(ctx->identity->federations, ctx->remote_providerID);
if (federation == NULL)
return NULL;
if (remote_provider->role == LASSO_PROVIDER_ROLE_SP) {
if (federation->remote_nameIdentifier)
return federation->remote_nameIdentifier;
return federation->local_nameIdentifier;
}
if (remote_provider->role == LASSO_PROVIDER_ROLE_IDP) {
if (federation->local_nameIdentifier)
return federation->local_nameIdentifier;
return federation->remote_nameIdentifier;
}
return NULL;
}
lassoRequestType
lasso_profile_get_request_type_from_soap_msg(const gchar *soap)
{
LassoNode *soap_node, *body_node, *request_node;
GPtrArray *children;
xmlChar *name;
lassoRequestType type = lassoRequestTypeInvalid;
xmlDoc *doc;
xmlXPathContext *xpathCtx;
xmlXPathObject *xpathObj;
const xmlChar *name;
soap_node = lasso_node_new_from_dump(soap);
if (soap_node == NULL) {
message(G_LOG_LEVEL_WARNING, "Error while build node from soap msg\n");
return -1;
}
lassoRequestType type = LASSO_REQUEST_TYPE_INVALID;
body_node = lasso_node_get_child(soap_node, "Body", NULL, NULL);
if(body_node == NULL) {
message(G_LOG_LEVEL_WARNING, "Body node not found\n");
return -2;
}
/* FIXME: totally lacking error checking */
children = lasso_node_get_children(body_node);
if(children->len > 0) {
request_node = g_ptr_array_index(children, 0);
name = lasso_node_get_name(request_node);
doc = xmlParseMemory(soap, strlen(soap));
xpathCtx = xmlXPathNewContext(doc);
xmlXPathRegisterNs(xpathCtx, "s", LASSO_SOAP_ENV_HREF);
xpathObj = xmlXPathEvalExpression("//s:Body/*", xpathCtx);
if(xmlStrEqual(name, "Request")) {
type = lassoRequestTypeLogin;
}
else if(xmlStrEqual(name, "LogoutRequest")) {
type = lassoRequestTypeLogout;
}
else if(xmlStrEqual(name, "FederationTerminationNotification")) {
type = lassoRequestTypeDefederation;
}
else if(xmlStrEqual(name, "RegisterNameIdentifierRequest")) {
type = lassoRequestTypeNameRegistration;
}
else if(xmlStrEqual(name, "NameIdentifierMappingRequest")) {
type = lassoRequestTypeNameIdentifierMapping;
}
else if(xmlStrEqual(name, "AuthnRequest")) {
type = lassoRequestTypeLecp;
}
else {
message(G_LOG_LEVEL_WARNING, "Unkown node name : %s\n", name);
}
xmlFree(name);
}
name = xpathObj->nodesetval->nodeTab[0]->name;
return type;
if (xmlStrEqual(name, "Request")) {
type = LASSO_REQUEST_TYPE_LOGIN;
}
else if (xmlStrEqual(name, "LogoutRequest")) {
type = LASSO_REQUEST_TYPE_LOGOUT;
}
else if (xmlStrEqual(name, "FederationTerminationNotification")) {
type = LASSO_REQUEST_TYPE_DEFEDERATION;
}
else if (xmlStrEqual(name, "RegisterNameIdentifierRequest")) {
type = LASSO_REQUEST_TYPE_NAME_REGISTRATION;
}
else if (xmlStrEqual(name, "NameIdentifierMappingRequest")) {
type = LASSO_REQUEST_TYPE_NAME_IDENTIFIER_MAPPING;
}
else if (xmlStrEqual(name, "AuthnRequest")) {
type = LASSO_REQUEST_TYPE_LECP;
}
else {
message(G_LOG_LEVEL_WARNING, "Unkown node name : %s\n", name);
}
xmlFreeDoc(doc);
xmlXPathFreeContext(xpathCtx);
xmlXPathFreeObject(xpathObj);
return type;
}
/**
@ -110,23 +142,23 @@ lasso_profile_get_request_type_from_soap_msg(const gchar *soap)
gboolean
lasso_profile_is_liberty_query(const gchar *query)
{
/* logic is that a lasso query always has some parameters (RequestId,
* MajorVersion, MinorVersion, IssueInstant, ProviderID,
* NameIdentifier, NameQualifier, Format). If three of them are there;
* it's a lasso query, possibly broken, but a lasso query nevertheless.
*/
gchar *parameters[] = {
"RequestId=", "MajorVersion=", "MinorVersion=", "IssueInstant=",
"ProviderID=", "NameIdentifier=", "NameQualifier=", "Format=",
NULL };
gint i, n = 0;
/* logic is that a lasso query always has some parameters (RequestId,
* MajorVersion, MinorVersion, IssueInstant, ProviderID,
* NameIdentifier, NameQualifier, Format). If three of them are there;
* it's a lasso query, possibly broken, but a lasso query nevertheless.
*/
gchar *parameters[] = {
"RequestId=", "MajorVersion=", "MinorVersion=", "IssueInstant=",
"ProviderID=", "NameIdentifier=", "NameQualifier=", "Format=",
NULL };
gint i, n = 0;
for (i=0; parameters[i] && n < 3; i++) {
if (strstr(query, parameters[i]))
n++;
}
for (i=0; parameters[i] && n < 3; i++) {
if (strstr(query, parameters[i]))
n++;
}
return (n == 3);
return (n == 3);
}
@ -134,443 +166,306 @@ lasso_profile_is_liberty_query(const gchar *query)
/* public methods */
/*****************************************************************************/
gchar*
lasso_profile_dump(LassoProfile *ctx,
const gchar *name)
{
LassoNode *node;
LassoNode *request, *response = NULL;
gchar *dump = NULL;
gchar *request_type = g_new0(gchar, 6);
gchar *response_type = g_new0(gchar, 6);
gchar *provider_type = g_new0(gchar, 6);
node = lasso_node_new();
if (name != NULL) {
LASSO_NODE_GET_CLASS(node)->set_name(node, name);
}
else {
LASSO_NODE_GET_CLASS(node)->set_name(node, "LassoProfile");
}
LASSO_NODE_GET_CLASS(node)->set_ns(node, lassoLassoHRef, NULL);
/* Add lasso version in the xml node */
LASSO_NODE_GET_CLASS(node)->set_prop(LASSO_NODE(node), "version", PACKAGE_VERSION);
if (ctx->request != NULL) {
request = lasso_node_copy(ctx->request);
LASSO_NODE_GET_CLASS(node)->add_child(node, request, FALSE);
lasso_node_destroy(request);
}
if (ctx->response != NULL) {
response = lasso_node_copy(ctx->response);
LASSO_NODE_GET_CLASS(node)->add_child(node, response, FALSE);
lasso_node_destroy(response);
}
if (ctx->nameIdentifier != NULL) {
LASSO_NODE_GET_CLASS(node)->new_child(node, "NameIdentifier",
ctx->nameIdentifier, FALSE);
}
if (ctx->remote_providerID != NULL) {
LASSO_NODE_GET_CLASS(node)->new_child(node, "RemoteProviderID",
ctx->remote_providerID, FALSE);
}
if (ctx->msg_url != NULL) {
LASSO_NODE_GET_CLASS(node)->new_child(node, "MsgUrl", ctx->msg_url, FALSE);
}
if (ctx->msg_body != NULL) {
LASSO_NODE_GET_CLASS(node)->new_child(node, "MsgBody", ctx->msg_body, FALSE);
}
if (ctx->msg_relayState != NULL) {
LASSO_NODE_GET_CLASS(node)->new_child(node, "MsgRelayState",
ctx->msg_relayState, FALSE);
}
g_snprintf(request_type, 6, "%d", ctx->request_type);
LASSO_NODE_GET_CLASS(node)->new_child(node, "RequestType", request_type, FALSE);
g_free(request_type);
g_snprintf(response_type, 6, "%d", ctx->response_type);
LASSO_NODE_GET_CLASS(node)->new_child(node, "ResponseType", response_type, FALSE);
g_free(response_type);
g_snprintf(provider_type, 6, "%d", ctx->provider_type);
LASSO_NODE_GET_CLASS(node)->new_child(node, "ProviderType", provider_type, FALSE);
g_free(provider_type);
dump = lasso_node_export(node);
lasso_node_destroy(node);
return dump;
}
LassoIdentity*
lasso_profile_get_identity(LassoProfile *ctx)
{
g_return_val_if_fail(LASSO_IS_PROFILE(ctx), NULL);
if (ctx->identity != NULL) {
/* return identity copy only if identity isn't empty */
if (ctx->identity->providerIDs->len > 0) {
return lasso_identity_copy(ctx->identity);
}
}
return NULL;
}
gchar*
lasso_profile_get_remote_providerID(LassoProfile *ctx)
{
g_return_val_if_fail(LASSO_IS_PROFILE(ctx), NULL);
if (ctx->remote_providerID != NULL) {
return g_strdup(ctx->remote_providerID);
}
return NULL;
if (ctx->identity && g_hash_table_size(ctx->identity->federations))
return ctx->identity;
return NULL;
}
LassoSession*
lasso_profile_get_session(LassoProfile *ctx)
{
g_return_val_if_fail(LASSO_IS_PROFILE(ctx), NULL);
if (ctx->session != NULL) {
/* return session copy only if session isn't empty */
if (ctx->session->providerIDs->len > 0) {
return lasso_session_copy(ctx->session);
}
}
return NULL;
if (ctx->session && g_hash_table_size(ctx->session->assertions))
return ctx->session;
return NULL;
}
gboolean
lasso_profile_is_identity_dirty(LassoProfile *ctx)
{
if (ctx->identity != NULL) {
return ctx->identity->is_dirty;
}
else {
return FALSE;
}
return (ctx->identity && ctx->identity->is_dirty);
}
gboolean
lasso_profile_is_session_dirty(LassoProfile *ctx)
{
if (ctx->session != NULL) {
return ctx->session->is_dirty;
}
else {
return FALSE;
}
}
gint
lasso_profile_set_remote_providerID(LassoProfile *ctx,
gchar *providerID)
{
g_free(ctx->remote_providerID);
ctx->remote_providerID = g_strdup(providerID);
return 1;
return (ctx->session && ctx->session->is_dirty);
}
void
lasso_profile_set_response_status(LassoProfile *ctx,
const gchar *statusCodeValue)
lasso_profile_set_response_status(LassoProfile *ctx, const char *statusCodeValue)
{
LassoNode *status, *status_code;
LassoSamlpStatus *status;
/* XXX: cleanup before if necessary */
status = lasso_samlp_status_new();
status = lasso_samlp_status_new();
status->StatusCode = lasso_samlp_status_code_new();
status->StatusCode->Value = g_strdup(statusCodeValue);
status_code = lasso_samlp_status_code_new();
lasso_samlp_status_code_set_value(LASSO_SAMLP_STATUS_CODE(status_code),
statusCodeValue);
if (LASSO_IS_SAMLP_RESPONSE(ctx->response)) {
LASSO_SAMLP_RESPONSE(ctx->response)->Status = status;
return;
}
if (LASSO_IS_LIB_STATUS_RESPONSE(ctx->response)) {
LASSO_LIB_STATUS_RESPONSE(ctx->response)->Status = status;
return;
}
lasso_samlp_status_set_statusCode(LASSO_SAMLP_STATUS(status),
LASSO_SAMLP_STATUS_CODE(status_code));
message(G_LOG_LEVEL_CRITICAL, "Failed to set status");
g_assert_not_reached();
}
lasso_samlp_response_set_status(LASSO_SAMLP_RESPONSE(ctx->response),
LASSO_SAMLP_STATUS(status));
lasso_node_destroy(status_code);
lasso_node_destroy(status);
gint
lasso_profile_set_identity_from_dump(LassoProfile *ctx, const gchar *dump)
{
g_return_val_if_fail(dump != NULL, LASSO_PARAM_ERROR_INVALID_VALUE);
ctx->identity = lasso_identity_new_from_dump(dump);
if (ctx->identity == NULL) {
message(G_LOG_LEVEL_WARNING, "Failed to create the identity from the identity dump");
return -1;
}
ctx->identity->is_dirty = FALSE;
return 0;
}
gint
lasso_profile_set_identity(LassoProfile *ctx,
LassoIdentity *identity)
lasso_profile_set_session_from_dump(LassoProfile *ctx, const gchar *dump)
{
g_return_val_if_fail(LASSO_IS_IDENTITY(identity), LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
g_return_val_if_fail(dump != NULL, LASSO_PARAM_ERROR_INVALID_VALUE);
ctx->identity = lasso_identity_copy(identity);
ctx->identity->is_dirty = FALSE;
ctx->session = lasso_session_new_from_dump(dump);
if (ctx->session == NULL) {
message(G_LOG_LEVEL_WARNING, "Failed to create the session from the session dump");
return -1;
}
ctx->session->is_dirty = FALSE;
return 0;
}
gint
lasso_profile_set_identity_from_dump(LassoProfile *ctx,
const gchar *dump)
/*****************************************************************************/
/* private methods */
/*****************************************************************************/
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
g_return_val_if_fail(dump != NULL, LASSO_PARAM_ERROR_INVALID_VALUE);
xmlNode *xmlnode, *t;
LassoProfile *profile = LASSO_PROFILE(node);
ctx->identity = lasso_identity_new_from_dump((gchar *)dump);
if (ctx->identity == NULL) {
message(G_LOG_LEVEL_WARNING, "Failed to create the identity from the identity dump\n");
return -1;
}
ctx->identity->is_dirty = FALSE;
xmlnode = xmlNewNode(NULL, "Profile");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LASSO_HREF, NULL));
xmlSetProp(xmlnode, "Version", "2");
return 0;
/* XXX: server is not saved in profile dump */
/* (what was the reason ?)
if (profile->server) {
xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(profile->server)));
}
*/
if (profile->request) {
t = xmlNewTextChild(xmlnode, NULL, "Request", NULL);
xmlAddChild(t, lasso_node_get_xmlNode(profile->request));
}
if (profile->response) {
t = xmlNewTextChild(xmlnode, NULL, "Response", NULL);
xmlAddChild(t, lasso_node_get_xmlNode(profile->response));
}
if (profile->nameIdentifier)
xmlNewTextChild(xmlnode, NULL, "NameIdentifier", profile->nameIdentifier);
if (profile->remote_providerID)
xmlNewTextChild(xmlnode, NULL, "RemoteProviderID", profile->remote_providerID);
if (profile->msg_url)
xmlNewTextChild(xmlnode, NULL, "MsgUrl", profile->msg_url);
if (profile->msg_body)
xmlNewTextChild(xmlnode, NULL, "MsgBody", profile->msg_body);
if (profile->msg_relayState)
xmlNewTextChild(xmlnode, NULL, "MsgRelayState", profile->msg_relayState);
/* XXX: save signature status ? */
return xmlnode;
}
gint
lasso_profile_set_session(LassoProfile *ctx,
LassoSession *session)
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
g_return_val_if_fail(LASSO_IS_SESSION(session), LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
LassoProfile *profile = LASSO_PROFILE(node);
xmlNode *t;
ctx->session = lasso_session_copy(session);
ctx->session->is_dirty = FALSE;
t = xmlnode->children;
while (t) {
if (t->type != XML_ELEMENT_NODE) {
t = t->next;
continue;
}
if (strcmp(t->name, "NameIdentifier") == 0)
profile->nameIdentifier = xmlNodeGetContent(t);
if (strcmp(t->name, "RemoteProviderID") == 0)
profile->remote_providerID = xmlNodeGetContent(t);
if (strcmp(t->name, "MsgUrl") == 0)
profile->msg_url = xmlNodeGetContent(t);
if (strcmp(t->name, "MsgBody") == 0)
profile->msg_body = xmlNodeGetContent(t);
if (strcmp(t->name, "MsgRelayState") == 0)
profile->msg_relayState = xmlNodeGetContent(t);
return 0;
if (strcmp(t->name, "Server") == 0) {
LassoServer *s;
s = g_object_new(LASSO_TYPE_SERVER, NULL);
LASSO_NODE_GET_CLASS(s)->init_from_xml(LASSO_NODE(s), t);
}
if (strcmp(t->name, "Request") == 0) {
xmlNode *t2 = t->children;
while (t2 && t2->type != XML_ELEMENT_NODE)
t2 = t2->next;
if (t2)
profile->request = lasso_node_new_from_xmlNode(t2);
}
if (strcmp(t->name, "Response") == 0) {
xmlNode *t2 = t->children;
while (t2 && t2->type != XML_ELEMENT_NODE)
t2 = t2->next;
if (t2)
profile->response = lasso_node_new_from_xmlNode(t2);
}
t = t->next;
}
}
gint
lasso_profile_set_session_from_dump(LassoProfile *ctx,
const gchar *dump)
{
g_return_val_if_fail(dump != NULL, LASSO_PARAM_ERROR_INVALID_VALUE);
ctx->session = lasso_session_new_from_dump((gchar *)dump);
if (ctx->session == NULL) {
message(G_LOG_LEVEL_WARNING, "Failed to create the session from the session dump\n");
return -1;
}
ctx->session->is_dirty = FALSE;
return 0;
}
/*****************************************************************************/
/* overrided parent class methods */
/*****************************************************************************/
static void
lasso_profile_dispose(LassoProfile *ctx)
dispose(GObject *object)
{
if (ctx->private->dispose_has_run) {
return;
}
ctx->private->dispose_has_run = TRUE;
LassoProfile *profile = LASSO_PROFILE(object);
debug("Profile object 0x%x disposed ...\n", ctx);
if (profile->private->dispose_has_run) {
return;
}
profile->private->dispose_has_run = TRUE;
/* unref reference counted objects */
lasso_server_destroy(ctx->server);
lasso_identity_destroy(ctx->identity);
lasso_session_destroy(ctx->session);
debug("Profile object 0x%x disposed ...\n", profile);
lasso_node_destroy(ctx->request);
lasso_node_destroy(ctx->response);
/* XXX unref reference counted objects */
/* lasso_server_destroy(profile->server);
lasso_identity_destroy(profile->identity);
lasso_session_destroy(profile->session);
parent_class->dispose(G_OBJECT(ctx));
lasso_node_destroy(profile->request);
lasso_node_destroy(profile->response);
*/
G_OBJECT_CLASS(parent_class)->dispose(G_OBJECT(profile));
}
static void
lasso_profile_finalize(LassoProfile *ctx)
finalize(GObject *object)
{
debug("Profile object 0x%x finalized ...\n", ctx);
LassoProfile *profile = LASSO_PROFILE(object);
g_free(ctx->nameIdentifier);
g_free(ctx->remote_providerID);
g_free(ctx->msg_url);
g_free(ctx->msg_body);
g_free(ctx->msg_relayState);
debug("Profile object 0x%x finalized ...\n", ctx);
g_free (ctx->private);
g_free(profile->nameIdentifier);
g_free(profile->remote_providerID);
g_free(profile->msg_url);
g_free(profile->msg_body);
g_free(profile->msg_relayState);
parent_class->finalize(G_OBJECT(ctx));
g_free (profile->private);
G_OBJECT_CLASS(parent_class)->finalize(object);
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
enum {
LASSO_PROFILE_SERVER = 1,
LASSO_PROFILE_IDENTITY,
LASSO_PROFILE_SESSION,
LASSO_PROFILE_PROVIDER_TYPE
};
static void
lasso_profile_instance_init(GTypeInstance *instance,
gpointer g_class)
instance_init(LassoProfile *profile)
{
LassoProfile *ctx = LASSO_PROFILE(instance);
profile->private = g_new (LassoProfilePrivate, 1);
profile->private->dispose_has_run = FALSE;
ctx->private = g_new (LassoProfilePrivate, 1);
ctx->private->dispose_has_run = FALSE;
profile->server = NULL;
profile->request = NULL;
profile->response = NULL;
profile->nameIdentifier = NULL;
profile->remote_providerID = NULL;
profile->msg_url = NULL;
profile->msg_body = NULL;
profile->msg_relayState = NULL;
ctx->server = NULL;
ctx->request = NULL;
ctx->response = NULL;
ctx->nameIdentifier = NULL;
ctx->remote_providerID = NULL;
ctx->msg_url = NULL;
ctx->msg_body = NULL;
ctx->msg_relayState = NULL;
ctx->identity = NULL;
ctx->session = NULL;
ctx->request_type = lassoMessageTypeNone;
ctx->response_type = lassoMessageTypeNone;
ctx->provider_type = lassoProviderTypeNone;
ctx->signature_status = 0;
profile->identity = NULL;
profile->session = NULL;
profile->signature_status = 0;
}
static void
lasso_profile_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
class_init(LassoProfileClass *klass)
{
LassoProfile *self = LASSO_PROFILE(object);
parent_class = g_type_class_peek_parent(klass);
switch (property_id) {
case LASSO_PROFILE_SERVER: {
if (self->server) {
g_object_unref(self->server);
}
self->server = g_value_get_pointer (value);
}
break;
case LASSO_PROFILE_IDENTITY: {
if (self->identity) {
g_object_unref(self->identity);
}
self->identity = g_value_get_pointer (value);
}
break;
case LASSO_PROFILE_SESSION: {
if (self->session) {
g_object_unref(self->session);
}
self->session = g_value_get_pointer (value);
}
break;
case LASSO_PROFILE_PROVIDER_TYPE: {
self->provider_type = g_value_get_uint (value);
}
break;
default:
/* We don't have any other property... */
g_assert (FALSE);
break;
}
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
G_OBJECT_CLASS(klass)->dispose = dispose;
G_OBJECT_CLASS(klass)->finalize = finalize;
}
static void
lasso_profile_get_property(GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
GType
lasso_profile_get_type()
{
}
static GType this_type = 0;
static void
lasso_profile_class_init(gpointer g_class,
gpointer g_class_data)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (g_class);
GParamSpec *pspec;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof(LassoProfileClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoProfile),
0,
(GInstanceInitFunc) instance_init,
};
parent_class = g_type_class_peek_parent(g_class);
/* override parent class methods */
gobject_class->set_property = lasso_profile_set_property;
gobject_class->get_property = lasso_profile_get_property;
pspec = g_param_spec_pointer ("server",
"server metadata and keys/certs",
"Data of server",
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
g_object_class_install_property (gobject_class,
LASSO_PROFILE_SERVER,
pspec);
pspec = g_param_spec_pointer ("identity",
"user's federations",
"User's federations",
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
g_object_class_install_property (gobject_class,
LASSO_PROFILE_IDENTITY,
pspec);
pspec = g_param_spec_pointer ("session",
"user's assertions",
"User's assertions",
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
g_object_class_install_property (gobject_class,
LASSO_PROFILE_SESSION,
pspec);
pspec = g_param_spec_uint ("provider_type",
"provider type",
"The provider type",
0,
G_MAXINT,
0,
G_PARAM_READABLE | G_PARAM_WRITABLE);
g_object_class_install_property (gobject_class,
LASSO_PROFILE_PROVIDER_TYPE,
pspec);
gobject_class->dispose = (void *)lasso_profile_dispose;
gobject_class->finalize = (void *)lasso_profile_finalize;
}
GType lasso_profile_get_type() {
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoProfileClass),
NULL,
NULL,
(GClassInitFunc) lasso_profile_class_init,
NULL,
NULL,
sizeof(LassoProfile),
0,
(GInstanceInitFunc) lasso_profile_instance_init,
};
this_type = g_type_register_static(G_TYPE_OBJECT,
"LassoProfile",
&this_info, 0);
}
return this_type;
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoProfile", &this_info, 0);
}
return this_type;
}
LassoProfile*
lasso_profile_new(LassoServer *server,
LassoIdentity *identity,
LassoSession *session)
lasso_profile_new(LassoServer *server, LassoIdentity *identity, LassoSession *session)
{
LassoProfile *ctx;
LassoProfile *profile = NULL;
g_return_val_if_fail(server != NULL, NULL);
g_return_val_if_fail(server != NULL, NULL);
ctx = LASSO_PROFILE(g_object_new(LASSO_TYPE_PROFILE,
"server", lasso_server_copy(server),
"identity", lasso_identity_copy(identity),
"session", lasso_session_copy(session),
NULL));
profile = g_object_new(LASSO_TYPE_PROFILE, NULL);
profile->identity = identity;
profile->session = session;
return ctx;
return profile;
}
gchar*
lasso_profile_dump(LassoProfile *profile)
{
return lasso_node_dump(LASSO_NODE(profile), NULL, 1);
}

View File

@ -51,67 +51,53 @@ typedef struct _LassoProfilePrivate LassoProfilePrivate;
/* Request types (used by SOAP endpoint) */
typedef enum {
lassoRequestTypeInvalid = 0,
lassoRequestTypeLogin = 1,
lassoRequestTypeLogout = 2,
lassoRequestTypeDefederation = 3,
lassoRequestTypeRegisterNameIdentifier = 4, /* obsolete, use lassoRequestTypeNameRegistration instead */
lassoRequestTypeNameRegistration = 4,
lassoRequestTypeNameIdentifierMapping = 5,
lassoRequestTypeLecp = 6
LASSO_REQUEST_TYPE_INVALID = 0,
LASSO_REQUEST_TYPE_LOGIN = 1,
LASSO_REQUEST_TYPE_LOGOUT = 2,
LASSO_REQUEST_TYPE_DEFEDERATION = 3,
LASSO_REQUEST_TYPE_NAME_REGISTRATION = 4,
LASSO_REQUEST_TYPE_NAME_IDENTIFIER_MAPPING = 5,
LASSO_REQUEST_TYPE_LECP = 6
} lassoRequestType;
typedef enum {
lassoHttpMethodAny = -1,
lassoHttpMethodSelfAddressed,
lassoHttpMethodGet,
lassoHttpMethodPost,
lassoHttpMethodRedirect,
lassoHttpMethodSoap
} lassoHttpMethod;
typedef enum {
lassoMessageTypeNone = 0,
lassoMessageTypeAuthnRequest,
lassoMessageTypeAuthnResponse,
lassoMessageTypeRequest,
lassoMessageTypeResponse,
lassoMessageTypeArtifact
LASSO_MESSAGE_TYPE_NONE = 0,
LASSO_MESSAGE_TYPE_AUTHN_REQUEST,
LASSO_MESSAGE_TYPE_AUTHN_RESPONSE,
LASSO_MESSAGE_TYPE_REQUEST,
LASSO_MESSAGE_TYPE_RESPONSE,
LASSO_MESSAGE_TYPE_ARTIFACT
} lassoMessageType;
struct _LassoProfile {
GObject parent;
LassoNode parent;
/*< public >*/
LassoServer *server;
/*< public >*/
LassoServer *server;
LassoNode *request;
LassoNode *response;
LassoNode *request;
LassoNode *response;
gchar *nameIdentifier;
gchar *nameIdentifier; /* XXX: shouldn't it be LassoSamlNameIdentifier ? */
gchar *remote_providerID;
gchar *remote_providerID;
gchar *msg_url;
gchar *msg_body;
gchar *msg_relayState;
gchar *msg_url;
gchar *msg_body;
gchar *msg_relayState;
/*< private >*/
LassoIdentity *identity;
LassoSession *session;
/*< private >*/
LassoIdentity *identity;
LassoSession *session;
lassoMessageType request_type;
lassoMessageType response_type;
lassoProviderType provider_type;
lassoHttpMethod http_request_method;
gint signature_status;
lassoHttpMethod http_request_method;
gint signature_status;
LassoProfilePrivate *private;
LassoProfilePrivate *private;
};
struct _LassoProfileClass {
GObjectClass parent;
LassoNodeClass parent;
};
/* public functions */
@ -128,37 +114,27 @@ LASSO_EXPORT LassoProfile* lasso_profile_new (LassoS
LassoIdentity *identity,
LassoSession *session);
LASSO_EXPORT gchar* lasso_profile_dump (LassoProfile *ctx,
const gchar *name);
LASSO_EXPORT gchar* lasso_profile_dump (LassoProfile *ctx);
LASSO_EXPORT LassoIdentity* lasso_profile_get_identity (LassoProfile *ctx);
LASSO_EXPORT gchar* lasso_profile_get_remote_providerID (LassoProfile *ctx);
LASSO_EXPORT LassoSession* lasso_profile_get_session (LassoProfile *ctx);
LASSO_EXPORT gboolean lasso_profile_is_identity_dirty (LassoProfile *ctx);
LASSO_EXPORT gboolean lasso_profile_is_session_dirty (LassoProfile *ctx);
LASSO_EXPORT gint lasso_profile_set_remote_providerID (LassoProfile *ctx,
gchar *providerID);
LASSO_EXPORT void lasso_profile_set_response_status (LassoProfile *ctx,
const gchar *statusCodeValue);
LASSO_EXPORT gint lasso_profile_set_identity (LassoProfile *ctx,
LassoIdentity *identity);
LASSO_EXPORT gint lasso_profile_set_identity_from_dump (LassoProfile *ctx,
const gchar *dump);
LASSO_EXPORT gint lasso_profile_set_session (LassoProfile *ctx,
LassoSession *session);
LASSO_EXPORT gint lasso_profile_set_session_from_dump (LassoProfile *ctx,
const gchar *dump);
LASSO_EXPORT LassoSamlNameIdentifier* lasso_profile_get_nameIdentifier(LassoProfile *ctx);
#ifdef __cplusplus
}
#endif /* __cplusplus */

517
lasso/id-ff/provider.c Normal file
View File

@ -0,0 +1,517 @@
/* $Id$
*
* Lasso - A free implementation of the Liberty Alliance specifications.
*
* Copyright (C) 2004 Entr'ouvert
* http://lasso.entrouvert.org
*
* Authors: Nicolas Clapies <nclapies@entrouvert.com>
* Valery Febvre <vfebvre@easter-eggs.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
#include <xmlsec/xmldsig.h>
#include <xmlsec/xmltree.h>
#include <lasso/environs/provider.h>
#include <lasso/xml/errors.h>
struct _LassoProviderPrivate
{
gboolean dispose_has_run;
GHashTable *SPDescriptor;
GHashTable *IDPDescriptor;
};
static char *protocol_uris[] = {
"http://projectliberty.org/profiles/fedterm",
"http://projectliberty.org/profiles/nim",
"http://projectliberty.org/profiles/rni",
"http://projectliberty.org/profiles/slo",
NULL /* none for single sign on */
};
static char *protocol_md_nodename[] = {
"FederationTerminationNotificationProtocolProfile",
"NameIdentifierMappingProtocolProfile",
"RegisterNameIdentifierProtocolProfile",
"SingleLogoutProtocolProfile",
"SingleSignOnProtocolProfile"
};
static char *protocol_roles[] = { NULL, "sp", "idp"};
char *protocol_methods[] = {"", "", "", "", "", "-http", "-soap"};
/*****************************************************************************/
/* public methods */
/*****************************************************************************/
gchar*
lasso_provider_get_metadata_one(LassoProvider *provider, gchar *name)
{
GList *l;
GHashTable *descriptor;
descriptor = provider->private->SPDescriptor; /* default to SP */
if (provider->role == LASSO_PROVIDER_ROLE_IDP)
descriptor = provider->private->IDPDescriptor;
l = g_hash_table_lookup(descriptor, name);
if (l)
return g_strdup(l->data);
return NULL;
}
GList*
lasso_provider_get_metadata_list(LassoProvider *provider, gchar *name)
{
GHashTable *descriptor;
descriptor = provider->private->SPDescriptor; /* default to SP */
if (provider->role == LASSO_PROVIDER_ROLE_IDP)
descriptor = provider->private->IDPDescriptor;
return g_hash_table_lookup(descriptor, name);
}
lassoHttpMethod lasso_provider_get_first_http_method(LassoProvider *provider,
LassoProvider *remote_provider, lassoMdProtocolType protocol_type)
{
char *protocol_profile_prefix;
GList *local_supported_profiles;
GList *remote_supported_profiles;
GList *t1, *t2;
gboolean found;
if (remote_provider->role == LASSO_PROVIDER_ROLE_SP)
provider->role = LASSO_PROVIDER_ROLE_IDP;
if (remote_provider->role == LASSO_PROVIDER_ROLE_IDP)
provider->role = LASSO_PROVIDER_ROLE_SP;
protocol_profile_prefix = g_strdup_printf("%s-%s",
protocol_uris[protocol_type], protocol_roles[provider->role]);
local_supported_profiles = lasso_provider_get_metadata_list(
provider, protocol_md_nodename[protocol_type]);
remote_supported_profiles = lasso_provider_get_metadata_list(
remote_provider, protocol_md_nodename[protocol_type]);
found = FALSE;
t1 = local_supported_profiles;
while (t1 && !found) {
if (g_str_has_prefix(t1->data, protocol_profile_prefix)) {
t2 = remote_supported_profiles;
while (t2 && !found) {
if (strcmp(t1->data, t2->data) == 0) {
found = TRUE;
break; /* avoid the g_list_next */
}
t2 = g_list_next(t2);
}
}
t1 = g_list_next(t1);
}
g_free(protocol_profile_prefix);
if (found) {
if (g_str_has_suffix(t2->data, "http"))
return LASSO_HTTP_METHOD_REDIRECT;
if (g_str_has_suffix(t2->data, "soap"))
return LASSO_HTTP_METHOD_SOAP;
g_assert_not_reached();
}
return LASSO_HTTP_METHOD_NONE;
}
gboolean
lasso_provider_accept_http_method(LassoProvider *provider, LassoProvider *remote_provider,
lassoMdProtocolType protocol_type, lassoHttpMethod http_method,
gboolean initiate_profile)
{
LassoProviderRole initiating_role;
char *protocol_profile;
GList *local_supported_profiles;
GList *remote_supported_profiles;
initiating_role = remote_provider->role;
if (remote_provider->role == LASSO_PROVIDER_ROLE_SP) {
provider->role = LASSO_PROVIDER_ROLE_IDP;
}
if (remote_provider->role == LASSO_PROVIDER_ROLE_IDP) {
provider->role = LASSO_PROVIDER_ROLE_SP;
}
if (initiate_profile)
initiating_role = provider->role;
protocol_profile = g_strdup_printf("%s-%s%s",
protocol_uris[protocol_type],
protocol_roles[initiating_role],
protocol_methods[http_method+1]);
local_supported_profiles = lasso_provider_get_metadata_list(
provider, protocol_md_nodename[protocol_type]);
remote_supported_profiles = lasso_provider_get_metadata_list(
remote_provider, protocol_md_nodename[protocol_type]);
if (g_list_find_custom(local_supported_profiles, protocol_profile,
(GCompareFunc)strcmp) == NULL)
return FALSE;
if (g_list_find_custom(remote_supported_profiles, protocol_profile,
(GCompareFunc)strcmp) == NULL)
return FALSE;
return TRUE;
}
/*****************************************************************************/
/* private methods */
/*****************************************************************************/
static LassoNodeClass *parent_class = NULL;
static void
load_descriptor(xmlNode *xmlnode, GHashTable *descriptor)
{
xmlNode *t;
GList *elements;
t = xmlnode->children;
while (t) {
if (t->type != XML_ELEMENT_NODE) {
t = t->next;
continue;
}
/* XXX: AssertionConsumerServiceURL nodes have attributes */
elements = g_hash_table_lookup(descriptor, t->name);
elements = g_list_append(elements, g_strdup(xmlNodeGetContent(t)));
g_hash_table_insert(descriptor, g_strdup(t->name), elements);
t = t->next;
}
}
static void
add_descriptor_childnodes(gchar *key, GList *value, xmlNode *xmlnode)
{
while (value) {
xmlNewTextChild(xmlnode, NULL, key, value->data);
value = g_list_next(value);
}
}
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode, *t;
LassoProvider *provider = LASSO_PROVIDER(node);
char *roles[] = { "None", "SP", "IdP"};
xmlnode = xmlNewNode(NULL, "Provider");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LASSO_HREF, NULL));
xmlSetProp(xmlnode, "Version", "2");
if (provider->role)
xmlSetProp(xmlnode, "ProviderRole", roles[provider->role]);
xmlSetProp(xmlnode, "ProviderID", provider->ProviderID);
if (provider->public_key)
xmlNewTextChild(xmlnode, NULL, "PublicKeyFilePath", provider->public_key);
if (provider->ca_cert_chain)
xmlNewTextChild(xmlnode, NULL, "CaCertChainFilePath", provider->ca_cert_chain);
if (g_hash_table_size(provider->private->SPDescriptor)) {
t = xmlNewTextChild(xmlnode, NULL, "SPDescriptor", NULL);
g_hash_table_foreach(provider->private->SPDescriptor,
(GHFunc)add_descriptor_childnodes, t);
}
if (g_hash_table_size(provider->private->IDPDescriptor)) {
t = xmlNewTextChild(xmlnode, NULL, "IDPDescriptor", NULL);
g_hash_table_foreach(provider->private->IDPDescriptor,
(GHFunc)add_descriptor_childnodes, t);
}
return xmlnode;
}
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoProvider *provider = LASSO_PROVIDER(node);
xmlNode *t;
xmlChar *s;
s = xmlGetProp(xmlnode, "ProviderRole");
if (s && strcmp(s, "SP") == 0)
provider->role = LASSO_PROVIDER_ROLE_SP;
if (s && strcmp(s, "IdP") == 0)
provider->role = LASSO_PROVIDER_ROLE_IDP;
if (s)
xmlFree(s);
provider->ProviderID = xmlGetProp(xmlnode, "ProviderID");
t = xmlnode->children;
while (t) {
if (t->type != XML_ELEMENT_NODE) {
t = t->next;
continue;
}
if (strcmp(t->name, "PublicKeyFilePath") == 0)
provider->public_key = xmlNodeGetContent(t);
if (strcmp(t->name, "CaCertChainFilePath") == 0)
provider->ca_cert_chain = xmlNodeGetContent(t);
if (strcmp(t->name, "SPDescriptor") == 0)
load_descriptor(t, provider->private->SPDescriptor);
if (strcmp(t->name, "IDPDescriptor") == 0)
load_descriptor(t, provider->private->IDPDescriptor);
t = t->next;
}
}
/*****************************************************************************/
/* overrided parent class methods */
/*****************************************************************************/
static void
dispose(GObject *object)
{
LassoProvider *provider = LASSO_PROVIDER(object);
if (provider->private->dispose_has_run) {
return;
}
provider->private->dispose_has_run = TRUE;
debug("Provider object 0x%x disposed ...\n", provider);
/* XXX: free hash tables (here or in finalize() below) ? */
G_OBJECT_CLASS(parent_class)->dispose(G_OBJECT(provider));
}
static void
finalize(GObject *object)
{
LassoProvider *provider = LASSO_PROVIDER(object);
debug("Provider object 0x%x finalized ...\n", provider);
g_free(provider->public_key);
g_free(provider->ca_cert_chain);
g_free(provider->private);
G_OBJECT_CLASS(parent_class)->finalize(G_OBJECT(provider));
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
instance_init(LassoProvider *provider)
{
provider->private = g_new (LassoProviderPrivate, 1);
provider->private->dispose_has_run = FALSE;
provider->role = LASSO_PROVIDER_ROLE_NONE;
provider->public_key = NULL;
provider->ca_cert_chain = NULL;
provider->ProviderID = NULL;
provider->private->IDPDescriptor = g_hash_table_new_full(
g_str_hash, g_str_equal, g_free, NULL);
provider->private->SPDescriptor = g_hash_table_new_full(
g_str_hash, g_str_equal, g_free, NULL);
}
static void
class_init(LassoProviderClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
G_OBJECT_CLASS(klass)->dispose = dispose;
G_OBJECT_CLASS(klass)->finalize = finalize;
}
GType
lasso_provider_get_type()
{
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoProviderClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoProvider),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoProvider", &this_info, 0);
}
return this_type;
}
gboolean
lasso_provider_load_metadata(LassoProvider *provider, const gchar *metadata)
{
xmlDoc *doc;
xmlXPathContext *xpathCtx;
xmlXPathObject *xpathObj;
xmlNode *node;
doc = xmlParseFile(metadata);
/* FIXME: lacking error checking */
xpathCtx = xmlXPathNewContext(doc);
xmlXPathRegisterNs(xpathCtx, "md", LASSO_METADATA_HREF);
xpathObj = xmlXPathEvalExpression("/md:EntityDescriptor", xpathCtx);
/* if empty: not a metadata file -> bails out */
if (xpathObj->nodesetval == NULL || xpathObj->nodesetval->nodeNr == 0) {
return FALSE;
}
node = xpathObj->nodesetval->nodeTab[0];
provider->ProviderID = xmlGetProp(node, "providerID");
xpathObj = xmlXPathEvalExpression("md:EntityDescriptor/md:IDPDescriptor", xpathCtx);
if (xpathObj && xpathObj->nodesetval->nodeNr == 1)
load_descriptor(xpathObj->nodesetval->nodeTab[0], provider->private->IDPDescriptor);
xmlXPathFreeObject(xpathObj);
xpathObj = xmlXPathEvalExpression("md:EntityDescriptor/md:SPDescriptor", xpathCtx);
if (xpathObj && xpathObj->nodesetval->nodeNr == 1)
load_descriptor(xpathObj->nodesetval->nodeTab[0], provider->private->SPDescriptor);
xmlXPathFreeObject(xpathObj);
xmlFreeDoc(doc);
xmlXPathFreeContext(xpathCtx);
return TRUE;
}
LassoProvider*
lasso_provider_new(LassoProviderRole role, gchar *metadata, gchar *public_key, gchar *ca_cert_chain)
{
LassoProvider *provider;
provider = LASSO_PROVIDER(g_object_new(LASSO_TYPE_PROVIDER, NULL));
provider->role = role;
if (lasso_provider_load_metadata(provider, metadata) == FALSE) {
/* XXX */
}
provider->public_key = g_strdup(public_key);
provider->ca_cert_chain = g_strdup(ca_cert_chain);
return provider;
}
LassoProvider*
lasso_provider_new_from_dump(const gchar *dump)
{
LassoProvider *provider;
xmlDoc *doc;
provider = g_object_new(LASSO_TYPE_PROVIDER, NULL);
doc = xmlParseMemory(dump, strlen(dump));
init_from_xml(LASSO_NODE(provider), xmlDocGetRootElement(doc));
return provider;
}
int lasso_provider_verify_signature(LassoProvider *provider,
const char *message, const char *id_attr_name)
{
return 0; /* XXX */
if (message[0] == '<') {
xmlDoc *doc;
xmlNode *xmlnode, *sign, *x509data;
xmlSecKeysMngr *keys_mngr = NULL;
xmlSecDSigCtx *dsigCtx;
lassoPemFileType public_key_file_type;
doc = xmlParseMemory(message, strlen(message));
xmlnode = xmlDocGetRootElement(doc);
sign = xmlSecFindNode(xmlnode, xmlSecNodeSignature, xmlSecDSigNs);
if (sign == NULL) {
xmlFreeDoc(doc);
return LASSO_DS_ERROR_SIGNATURE_NOT_FOUND;
}
x509data = xmlSecFindNode(xmlnode, xmlSecNodeX509Data, xmlSecDSigNs);
if (x509data != NULL && provider->ca_cert_chain != NULL) {
keys_mngr = lasso_load_certs_from_pem_certs_chain_file(
provider->ca_cert_chain);
if (keys_mngr == NULL)
return LASSO_DS_ERROR_CA_CERT_CHAIN_LOAD_FAILED;
}
dsigCtx = xmlSecDSigCtxCreate(keys_mngr);
if (keys_mngr == NULL) {
if (provider->public_key) {
public_key_file_type = lasso_get_pem_file_type(
provider->public_key);
if (public_key_file_type == LASSO_PEM_FILE_TYPE_CERT) {
/* public_key_file is a certificate file
* => get public key in it */
dsigCtx->signKey = lasso_get_public_key_from_pem_cert_file(
provider->public_key);
} else {
/* load public key */
dsigCtx->signKey = xmlSecCryptoAppKeyLoad(
provider->public_key,
xmlSecKeyDataFormatPem,
NULL, NULL, NULL);
}
}
if (dsigCtx->signKey == NULL) {
return LASSO_DS_ERROR_PUBLIC_KEY_LOAD_FAILED;
}
}
if (xmlSecDSigCtxVerify(dsigCtx, sign) < 0) {
return LASSO_DS_ERROR_SIGNATURE_VERIFICATION_FAILED;
}
if (dsigCtx->status != xmlSecDSigStatusSucceeded) {
return LASSO_DS_ERROR_INVALID_SIGNATURE;
}
return 0;
}
if (strchr(message, '&')) {
return lasso_query_verify_signature(message, provider->public_key);
}
return -1;
}

111
lasso/id-ff/provider.h Normal file
View File

@ -0,0 +1,111 @@
/* $Id$
*
* Lasso - A free implementation of the Liberty Alliance specifications.
*
* Copyright (C) 2004 Entr'ouvert
* http://lasso.entrouvert.org
*
* Authors: Nicolas Clapies <nclapies@entrouvert.com>
* Valery Febvre <vfebvre@easter-eggs.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __LASSO_PROVIDER_H__
#define __LASSO_PROVIDER_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <lasso/xml/xml.h>
#define LASSO_TYPE_PROVIDER (lasso_provider_get_type())
#define LASSO_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_PROVIDER, LassoProvider))
#define LASSO_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), LASSO_TYPE_PROVIDER, LassoProviderClass))
#define LASSO_IS_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), LASSO_TYPE_PROVIDER))
#define LASSO_IS_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LASSO_TYPE_PROVIDER))
#define LASSO_PROVIDER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), LASSO_TYPE_PROVIDER, LassoProviderClass))
typedef struct _LassoProvider LassoProvider;
typedef struct _LassoProviderClass LassoProviderClass;
typedef struct _LassoProviderPrivate LassoProviderPrivate;
typedef enum {
LASSO_HTTP_METHOD_NONE = -1,
LASSO_HTTP_METHOD_ANY,
LASSO_HTTP_METHOD_IDP_INITIATED,
LASSO_HTTP_METHOD_GET,
LASSO_HTTP_METHOD_POST,
LASSO_HTTP_METHOD_REDIRECT,
LASSO_HTTP_METHOD_SOAP
} lassoHttpMethod;
typedef enum {
LASSO_MD_PROTOCOL_TYPE_FEDERATION_TERMINATION = 0,
LASSO_MD_PROTOCOL_TYPE_NAME_IDENTIFIER_MAPPING,
LASSO_MD_PROTOCOL_TYPE_REGISTER_NAME_IDENTIFIER,
LASSO_MD_PROTOCOL_TYPE_SINGLE_LOGOUT,
LASSO_MD_PROTOCOL_TYPE_SINGLE_SIGN_ON
} lassoMdProtocolType;
typedef enum {
LASSO_PROVIDER_ROLE_NONE = 0,
LASSO_PROVIDER_ROLE_SP,
LASSO_PROVIDER_ROLE_IDP
} LassoProviderRole;
struct _LassoProvider {
LassoNode parent;
gchar *ProviderID;
LassoProviderRole role;
gchar *public_key;
gchar *ca_cert_chain;
/*< private >*/
LassoProviderPrivate *private;
};
struct _LassoProviderClass {
LassoNodeClass parent;
};
LASSO_EXPORT GType lasso_provider_get_type(void);
LASSO_EXPORT LassoProvider* lasso_provider_new(LassoProviderRole role, gchar *metadata,
gchar *public_key, gchar *ca_cert_chain);
LASSO_EXPORT gchar* lasso_provider_get_metadata_one(LassoProvider *provider, gchar *name);
LASSO_EXPORT GList* lasso_provider_get_metadata_list(LassoProvider *provider, gchar *name);
LASSO_EXPORT gboolean lasso_provider_load_metadata(LassoProvider *provider, const gchar *metadata);
LASSO_EXPORT LassoProvider* lasso_provider_new_from_dump(const gchar *dump);
LASSO_EXPORT int lasso_provider_verify_signature(LassoProvider *provider,
const char *message, const char *id_attr_name);
LASSO_EXPORT lassoHttpMethod lasso_provider_get_first_http_method(LassoProvider *provider,
LassoProvider *remote_provider, lassoMdProtocolType protocol_type);
LASSO_EXPORT gboolean lasso_provider_accept_http_method(LassoProvider *provider,
LassoProvider *remote_provider, lassoMdProtocolType protocol_type,
lassoHttpMethod http_method, gboolean initiate_profile);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __LASSO_PROVIDER_H__ */

View File

@ -32,38 +32,11 @@
#include <lasso/lasso_config.h>
#define LASSO_SERVER_NODE "Server"
#define LASSO_SERVER_METADATA_NODE "ServerMetadata"
#define LASSO_SERVER_PROVIDERS_NODE "Providers"
#define LASSO_SERVER_PROVIDERID_NODE "ProviderID"
#define LASSO_SERVER_PRIVATE_KEY_NODE "PrivateKey"
#define LASSO_SERVER_SECRET_KEY_NODE "SecretKey"
#define LASSO_SERVER_CERTIFICATE_NODE "Certificate"
#define LASSO_SERVER_SIGNATURE_METHOD_NODE "SignatureMethod"
struct _LassoServerPrivate
{
gboolean dispose_has_run;
gboolean dispose_has_run;
};
static GObjectClass *parent_class = NULL;
/*****************************************************************************/
/* private methods */
/*****************************************************************************/
static gint
lasso_server_add_lasso_provider(LassoServer *server,
LassoProvider *provider)
{
g_return_val_if_fail(LASSO_IS_SERVER(server), -1);
g_return_val_if_fail(LASSO_IS_PROVIDER(provider), -2);
g_ptr_array_add(server->providers, provider);
return 0;
}
/*****************************************************************************/
/* public methods */
/*****************************************************************************/
@ -80,281 +53,181 @@ lasso_server_add_lasso_provider(LassoServer *server,
* Return value: 0 on success or a negative value if an error occurs.
**/
gint
lasso_server_add_provider(LassoServer *server,
gchar *metadata,
gchar *public_key,
gchar *ca_cert_chain)
lasso_server_add_provider(LassoServer *server, LassoProviderRole role,
gchar *metadata, gchar *public_key, gchar *ca_cert_chain)
{
LassoProvider *provider;
LassoProvider *provider;
g_return_val_if_fail(LASSO_IS_SERVER(server), LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
g_return_val_if_fail(metadata != NULL, LASSO_PARAM_ERROR_INVALID_VALUE);
g_return_val_if_fail(LASSO_IS_SERVER(server), LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
g_return_val_if_fail(metadata != NULL, LASSO_PARAM_ERROR_INVALID_VALUE);
provider = lasso_provider_new(metadata, public_key, ca_cert_chain);
if (provider != NULL) {
g_ptr_array_add(server->providers, provider);
}
else {
message(G_LOG_LEVEL_CRITICAL, "Failed to add new provider.\n");
return LASSO_SERVER_ERROR_ADD_PROVIDER_FAILED;
}
provider = lasso_provider_new(role, metadata, public_key, ca_cert_chain);
if (provider == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Failed to add new provider.\n");
return LASSO_SERVER_ERROR_ADD_PROVIDER_FAILED;
}
return 0;
g_hash_table_insert(server->providers, g_strdup(provider->ProviderID), provider);
return 0;
}
LassoServer*
lasso_server_copy(LassoServer *server)
gchar*
lasso_server_get_authnRequestsSigned(LassoServer *server, GError **err)
{
LassoServer *copy;
LassoProvider *p;
guint i;
g_return_val_if_fail(LASSO_IS_SERVER(server), NULL);
copy = LASSO_SERVER(g_object_new(LASSO_TYPE_SERVER, NULL));
/* herited provider attrs */
LASSO_PROVIDER(copy)->metadata = lasso_node_copy(LASSO_PROVIDER(server)->metadata);
LASSO_PROVIDER(copy)->public_key = g_strdup(LASSO_PROVIDER(server)->public_key);
LASSO_PROVIDER(copy)->ca_cert_chain = g_strdup(LASSO_PROVIDER(server)->ca_cert_chain);
/* server attrs */
copy->providers = g_ptr_array_new();
for (i=0; i<server->providers->len; i++) {
p = g_ptr_array_index(server->providers, i);
g_ptr_array_add(copy->providers, lasso_provider_copy(p));
}
copy->providerID = g_strdup(server->providerID);
copy->private_key = g_strdup(server->private_key);
copy->secret_key = g_strdup(server->secret_key);
copy->certificate = g_strdup(server->certificate);
copy->signature_method = server->signature_method;
return copy;
/* XXX to do differently (add a boolean to struct) */
g_assert_not_reached();
return NULL;
}
void
lasso_server_destroy(LassoServer *server)
{
g_object_unref(G_OBJECT(server));
g_object_unref(G_OBJECT(server));
}
gchar *
lasso_server_dump(LassoServer *server)
/*****************************************************************************/
/* private methods */
/*****************************************************************************/
static LassoNodeClass *parent_class = NULL;
static void add_provider_childnode(gchar *key, LassoProvider *value, xmlNode *xmlnode)
{
LassoProvider *provider;
LassoNode *server_node, *providers_node, *provider_node, *metadata_copy, *metadata_node;
LassoNodeClass *metadata_class, *server_class, *providers_class;
xmlChar *signature_method_str, *dump;
gint i;
xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(value)));
}
g_return_val_if_fail(LASSO_IS_SERVER(server), NULL);
static xmlNode*
get_xmlNode(LassoNode *node)
{
LassoServer *server = LASSO_SERVER(node);
char *signature_methods[] = { NULL, "RSA_SHA1", "DSA_SHA1"};
xmlNode *xmlnode;
server_node = lasso_node_new();
server_class = LASSO_NODE_GET_CLASS(server_node);
server_class->set_name(server_node, LASSO_SERVER_NODE);
server_class->set_ns(server_node, lassoLassoHRef, NULL);
xmlnode = parent_class->get_xmlNode(node);
xmlNodeSetName(xmlnode, "Server");
xmlSetProp(xmlnode, "ServerDumpVersion", "2");
/* Add lasso version in the xml node */
server_class->set_prop(LASSO_NODE(server_node), "version", PACKAGE_VERSION);
xmlNewTextChild(xmlnode, NULL, "PrivateKeyFilePath", server->private_key);
if (server->secret_key)
xmlNewTextChild(xmlnode, NULL, "SecretKey", server->secret_key);
xmlNewTextChild(xmlnode, NULL, "CertificateFilePath", server->certificate);
xmlSetProp(xmlnode, "SignatureMethod", signature_methods[server->signature_method]);
/* signature method */
signature_method_str = g_new(gchar, 6);
g_snprintf(signature_method_str, 6, "%d", server->signature_method);
server_class->set_prop(server_node, LASSO_SERVER_SIGNATURE_METHOD_NODE, signature_method_str);
g_free(signature_method_str);
if (g_hash_table_size(server->providers)) {
xmlNode *t;
t = xmlNewTextChild(xmlnode, NULL, "Providers", NULL);
g_hash_table_foreach(server->providers,
(GHFunc)add_provider_childnode, t);
}
/* providerID */
if (server->providerID != NULL) {
server_class->set_prop(server_node, LASSO_SERVER_PROVIDERID_NODE, server->providerID);
}
/* private key */
if (server->private_key != NULL) {
server_class->set_prop(server_node, LASSO_SERVER_PRIVATE_KEY_NODE, server->private_key);
}
/* secret key */
if (server->secret_key != NULL) {
server_class->set_prop(server_node, LASSO_SERVER_SECRET_KEY_NODE, server->secret_key);
}
/* certificate */
if (server->certificate != NULL) {
server_class->set_prop(server_node, LASSO_SERVER_CERTIFICATE_NODE, server->certificate);
}
/* metadata */
provider = LASSO_PROVIDER(server);
if (provider->metadata != NULL) {
metadata_node = lasso_node_new();
metadata_class = LASSO_NODE_GET_CLASS(metadata_node);
metadata_class->set_name(metadata_node, LASSO_SERVER_METADATA_NODE);
metadata_class->set_ns(metadata_node, lassoLassoHRef, NULL);
return xmlnode;
}
metadata_copy = lasso_node_copy(provider->metadata);
metadata_class->add_child(metadata_node, metadata_copy, FALSE);
lasso_node_destroy(metadata_copy);
server_class->add_child(server_node, metadata_node, FALSE);
}
/* providers */
providers_node = lasso_node_new();
providers_class = LASSO_NODE_GET_CLASS(providers_node);
providers_class->set_name(providers_node, LASSO_SERVER_PROVIDERS_NODE);
for (i = 0; i<server->providers->len; i++) {
dump = lasso_provider_dump(g_ptr_array_index(server->providers, i));
provider_node = lasso_node_new_from_dump(dump);
xmlFree(dump);
providers_class->add_child(providers_node, provider_node, TRUE);
lasso_node_destroy(provider_node);
}
server_class->add_child(server_node, providers_node, FALSE);
lasso_node_destroy(providers_node);
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoServer *server = LASSO_SERVER(node);
xmlNode *t;
xmlChar *s;
dump = lasso_node_export(server_node);
lasso_node_destroy(server_node);
parent_class->init_from_xml(node, xmlnode);
return dump;
s = xmlGetProp(xmlnode, "SignatureMethod");
if (s && strcmp(s, "RSA_SHA1") == 0)
server->signature_method = LASSO_SIGNATURE_METHOD_RSA_SHA1;
if (s && strcmp(s, "DSA_SHA1") == 0)
server->signature_method = LASSO_SIGNATURE_METHOD_DSA_SHA1;
if (s)
xmlFree(s);
t = xmlnode->children;
while (t) {
if (t->type != XML_ELEMENT_NODE) {
t = t->next;
continue;
}
if (strcmp(t->name, "PrivateKeyFilePath") == 0)
server->private_key = xmlNodeGetContent(t);
if (strcmp(t->name, "SecretKey") == 0)
server->secret_key = xmlNodeGetContent(t);
if (strcmp(t->name, "CertificateFilePath") == 0)
server->certificate = xmlNodeGetContent(t);
if (strcmp(t->name, "Providers") == 0) {
xmlNode *t2 = t->children;
LassoProvider *p;
while (t2) {
if (t2->type != XML_ELEMENT_NODE) {
t2 = t2->next;
continue;
}
p = g_object_new(LASSO_TYPE_PROVIDER, NULL);
LASSO_NODE_GET_CLASS(p)->init_from_xml(LASSO_NODE(p), t2);
g_hash_table_insert(server->providers,
g_strdup(p->ProviderID), p);
t2 = t2->next;
}
}
t = t->next;
}
}
static gboolean
get_first_providerID(gchar *key, gpointer value, char **providerID)
{
*providerID = key;
return TRUE;
}
gchar*
lasso_server_get_first_providerID(LassoServer *server)
{
LassoProvider *provider;
gchar *providerID = NULL;
if (server->providers->len > 0) {
provider = (LassoProvider *)g_ptr_array_index(server->providers, 0);
return lasso_provider_get_providerID(provider);
}
else {
return NULL;
}
g_hash_table_find(server->providers, (GHRFunc)get_first_providerID, &providerID);
return g_strdup(providerID);
}
LassoProvider*
lasso_server_get_provider(LassoServer *server,
gchar *providerID,
GError **err)
lasso_server_get_provider(LassoServer *server, gchar *providerID)
{
LassoProvider *provider;
GError *tmp_err = NULL;
if (err != NULL && *err != NULL) {
g_set_error(err, g_quark_from_string("Lasso"),
LASSO_PARAM_ERROR_CHECK_FAILED,
lasso_strerror(LASSO_PARAM_ERROR_CHECK_FAILED));
g_return_val_if_fail (err == NULL || *err == NULL, NULL);
}
provider = lasso_server_get_provider_ref(server, providerID, &tmp_err);
if (provider != NULL) {
return lasso_provider_copy(provider);
}
else {
g_propagate_error (err, tmp_err);
}
return NULL;
return g_hash_table_lookup(server->providers, providerID);
}
LassoProvider*
lasso_server_get_provider_ref(LassoServer *server,
gchar *providerID,
GError **err)
static gboolean
get_providerID_with_hash(gchar *key, gpointer value, char **providerID)
{
LassoProvider *provider;
xmlChar *id;
int index, len;
if (err != NULL && *err != NULL) {
g_set_error(err, g_quark_from_string("Lasso"),
LASSO_PARAM_ERROR_CHECK_FAILED,
lasso_strerror(LASSO_PARAM_ERROR_CHECK_FAILED));
g_return_val_if_fail (err == NULL || *err == NULL, NULL);
}
if (LASSO_IS_SERVER(server) == FALSE) {
g_set_error(err, g_quark_from_string("Lasso"),
LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ,
lasso_strerror(LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ));
g_return_val_if_fail(LASSO_IS_SERVER(server), NULL);
}
if (providerID == NULL) {
g_set_error(err, g_quark_from_string("Lasso"),
LASSO_PARAM_ERROR_INVALID_VALUE,
lasso_strerror(LASSO_PARAM_ERROR_INVALID_VALUE));
g_return_val_if_fail(providerID != NULL, NULL);
}
char *hash = *providerID;
char *hash_providerID, *b64_hash_providerID;
len = server->providers->len;
for (index = 0; index<len; index++) {
provider = g_ptr_array_index(server->providers, index);
hash_providerID = lasso_sha1(key);
b64_hash_providerID = xmlSecBase64Encode(hash_providerID, 20, 0);
xmlFree(hash_providerID);
id = lasso_provider_get_providerID(provider);
if (id != NULL) {
if (xmlStrEqual(providerID, id)) {
xmlFree(id);
return provider;
}
xmlFree(id);
}
}
/* no provider was found */
g_set_error(err, g_quark_from_string("Lasso"),
LASSO_SERVER_ERROR_PROVIDER_NOT_FOUND,
lasso_strerror(LASSO_SERVER_ERROR_PROVIDER_NOT_FOUND),
providerID);
/* print error msg here so that caller just check err->code */
message(G_LOG_LEVEL_CRITICAL, err[0]->message);
return NULL;
}
gchar *
lasso_server_get_providerID_from_hash(LassoServer *server,
gchar *b64_hash)
{
LassoProvider *provider;
xmlChar *providerID, *hash_providerID;
xmlChar *b64_hash_providerID;
int i;
g_return_val_if_fail(LASSO_IS_SERVER(server), NULL);
g_return_val_if_fail(b64_hash != NULL, NULL);
for (i=0; i<server->providers->len; i++) {
provider = g_ptr_array_index(server->providers, i);
providerID = lasso_provider_get_providerID(provider);
if (providerID != NULL) {
hash_providerID = lasso_sha1(providerID);
b64_hash_providerID = xmlSecBase64Encode(hash_providerID, 20, 0);
xmlFree(hash_providerID);
if (xmlStrEqual(b64_hash_providerID, b64_hash)) {
if (strcmp(b64_hash_providerID, hash) == 0) {
xmlFree(b64_hash_providerID);
*providerID = key;
return TRUE;
}
xmlFree(b64_hash_providerID);
return providerID;
}
else {
xmlFree(b64_hash_providerID);
xmlFree(providerID);
}
}
}
/* failed to get the providerID */
message(G_LOG_LEVEL_CRITICAL,
"Failed to get a providerID corresponding to the hash.\n")
return NULL;
return FALSE;
}
lassoSignatureMethod
lasso_server_get_signature_method(LassoServer *server)
{
return server->signature_method;
}
void
lasso_server_set_signature_method(LassoServer *server,
lassoSignatureMethod signature_method)
gchar*
lasso_server_get_providerID_from_hash(LassoServer *server, gchar *b64_hash)
{
server->signature_method = signature_method;
gchar *providerID = b64_hash; /* kludge */
g_hash_table_find(server->providers, (GHRFunc)get_providerID_with_hash, &providerID);
return g_strdup(providerID);
}
/*****************************************************************************/
@ -362,39 +235,37 @@ lasso_server_set_signature_method(LassoServer *server,
/*****************************************************************************/
static void
lasso_server_dispose(LassoServer *server)
dispose(GObject *object)
{
guint i;
LassoServer *server = LASSO_SERVER(object);
if (server->private->dispose_has_run == TRUE) {
return;
}
server->private->dispose_has_run = TRUE;
if (server->private->dispose_has_run == TRUE) {
return;
}
server->private->dispose_has_run = TRUE;
debug("Server object 0x%x disposed ...\n", server);
debug("Server object 0x%x disposed ...\n", server);
/* free allocated memory for providers array */
for (i=0; i<server->providers->len; i++) {
lasso_provider_destroy(server->providers->pdata[i]);
}
g_ptr_array_free(server->providers, TRUE);
/* free allocated memory for providers array */
/* XXX */
parent_class->dispose(G_OBJECT(server));
G_OBJECT_CLASS(parent_class)->dispose(G_OBJECT(server));
}
static void
lasso_server_finalize(LassoServer *server)
finalize(GObject *object)
{
debug("Server object 0x%x finalized ...\n", server);
LassoServer *server = LASSO_SERVER(object);
g_free(server->providerID);
g_free(server->private_key);
g_free(server->secret_key);
g_free(server->certificate);
debug("Server object 0x%x finalized ...\n", server);
g_free(server->private);
g_free(server->private_key);
g_free(server->secret_key);
g_free(server->certificate);
parent_class->finalize(G_OBJECT(server));
g_free(server->private);
G_OBJECT_CLASS(parent_class)->finalize(G_OBJECT(server));
}
/*****************************************************************************/
@ -402,50 +273,54 @@ lasso_server_finalize(LassoServer *server)
/*****************************************************************************/
static void
lasso_server_instance_init(LassoServer *server)
instance_init(LassoServer *server)
{
server->private = g_new (LassoServerPrivate, 1);
server->private->dispose_has_run = FALSE;
server->private = g_new(LassoServerPrivate, 1);
server->private->dispose_has_run = FALSE;
server->providers = g_ptr_array_new();
server->providerID = NULL;
server->private_key = NULL;
server->secret_key = NULL;
server->certificate = NULL;
server->signature_method = lassoSignatureMethodRsaSha1;
server->providers = g_hash_table_new_full(
g_str_hash, g_str_equal, g_free,
(GDestroyNotify)lasso_node_destroy);
server->private_key = NULL;
server->secret_key = NULL;
server->certificate = NULL;
server->signature_method = LASSO_SIGNATURE_METHOD_RSA_SHA1;
}
static void
lasso_server_class_init(LassoServerClass *class) {
GObjectClass *gobject_class = G_OBJECT_CLASS(class);
parent_class = g_type_class_peek_parent(class);
/* override parent class methods */
gobject_class->dispose = (void *)lasso_server_dispose;
gobject_class->finalize = (void *)lasso_server_finalize;
class_init(LassoServerClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
G_OBJECT_CLASS(klass)->dispose = dispose;
G_OBJECT_CLASS(klass)->finalize = finalize;
}
GType lasso_server_get_type() {
static GType this_type = 0;
GType
lasso_server_get_type()
{
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoServerClass),
NULL,
NULL,
(GClassInitFunc) lasso_server_class_init,
NULL,
NULL,
sizeof(LassoServer),
0,
(GInstanceInitFunc) lasso_server_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_PROVIDER,
"LassoServer",
&this_info, 0);
}
return this_type;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoServerClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoServer),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_PROVIDER,
"LassoServer", &this_info, 0);
}
return this_type;
}
/**
@ -460,161 +335,46 @@ GType lasso_server_get_type() {
*
* Return value: a newly allocated #LassoServer object or NULL if an error occurs.
**/
LassoServer *
LassoServer*
lasso_server_new(const gchar *metadata,
const gchar *private_key,
const gchar *secret_key,
const gchar *certificate)
{
LassoServer *server;
xmlDocPtr doc;
xmlNodePtr root;
LassoNode *md_node = NULL;
gchar *providerID = NULL;
GError *err = NULL;
LassoServer *server;
/* metadata can be NULL (if server is a LECP) */
server = g_object_new(LASSO_TYPE_SERVER, NULL);
/* put server metadata in a LassoNode */
if (metadata != NULL) {
doc = xmlParseFile(metadata);
if (doc == NULL) {
message(G_LOG_LEVEL_CRITICAL, "Failed to parse file \"%s\"\n", metadata);
return NULL;
}
root = xmlCopyNode(xmlDocGetRootElement(doc), 1);
xmlFreeDoc(doc);
md_node = lasso_node_new();
LASSO_NODE_GET_CLASS(md_node)->set_xmlNode(md_node, root);
/* get ProviderID in metadata */
providerID = lasso_node_get_attr_value(md_node, "providerID", &err);
if (providerID == NULL) {
message(G_LOG_LEVEL_WARNING, err->message);
g_error_free(err);
lasso_node_destroy(md_node);
return NULL;
}
}
/* metadata can be NULL (if server is a LECP) */
if (metadata != NULL) {
lasso_provider_load_metadata(LASSO_PROVIDER(server), metadata);
/* XXX: error checking */
}
/* Ok, we can create server */
server = LASSO_SERVER(g_object_new(LASSO_TYPE_SERVER, NULL));
server->private_key = g_strdup(private_key);
server->secret_key = g_strdup(secret_key);
server->certificate = g_strdup(certificate);
if (md_node != NULL) {
LASSO_PROVIDER(server)->metadata = md_node;
}
if (providerID != NULL) {
server->providerID = providerID;
}
server->private_key = g_strdup(private_key);
server->secret_key = g_strdup(secret_key);
server->certificate = g_strdup(certificate);
return server;
return server;
}
LassoServer *
lasso_server_new_from_dump(gchar *dump)
LassoServer*
lasso_server_new_from_dump(const gchar *dump)
{
LassoNodeClass *server_class, *providers_class;
LassoNode *server_node, *providers_node, *provider_node, *entity_node, *server_metadata_node;
LassoServer *server;
LassoProvider *provider;
xmlNodePtr providers_xmlNode, provider_xmlNode;
xmlChar *public_key, *ca_cert_chain, *signature_method;
LassoServer *server;
xmlDoc *doc;
server = LASSO_SERVER(g_object_new(LASSO_TYPE_SERVER, NULL));
server = g_object_new(LASSO_TYPE_SERVER, NULL);
doc = xmlParseMemory(dump, strlen(dump));
init_from_xml(LASSO_NODE(server), xmlDocGetRootElement(doc));
xmlFreeDoc(doc);
server_node = lasso_node_new_from_dump(dump);
if (server_node == NULL) {
message(G_LOG_LEVEL_WARNING, "Error while loading server dump\n");
return NULL;
}
server_class = LASSO_NODE_GET_CLASS(server_node);
if (strcmp(server_class->get_name(server_node), LASSO_SERVER_NODE) != 0) {
message(G_LOG_LEVEL_WARNING, "XML is not a server dump\n");
lasso_node_destroy(server_node);
return NULL;
}
/* providerID */
server->providerID = lasso_node_get_attr_value(server_node, LASSO_SERVER_PROVIDERID_NODE, NULL);
/* private key */
server->private_key = lasso_node_get_attr_value(server_node, LASSO_SERVER_PRIVATE_KEY_NODE, NULL);
/* secret key */
server->secret_key = lasso_node_get_attr_value(server_node, LASSO_SERVER_SECRET_KEY_NODE, NULL);
/* certificate */
server->certificate = lasso_node_get_attr_value(server_node, LASSO_SERVER_CERTIFICATE_NODE, NULL);
/* signature method */
signature_method = lasso_node_get_attr_value(server_node, LASSO_SERVER_SIGNATURE_METHOD_NODE, NULL);
if (signature_method != NULL) {
server->signature_method = atoi(signature_method);
xmlFree(signature_method);
}
/* metadata */
server_metadata_node = lasso_node_get_child(server_node, LASSO_SERVER_METADATA_NODE, NULL, NULL);
if (server_metadata_node != NULL) {
entity_node = lasso_node_get_child(server_metadata_node, "EntityDescriptor", NULL, NULL);
LASSO_PROVIDER(server)->metadata = lasso_node_copy(entity_node);
lasso_node_destroy(entity_node);
}
/* public key */
LASSO_PROVIDER(server)->public_key = lasso_node_get_attr_value(server_node, LASSO_PROVIDER_PUBLIC_KEY_NODE, NULL);
/* ca_cert_chain */
LASSO_PROVIDER(server)->ca_cert_chain = lasso_node_get_attr_value(server_node, LASSO_PROVIDER_CA_CERT_CHAIN_NODE, NULL);
/* providers */
providers_node = lasso_node_get_child(server_node, LASSO_SERVER_PROVIDERS_NODE, lassoLassoHRef, NULL);
if (providers_node != NULL) {
providers_class = LASSO_NODE_GET_CLASS(providers_node);
providers_xmlNode = providers_class->get_xmlNode(providers_node);
provider_xmlNode = providers_xmlNode->children;
while (provider_xmlNode != NULL) {
if (provider_xmlNode->type == XML_ELEMENT_NODE && \
xmlStrEqual(provider_xmlNode->name, LASSO_PROVIDER_NODE)) {
/* provider node */
provider_node = lasso_node_new_from_xmlNode(provider_xmlNode);
/* metadata */
entity_node = lasso_node_get_child(provider_node, "EntityDescriptor", NULL, NULL);
/* public key */
public_key = lasso_node_get_attr_value(provider_node, LASSO_PROVIDER_PUBLIC_KEY_NODE, NULL);
/* ca certificate */
ca_cert_chain = lasso_node_get_attr_value(provider_node, LASSO_PROVIDER_CA_CERT_CHAIN_NODE, NULL);
/* add provider */
provider = lasso_provider_new_from_metadata_node(entity_node);
lasso_node_destroy(entity_node);
if (public_key != NULL) {
lasso_provider_set_public_key(provider, public_key);
xmlFree(public_key);
}
if (ca_cert_chain != NULL) {
lasso_provider_set_ca_cert_chain(provider, ca_cert_chain);
xmlFree(ca_cert_chain);
}
lasso_server_add_lasso_provider(server, provider);
lasso_node_destroy(provider_node);
}
provider_xmlNode = provider_xmlNode->next;
}
lasso_node_destroy(providers_node);
}
lasso_node_destroy(server_node);
return server;
return server;
}
gchar*
lasso_server_dump(LassoServer *server)
{
return lasso_node_dump(LASSO_NODE(server), NULL, 1);
}

View File

@ -30,7 +30,7 @@
extern "C" {
#endif /* __cplusplus */
#include <lasso/protocols/provider.h>
#include <lasso/environs/provider.h>
#define LASSO_TYPE_SERVER (lasso_server_get_type())
#define LASSO_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_SERVER, LassoServer))
@ -44,17 +44,17 @@ typedef struct _LassoServerClass LassoServerClass;
typedef struct _LassoServerPrivate LassoServerPrivate;
struct _LassoServer {
LassoProvider parent;
LassoProvider parent;
GPtrArray *providers;
gchar *providerID;
gchar *private_key;
gchar *secret_key;
gchar *certificate;
lassoSignatureMethod signature_method;
/*< private >*/
LassoServerPrivate *private;
GHashTable *providers;
gchar *private_key;
gchar *secret_key;
gchar *certificate;
lassoSignatureMethod signature_method;
/*< private >*/
LassoServerPrivate *private;
};
struct _LassoServerClass {
@ -68,36 +68,25 @@ LASSO_EXPORT LassoServer* lasso_server_new (const g
const gchar *secret_key,
const gchar *certificate);
LASSO_EXPORT LassoServer* lasso_server_new_from_dump (gchar *dump);
LASSO_EXPORT LassoServer* lasso_server_new_from_dump (const gchar *dump);
LASSO_EXPORT gint lasso_server_add_provider (LassoServer *server,
gchar *metadata,
gchar *public_key,
gchar *ca_cert_chain);
LASSO_EXPORT LassoServer* lasso_server_copy (LassoServer *server);
LassoProviderRole role,
gchar *metadata,
gchar *public_key,
gchar *ca_cert_chain);
LASSO_EXPORT void lasso_server_destroy (LassoServer *server);
LASSO_EXPORT gchar* lasso_server_dump (LassoServer *server);
LASSO_EXPORT gchar* lasso_server_get_first_providerID (LassoServer *server);
LASSO_EXPORT LassoProvider* lasso_server_get_provider (LassoServer *server,
gchar *providerID,
GError **err);
LASSO_EXPORT LassoProvider* lasso_server_get_provider_ref (LassoServer *server,
gchar *providerID,
GError **err);
gchar *providerID);
LASSO_EXPORT gchar* lasso_server_get_providerID_from_hash (LassoServer *server,
gchar *b64_hash);
LASSO_EXPORT lassoSignatureMethod lasso_server_get_signature_method (LassoServer *server);
LASSO_EXPORT void lasso_server_set_signature_method (LassoServer *server,
lassoSignatureMethod signature_method);
LASSO_EXPORT gchar* lasso_server_dump(LassoServer *server);
#ifdef __cplusplus
}

View File

@ -24,332 +24,198 @@
*/
#include <lasso/environs/session.h>
#include <lasso/xml/errors.h>
#include <lasso/lasso_config.h>
#define LASSO_SESSION_NODE "Session"
#define LASSO_SESSION_ASSERTIONS_NODE "Assertions"
#define LASSO_SESSION_ASSERTION_NODE "AuthnAssertion"
#define LASSO_SESSION_REMOTE_PROVIDERID_ATTR "RemoteProviderID"
#include <libxml/tree.h>
struct _LassoSessionPrivate
{
gboolean dispose_has_run;
gboolean dispose_has_run;
GList *providerIDs;
};
static GObjectClass *parent_class = NULL;
/*****************************************************************************/
/* private functions */
/*****************************************************************************/
static void
lasso_session_copy_assertion(gpointer key,
gpointer value,
gpointer assertions)
{
g_hash_table_insert((GHashTable *)assertions, g_strdup((gchar *)key),
lasso_node_copy(LASSO_NODE(value)));
}
static void
lasso_session_dump_assertion(gpointer key,
gpointer value,
LassoNode *assertions)
{
LassoNode *assertion_node, *assertion_copy;
LassoNodeClass *assertion_class, *assertions_class;
/* new lasso assertion node */
assertion_node = lasso_node_new();
assertion_class = LASSO_NODE_GET_CLASS(assertion_node);
assertion_class->set_name(assertion_node, LASSO_SESSION_ASSERTION_NODE);
/* set the remote provider id */
assertion_class->set_prop(assertion_node, LASSO_SESSION_REMOTE_PROVIDERID_ATTR, key);
/* set assertion node */
assertion_copy = lasso_node_copy(LASSO_NODE(value));
assertion_class->add_child(assertion_node, assertion_copy, FALSE);
lasso_node_destroy(assertion_copy);
/* add lasso assertion node to lasso assertions node */
assertions_class = LASSO_NODE_GET_CLASS(assertions);
assertions_class->add_child(assertions, assertion_node, TRUE);
lasso_node_destroy(assertion_node);
}
/*****************************************************************************/
/* public methods */
/*****************************************************************************/
gint
lasso_session_add_assertion(LassoSession *session,
gchar *providerID,
LassoNode *assertion)
lasso_session_add_assertion(LassoSession *session, gchar *providerID, LassoSamlAssertion *assertion)
{
int i;
gboolean found = FALSE;
g_return_val_if_fail(session != NULL, -1);
g_return_val_if_fail(providerID != NULL, -2);
g_return_val_if_fail(assertion != NULL, -3);
g_return_val_if_fail(session != NULL, -1);
g_return_val_if_fail(providerID != NULL, -2);
g_return_val_if_fail(assertion != NULL, -3);
if (g_hash_table_lookup(session->assertions, providerID)) {
debug("An assertion existed already for this providerID, replaced by new one.");
}
/* add the remote provider id */
for(i = 0; i<session->providerIDs->len; i++) {
if(xmlStrEqual(providerID, g_ptr_array_index(session->providerIDs, i))) {
found = TRUE;
break;
}
}
if(found == TRUE) {
debug("An assertion existed already for this providerID, it was replaced by the new one.\n");
}
else {
g_ptr_array_add(session->providerIDs, g_strdup(providerID));
}
g_hash_table_insert(session->assertions, g_strdup(providerID), assertion);
/* add the assertion */
g_hash_table_insert(session->assertions, g_strdup(providerID),
lasso_node_copy(assertion));
session->is_dirty = TRUE;
session->is_dirty = TRUE;
return 0;
return 0;
}
LassoSession*
lasso_session_copy(LassoSession *session)
LassoSamlAssertion*
lasso_session_get_assertion(LassoSession *session, gchar *providerID)
{
LassoSession *copy;
guint i;
if (session == NULL) {
return NULL;
}
copy = LASSO_SESSION(g_object_new(LASSO_TYPE_SESSION, NULL));
copy->providerIDs = g_ptr_array_new();
for(i=0; i<session->providerIDs->len; i++) {
g_ptr_array_add(copy->providerIDs,
g_strdup(g_ptr_array_index(session->providerIDs, i)));
}
copy->assertions = g_hash_table_new_full(g_str_hash, g_str_equal,
(GDestroyNotify)g_free,
(GDestroyNotify)lasso_node_destroy);
g_hash_table_foreach(session->assertions, (GHFunc)lasso_session_copy_assertion,
(gpointer)copy->assertions);
copy->is_dirty = session->is_dirty;
return copy;
}
void
lasso_session_destroy(LassoSession *session)
{
if (LASSO_IS_SESSION(session)) {
g_object_unref(G_OBJECT(session));
}
return g_hash_table_lookup(session->assertions, providerID);
}
gchar*
lasso_session_dump(LassoSession *session)
lasso_session_get_authentication_method(LassoSession *session, gchar *remote_providerID)
{
LassoNode *session_node, *assertions_node;
LassoNodeClass *session_class, *assertions_class;
int table_size;
gchar *dump;
/* XXX: somewhere in
* session/Assertion[remote_providerID]/AuthenticationStatement
*/
g_return_val_if_fail(session != NULL, NULL);
session_node = lasso_node_new();
session_class = LASSO_NODE_GET_CLASS(session_node);
session_class->set_name(session_node, LASSO_SESSION_NODE);
session_class->set_ns(session_node, lassoLassoHRef, NULL);
/* dump the assertions */
table_size = g_hash_table_size(session->assertions);
if (table_size > 0) {
assertions_node = lasso_node_new();
assertions_class = LASSO_NODE_GET_CLASS(assertions_node);
assertions_class->set_name(assertions_node, LASSO_SESSION_ASSERTIONS_NODE);
g_hash_table_foreach(session->assertions, (GHFunc)lasso_session_dump_assertion,
assertions_node);
session_class->add_child(session_node, assertions_node, FALSE);
lasso_node_destroy(assertions_node);
}
/* Add lasso version in the xml node */
session_class->set_prop(LASSO_NODE(session_node), "version", PACKAGE_VERSION);
dump = lasso_node_export(session_node);
lasso_node_destroy(session_node);
return dump;
}
LassoNode*
lasso_session_get_assertion(LassoSession *session,
gchar *providerID)
{
LassoNode *assertion;
g_return_val_if_fail(session != NULL, NULL);
g_return_val_if_fail(providerID != NULL, NULL);
assertion = (LassoNode *)g_hash_table_lookup(session->assertions,
providerID);
if (assertion == NULL) {
return NULL;
}
return lasso_node_copy(assertion);
}
gchar*
lasso_session_get_authentication_method(LassoSession *session,
gchar *remote_providerID)
{
LassoNode *assertion, *as;
gchar *providerID = remote_providerID;
gchar *authentication_method;
GError *err = NULL;
if (providerID == NULL) {
providerID = lasso_session_get_first_providerID(session);
}
assertion = lasso_session_get_assertion(session, providerID);
if (providerID == NULL) {
g_free(providerID);
}
as = lasso_node_get_child(assertion, "AuthenticationStatement", NULL, NULL);
authentication_method = lasso_node_get_attr_value(as, "AuthenticationMethod", &err);
if (authentication_method == NULL) {
message(G_LOG_LEVEL_CRITICAL, err->message);
g_error_free(err);
goto done;
}
done:
lasso_node_destroy(as);
lasso_node_destroy(assertion);
return authentication_method;
g_assert_not_reached();
return NULL;
}
gchar*
lasso_session_get_first_providerID(LassoSession *session)
{
gchar *providerID;
/* XXX: why didn't it use get_provider_index directly ? */
return lasso_session_get_provider_index(session, 0);
}
g_return_val_if_fail(session != NULL, NULL);
if(session->providerIDs->len == 0) {
return NULL;
}
providerID = g_ptr_array_index(session->providerIDs, 0);
if (providerID == NULL) {
return NULL;
}
return g_strdup(providerID);
static void
add_providerID(gchar *key, LassoLibAssertion *assertion, LassoSession *session)
{
session->private->providerIDs = g_list_append(session->private->providerIDs, key);
}
gchar*
lasso_session_get_provider_index(LassoSession *session,
gint index)
lasso_session_get_provider_index(LassoSession *session, gint index)
{
gchar *providerID;
GList *element;
g_return_val_if_fail(session != NULL, NULL);
if (session->private->providerIDs == NULL) {
g_hash_table_foreach(session->assertions, (GHFunc)add_providerID, session);
/* XXX? create list */
}
/* verify index is valid */
if ((session->providerIDs == NULL) && (session->providerIDs->len < 0)) {
return NULL;
}
if ((index < 0) || (index >= session->providerIDs->len)) {
return NULL;
}
if (g_hash_table_size(session->assertions) == 0)
return NULL;
/* get the provider id */
providerID = g_ptr_array_index(session->providerIDs, index);
if (providerID == NULL) {
return NULL;
}
element = g_list_nth(session->private->providerIDs, index);
if (element == NULL)
return NULL;
return g_strdup(providerID);
return g_strdup(element->data);
}
gint
lasso_session_remove_assertion(LassoSession *session,
gchar *providerID)
lasso_session_remove_assertion(LassoSession *session, gchar *providerID)
{
LassoNode *assertion;
int i;
if (g_hash_table_remove(session->assertions, providerID)) {
session->is_dirty = TRUE;
return 0;
}
g_return_val_if_fail(session != NULL, -1);
g_return_val_if_fail(providerID != NULL, -1);
/* remove the assertion */
assertion = lasso_session_get_assertion(session, providerID);
if (assertion != NULL) {
g_hash_table_remove(session->assertions, providerID);
lasso_node_destroy(assertion);
}
/* remove the remote provider id */
for(i = 0; i<session->providerIDs->len; i++) {
if(xmlStrEqual(providerID, g_ptr_array_index(session->providerIDs, i))) {
g_ptr_array_remove_index(session->providerIDs, i);
break;
}
}
session->is_dirty = TRUE;
return 0;
return LASSO_ERROR_UNDEFINED; /* assertion not found */
}
/*****************************************************************************/
/* private methods */
/*****************************************************************************/
static LassoNodeClass *parent_class = NULL;
static void
add_assertion_childnode(gchar *key, LassoLibAssertion *value, xmlNode *xmlnode)
{
xmlNode *t;
t = xmlNewTextChild(xmlnode, NULL, "Assertion", NULL);
xmlSetProp(t, "RemoteProviderID", key);
xmlAddChild(t, lasso_node_get_xmlNode(LASSO_NODE(value)));
}
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
LassoSession *session = LASSO_SESSION(node);
xmlnode = xmlNewNode(NULL, "Session");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LASSO_HREF, NULL));
xmlSetProp(xmlnode, "Version", "2");
if (g_hash_table_size(session->assertions))
g_hash_table_foreach(session->assertions, (GHFunc)add_assertion_childnode, xmlnode);
return xmlnode;
}
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoSession *session = LASSO_SESSION(node);
xmlNode *t, *n;
t = xmlnode->children;
while (t) {
if (t->type != XML_ELEMENT_NODE) {
t = t->next;
continue;
}
if (strcmp(t->name, "Assertion") == 0) {
n = t->children;
while (n && n->type != XML_ELEMENT_NODE) n = n->next;
if (n) {
LassoLibAssertion *assertion;
assertion = LASSO_LIB_ASSERTION(lasso_node_new_from_xmlNode(n));
g_hash_table_insert(
session->assertions,
xmlGetProp(t, "RemoteProviderID"),
assertion);
}
}
t = t->next;
}
}
/*****************************************************************************/
/* overrided parent class methods */
/*****************************************************************************/
static void
lasso_session_dispose(LassoSession *session)
dispose(GObject *object)
{
if (session->private->dispose_has_run == TRUE) {
return;
}
session->private->dispose_has_run = TRUE;
LassoSession *session = LASSO_SESSION(object);
debug("Session object 0x%x disposed ...\n", session);
if (session->private->dispose_has_run == TRUE) {
return;
}
session->private->dispose_has_run = TRUE;
g_hash_table_destroy(session->assertions);
session->assertions = NULL;
debug("Session object 0x%x disposed ...\n", session);
parent_class->dispose(G_OBJECT(session));
/* XXX: here or not ?
g_hash_table_destroy(session->assertions);
session->assertions = NULL;
*/
G_OBJECT_CLASS(parent_class)->dispose(object);
}
static void
lasso_session_finalize(LassoSession *session)
finalize(GObject *object)
{
gint i;
LassoSession *session = LASSO_SESSION(object);
debug("Session object 0x%x finalized ...\n", session);
debug("Session object 0x%x finalized ...\n", session);
/* free allocated memory for providerIDs array */
for (i=0; i<session->providerIDs->len; i++) {
g_free(session->providerIDs->pdata[i]);
session->providerIDs->pdata[i] = NULL;
}
g_ptr_array_free(session->providerIDs, TRUE);
session->providerIDs = NULL;
g_free(session->private);
session->private = NULL;
g_free(session->private);
session->private = NULL;
parent_class->finalize(G_OBJECT(session));
G_OBJECT_CLASS(parent_class)->finalize(object);
}
/*****************************************************************************/
@ -357,126 +223,85 @@ lasso_session_finalize(LassoSession *session)
/*****************************************************************************/
static void
lasso_session_instance_init(LassoSession *session)
instance_init(LassoSession *session)
{
session->private = g_new (LassoSessionPrivate, 1);
session->private->dispose_has_run = FALSE;
session->private = g_new (LassoSessionPrivate, 1);
session->private->dispose_has_run = FALSE;
session->private->providerIDs = NULL;
session->providerIDs = g_ptr_array_new();
session->assertions = g_hash_table_new_full(g_str_hash, g_str_equal,
(GDestroyNotify)g_free,
(GDestroyNotify)lasso_node_destroy);
session->is_dirty = FALSE;
session->assertions = g_hash_table_new_full(g_str_hash, g_str_equal,
(GDestroyNotify)g_free,
(GDestroyNotify)lasso_node_destroy);
session->is_dirty = FALSE;
}
static void
lasso_session_class_init(LassoSessionClass *class)
class_init(LassoSessionClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS(class);
parent_class = g_type_class_peek_parent(class);
/* override parent class methods */
gobject_class->dispose = (void *)lasso_session_dispose;
gobject_class->finalize = (void *)lasso_session_finalize;
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
G_OBJECT_CLASS(klass)->dispose = dispose;
G_OBJECT_CLASS(klass)->finalize = finalize;
}
GType lasso_session_get_type() {
static GType this_type = 0;
GType
lasso_session_get_type()
{
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoSessionClass),
NULL,
NULL,
(GClassInitFunc) lasso_session_class_init,
NULL,
NULL,
sizeof(LassoSession),
0,
(GInstanceInitFunc) lasso_session_instance_init,
};
this_type = g_type_register_static(G_TYPE_OBJECT,
"LassoSession",
&this_info, 0);
}
return this_type;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoSessionClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoSession),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoSession", &this_info, 0);
}
return this_type;
}
LassoSession*
lasso_session_new()
{
LassoSession *session;
session = LASSO_SESSION(g_object_new(LASSO_TYPE_SESSION, NULL));
return session;
return g_object_new(LASSO_TYPE_SESSION, NULL);
}
LassoSession*
lasso_session_new_from_dump(gchar *dump)
lasso_session_new_from_dump(const gchar *dump)
{
LassoSession *session;
LassoNode *session_node;
LassoNode *assertions_node, *assertion_node, *assertion;
xmlNodePtr assertions_xmlNode, assertion_xmlNode;
xmlChar *providerID;
GError *err = NULL;
LassoSession *session;
xmlDoc *doc;
g_return_val_if_fail(dump != NULL, NULL);
session = lasso_session_new();
doc = xmlParseMemory(dump, strlen(dump));
init_from_xml(LASSO_NODE(session), xmlDocGetRootElement(doc));
xmlFreeDoc(doc);
session = LASSO_SESSION(g_object_new(LASSO_TYPE_SESSION, NULL));
/* get session */
session_node = lasso_node_new_from_dump(dump);
if (session_node == NULL) {
message(G_LOG_LEVEL_WARNING, "Can't create a session from dump\n");
return NULL;
}
/* get assertions */
assertions_node = lasso_node_get_child(session_node,
LASSO_SESSION_ASSERTIONS_NODE,
lassoLassoHRef, NULL);
if (assertions_node != NULL) {
assertions_xmlNode = LASSO_NODE_GET_CLASS(assertions_node)->get_xmlNode(assertions_node);
assertion_xmlNode = assertions_xmlNode->children;
while (assertion_xmlNode != NULL) {
/* assertion xmlNode */
if (assertion_xmlNode->type == XML_ELEMENT_NODE && \
xmlStrEqual(assertion_xmlNode->name, LASSO_SESSION_ASSERTION_NODE)) {
/* assertion node */
assertion_node = lasso_node_new_from_xmlNode(assertion_xmlNode);
providerID = lasso_node_get_attr_value(assertion_node,
LASSO_SESSION_REMOTE_PROVIDERID_ATTR,
&err);
if (providerID != NULL) {
assertion = lasso_node_get_child(assertion_node,
"Assertion",
NULL, /* lassoLibHRef, FIXME changed for SourceID */
&err);
if (assertion != NULL) {
lasso_session_add_assertion(session, providerID, assertion);
lasso_node_destroy(assertion);
}
else {
message(G_LOG_LEVEL_CRITICAL, err->message);
g_clear_error(&err);
}
}
else {
message(G_LOG_LEVEL_CRITICAL, err->message);
g_clear_error(&err);
}
xmlFree(providerID);
lasso_node_destroy(assertion_node);
}
assertion_xmlNode = assertion_xmlNode->next;
}
}
lasso_node_destroy(assertions_node);
lasso_node_destroy(session_node);
return session;
return session;
}
gchar*
lasso_session_dump(LassoSession *session)
{
if (g_hash_table_size(session->assertions) == 0)
return g_strdup("");
return lasso_node_dump(LASSO_NODE(session), NULL, 1);
}
void lasso_session_destroy(LassoSession *session)
{
/* XXX do nothing */
}

View File

@ -31,7 +31,7 @@ extern "C" {
#endif /* __cplusplus */
#include <lasso/xml/xml.h>
#include <lasso/protocols/elements/assertion.h>
#include <lasso/xml/lib_assertion.h>
#define LASSO_TYPE_SESSION (lasso_session_get_type())
#define LASSO_SESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_SESSION, LassoSession))
@ -45,51 +45,44 @@ typedef struct _LassoSessionClass LassoSessionClass;
typedef struct _LassoSessionPrivate LassoSessionPrivate;
struct _LassoSession {
GObject parent;
LassoNode parent;
/*< public >*/
GPtrArray *providerIDs; /* list of the remote provider IDs for assertions hash table */
GHashTable *assertions; /* hash for assertions with remote providerID as key */
GHashTable *assertions; /* hash for assertions with remote providerID as key */
gboolean is_dirty;
gboolean is_dirty;
/*< private >*/
LassoSessionPrivate *private; /* Index of the current remote provider id in the providerIDs list */
/*< private >*/
LassoSessionPrivate *private;
};
struct _LassoSessionClass {
GObjectClass parent;
LassoNodeClass parent;
};
LASSO_EXPORT GType lasso_session_get_type (void);
LASSO_EXPORT LassoSession* lasso_session_new (void);
LASSO_EXPORT LassoSession* lasso_session_new_from_dump (gchar *dump);
LASSO_EXPORT LassoSession* lasso_session_new_from_dump(const gchar *dump);
LASSO_EXPORT gint lasso_session_add_assertion (LassoSession *session,
gchar *providerID,
LassoNode *assertion);
LASSO_EXPORT gint lasso_session_add_assertion(LassoSession *session,
gchar *providerID, LassoSamlAssertion *assertion);
LASSO_EXPORT LassoSession* lasso_session_copy (LassoSession *session);
LASSO_EXPORT gchar* lasso_session_dump(LassoSession *session);
LASSO_EXPORT void lasso_session_destroy (LassoSession *session);
LASSO_EXPORT LassoSamlAssertion* lasso_session_get_assertion(
LassoSession *session, gchar *providerID);
LASSO_EXPORT gchar* lasso_session_dump (LassoSession *session);
LASSO_EXPORT gchar* lasso_session_get_authentication_method(LassoSession *session,
gchar *providerID);
LASSO_EXPORT LassoNode* lasso_session_get_assertion (LassoSession *session,
gchar *providerID);
LASSO_EXPORT gchar* lasso_session_get_first_providerID(LassoSession *session);
LASSO_EXPORT gchar* lasso_session_get_authentication_method (LassoSession *session,
gchar *providerID);
LASSO_EXPORT gchar* lasso_session_get_provider_index(LassoSession *session, gint index);
LASSO_EXPORT gchar* lasso_session_get_first_providerID (LassoSession *session);
LASSO_EXPORT gint lasso_session_remove_assertion(LassoSession *session, gchar *providerID);
LASSO_EXPORT gchar* lasso_session_get_provider_index (LassoSession *session,
gint index);
LASSO_EXPORT void lasso_session_destroy(LassoSession *session);
LASSO_EXPORT gint lasso_session_remove_assertion (LassoSession *session,
gchar *providerID);
#ifdef __cplusplus
}

View File

@ -169,7 +169,7 @@ lasso_check_version_ext(int major, int minor, int subminor, lassoCheckVersionMod
}
switch (mode) {
case lassoCheckVersionExact:
case LASSO_CHECK_VERSION_EXACT:
if ((minor != LASSO_VERSION_MINOR) || (subminor != LASSO_VERSION_SUBMINOR)) {
g_message("mode=exact;expected minor version=%d;real minor version=%d;expected subminor version=%d;real subminor version=%d",
LASSO_VERSION_MINOR, minor,
@ -177,7 +177,7 @@ lasso_check_version_ext(int major, int minor, int subminor, lassoCheckVersionMod
return 0;
}
break;
case lassoCheckVersionABICompatible:
case LASSO_CHECK_VERSIONABI_COMPATIBLE:
if ((minor < LASSO_VERSION_MINOR) ||
((minor == LASSO_VERSION_MINOR) && (subminor < LASSO_VERSION_SUBMINOR))) {
g_message("mode=abi compatible;expected minor version=%d;real minor version=%d;expected subminor version=%d;real subminor version=%d",

View File

@ -48,14 +48,14 @@ LASSO_EXPORT int lasso_shutdown(void);
/**
* lassoCheckVersionMode:
* @lassoCheckVersionExact: the version should match exactly.
* @lassoCheckVersionABICompatible: the version should be ABI compatible.
* @LASSO_CHECK_VERSION_EXACT: the version should match exactly.
* @LASSO_CHECK_VERSIONABI_COMPATIBLE: the version should be ABI compatible.
*
* The lasso library version mode.
*/
typedef enum {
lassoCheckVersionExact = 0,
lassoCheckVersionABICompatible
LASSO_CHECK_VERSION_EXACT = 0,
LASSO_CHECK_VERSIONABI_COMPATIBLE
} lassoCheckVersionMode;
/**
@ -67,7 +67,7 @@ typedef enum {
*/
#define lasso_check_version_exact() \
lasso_check_version_ext(LASSO_VERSION_MAJOR, LASSO_VERSION_MINOR, \
LASSO_VERSION_SUBMINOR, lassoCheckVersionExact)
LASSO_VERSION_SUBMINOR, LASSO_CHECK_VERSION_EXACT)
/**
* lasso_check_version:
@ -79,7 +79,7 @@ typedef enum {
#define lasso_check_version() \
lasso_check_version_ext(LASSO_VERSION_MAJOR, LASSO_VERSION_MINOR, \
LASSO_VERSION_SUBMINOR, \
lassoCheckVersionABICompatible)
LASSO_CHECK_VERSIONABI_COMPATIBLE)
LASSO_EXPORT int lasso_check_version_ext(int major,
int minor,

View File

@ -25,17 +25,14 @@ liblasso_xml_la_SOURCES = \
lib_idp_entries.c \
lib_idp_entry.c \
lib_idp_list.c \
lib_idp_provided_name_identifier.c \
lib_logout_request.c \
lib_logout_response.c \
lib_name_identifier_mapping_request.c \
lib_name_identifier_mapping_response.c \
lib_old_provided_name_identifier.c \
lib_register_name_identifier_request.c \
lib_register_name_identifier_response.c \
lib_request_authn_context.c \
lib_scoping.c \
lib_sp_provided_name_identifier.c \
lib_status_response.c \
lib_subject.c \
saml_advice.c \
@ -50,23 +47,20 @@ liblasso_xml_la_SOURCES = \
saml_subject.c \
saml_subject_confirmation.c \
saml_subject_locality.c \
saml_subject_statement.c \
saml_subject_statement_abstract.c \
samlp_request.c \
samlp_request_abstract.c \
samlp_response.c \
samlp_response_abstract.c \
samlp_status.c \
samlp_status_code.c \
soap-env_envelope.c \
soap-env_body.c
samlp_status_code.c
liblassoinclude_HEADERS = \
strings.h \
tools.h \
debug.h \
errors.h \
lib.h \
saml.h \
xml.h \
lib_assertion.h \
lib_authentication_statement.h \
@ -79,17 +73,14 @@ liblassoinclude_HEADERS = \
lib_idp_entries.h \
lib_idp_entry.h \
lib_idp_list.h \
lib_idp_provided_name_identifier.h \
lib_logout_request.h \
lib_logout_response.h \
lib_name_identifier_mapping_request.h \
lib_name_identifier_mapping_response.h \
lib_old_provided_name_identifier.h \
lib_register_name_identifier_request.h \
lib_register_name_identifier_response.h \
lib_request_authn_context.h \
lib_scoping.h \
lib_sp_provided_name_identifier.h \
lib_status_response.h \
lib_subject.h \
saml_advice.h \
@ -104,12 +95,12 @@ liblassoinclude_HEADERS = \
saml_subject.h \
saml_subject_confirmation.h \
saml_subject_locality.h \
saml_subject_statement.h \
saml_subject_statement_abstract.h \
samlp_request.h \
samlp_request_abstract.h \
samlp_response.h \
samlp_response_abstract.h \
samlp_status.h \
samlp_status_code.h \
soap-env_envelope.h \
soap-env_body.h
samlp_status_code.h

View File

@ -46,6 +46,7 @@
#define LASSO_DS_ERROR_SIGNATURE_VERIFICATION_FAILED -111
#define LASSO_DS_ERROR_CA_CERT_CHAIN_LOAD_FAILED -112
#define LASSO_DS_ERROR_INVALID_SIGALG -113
#define LASSO_DS_ERROR_DIGEST_COMPUTE_FAILED -114
/* server */
#define LASSO_SERVER_ERROR_PROVIDER_NOT_FOUND -201
@ -61,6 +62,9 @@
#define LASSO_PROFILE_ERROR_MISSING_REQUEST -404
#define LASSO_PROFILE_ERROR_INVALID_HTTP_METHOD -405
#define LASSO_PROFILE_ERROR_INVALID_PROTOCOLPROFILE -406
#define LASSO_PROFILE_ERROR_INVALID_MSG -407
#define LASSO_PROFILE_ERROR_MISSING_REMOTE_PROVIDERID -408
#define LASSO_PROFILE_ERROR_UNSUPPORTED_PROFILE -409
/* functions/methods parameters checking */
#define LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ -501

View File

@ -1,60 +0,0 @@
/* $Id$
*
* Lasso - A free implementation of the Liberty Alliance specifications.
*
* Copyright (C) 2004 Entr'ouvert
* http://lasso.entrouvert.org
*
* Authors: Nicolas Clapies <nclapies@entrouvert.com>
* Valery Febvre <vfebvre@easter-eggs.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __LASSO_LIB_H__
#define __LASSO_LIB_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <lasso/xml/lib_assertion.h>
#include <lasso/xml/lib_authentication_statement.h>
#include <lasso/xml/lib_authn_context.h>
#include <lasso/xml/lib_authn_response.h>
#include <lasso/xml/lib_authn_request.h>
#include <lasso/xml/lib_federation_termination_notification.h>
#include <lasso/xml/lib_idp_entries.h>
#include <lasso/xml/lib_idp_entry.h>
#include <lasso/xml/lib_idp_list.h>
#include <lasso/xml/lib_idp_provided_name_identifier.h>
#include <lasso/xml/lib_logout_request.h>
#include <lasso/xml/lib_logout_response.h>
#include <lasso/xml/lib_name_identifier_mapping_request.h>
#include <lasso/xml/lib_name_identifier_mapping_response.h>
#include <lasso/xml/lib_old_provided_name_identifier.h>
#include <lasso/xml/lib_register_name_identifier_request.h>
#include <lasso/xml/lib_register_name_identifier_response.h>
#include <lasso/xml/lib_request_authn_context.h>
#include <lasso/xml/lib_scoping.h>
#include <lasso/xml/lib_sp_provided_name_identifier.h>
#include <lasso/xml/lib_status_response.h>
#include <lasso/xml/lib_subject.h>
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __LASSO_LIB_H__ */

View File

@ -52,117 +52,98 @@ The schema fragment is as follows:
*/
/*****************************************************************************/
/* public methods */
/* private methods */
/*****************************************************************************/
void
lasso_lib_assertion_set_inResponseTo(LassoLibAssertion *node,
const xmlChar *inResponseTo)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_ASSERTION(node));
g_assert(inResponseTo != NULL);
static LassoNodeClass *parent_class = NULL;
class = LASSO_NODE_GET_CLASS(node);
class->set_prop(LASSO_NODE (node), "InResponseTo", inResponseTo);
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
xmlnode = parent_class->get_xmlNode(node);
xmlSetProp(xmlnode, "InResponseTo", LASSO_LIB_ASSERTION(node)->InResponseTo);
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
return xmlnode;
}
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
parent_class->init_from_xml(node, xmlnode);
LASSO_LIB_ASSERTION(node)->InResponseTo = xmlGetProp(xmlnode, "InResponseTo");
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
enum {
LASSO_LIB_ASSERTION_USE_XSITYPE = 1
};
static void
lasso_lib_assertion_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
instance_init(LassoLibAssertion *node)
{
LassoLibAssertion *self = LASSO_LIB_ASSERTION(object);
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(object));
switch (property_id) {
case LASSO_LIB_ASSERTION_USE_XSITYPE:
self->use_xsitype = g_value_get_boolean (value);
if (self->use_xsitype == TRUE) {
/* namespace and name were already set in parent class
LassoSamlAssertion */
class->new_ns_prop(LASSO_NODE(object),
"type", "lib:AssertionType",
lassoXsiHRef, lassoXsiPrefix);
}
else {
/* node name was already set in parent class LassoSamlAssertion
just change ns */
class->set_ns(LASSO_NODE(object), lassoLibHRef, lassoLibPrefix);
}
break;
default:
/* We don't have any other property... */
g_assert (FALSE);
break;
}
node->InResponseTo = NULL;
}
static void
lasso_lib_assertion_instance_init(LassoLibAssertion *node)
class_init(LassoLibAssertionClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
}
static void
lasso_lib_assertion_class_init(LassoLibAssertionClass *g_class,
gpointer g_class_data)
GType lasso_lib_assertion_get_type()
{
GObjectClass *gobject_class = G_OBJECT_CLASS (g_class);
GParamSpec *pspec;
static GType this_type = 0;
/* override parent class methods */
gobject_class->set_property = lasso_lib_assertion_set_property;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibAssertionClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoLibAssertion),
0,
(GInstanceInitFunc) instance_init,
};
pspec = g_param_spec_boolean ("use_xsitype",
"use_xsitype",
"using xsi:type",
FALSE,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE);
g_object_class_install_property (gobject_class,
LASSO_LIB_ASSERTION_USE_XSITYPE,
pspec);
this_type = g_type_register_static(LASSO_TYPE_SAML_ASSERTION,
"LassoLibAssertion", &this_info, 0);
}
return this_type;
}
GType lasso_lib_assertion_get_type() {
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibAssertionClass),
NULL,
NULL,
(GClassInitFunc) lasso_lib_assertion_class_init,
NULL,
NULL,
sizeof(LassoLibAssertion),
0,
(GInstanceInitFunc) lasso_lib_assertion_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_SAML_ASSERTION,
"LassoLibAssertion",
&this_info, 0);
}
return this_type;
}
LassoNode*
lasso_lib_assertion_new(gboolean use_xsitype)
LassoLibAssertion*
lasso_lib_assertion_new_full(const char *issuer, const char *requestID,
const char *audience, const char *notBefore, const char *notOnOrAfter)
{
LassoNode *node;
LassoSamlAssertion *assertion;
node = LASSO_NODE(g_object_new(LASSO_TYPE_LIB_ASSERTION,
"use_xsitype", use_xsitype,
NULL));
g_return_val_if_fail(issuer != NULL, NULL);
return node;
assertion = LASSO_SAML_ASSERTION(g_object_new(LASSO_TYPE_LIB_ASSERTION, NULL));
assertion->AssertionID = lasso_build_unique_id(32);
assertion->MajorVersion = LASSO_LIB_MAJOR_VERSION_N;
assertion->MinorVersion = LASSO_LIB_MINOR_VERSION_N;
assertion->IssueInstant = lasso_get_current_time();
assertion->Issuer = g_strdup(issuer);
if (requestID != NULL)
LASSO_LIB_ASSERTION(assertion)->InResponseTo = g_strdup(requestID);
assertion->Conditions = lasso_saml_conditions_new();
assertion->Conditions->NotBefore = g_strdup(notBefore);
assertion->Conditions->NotOnOrAfter = g_strdup(notOnOrAfter);
if (audience) {
assertion->Conditions->AudienceRestrictionCondition =
lasso_saml_audience_restriction_condition_new();
assertion->Conditions->AudienceRestrictionCondition->Audience = g_strdup(audience);
}
return LASSO_LIB_ASSERTION(assertion);
}

View File

@ -45,21 +45,19 @@ typedef struct _LassoLibAssertion LassoLibAssertion;
typedef struct _LassoLibAssertionClass LassoLibAssertionClass;
struct _LassoLibAssertion {
LassoSamlAssertion parent;
/*< private >*/
gboolean use_xsitype;
LassoSamlAssertion parent;
char *InResponseTo;
};
struct _LassoLibAssertionClass {
LassoSamlAssertionClass parent;
LassoSamlAssertionClass parent;
};
LASSO_EXPORT GType lasso_lib_assertion_get_type (void);
LASSO_EXPORT LassoNode* lasso_lib_assertion_new (gboolean use_xsitype);
LASSO_EXPORT void lasso_lib_assertion_set_inResponseTo (LassoLibAssertion *,
const xmlChar *);
LASSO_EXPORT LassoLibAssertion* lasso_lib_assertion_new_full(
const char *issuer, const char *requestID, const char *audience,
const char *notBefore, const char *notOnOrAfter);
#ifdef __cplusplus
}

View File

@ -36,152 +36,158 @@ The schema fragment (liberty-idff-protocols-schema-v1.2.xsd):
<xs:element ref="AuthnContext" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="ReauthenticateOnOrAfter" type="xs:dateTime" use="optional"/>
<xs:attribute name="SessionIndex" type="xs:string" use="optional"/>
<xs:attribute name="SessionIndex" type="xs:string" use="required"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
*/
/*****************************************************************************/
/* public methods */
/* private methods */
/*****************************************************************************/
void
lasso_lib_authentication_statement_set_authnContext(LassoLibAuthenticationStatement *node,
LassoLibAuthnContext *authnContext)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_AUTHENTICATION_STATEMENT(node));
g_assert(LASSO_IS_LIB_AUTHN_CONTEXT(authnContext));
static LassoNodeClass *parent_class = NULL;
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE (node), LASSO_NODE(authnContext), FALSE);
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
LassoLibAuthenticationStatement *statement = LASSO_LIB_AUTHENTICATION_STATEMENT(node);
xmlnode = parent_class->get_xmlNode(node);
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
if (statement->AuthnContext)
xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(statement->AuthnContext)));
if (statement->ReauthenticateOnOrAfter)
xmlSetProp(xmlnode, "ReauthenticateOnOrAfter", statement->ReauthenticateOnOrAfter);
if (statement->SessionIndex)
xmlSetProp(xmlnode, "SessionIndex", statement->SessionIndex);
return xmlnode;
}
void
lasso_lib_authentication_statement_set_reauthenticateOnOrAfter(LassoLibAuthenticationStatement *node,
const xmlChar *reauthenticateOnOrAfter)
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_AUTHENTICATION_STATEMENT(node));
g_assert(reauthenticateOnOrAfter != NULL);
LassoLibAuthenticationStatement *statement = LASSO_LIB_AUTHENTICATION_STATEMENT(node);
xmlNode *t;
class = LASSO_NODE_GET_CLASS(node);
class->set_prop(LASSO_NODE (node), "ReauthenticateOnOrAfter", reauthenticateOnOrAfter);
}
parent_class->init_from_xml(node, xmlnode);
void
lasso_lib_authentication_statement_set_sessionIndex(LassoLibAuthenticationStatement *node,
const xmlChar *sessionIndex)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_AUTHENTICATION_STATEMENT(node));
g_assert(sessionIndex != NULL);
t = xmlnode->children;
while (t) {
if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "AuthnContext") == 0) {
statement->AuthnContext = LASSO_LIB_AUTHN_CONTEXT(
lasso_node_new_from_xmlNode(t));
break;
}
t = t->next;
}
class = LASSO_NODE_GET_CLASS(node);
class->set_prop(LASSO_NODE (node), "SessionIndex", sessionIndex);
statement->ReauthenticateOnOrAfter = xmlGetProp(xmlnode, "ReauthenticateOnOrAfter");
statement->SessionIndex = xmlGetProp(xmlnode, "SessionIndex");
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
enum {
LASSO_LIB_AUTHENTICATION_STATEMENT_USE_XSITYPE = 1
};
static void
lasso_lib_authentication_statement_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
instance_init(LassoLibAuthenticationStatement *node)
{
LassoLibAuthenticationStatement *self = LASSO_LIB_AUTHENTICATION_STATEMENT(object);
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(object));
switch (property_id) {
case LASSO_LIB_AUTHENTICATION_STATEMENT_USE_XSITYPE:
self->use_xsitype = g_value_get_boolean (value);
if (self->use_xsitype == TRUE) {
/* namespace and name were already set in parent class
LassoSamlAuthenticationStatement */
class->new_ns_prop(LASSO_NODE(object),
"type", "lib:AuthenticationStatementType",
lassoXsiHRef, lassoXsiPrefix);
}
else {
/* node name was already set in parent class
LassoSamlAuthenticationStatement, just change ns */
class->set_ns(LASSO_NODE(object), lassoLibHRef, lassoLibPrefix);
}
break;
default:
/* We don't have any other property... */
g_assert (FALSE);
break;
}
node->AuthnContext = NULL;
node->ReauthenticateOnOrAfter = NULL;
node->SessionIndex = "1"; /* FIXME: proper SessionIndex usage */
}
static void
lasso_lib_authentication_statement_instance_init(LassoLibAuthenticationStatement *node)
class_init(LassoLibAuthenticationStatementClass *klass)
{
/* LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node)); */
LassoNodeClass *nodeClass = LASSO_NODE_CLASS(klass);
/* class->set_name(LASSO_NODE(node), "AuthenticationStatement"); */
/* class->set_ns(LASSO_NODE(node), lassoLibHRef, lassoLibPrefix); */
parent_class = g_type_class_peek_parent(klass);
nodeClass->get_xmlNode = get_xmlNode;
nodeClass->init_from_xml = init_from_xml;
}
static void
lasso_lib_authentication_statement_class_init(LassoLibAuthenticationStatementClass *g_class,
gpointer g_class_data)
GType
lasso_lib_authentication_statement_get_type()
{
GObjectClass *gobject_class = G_OBJECT_CLASS (g_class);
GParamSpec *pspec;
/* override parent class methods */
gobject_class->set_property = lasso_lib_authentication_statement_set_property;
pspec = g_param_spec_boolean ("use_xsitype",
"use_xsitype",
"using xsi:type",
FALSE,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE);
g_object_class_install_property (gobject_class,
LASSO_LIB_AUTHENTICATION_STATEMENT_USE_XSITYPE,
pspec);
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibAuthenticationStatementClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoLibAuthenticationStatement),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_SAML_AUTHENTICATION_STATEMENT,
"LassoLibAuthenticationStatement", &this_info, 0);
}
return this_type;
}
GType lasso_lib_authentication_statement_get_type() {
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibAuthenticationStatementClass),
NULL,
NULL,
(GClassInitFunc) lasso_lib_authentication_statement_class_init,
NULL,
NULL,
sizeof(LassoLibAuthenticationStatement),
0,
(GInstanceInitFunc) lasso_lib_authentication_statement_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_SAML_AUTHENTICATION_STATEMENT,
"LassoLibAuthenticationStatement",
&this_info, 0);
}
return this_type;
}
LassoNode*
lasso_lib_authentication_statement_new(gboolean use_xsitype)
LassoLibAuthenticationStatement*
lasso_lib_authentication_statement_new_full(const char *authenticationMethod,
const char *authenticationInstant,
const char *reauthenticateOnOrAfter,
LassoSamlNameIdentifier *sp_identifier,
LassoSamlNameIdentifier *idp_identifier)
{
LassoNode *node;
LassoSamlAuthenticationStatement *statement;
LassoSamlNameIdentifier *new_identifier, *new_idp_identifier;
LassoLibSubject *subject;
LassoSamlSubjectConfirmation *subject_confirmation;
char *time;
node = LASSO_NODE(g_object_new(LASSO_TYPE_LIB_AUTHENTICATION_STATEMENT,
"use_xsitype", use_xsitype,
NULL));
g_return_val_if_fail(LASSO_IS_SAML_NAME_IDENTIFIER(idp_identifier), NULL);
g_return_val_if_fail(sp_identifier || idp_identifier, NULL);
return node;
subject = lasso_lib_subject_new();
if (sp_identifier == NULL) {
new_identifier = idp_identifier;
} else {
new_identifier = sp_identifier;
}
statement = g_object_new(LASSO_TYPE_LIB_AUTHENTICATION_STATEMENT, NULL);
statement->AuthenticationMethod = g_strdup(authenticationMethod);
if (authenticationInstant == NULL)
time = lasso_get_current_time();
else
time = g_strdup(authenticationInstant);
statement->AuthenticationInstant = time;
LASSO_LIB_AUTHENTICATION_STATEMENT(statement)->ReauthenticateOnOrAfter =
g_strdup(reauthenticateOnOrAfter);
LASSO_SAML_SUBJECT(subject)->NameIdentifier = new_identifier;
if (sp_identifier != NULL) {
/* create a new IdpProvidedNameIdentifier and use idp_identifier data to fill it */
new_idp_identifier = lasso_saml_name_identifier_new();
new_idp_identifier->content = g_strdup(idp_identifier->content);
new_idp_identifier->NameQualifier = g_strdup(idp_identifier->NameQualifier);
new_idp_identifier->Format = g_strdup(idp_identifier->Format);
subject->IDPProvidedNameIdentifier = new_idp_identifier;
}
/* SubjectConfirmation & Subject */
subject_confirmation = lasso_saml_subject_confirmation_new();
subject_confirmation->ConfirmationMethod = LASSO_SAML_CONFIRMATION_METHOD_BEARER;
LASSO_SAML_SUBJECT(subject)->SubjectConfirmation = subject_confirmation;
LASSO_SAML_SUBJECT_STATEMENT_ABSTRACT(statement)->Subject = LASSO_SAML_SUBJECT(subject);
return LASSO_LIB_AUTHENTICATION_STATEMENT(statement);
}

View File

@ -46,28 +46,28 @@ typedef struct _LassoLibAuthenticationStatement LassoLibAuthenticationStatement;
typedef struct _LassoLibAuthenticationStatementClass LassoLibAuthenticationStatementClass;
struct _LassoLibAuthenticationStatement {
LassoSamlAuthenticationStatement parent;
/*< private >*/
gboolean use_xsitype;
LassoSamlAuthenticationStatement parent;
/* <xs:element ref="AuthnContext" minOccurs="0"/> */
LassoLibAuthnContext *AuthnContext;
/* <xs:attribute name="ReauthenticateOnOrAfter" type="xs:dateTime" use="optional"/> */
char *ReauthenticateOnOrAfter;
/* <xs:attribute name="SessionIndex" type="xs:string" use="required"/> */
char *SessionIndex;
};
struct _LassoLibAuthenticationStatementClass {
LassoSamlAuthenticationStatementClass parent;
/*< vtable >*/
LassoSamlAuthenticationStatementClass parent;
};
LASSO_EXPORT GType lasso_lib_authentication_statement_get_type (void);
LASSO_EXPORT LassoNode* lasso_lib_authentication_statement_new (gboolean use_xsitype);
LASSO_EXPORT void lasso_lib_authentication_statement_set_authnContext (LassoLibAuthenticationStatement *node,
LassoLibAuthnContext *authnContext);
LASSO_EXPORT void lasso_lib_authentication_statement_set_reauthenticateOnOrAfter (LassoLibAuthenticationStatement *node,
const xmlChar *reauthenticateOnOrAfter);
LASSO_EXPORT void lasso_lib_authentication_statement_set_sessionIndex (LassoLibAuthenticationStatement *node,
const xmlChar *sessionIndex);
LASSO_EXPORT LassoLibAuthenticationStatement* lasso_lib_authentication_statement_new(void);
LASSO_EXPORT LassoLibAuthenticationStatement* lasso_lib_authentication_statement_new_full(
const char *authenticationMethod,
const char *authenticationInstant,
const char *reauthenticateOnOrAfter,
LassoSamlNameIdentifier *sp_identifier,
LassoSamlNameIdentifier *idp_identifier);
#ifdef __cplusplus
}

View File

@ -53,33 +53,49 @@ From schema liberty-authentication-context-v1.2.xsd:
*/
/*****************************************************************************/
/* public methods */
/* private methods */
/*****************************************************************************/
void
lasso_lib_authn_context_set_authnContextClassRef(LassoLibAuthnContext *node,
const xmlChar *authnContextClassRef)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_AUTHN_CONTEXT(node));
g_assert(authnContextClassRef != NULL);
static LassoNodeClass *parent_class = NULL;
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "AuthnContextClassRef",
authnContextClassRef, FALSE);
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
xmlnode = parent_class->get_xmlNode(node);
if (LASSO_LIB_AUTHN_CONTEXT(node)->AuthnContextClassRef)
xmlNewTextChild(xmlnode, NULL, "AuthnContextClassRef",
LASSO_LIB_AUTHN_CONTEXT(node)->AuthnContextClassRef);
if (LASSO_LIB_AUTHN_CONTEXT(node)->AuthnContextStatementRef)
xmlNewTextChild(xmlnode, NULL, "AuthnContextStatementRef",
LASSO_LIB_AUTHN_CONTEXT(node)->AuthnContextStatementRef);
xmlNodeSetName(xmlnode, "AuthnContext");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
return xmlnode;
}
void
lasso_lib_authn_context_set_authnContextStatementRef(LassoLibAuthnContext *node,
const xmlChar *authnContextStatementRef)
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_AUTHN_CONTEXT(node));
g_assert(authnContextStatementRef != NULL);
LassoLibAuthnContext *context = LASSO_LIB_AUTHN_CONTEXT(node);
xmlNode *t;
parent_class->init_from_xml(node, xmlnode);
t = xmlnode->children;
while (t) {
if (t->type == XML_ELEMENT_NODE) {
if (strcmp(t->name, "AuthnContextClassRef") == 0)
context->AuthnContextClassRef = xmlNodeGetContent(t);
if (strcmp(t->name, "AuthnContextStatementRef") == 0 )
context->AuthnContextStatementRef = xmlNodeGetContent(t);
}
t = t->next;
}
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "AuthnContextStatementRef",
authnContextStatementRef, FALSE);
}
/*****************************************************************************/
@ -87,43 +103,46 @@ lasso_lib_authn_context_set_authnContextStatementRef(LassoLibAuthnContext *node,
/*****************************************************************************/
static void
lasso_lib_authn_context_instance_init(LassoLibAuthnContext *node)
instance_init(LassoLibAuthnContext *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
class->set_ns(LASSO_NODE(node), lassoLibHRef, lassoLibPrefix);
class->set_name(LASSO_NODE(node), "AuthnContext");
node->AuthnContextClassRef = NULL;
node->AuthnContextStatementRef = NULL;
}
static void
lasso_lib_authn_context_class_init(LassoLibAuthnContextClass *klass)
class_init(LassoLibAuthnContextClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
}
GType lasso_lib_authn_context_get_type() {
static GType this_type = 0;
GType
lasso_lib_authn_context_get_type()
{
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibAuthnContextClass),
NULL,
NULL,
(GClassInitFunc) lasso_lib_authn_context_class_init,
NULL,
NULL,
sizeof(LassoLibAuthnContext),
0,
(GInstanceInitFunc) lasso_lib_authn_context_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoLibAuthnContext",
&this_info, 0);
}
return this_type;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibAuthnContextClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoLibAuthnContext),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoLibAuthnContext", &this_info, 0);
}
return this_type;
}
LassoNode* lasso_lib_authn_context_new() {
return LASSO_NODE(g_object_new(LASSO_TYPE_LIB_AUTHN_CONTEXT,
NULL));
LassoNode*
lasso_lib_authn_context_new() {
return g_object_new(LASSO_TYPE_LIB_AUTHN_CONTEXT, NULL);
}

View File

@ -43,23 +43,20 @@ typedef struct _LassoLibAuthnContext LassoLibAuthnContext;
typedef struct _LassoLibAuthnContextClass LassoLibAuthnContextClass;
struct _LassoLibAuthnContext {
LassoNode parent;
/*< private >*/
LassoNode parent;
/* <xs:element name="AuthnContextClassRef" type="xs:anyURI" minOccurs="0"/> */
char *AuthnContextClassRef;
/* <xs:element name="AuthnContextStatementRef" type="xs:anyURI"/> */
char *AuthnContextStatementRef;
};
struct _LassoLibAuthnContextClass {
LassoNodeClass parent;
LassoNodeClass parent;
};
LASSO_EXPORT GType lasso_lib_authn_context_get_type(void);
LASSO_EXPORT LassoNode* lasso_lib_authn_context_new(void);
LASSO_EXPORT void lasso_lib_authn_context_set_authnContextClassRef (LassoLibAuthnContext *node,
const xmlChar *authnContextClassRef);
LASSO_EXPORT void lasso_lib_authn_context_set_authnContextStatementRef (LassoLibAuthnContext *node,
const xmlChar *authnContextStatementRef);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -24,6 +24,7 @@
*/
#include <lasso/xml/lib_authn_request.h>
#include <libxml/uri.h>
/*
The <AuthnRequest> is defined as an extension of samlp:RequestAbstractType.
@ -40,7 +41,7 @@ Schema fragment (liberty-idff-protocols-schema-v1.2.xsd):
<xs:sequence>
<xs:element ref="Extension" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="ProviderID"/>
<xs:element ref="AffiliationID" minOccurs="0"/>
<xs:element ref="AffiliationID" minOccurs="0"/>
<xs:element ref="NameIDPolicy" minOccurs="0"/>
<xs:element name="ForceAuthn" type="xs:boolean" minOccurs="0"/>
<xs:element name="IsPassive" type="xs:boolean "minOccurs="0"/>
@ -79,218 +80,255 @@ From liberty-metadata-v1.0.xsd:
<xs:element name="RelayState" type="xs:string"/>
*/
static LassoNodeClass *parent_class = NULL;
/*****************************************************************************/
/* public methods */
/* private methods */
/*****************************************************************************/
void
lasso_lib_authn_request_set_affiliationID(LassoLibAuthnRequest *node,
const xmlChar *affiliationID)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_AUTHN_REQUEST(node));
g_assert(affiliationID != NULL);
/* FIXME : affiliationID length SHOULD be <= 1024 */
static xmlNode*
get_xmlNode(LassoNode *node)
{
LassoLibAuthnRequest *request = LASSO_LIB_AUTHN_REQUEST(node);
xmlNode *xmlnode;
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "AffiliationID", affiliationID, FALSE);
xmlnode = parent_class->get_xmlNode(node);
xmlNodeSetName(xmlnode, "AuthnRequest");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
if (request->ProviderID)
xmlNewTextChild(xmlnode, NULL, "ProviderID", request->ProviderID);
if (request->AffiliationID)
xmlNewTextChild(xmlnode, NULL, "AffiliationID", request->AffiliationID);
if (request->NameIDPolicy)
xmlNewTextChild(xmlnode, NULL, "NameIDPolicy", request->NameIDPolicy);
if (request->ProtocolProfile)
xmlNewTextChild(xmlnode, NULL, "ProtocolProfile", request->ProtocolProfile);
if (request->AssertionConsumerServiceID)
xmlNewTextChild(xmlnode, NULL, "AssertionConsumerServiceID",
request->AssertionConsumerServiceID);
if (request->RelayState)
xmlNewTextChild(xmlnode, NULL, "RelayState", request->RelayState);
if (request->consent)
xmlSetProp(xmlnode, "consent", request->consent);
xmlNewTextChild(xmlnode, NULL, "IsPassive", request->IsPassive ? "true" : "false");
xmlNewTextChild(xmlnode, NULL, "ForceAuthn", request->ForceAuthn ? "true" : "false");
if (request->RequestAuthnContext)
xmlAddChild(xmlnode, lasso_node_get_xmlNode(
LASSO_NODE(request->RequestAuthnContext)));
if (request->Scoping)
xmlAddChild(xmlnode, lasso_node_get_xmlNode(
LASSO_NODE(request->Scoping)));
return xmlnode;
}
void
lasso_lib_authn_request_set_assertionConsumerServiceID(LassoLibAuthnRequest *node,
const xmlChar *assertionConsumerServiceID)
static gchar*
build_query(LassoNode *node)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_AUTHN_REQUEST(node));
g_assert(assertionConsumerServiceID != NULL);
char *str, *t;
GString *s;
LassoLibAuthnRequest *request = LASSO_LIB_AUTHN_REQUEST(node);
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "AssertionConsumerServiceID",
assertionConsumerServiceID, FALSE);
str = parent_class->build_query(node);
s = g_string_new(str);
g_free(str);
if (request->ProviderID) {
t = xmlURIEscapeStr(request->ProviderID, NULL);
g_string_append_printf(s, "&ProviderID=%s", t);
xmlFree(t);
}
if (request->AffiliationID)
g_string_append_printf(s, "&AffiliationID=%s", request->AffiliationID);
if (request->NameIDPolicy)
g_string_append_printf(s, "&NameIDPolicy=%s", request->NameIDPolicy);
if (request->ProtocolProfile) {
t = xmlURIEscapeStr(request->ProtocolProfile, NULL);
g_string_append_printf(s, "&ProtocolProfile=%s", t);
xmlFree(t);
}
if (request->RelayState)
g_string_append_printf(s, "&RelayState=%s", request->RelayState);
if (request->consent)
g_string_append_printf(s, "&consent=%s", request->consent);
g_string_append_printf(s, "&ForceAuthn=%s", request->ForceAuthn ? "true" : "false");
g_string_append_printf(s, "&IsPassive=%s", request->IsPassive ? "true" : "false");
str = s->str;
g_string_free(s, FALSE);
return str;
}
void
lasso_lib_authn_request_set_consent(LassoLibAuthnRequest *node,
const xmlChar *consent)
static void
init_from_query(LassoNode *node, char **query_fields)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_AUTHN_REQUEST(node));
g_assert(consent != NULL);
class = LASSO_NODE_GET_CLASS(node);
class->set_prop(LASSO_NODE (node), "consent", consent);
LassoLibAuthnRequest *request = LASSO_LIB_AUTHN_REQUEST(node);
int i;
char *t;
for (i=0; (t=query_fields[i]); i++) {
if (strncmp(t, "ProviderID=", 11) == 0) {
request->ProviderID = g_strdup(t+11);
continue;
}
if (strncmp(t, "AffiliationID=", 14) == 0) {
request->AffiliationID = g_strdup(t+14);
continue;
}
if (strncmp(t, "NameIDPolicy=", 13) == 0) {
request->NameIDPolicy = g_strdup(t+13);
continue;
}
if (strncmp(t, "ProtocolProfile=", 16) == 0) {
request->ProtocolProfile = g_strdup(t+16);
continue;
}
if (strncmp(t, "RelayState=", 11) == 0) {
request->RelayState = g_strdup(t+11);
continue;
}
if (strncmp(t, "consent=", 8) == 0) {
request->consent =g_strdup(t+8);
continue;
}
if (strncmp(t, "ForceAuthn=", 11) == 0) {
request->ForceAuthn = (strcmp(t+11, "true") == 0);
continue;
}
if (strncmp(t, "IsPassive=", 10) == 0) {
request->IsPassive = (strcmp(t+10, "true") == 0);
continue;
}
}
parent_class->init_from_query(node, query_fields);
}
void
lasso_lib_authn_request_set_forceAuthn(LassoLibAuthnRequest *node,
gboolean forceAuthn)
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_AUTHN_REQUEST(node));
g_assert(forceAuthn == FALSE || forceAuthn == TRUE);
LassoLibAuthnRequest *request = LASSO_LIB_AUTHN_REQUEST(node);
xmlNode *t, *n;
char *s;
class = LASSO_NODE_GET_CLASS(node);
parent_class->init_from_xml(node, xmlnode);
if (forceAuthn == FALSE) {
class->new_child(LASSO_NODE (node), "ForceAuthn", "false", FALSE);
}
if (forceAuthn == TRUE) {
class->new_child(LASSO_NODE (node), "ForceAuthn", "true", FALSE);
}
t = xmlnode->children;
while (t) {
n = t;
t = t->next;
if (n->type != XML_ELEMENT_NODE) {
continue;
}
if (strcmp(n->name, "ProviderID") == 0) {
request->ProviderID = xmlNodeGetContent(n);
continue;
}
if (strcmp(n->name, "NameIDPolicy") == 0) {
request->NameIDPolicy = xmlNodeGetContent(n);
continue;
}
if (strcmp(n->name, "ForceAuthn") == 0) {
s = xmlNodeGetContent(n);
request->ForceAuthn = (strcmp(s, "true") == 0);
xmlFree(s);
continue;
}
if (strcmp(n->name, "IsPassive") == 0) {
s = xmlNodeGetContent(n);
request->IsPassive = (strcmp(s, "true") == 0);
xmlFree(s);
continue;
}
if (strcmp(n->name, "ProtocolProfile") == 0) {
request->ProtocolProfile = xmlNodeGetContent(n);
continue;
}
if (strcmp(n->name, "AssertionConsumerServiceID") == 0) {
request->AssertionConsumerServiceID = xmlNodeGetContent(n);
continue;
}
if (strcmp(n->name, "RequestAuthnContext") == 0) {
/* XXX */
continue;
}
if (strcmp(n->name, "RelayState") == 0) {
request->RelayState = xmlNodeGetContent(n);
continue;
}
if (strcmp(n->name, "Scoping") == 0) {
/* XXX */
continue;
}
}
request->consent = xmlGetProp(xmlnode, "consent");
}
void
lasso_lib_authn_request_set_isPassive(LassoLibAuthnRequest *node,
gboolean isPassive)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_AUTHN_REQUEST(node));
g_assert(isPassive == FALSE || isPassive == TRUE);
class = LASSO_NODE_GET_CLASS(node);
if (isPassive == FALSE) {
class->new_child(LASSO_NODE (node), "IsPassive", "false", FALSE);
}
if (isPassive == TRUE) {
class->new_child(LASSO_NODE (node), "IsPassive", "true", FALSE);
}
}
/**
* lasso_lib_authn_request_set_nameIDPolicy:
* @node: the pointer to <lib:AuthnRequest> node
* @nameIDPolicy: the value of "NameIDPolicy" attribute.
*
* Sets the "NameIDPolicy" attribute. It's an enumeration permitting requester
* influence over name identifier policy at the identity provider.
**/
void
lasso_lib_authn_request_set_nameIDPolicy(LassoLibAuthnRequest *node,
const xmlChar *nameIDPolicy)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_AUTHN_REQUEST(node));
g_assert(nameIDPolicy != NULL);
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "NameIDPolicy", nameIDPolicy, FALSE);
}
void
lasso_lib_authn_request_set_protocolProfile(LassoLibAuthnRequest *node,
const xmlChar *protocolProfile)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_AUTHN_REQUEST(node));
g_assert(protocolProfile != NULL);
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "ProtocolProfile", protocolProfile, FALSE);
}
void
lasso_lib_authn_request_set_providerID(LassoLibAuthnRequest *node,
const xmlChar *providerID)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_AUTHN_REQUEST(node));
g_assert(providerID != NULL);
/* FIXME : providerID length SHOULD be <= 1024 */
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "ProviderID", providerID, FALSE);
}
void
lasso_lib_authn_request_set_relayState(LassoLibAuthnRequest *node,
const xmlChar *relayState)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_AUTHN_REQUEST(node));
g_assert(relayState != NULL);
/* FIXME : RelayState length SHOULD be <= 80 */
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "RelayState", relayState, FALSE);
}
void
lasso_lib_authn_request_set_requestAuthnContext(LassoLibAuthnRequest *node,
LassoLibRequestAuthnContext *requestAuthnContext)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_AUTHN_REQUEST(node));
g_assert(LASSO_IS_LIB_REQUEST_AUTHN_CONTEXT(requestAuthnContext));
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE (node),
LASSO_NODE (requestAuthnContext),
FALSE);
}
/**
* lasso_lib_authn_request_set_scoping:
* @node: the pointer to <lib:AuthnRequest/> node object
* @scoping: the pointer to <lib:Scoping/> node object
*
* Sets the "Scoping" element.
**/
void
lasso_lib_authn_request_set_scoping(LassoLibAuthnRequest *node,
LassoLibScoping *scoping)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_AUTHN_REQUEST(node));
g_assert(LASSO_IS_LIB_SCOPING(scoping));
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE (node),
LASSO_NODE (scoping),
FALSE);
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
lasso_lib_authn_request_instance_init(LassoLibAuthnRequest *node)
instance_init(LassoLibAuthnRequest *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
class->set_ns(LASSO_NODE(node), lassoLibHRef, lassoLibPrefix);
class->set_name(LASSO_NODE(node), "AuthnRequest");
node->ProviderID = NULL;
node->AffiliationID = NULL;
node->NameIDPolicy = NULL;
node->ForceAuthn = FALSE;
node->IsPassive = TRUE;
node->ProtocolProfile = NULL;
node->AssertionConsumerServiceID = NULL;
node->RequestAuthnContext = NULL;
node->RelayState = NULL;
node->Scoping = NULL;
node->consent = NULL;
}
static void
lasso_lib_authn_request_class_init(LassoLibAuthnRequestClass *klass)
class_init(LassoLibAuthnRequestClass *klass)
{
LassoNodeClass *nodeClass = LASSO_NODE_CLASS(klass);
parent_class = g_type_class_peek_parent(klass);
nodeClass->build_query = build_query;
nodeClass->get_xmlNode = get_xmlNode;
nodeClass->init_from_query = init_from_query;
nodeClass->init_from_xml = init_from_xml;
}
GType lasso_lib_authn_request_get_type() {
static GType this_type = 0;
GType
lasso_lib_authn_request_get_type()
{
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibAuthnRequestClass),
NULL,
NULL,
(GClassInitFunc) lasso_lib_authn_request_class_init,
NULL,
NULL,
sizeof(LassoLibAuthnRequest),
0,
(GInstanceInitFunc) lasso_lib_authn_request_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_SAMLP_REQUEST_ABSTRACT,
"LassoLibAuthnRequest",
&this_info, 0);
}
return this_type;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibAuthnRequestClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoLibAuthnRequest),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_SAMLP_REQUEST_ABSTRACT,
"LassoLibAuthnRequest", &this_info, 0);
}
return this_type;
}
LassoNode* lasso_lib_authn_request_new() {
return LASSO_NODE(g_object_new(LASSO_TYPE_LIB_AUTHN_REQUEST,
NULL));
LassoLibAuthnRequest*
lasso_lib_authn_request_new()
{
return g_object_new(LASSO_TYPE_LIB_AUTHN_REQUEST, NULL);
}

View File

@ -45,49 +45,38 @@ typedef struct _LassoLibAuthnRequest LassoLibAuthnRequest;
typedef struct _LassoLibAuthnRequestClass LassoLibAuthnRequestClass;
struct _LassoLibAuthnRequest {
LassoSamlpRequestAbstract parent;
/*< private >*/
LassoSamlpRequestAbstract parent;
/* <xs:element ref="ProviderID"/> */
char *ProviderID;
/* <xs:element ref="AffiliationID" minOccurs="0"/> */
char *AffiliationID;
/* <xs:element ref="NameIDPolicy" minOccurs="0"/> */
char *NameIDPolicy; /* XXX: move to enum ?*/
/* <xs:element name="ForceAuthn" type="xs:boolean" minOccurs="0"/> */
gboolean ForceAuthn;
/* <xs:element name="IsPassive" type="xs:boolean "minOccurs="0"/> */
gboolean IsPassive;
/* <xs:element ref="ProtocolProfile" minOccurs="0"/> */
char *ProtocolProfile; /* XXX: move to enum */
/* <xs:element name="AssertionConsumerServiceID" type="xs:string" minOccurs="0"/> */
char *AssertionConsumerServiceID; /* XXX: move to enum? */
/* <xs:element ref="RequestAuthnContext" minOccurs="0"/> */
LassoLibRequestAuthnContext *RequestAuthnContext;
/* <xs:element ref="RelayState" minOccurs="0"/> */
char *RelayState;
/* <xs:element ref="Scoping" minOccurs="0 "/> */
LassoLibScoping *Scoping;
/* <xs:attribute ref="consent" use="optional"/> */
char *consent;
};
struct _LassoLibAuthnRequestClass {
LassoSamlpRequestAbstractClass parent;
LassoSamlpRequestAbstractClass parent;
};
LASSO_EXPORT GType lasso_lib_authn_request_get_type(void);
LASSO_EXPORT LassoNode* lasso_lib_authn_request_new(void);
LASSO_EXPORT void lasso_lib_authn_request_set_affiliationID (LassoLibAuthnRequest *,
const xmlChar *);
LASSO_EXPORT void lasso_lib_authn_request_set_assertionConsumerServiceID (LassoLibAuthnRequest *,
const xmlChar *);
LASSO_EXPORT void lasso_lib_authn_request_set_consent (LassoLibAuthnRequest *,
const xmlChar *);
LASSO_EXPORT void lasso_lib_authn_request_set_forceAuthn (LassoLibAuthnRequest *,
gboolean);
LASSO_EXPORT void lasso_lib_authn_request_set_isPassive (LassoLibAuthnRequest *,
gboolean);
LASSO_EXPORT void lasso_lib_authn_request_set_nameIDPolicy (LassoLibAuthnRequest *node,
const xmlChar *nameIDPolicy);
LASSO_EXPORT void lasso_lib_authn_request_set_protocolProfile (LassoLibAuthnRequest *,
const xmlChar *);
LASSO_EXPORT void lasso_lib_authn_request_set_providerID (LassoLibAuthnRequest *,
const xmlChar *);
LASSO_EXPORT void lasso_lib_authn_request_set_relayState (LassoLibAuthnRequest *,
const xmlChar *);
LASSO_EXPORT void lasso_lib_authn_request_set_requestAuthnContext (LassoLibAuthnRequest *,
LassoLibRequestAuthnContext *);
LASSO_EXPORT void lasso_lib_authn_request_set_scoping (LassoLibAuthnRequest *node,
LassoLibScoping *scoping);
LASSO_EXPORT LassoLibAuthnRequest* lasso_lib_authn_request_new(void);
#ifdef __cplusplus
}

View File

@ -59,138 +59,133 @@
/*****************************************************************************/
/* public methods */
/* private methods */
/*****************************************************************************/
void
lasso_lib_authn_request_envelope_set_extension(LassoLibAuthnRequestEnvelope *node,
LassoNode *extension)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_AUTHN_REQUEST_ENVELOPE(node));
g_assert(LASSO_IS_NODE(extension));
static LassoNodeClass *parent_class = NULL;
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE(node), extension, FALSE);
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
LassoLibAuthnRequestEnvelope *env = LASSO_LIB_AUTHN_REQUEST_ENVELOPE(node);
xmlnode = xmlNewNode(NULL, "AuthnRequestEnvelope");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
if (env->Extension)
xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(env->Extension)));
if (env->ProviderID)
xmlNewTextChild(xmlnode, NULL, "ProviderID", env->ProviderID);
if (env->ProviderName)
xmlNewTextChild(xmlnode, NULL, "ProviderName", env->ProviderName);
if (env->AssertionConsumerServiceURL)
xmlNewTextChild(xmlnode, NULL, "AssertionConsumerServiceURL",
env->AssertionConsumerServiceURL);
if (env->IDPList)
xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(env->IDPList)));
xmlNewTextChild(xmlnode, NULL, "IsPassive", env->IsPassive ? "true" : "false");
return xmlnode;
}
void lasso_lib_authn_request_envelope_set_authnRequest(LassoLibAuthnRequestEnvelope *node,
LassoLibAuthnRequest *request)
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_AUTHN_REQUEST_ENVELOPE(node));
g_assert(LASSO_IS_LIB_AUTHN_REQUEST(request));
LassoLibAuthnRequestEnvelope *env = LASSO_LIB_AUTHN_REQUEST_ENVELOPE(node);
xmlNode *t, *n;
char *s;
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE(node), LASSO_NODE(request), FALSE);
parent_class->init_from_xml(node, xmlnode);
t = xmlnode->children;
while (t) {
n = t;
t = t->next;
if (n->type != XML_ELEMENT_NODE) {
continue;
}
if (strcmp(n->name, "Extension") == 0) {
/* XXX */
continue;
}
if (strcmp(n->name, "ProviderID") == 0) {
env->ProviderID = xmlNodeGetContent(n);
continue;
}
if (strcmp(n->name, "ProviderName") == 0) {
env->ProviderName = xmlNodeGetContent(n);
continue;
}
if (strcmp(n->name, "AssertionConsumerServiceURL") == 0) {
env->AssertionConsumerServiceURL = xmlNodeGetContent(n);
continue;
}
if (strcmp(n->name, "IDPList") == 0) {
env->IDPList = LASSO_LIB_IDP_LIST(lasso_node_new_from_xmlNode(n));
continue;
}
}
s = xmlGetProp(xmlnode, "IsPassive");
if (s) {
env->IsPassive = (strcmp(s, "true") == 0);
xmlFree(s);
}
}
void
lasso_lib_authn_request_envelope_set_assertionConsumerServiceURL(LassoLibAuthnRequestEnvelope *node,
const xmlChar *assertionConsumerServiceURL)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_AUTHN_REQUEST_ENVELOPE(node));
g_assert(assertionConsumerServiceURL != NULL);
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE(node), "AssertionConsumerServiceURL", assertionConsumerServiceURL, FALSE);
}
void
lasso_lib_authn_request_envelope_set_providerID(LassoLibAuthnRequestEnvelope *node,
const xmlChar *providerID)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_AUTHN_REQUEST_ENVELOPE(node));
g_assert(providerID != NULL);
/* FIXME : providerID length SHOULD be <= 1024 */
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE(node), "ProviderID", providerID, FALSE);
}
void lasso_lib_authn_request_envelope_set_providerName(LassoLibAuthnRequestEnvelope *node,
const xmlChar *providerName)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_AUTHN_REQUEST_ENVELOPE(node));
g_assert(providerName != NULL);
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE(node), "ProviderName", providerName, FALSE);
}
void lasso_lib_authn_request_envelope_set_idpList(LassoLibAuthnRequestEnvelope *node,
LassoLibIDPList *idpList)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_AUTHN_REQUEST_ENVELOPE(node));
g_assert(LASSO_IS_LIB_IDP_LIST(idpList));
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE(node), LASSO_NODE(idpList), FALSE);
}
void
lasso_lib_authn_request_envelope_set_isPassive(LassoLibAuthnRequestEnvelope *node,
gboolean isPassive)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_AUTHN_REQUEST_ENVELOPE(node));
g_assert(isPassive == FALSE || isPassive == TRUE);
class = LASSO_NODE_GET_CLASS(node);
if (isPassive == FALSE) {
class->new_child(LASSO_NODE (node), "IsPassive", "false", FALSE);
}
if (isPassive == TRUE) {
class->new_child(LASSO_NODE (node), "IsPassive", "true", FALSE);
}
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
lasso_lib_authn_request_envelope_instance_init(LassoLibAuthnRequestEnvelope *node)
instance_init(LassoLibAuthnRequestEnvelope *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
class->set_ns(LASSO_NODE(node), lassoLibHRef, lassoLibPrefix);
class->set_name(LASSO_NODE(node), "AuthnRequestEnvelope");
node->Extension = NULL;
node->AuthnRequest = NULL;
node->ProviderID = NULL;
node->ProviderName = NULL;
node->AssertionConsumerServiceURL = NULL;
node->IDPList = NULL;
node->IsPassive = FALSE;
}
static void
lasso_lib_authn_request_envelope_class_init(LassoLibAuthnRequestEnvelopeClass *class)
class_init(LassoLibAuthnRequestEnvelopeClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
}
GType lasso_lib_authn_request_envelope_get_type() {
static GType this_type = 0;
GType
lasso_lib_authn_request_envelope_get_type()
{
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibAuthnRequestEnvelopeClass),
NULL,
NULL,
(GClassInitFunc) lasso_lib_authn_request_envelope_class_init,
NULL,
NULL,
sizeof(LassoLibAuthnRequestEnvelope),
0,
(GInstanceInitFunc) lasso_lib_authn_request_envelope_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoLibAuthnRequestEnvelope",
&this_info, 0);
}
return this_type;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibAuthnRequestEnvelopeClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoLibAuthnRequestEnvelope),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoLibAuthnRequestEnvelope", &this_info, 0);
}
return this_type;
}
LassoNode* lasso_lib_authn_request_envelope_new() {
return LASSO_NODE(g_object_new(LASSO_TYPE_LIB_AUTHN_REQUEST_ENVELOPE,
NULL));
LassoNode*
lasso_lib_authn_request_envelope_new()
{
return LASSO_NODE(g_object_new(LASSO_TYPE_LIB_AUTHN_REQUEST_ENVELOPE, NULL));
}

View File

@ -45,40 +45,32 @@ typedef struct _LassoLibAuthnRequestEnvelope LassoLibAuthnRequestEnvelope;
typedef struct _LassoLibAuthnRequestEnvelopeClass LassoLibAuthnRequestEnvelopeClass;
struct _LassoLibAuthnRequestEnvelope {
LassoNode parent;
LassoNode parent;
/* <xs:element ref="Extension" minOccurs="0" maxOccurs="unbounded"/> */
LassoNode *Extension; /* XXX */
/* <xs:element ref="AuthnRequest"/> */
LassoLibAuthnRequest *AuthnRequest;
/* <xs:element ref="ProviderID"/> */
char *ProviderID;
/* <xs:element name="ProviderName" type="xs:string" minOccurs="0"/> */
char *ProviderName;
/* <xs:element name="AssertionConsumerServiceURL" type="xs:anyURI"/> */
char *AssertionConsumerServiceURL;
/* <xs:element ref="IDPList" minOccurs="0"/> */
LassoLibIDPList *IDPList;
/* <xs:element name="IsPassive" type="xs:boolean" minOccurs="0"/> */
gboolean IsPassive;
/*< private >*/
};
struct _LassoLibAuthnRequestEnvelopeClass {
LassoNodeClass parent;
LassoNodeClass parent;
};
LASSO_EXPORT GType lasso_lib_authn_request_envelope_get_type (void);
LASSO_EXPORT LassoNode* lasso_lib_authn_request_envelope_new (void);
LASSO_EXPORT void lasso_lib_authn_request_envelope_set_extension (LassoLibAuthnRequestEnvelope *node,
LassoNode *extension);
LASSO_EXPORT void lasso_lib_authn_request_envelope_set_authnRequest (LassoLibAuthnRequestEnvelope *node,
LassoLibAuthnRequest *request);
LASSO_EXPORT void lasso_lib_authn_request_envelope_set_assertionConsumerServiceURL (LassoLibAuthnRequestEnvelope *node,
const xmlChar *assertionConsumerServiceURL);
LASSO_EXPORT void lasso_lib_authn_request_envelope_set_providerID (LassoLibAuthnRequestEnvelope *node,
const xmlChar *providerID);
LASSO_EXPORT void lasso_lib_authn_request_envelope_set_providerName (LassoLibAuthnRequestEnvelope *node,
const xmlChar *providerName);
LASSO_EXPORT void lasso_lib_authn_request_envelope_set_idpList (LassoLibAuthnRequestEnvelope *node,
LassoLibIDPList *idpList);
LASSO_EXPORT void lasso_lib_authn_request_envelope_set_isPassive (LassoLibAuthnRequestEnvelope *node,
gboolean isPassive);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -54,88 +54,119 @@ From liberty-metadata-v1.0.xsd:
*/
/*****************************************************************************/
/* public methods */
/* private methods */
/*****************************************************************************/
void
lasso_lib_authn_response_set_consent(LassoLibAuthnResponse *node,
const xmlChar *consent)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_AUTHN_RESPONSE(node));
g_assert(consent != NULL);
static LassoNodeClass *parent_class = NULL;
class = LASSO_NODE_GET_CLASS(node);
class->set_prop(LASSO_NODE (node), "consent", consent);
static xmlNode*
get_xmlNode(LassoNode *node)
{
LassoLibAuthnResponse *response = LASSO_LIB_AUTHN_RESPONSE(node);
xmlNode *xmlnode;
xmlnode = parent_class->get_xmlNode(node);
xmlNodeSetName(xmlnode, "AuthnResponse");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
if (response->ProviderID)
xmlNewTextChild(xmlnode, NULL, "ProviderID", response->ProviderID);
if (response->RelayState)
xmlNewTextChild(xmlnode, NULL, "RelayState", response->RelayState);
if (response->consent)
xmlSetProp(xmlnode, "consent", response->consent);
return xmlnode;
}
void
lasso_lib_authn_response_set_providerID(LassoLibAuthnResponse *node,
const xmlChar *providerID)
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_AUTHN_RESPONSE(node));
g_assert(providerID != NULL);
/* FIXME : providerID length SHOULD be <= 1024 */
LassoLibAuthnResponse *response = LASSO_LIB_AUTHN_RESPONSE(node);
xmlNode *t;
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "ProviderID", providerID, FALSE);
parent_class->init_from_xml(node, xmlnode);
t = xmlnode->children;
while (t) {
if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "ProviderID") == 0) {
response->ProviderID = xmlNodeGetContent(t);
}
if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "RelayState") == 0 ) {
response->RelayState = xmlNodeGetContent(t);
}
t = t->next;
}
response->consent = xmlGetProp(xmlnode, "consent");
}
void
lasso_lib_authn_response_set_relayState(LassoLibAuthnResponse *node,
const xmlChar *relayState)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_AUTHN_RESPONSE(node));
g_assert(relayState != NULL);
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "RelayState", relayState, FALSE);
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
lasso_lib_authn_response_instance_init(LassoLibAuthnResponse *node)
instance_init(LassoLibAuthnResponse *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
class->set_ns(LASSO_NODE(node), lassoLibHRef, lassoLibPrefix);
class->set_name(LASSO_NODE(node), "AuthnResponse");
node->Extension = NULL;
node->ProviderID = NULL;
node->RelayState = NULL;
node->consent = NULL;
}
static void
lasso_lib_authn_response_class_init(LassoLibAuthnResponseClass *klass)
class_init(LassoLibAuthnResponseClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
}
GType lasso_lib_authn_response_get_type() {
static GType authn_response_type = 0;
if (!authn_response_type) {
static const GTypeInfo authn_response_info = {
sizeof (LassoLibAuthnResponseClass),
NULL,
NULL,
(GClassInitFunc) lasso_lib_authn_response_class_init,
NULL,
NULL,
sizeof(LassoLibAuthnResponse),
0,
(GInstanceInitFunc) lasso_lib_authn_response_instance_init,
};
authn_response_type = g_type_register_static(LASSO_TYPE_SAMLP_RESPONSE,
"LassoLibAuthnResponse",
&authn_response_info, 0);
}
return authn_response_type;
}
LassoNode* lasso_lib_authn_response_new()
GType
lasso_lib_authn_response_get_type()
{
return LASSO_NODE(g_object_new(LASSO_TYPE_LIB_AUTHN_RESPONSE, NULL));
static GType authn_response_type = 0;
if (!authn_response_type) {
static const GTypeInfo authn_response_info = {
sizeof (LassoLibAuthnResponseClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoLibAuthnResponse),
0,
(GInstanceInitFunc) instance_init,
};
authn_response_type = g_type_register_static(LASSO_TYPE_SAMLP_RESPONSE,
"LassoLibAuthnResponse", &authn_response_info, 0);
}
return authn_response_type;
}
LassoNode*
lasso_lib_authn_response_new(char *providerID, LassoLibAuthnRequest *request)
{
LassoSamlpResponseAbstract *response;
response = g_object_new(LASSO_TYPE_LIB_AUTHN_RESPONSE, NULL);
if (providerID) {
response->ResponseID = lasso_build_unique_id(32);
response->MajorVersion = LASSO_LIB_MAJOR_VERSION_N;
response->MinorVersion = LASSO_LIB_MINOR_VERSION_N;
response->IssueInstant = lasso_get_current_time();
LASSO_LIB_AUTHN_RESPONSE(response)->ProviderID = g_strdup(providerID);
LASSO_LIB_AUTHN_RESPONSE(response)->RelayState = g_strdup(
request->RelayState);
}
return LASSO_NODE(response);
}

View File

@ -31,6 +31,7 @@ extern "C" {
#endif /* __cplusplus */
#include <lasso/xml/samlp_response.h>
#include <lasso/xml/lib_authn_request.h>
#include <lasso/xml/lib_assertion.h>
#define LASSO_TYPE_LIB_AUTHN_RESPONSE (lasso_lib_authn_response_get_type())
@ -44,25 +45,25 @@ typedef struct _LassoLibAuthnResponse LassoLibAuthnResponse;
typedef struct _LassoLibAuthnResponseClass LassoLibAuthnResponseClass;
struct _LassoLibAuthnResponse {
LassoSamlpResponse parent;
/*< private >*/
LassoSamlpResponse parent;
/* <xs:element ref="Extension" minOccurs="0" maxOccurs="unbounded"/> */
LassoNode *Extension;
/* <xs:element ref="ProviderID"/> */
char *ProviderID;
/* <xs:element ref="RelayState" minOccurs="0"/> */
char *RelayState;
/* <xs:attribute ref="consent" use="optional"/> */
char *consent;
};
struct _LassoLibAuthnResponseClass {
LassoSamlpResponseClass parent;
LassoSamlpResponseClass parent;
};
LASSO_EXPORT GType lasso_lib_authn_response_get_type(void);
LASSO_EXPORT LassoNode* lasso_lib_authn_response_new(void);
LASSO_EXPORT void lasso_lib_authn_response_set_consent (LassoLibAuthnResponse *,
const xmlChar *);
LASSO_EXPORT void lasso_lib_authn_response_set_providerID (LassoLibAuthnResponse *,
const xmlChar *);
LASSO_EXPORT void lasso_lib_authn_response_set_relayState (LassoLibAuthnResponse *,
const xmlChar *);
LASSO_EXPORT LassoNode* lasso_lib_authn_response_new(
char *providerID, LassoLibAuthnRequest *request);
#ifdef __cplusplus
}

View File

@ -28,88 +28,120 @@
/*****************************************************************************/
/* public methods */
/* private methods */
/*****************************************************************************/
void
lasso_lib_authn_response_envelope_set_extension(LassoLibAuthnResponseEnvelope *node,
LassoNode *extension)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_AUTHN_RESPONSE_ENVELOPE(node));
g_assert(LASSO_NODE(extension));
static LassoNodeClass *parent_class = NULL;
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE(extension), extension, FALSE);
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
LassoLibAuthnResponseEnvelope *env = LASSO_LIB_AUTHN_RESPONSE_ENVELOPE(node);
xmlnode = xmlNewNode(NULL, "AuthnResponseEnvelope");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
if (env->Extension)
xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(env->Extension)));
if (env->AuthnResponse)
xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(env->AuthnResponse)));
if (env->AssertionConsumerServiceURL)
xmlNewTextChild(xmlnode, NULL, "AssertionConsumerServiceURL",
env->AssertionConsumerServiceURL);
return xmlnode;
}
void
lasso_lib_authn_response_envelope_set_authnResponse(LassoLibAuthnResponseEnvelope *node,
LassoLibAuthnResponse *authnResponse_node)
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_AUTHN_RESPONSE_ENVELOPE(node));
g_assert(LASSO_IS_LIB_AUTHN_RESPONSE(authnResponse_node));
LassoLibAuthnResponseEnvelope *env = LASSO_LIB_AUTHN_RESPONSE_ENVELOPE(node);
xmlNode *t, *n;
parent_class->init_from_xml(node, xmlnode);
t = xmlnode->children;
while (t) {
n = t;
t = t->next;
if (n->type != XML_ELEMENT_NODE) {
continue;
}
if (strcmp(n->name, "Extension") == 0) {
/* XXX */
continue;
}
if (strcmp(n->name, "AuthnResponse") == 0) {
env->AuthnResponse = LASSO_LIB_AUTHN_RESPONSE(
lasso_node_new_from_xmlNode(n));
continue;
}
if (strcmp(n->name, "AssertionConsumerServiceURL") == 0) {
env->AssertionConsumerServiceURL = xmlNodeGetContent(n);
continue;
}
}
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE(node), LASSO_NODE(authnResponse_node), FALSE);
}
void
lasso_lib_authn_response_envelope_set_assertionConsumerServiceURL(LassoLibAuthnResponseEnvelope *node,
const xmlChar *url)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_AUTHN_RESPONSE_ENVELOPE(node));
g_assert(url != NULL);
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "AssertionConsumerServiceURL",
url, FALSE);
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
lasso_lib_authn_response_envelope_instance_init(LassoLibAuthnResponseEnvelope *node)
instance_init(LassoLibAuthnResponseEnvelope *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
class->set_ns(LASSO_NODE(node), lassoLibHRef, lassoLibPrefix);
class->set_name(LASSO_NODE(node), "AuthnResponseEnvelope");
node->Extension = NULL;
node->AuthnResponse = NULL;
node->AssertionConsumerServiceURL = NULL;
}
static void
lasso_lib_authn_response_envelope_class_init(LassoLibAuthnResponseEnvelopeClass *class)
class_init(LassoLibAuthnResponseEnvelopeClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
}
GType
lasso_lib_authn_response_envelope_get_type()
{
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibAuthnResponseEnvelopeClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoLibAuthnResponseEnvelope),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoLibAuthnResponseEnvelope", &this_info, 0);
}
return this_type;
}
GType lasso_lib_authn_response_envelope_get_type() {
static GType this_type = 0;
LassoNode*
lasso_lib_authn_response_envelope_new(LassoLibAuthnResponse *response,
char *assertionConsumerServiceURL)
{
LassoLibAuthnResponseEnvelope *envelope;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibAuthnResponseEnvelopeClass),
NULL,
NULL,
(GClassInitFunc) lasso_lib_authn_response_envelope_class_init,
NULL,
NULL,
sizeof(LassoLibAuthnResponseEnvelope),
0,
(GInstanceInitFunc) lasso_lib_authn_response_envelope_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoLibAuthnResponseEnvelope",
&this_info, 0);
}
return this_type;
envelope = g_object_new(LASSO_TYPE_LIB_AUTHN_RESPONSE_ENVELOPE, NULL);
if (response) {
envelope->AuthnResponse = response;
envelope->AssertionConsumerServiceURL = g_strdup(assertionConsumerServiceURL);
}
return LASSO_NODE(envelope);
}
LassoNode* lasso_lib_authn_response_envelope_new() {
return LASSO_NODE(g_object_new(LASSO_TYPE_LIB_AUTHN_RESPONSE_ENVELOPE,
NULL));
}

View File

@ -43,27 +43,21 @@ typedef struct _LassoLibAuthnResponseEnvelope LassoLibAuthnResponseEnvelope;
typedef struct _LassoLibAuthnResponseEnvelopeClass LassoLibAuthnResponseEnvelopeClass;
struct _LassoLibAuthnResponseEnvelope {
LassoNode parent;
/*< private >*/
LassoNode parent;
LassoNode *Extension; /* XXX */
LassoLibAuthnResponse *AuthnResponse;
char *AssertionConsumerServiceURL;
};
struct _LassoLibAuthnResponseEnvelopeClass {
LassoNodeClass parent;
LassoNodeClass parent;
};
LASSO_EXPORT GType lasso_lib_authn_response_envelope_get_type (void);
LASSO_EXPORT LassoNode* lasso_lib_authn_response_envelope_new (void);
LASSO_EXPORT void lasso_lib_authn_response_envelope_set_extension (LassoLibAuthnResponseEnvelope *node,
LassoNode *extension);
LASSO_EXPORT void lasso_lib_authn_response_envelope_set_authnResponse (LassoLibAuthnResponseEnvelope *node,
LassoLibAuthnResponse *authnResponse);
LASSO_EXPORT void lasso_lib_authn_response_envelope_set_assertionConsumerServiceURL (LassoLibAuthnResponseEnvelope *node,
const xmlChar *url);
LASSO_EXPORT GType lasso_lib_authn_response_envelope_get_type (void);
LASSO_EXPORT LassoNode* lasso_lib_authn_response_envelope_new(
LassoLibAuthnResponse *response,
char *assertionConsumerServiceURL);
#ifdef __cplusplus
}

View File

@ -24,6 +24,7 @@
*/
#include <lasso/xml/lib_federation_termination_notification.h>
#include <libxml/uri.h>
/*
Schema fragment (liberty-idff-protocols-schema-v1.2.xsd):
@ -54,88 +55,212 @@ From liberty-metadata-v1.0.xsd:
*/
/*****************************************************************************/
/* public methods */
/* private methods */
/*****************************************************************************/
void
lasso_lib_federation_termination_notification_set_consent(LassoLibFederationTerminationNotification *node,
const xmlChar *consent)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_FEDERATION_TERMINATION_NOTIFICATION(node));
g_assert(consent != NULL);
static LassoNodeClass *parent_class = NULL;
class = LASSO_NODE_GET_CLASS(node);
class->set_prop(LASSO_NODE (node), "consent", consent);
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
LassoLibFederationTerminationNotification *ob;
ob = LASSO_LIB_FEDERATION_TERMINATION_NOTIFICATION(node);
xmlnode = parent_class->get_xmlNode(node);
xmlNodeSetName(xmlnode, "FederationTerminationNotification");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
if (ob->ProviderID)
xmlNewTextChild(xmlnode, NULL, "ProviderID", ob->ProviderID);
if (ob->NameIdentifier)
xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(ob->NameIdentifier)));
if (ob->consent)
xmlSetProp(xmlnode, "consent", ob->consent);
return xmlnode;
}
void
lasso_lib_federation_termination_notification_set_providerID(LassoLibFederationTerminationNotification *node,
const xmlChar *providerID)
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_FEDERATION_TERMINATION_NOTIFICATION(node));
g_assert(providerID != NULL);
/* FIXME : providerId length SHOULD be <= 1024 */
LassoLibFederationTerminationNotification *ob;
xmlNode *t, *n;
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "ProviderID", providerID, FALSE);
ob = LASSO_LIB_FEDERATION_TERMINATION_NOTIFICATION(node);
parent_class->init_from_xml(node, xmlnode);
t = xmlnode->children;
while (t) {
n = t;
t = t->next;
if (n->type != XML_ELEMENT_NODE)
continue;
if (strcmp(n->name, "ProviderID") == 0) {
ob->ProviderID = xmlNodeGetContent(n);
continue;
}
if (strcmp(n->name, "NameIdentifier") == 0) {
ob->NameIdentifier = LASSO_SAML_NAME_IDENTIFIER(
lasso_node_new_from_xmlNode(n));
continue;
}
}
ob->consent = xmlGetProp(xmlnode, "consent");
}
void
lasso_lib_federation_termination_notification_set_nameIdentifier(LassoLibFederationTerminationNotification *node,
LassoSamlNameIdentifier *nameIdentifier)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_FEDERATION_TERMINATION_NOTIFICATION(node));
g_assert(LASSO_IS_SAML_NAME_IDENTIFIER(nameIdentifier));
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE (node), LASSO_NODE (nameIdentifier), FALSE);
static gchar*
build_query(LassoNode *node)
{
char *str, *t;
GString *s;
LassoLibFederationTerminationNotification *request;
request = LASSO_LIB_FEDERATION_TERMINATION_NOTIFICATION(node);
str = parent_class->build_query(node);
s = g_string_new(str);
g_free(str);
if (request->ProviderID) {
t = xmlURIEscapeStr(request->ProviderID, NULL);
g_string_append_printf(s, "&ProviderID=%s", t);
xmlFree(t);
}
if (request->NameIdentifier) {
t = lasso_node_build_query(LASSO_NODE(request->NameIdentifier));
g_string_append_printf(s, "&%s", t);
g_free(t);
}
if (request->consent)
g_string_append_printf(s, "&consent=%s", request->consent);
str = s->str;
g_string_free(s, FALSE);
return str;
}
static void
init_from_query(LassoNode *node, char **query_fields)
{
LassoLibFederationTerminationNotification *request;
int i;
char *t;
request = LASSO_LIB_FEDERATION_TERMINATION_NOTIFICATION(node);
request->NameIdentifier = lasso_saml_name_identifier_new();
for (i=0; (t=query_fields[i]); i++) {
if (g_str_has_prefix(t, "ProviderID=")) {
request->ProviderID = g_strdup(t+11);
continue;
}
if (g_str_has_prefix(t, "consent=")) {
request->consent = g_strdup(t+8);
continue;
}
if (g_str_has_prefix(t, "NameIdentifier=")) {
request->NameIdentifier->content = g_strdup(t+15);
continue;
}
if (g_str_has_prefix(t, "NameFormat=")) {
request->NameIdentifier->Format = g_strdup(t+11);
continue;
}
if (g_str_has_prefix(t, "NameQualifier=")) {
request->NameIdentifier->NameQualifier = g_strdup(t+14);
continue;
}
}
parent_class->init_from_query(node, query_fields);
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
lasso_lib_federation_termination_notification_instance_init(LassoLibFederationTerminationNotification *node)
instance_init(LassoLibFederationTerminationNotification *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
class->set_ns(LASSO_NODE(node), lassoLibHRef, lassoLibPrefix);
class->set_name(LASSO_NODE(node), "FederationTerminationNotification");
node->ProviderID = NULL;
node->NameIdentifier = NULL;
node->consent = NULL;
}
static void
lasso_lib_federation_termination_notification_class_init(LassoLibFederationTerminationNotificationClass *klass)
class_init(LassoLibFederationTerminationNotificationClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
LASSO_NODE_CLASS(klass)->build_query = build_query;
LASSO_NODE_CLASS(klass)->init_from_query = init_from_query;
}
GType lasso_lib_federation_termination_notification_get_type() {
static GType this_type = 0;
GType
lasso_lib_federation_termination_notification_get_type()
{
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibFederationTerminationNotificationClass),
NULL,
NULL,
(GClassInitFunc) lasso_lib_federation_termination_notification_class_init,
NULL,
NULL,
sizeof(LassoLibFederationTerminationNotification),
0,
(GInstanceInitFunc) lasso_lib_federation_termination_notification_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_SAMLP_REQUEST_ABSTRACT,
"LassoLibFederationTerminationNotification",
&this_info, 0);
}
return this_type;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibFederationTerminationNotificationClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoLibFederationTerminationNotification),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_SAMLP_REQUEST_ABSTRACT,
"LassoLibFederationTerminationNotification", &this_info, 0);
}
return this_type;
}
LassoNode* lasso_lib_federation_termination_notification_new() {
return LASSO_NODE(g_object_new(LASSO_TYPE_LIB_FEDERATION_TERMINATION_NOTIFICATION,
NULL));
LassoNode*
lasso_lib_federation_termination_notification_new()
{
return g_object_new(LASSO_TYPE_LIB_FEDERATION_TERMINATION_NOTIFICATION, NULL);
}
LassoNode*
lasso_lib_federation_termination_notification_new_full(char *providerID,
LassoSamlNameIdentifier *nameIdentifier,
lassoSignatureType sign_type, lassoSignatureMethod sign_method)
{
LassoSamlpRequestAbstract *request;
request = g_object_new(LASSO_TYPE_LIB_FEDERATION_TERMINATION_NOTIFICATION, NULL);
request->RequestID = lasso_build_unique_id(32);
request->MajorVersion = LASSO_LIB_MAJOR_VERSION_N;
request->MinorVersion = LASSO_LIB_MINOR_VERSION_N;
request->IssueInstant = lasso_get_current_time();
/* set the signature template */
if (sign_type != LASSO_SIGNATURE_TYPE_NONE) {
#if 0 /* XXX: signatures are done differently */
lasso_samlp_request_abstract_set_signature_tmpl(request, sign_type, sign_method, NULL);
#endif
}
LASSO_LIB_FEDERATION_TERMINATION_NOTIFICATION(request)->ProviderID = g_strdup(providerID);
LASSO_LIB_FEDERATION_TERMINATION_NOTIFICATION(request)->NameIdentifier =
g_object_ref(nameIdentifier);
return LASSO_NODE(request);
}

View File

@ -44,25 +44,27 @@ typedef struct _LassoLibFederationTerminationNotification LassoLibFederationTerm
typedef struct _LassoLibFederationTerminationNotificationClass LassoLibFederationTerminationNotificationClass;
struct _LassoLibFederationTerminationNotification {
LassoSamlpRequestAbstract parent;
/*< private >*/
LassoSamlpRequestAbstract parent;
/* <xs:element ref="Extension" minOccurs="0" maxOccurs="unbounded"/> */
LassoNode *Extension;
/* <xs:element ref="ProviderID"/> */
char *ProviderID;
/* <xs:element ref="saml:NameIdentifier"/> */
LassoSamlNameIdentifier *NameIdentifier;
/* <xs:attribute ref="consent" use="optional"/> */
char *consent;
};
struct _LassoLibFederationTerminationNotificationClass {
LassoSamlpRequestAbstractClass parent;
LassoSamlpRequestAbstractClass parent;
};
LASSO_EXPORT GType lasso_lib_federation_termination_notification_get_type(void);
LASSO_EXPORT LassoNode* lasso_lib_federation_termination_notification_new(void);
LASSO_EXPORT void lasso_lib_federation_termination_notification_set_consent (LassoLibFederationTerminationNotification *,
const xmlChar *);
LASSO_EXPORT void lasso_lib_federation_termination_notification_set_providerID (LassoLibFederationTerminationNotification *,
const xmlChar *);
LASSO_EXPORT void lasso_lib_federation_termination_notification_set_nameIdentifier (LassoLibFederationTerminationNotification *,
LassoSamlNameIdentifier *);
LASSO_EXPORT LassoNode* lasso_lib_federation_termination_notification_new_full(
char *providerID, LassoSamlNameIdentifier *nameIdentifier,
lassoSignatureType sign_type, lassoSignatureMethod sign_method);
#ifdef __cplusplus
}

View File

@ -38,28 +38,41 @@ Schema fragment (liberty-idff-protocols-schema-v1.2.xsd):
*/
/*****************************************************************************/
/* public methods */
/* private methods */
/*****************************************************************************/
/**
* lasso_lib_idp_entries_add_idpEntry:
* @node: the pointer to <lib:IDPEntries/> node object
* @idpEntry: the pointer to <lib:IDPEntry/> node object
*
* Adds an "IDPEntry" element [required].
*
* It describes an identity provider that the service provider supports.
**/
void
lasso_lib_idp_entries_add_idpEntry(LassoLibIDPEntries *node,
LassoLibIDPEntry *idpEntry)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_IDP_ENTRIES(node));
g_assert(LASSO_IS_LIB_IDP_ENTRY(idpEntry));
static LassoNodeClass *parent_class = NULL;
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE (node), LASSO_NODE(idpEntry), TRUE);
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
LassoLibIDPEntries *entries = LASSO_LIB_IDP_ENTRIES(node);
xmlnode = xmlNewNode(NULL, "IDPEntries");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
if (entries->IDPEntry)
xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(entries->IDPEntry)));
return xmlnode;
}
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibIDPEntries *entries = LASSO_LIB_IDP_ENTRIES(node);
xmlNode *t;
parent_class->init_from_xml(node, xmlnode);
t = xmlnode->children;
while (t) {
if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "IDPEntry") == 0) {
/* XXX: should actually be "add to list" */
entries->IDPEntry = LASSO_LIB_IDP_ENTRY(lasso_node_new_from_xmlNode(t));
}
t = t->next;
}
}
/*****************************************************************************/
@ -67,40 +80,41 @@ lasso_lib_idp_entries_add_idpEntry(LassoLibIDPEntries *node,
/*****************************************************************************/
static void
lasso_lib_idp_entries_instance_init(LassoLibIDPEntries *node)
instance_init(LassoLibIDPEntries *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
class->set_ns(LASSO_NODE(node), lassoLibHRef, lassoLibPrefix);
class->set_name(LASSO_NODE(node), "IDPEntries");
node->IDPEntry = NULL;
}
static void
lasso_lib_idp_entries_class_init(LassoLibIDPEntriesClass *klass)
class_init(LassoLibIDPEntriesClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
}
GType lasso_lib_idp_entries_get_type() {
static GType this_type = 0;
GType
lasso_lib_idp_entries_get_type()
{
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibIDPEntriesClass),
NULL,
NULL,
(GClassInitFunc) lasso_lib_idp_entries_class_init,
NULL,
NULL,
sizeof(LassoLibIDPEntries),
0,
(GInstanceInitFunc) lasso_lib_idp_entries_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoLibIDPEntries",
&this_info, 0);
}
return this_type;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibIDPEntriesClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoLibIDPEntries),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoLibIDPEntries", &this_info, 0);
}
return this_type;
}
/**
@ -110,7 +124,9 @@ GType lasso_lib_idp_entries_get_type() {
*
* Return value: the new @LassoLibIDPEntries
**/
LassoNode* lasso_lib_idp_entries_new()
LassoNode*
lasso_lib_idp_entries_new()
{
return LASSO_NODE(g_object_new(LASSO_TYPE_LIB_IDP_ENTRIES, NULL));
return LASSO_NODE(g_object_new(LASSO_TYPE_LIB_IDP_ENTRIES, NULL));
}

View File

@ -44,20 +44,19 @@ typedef struct _LassoLibIDPEntries LassoLibIDPEntries;
typedef struct _LassoLibIDPEntriesClass LassoLibIDPEntriesClass;
struct _LassoLibIDPEntries{
LassoNode parent;
/*< private >*/
LassoNode parent;
/* <xs:element ref="IDPEntry" maxOccurs="unbounded"/> */
LassoLibIDPEntry *IDPEntry; /* XXX: should actually be a GList */
};
struct _LassoLibIDPEntriesClass {
LassoNodeClass parent;
LassoNodeClass parent;
};
LASSO_EXPORT GType lasso_lib_idp_entries_get_type(void);
LASSO_EXPORT LassoNode* lasso_lib_idp_entries_new(void);
LASSO_EXPORT void lasso_lib_idp_entries_add_idpEntry (LassoLibIDPEntries *node,
LassoLibIDPEntry *idpEntry);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -40,114 +40,95 @@ Schema fragment (liberty-idff-protocols-schema-v1.2.xsd):
*/
/*****************************************************************************/
/* public methods */
/* private methods */
/*****************************************************************************/
/**
* lasso_lib_idp_entry_set_providerID:
* @node: the pointer to <lib:IDPEntry/> node object
* @providerID: the value of "ProviderID" element
*
* Sets the "ProviderID" element [required].
*
* It's the identity provider's unique identifier.
**/
void
lasso_lib_idp_entry_set_providerID(LassoLibIDPEntry *node,
const xmlChar *providerID)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_IDP_ENTRY(node));
g_assert(providerID != NULL);
static LassoNodeClass *parent_class = NULL;
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "ProviderID", providerID, FALSE);
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
LassoLibIDPEntry *entry = LASSO_LIB_IDP_ENTRY(node);
xmlnode = xmlNewNode(NULL, "IDPEntry");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
if (entry->ProviderID)
xmlNewTextChild(xmlnode, NULL, "ProviderID", entry->ProviderID);
if (entry->ProviderName)
xmlNewTextChild(xmlnode, NULL, "ProviderName", entry->ProviderName);
if (entry->Loc)
xmlNewTextChild(xmlnode, NULL, "Loc", entry->Loc);
return xmlnode;
}
/**
* lasso_lib_idp_entry_set_providerName:
* @node: the pointer to <lib:IDPEntry/> node object
* @providerName: the value of "ProviderName" element
*
* Sets the "ProviderName" element [optional].
*
* It's the identity provider's human-readable name.
**/
void
lasso_lib_idp_entry_set_providerName(LassoLibIDPEntry *node,
const xmlChar *providerName)
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_IDP_ENTRY(node));
g_assert(providerName != NULL);
LassoLibIDPEntry *entry = LASSO_LIB_IDP_ENTRY(node);
xmlNode *t;
parent_class->init_from_xml(node, xmlnode);
t = xmlnode->children;
while (t) {
if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "Loc") == 0) {
entry->Loc = xmlNodeGetContent(t);
}
if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "ProviderID") == 0) {
entry->ProviderID = xmlNodeGetContent(t);
}
if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "ProviderName") == 0) {
entry->ProviderName = xmlNodeGetContent(t);
}
t = t->next;
}
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "ProviderName", providerName, FALSE);
}
/**
* lasso_lib_idp_entry_set_loc:
* @node: the pointer to <lib:IDPEntry/> node object
* @loc: the value of "Loc" element
*
* Sets the "Loc" element [optional].
*
* It's the identity provider's URI, to which authentication requests may be
* sent. If present, this MUST be set to the value of the identity provider's
* <SingleSignOnService> element, obtained from their metadata
* ([LibertyMetadata]).
**/
void
lasso_lib_idp_entry_set_loc(LassoLibIDPEntry *node,
const xmlChar *loc)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_IDP_ENTRY(node));
g_assert(loc != NULL);
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "Loc", loc, FALSE);
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
lasso_lib_idp_entry_instance_init(LassoLibIDPEntry *node)
instance_init(LassoLibIDPEntry *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
class->set_ns(LASSO_NODE(node), lassoLibHRef, lassoLibPrefix);
class->set_name(LASSO_NODE(node), "IDPEntry");
node->ProviderID = NULL;
node->ProviderName = NULL;
node->Loc = NULL;
}
static void
lasso_lib_idp_entry_class_init(LassoLibIDPEntryClass *klass)
class_init(LassoLibIDPEntryClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
}
GType lasso_lib_idp_entry_get_type() {
static GType this_type = 0;
GType
lasso_lib_idp_entry_get_type()
{
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibIDPEntryClass),
NULL,
NULL,
(GClassInitFunc) lasso_lib_idp_entry_class_init,
NULL,
NULL,
sizeof(LassoLibIDPEntry),
0,
(GInstanceInitFunc) lasso_lib_idp_entry_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoLibIDPEntry",
&this_info, 0);
}
return this_type;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibIDPEntryClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoLibIDPEntry),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoLibIDPEntry", &this_info, 0);
}
return this_type;
}
/**
@ -157,7 +138,9 @@ GType lasso_lib_idp_entry_get_type() {
*
* Return value: the new @LassoLibIDPEntry
**/
LassoNode* lasso_lib_idp_entry_new()
LassoNode*
lasso_lib_idp_entry_new()
{
return LASSO_NODE(g_object_new(LASSO_TYPE_LIB_IDP_ENTRY, NULL));
return LASSO_NODE(g_object_new(LASSO_TYPE_LIB_IDP_ENTRY, NULL));
}

View File

@ -43,26 +43,23 @@ typedef struct _LassoLibIDPEntry LassoLibIDPEntry;
typedef struct _LassoLibIDPEntryClass LassoLibIDPEntryClass;
struct _LassoLibIDPEntry{
LassoNode parent;
/*< private >*/
LassoNode parent;
/* <xs:element ref="ProviderID"/> */
char *ProviderID;
/* <xs:element name="ProviderName" type="xs:string" minOccurs="0"/> */
char *ProviderName;
/* <xs:element name="Loc" type="xs:anyURI"/> */
char *Loc;
};
struct _LassoLibIDPEntryClass {
LassoNodeClass parent;
LassoNodeClass parent;
};
LASSO_EXPORT GType lasso_lib_idp_entry_get_type(void);
LASSO_EXPORT LassoNode* lasso_lib_idp_entry_new(void);
LASSO_EXPORT void lasso_lib_idp_entry_set_providerID (LassoLibIDPEntry *node,
const xmlChar *providerID);
LASSO_EXPORT void lasso_lib_idp_entry_set_providerName (LassoLibIDPEntry *node,
const xmlChar *providerName);
LASSO_EXPORT void lasso_lib_idp_entry_set_loc (LassoLibIDPEntry *node,
const xmlChar *loc);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -40,91 +40,90 @@ Schema fragment (liberty-idff-protocols-schema-v1.2.xsd):
*/
/*****************************************************************************/
/* public methods */
/* private methods */
/*****************************************************************************/
/**
* lasso_lib_idp_list_set_getComplete:
* @node: the pointer to <lib:IDPList/> node object
* @getComplete: the value of "GetComplete" element.
*
* Sets the "GetComplete" element [optional].
*
* If the identity provider list is not complete, this element may be included
* with a URI that points to where the complete list can be retrieved.
**/
void
lasso_lib_idp_list_set_getComplete(LassoLibIDPList *node,
const xmlChar *getComplete)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_IDP_LIST(node));
g_assert(getComplete != NULL);
static LassoNodeClass *parent_class = NULL;
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "GetComplete", getComplete, FALSE);
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
LassoLibIDPList *list = LASSO_LIB_IDP_LIST(node);
xmlnode = xmlNewNode(NULL, "IDPList");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
if (list->IDPEntries)
xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(list->IDPEntries)));
if (list->GetComplete)
xmlNewTextChild(xmlnode, NULL, "GetComplete", list->GetComplete);
return xmlnode;
}
/**
* lasso_lib_idp_list_set_idpEntries:
* @node: the pointer to <lib:IDPList/> node object
* @idpEntries: the pointer to <lib:IDPEntries/> node object
*
* Set the "IDPEntries" element [required].
*
* It contains a list of identity provider entries.
**/
void
lasso_lib_idp_list_set_idpEntries(LassoLibIDPList *node,
LassoLibIDPEntries *idpEntries)
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_IDP_LIST(node));
g_assert(LASSO_IS_LIB_IDP_ENTRIES(idpEntries));
LassoLibIDPList *list = LASSO_LIB_IDP_LIST(node);
xmlNode *t;
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE (node), LASSO_NODE(idpEntries), FALSE);
parent_class->init_from_xml(node, xmlnode);
t = xmlnode->children;
while (t) {
if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "IDPEntries") == 0) {
list->IDPEntries = LASSO_LIB_IDP_ENTRIES(lasso_node_new_from_xmlNode(t));
}
if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "GetComplete") == 0) {
list->GetComplete = xmlNodeGetContent(t);
}
t = t->next;
}
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
lasso_lib_idp_list_instance_init(LassoLibIDPList *node)
instance_init(LassoLibIDPList *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
class->set_ns(LASSO_NODE(node), lassoLibHRef, lassoLibPrefix);
class->set_name(LASSO_NODE(node), "IDPList");
node->IDPEntries = NULL;
node->GetComplete = NULL;
}
static void
lasso_lib_idp_list_class_init(LassoLibIDPListClass *klass)
class_init(LassoLibIDPListClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
}
GType lasso_lib_idp_list_get_type() {
static GType this_type = 0;
GType
lasso_lib_idp_list_get_type()
{
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibIDPListClass),
NULL,
NULL,
(GClassInitFunc) lasso_lib_idp_list_class_init,
NULL,
NULL,
sizeof(LassoLibIDPList),
0,
(GInstanceInitFunc) lasso_lib_idp_list_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoLibIDPList",
&this_info, 0);
}
return this_type;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibIDPListClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoLibIDPList),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoLibIDPList", &this_info, 0);
}
return this_type;
}
/**
@ -138,7 +137,9 @@ GType lasso_lib_idp_list_get_type() {
*
* Return value: the new @LassoLibIDPList
**/
LassoNode* lasso_lib_idp_list_new()
LassoNode*
lasso_lib_idp_list_new()
{
return LASSO_NODE(g_object_new(LASSO_TYPE_LIB_IDP_LIST, NULL));
return LASSO_NODE(g_object_new(LASSO_TYPE_LIB_IDP_LIST, NULL));
}

View File

@ -44,23 +44,21 @@ typedef struct _LassoLibIDPList LassoLibIDPList;
typedef struct _LassoLibIDPListClass LassoLibIDPListClass;
struct _LassoLibIDPList {
LassoNode parent;
/*< private >*/
LassoNode parent;
/* <xs:element ref="IDPEntries"/> */
LassoLibIDPEntries *IDPEntries;
/* <xs:element ref="GetComplete" minOccurs="0"/> */
char *GetComplete;
};
struct _LassoLibIDPListClass {
LassoNodeClass parent;
LassoNodeClass parent;
};
LASSO_EXPORT GType lasso_lib_idp_list_get_type(void);
LASSO_EXPORT LassoNode* lasso_lib_idp_list_new(void);
LASSO_EXPORT void lasso_lib_idp_list_set_getComplete (LassoLibIDPList *node,
const xmlChar *getComplete);
LASSO_EXPORT void lasso_lib_idp_list_set_idpEntries (LassoLibIDPList *node,
LassoLibIDPEntries *idpEntries);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -1,87 +0,0 @@
/* $Id$
*
* Lasso - A free implementation of the Samlerty Alliance specifications.
*
* Copyright (C) 2004 Entr'ouvert
* http://lasso.entrouvert.org
*
* Authors: Nicolas Clapies <nclapies@entrouvert.com>
* Valery Febvre <vfebvre@easter-eggs.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <lasso/xml/lib_idp_provided_name_identifier.h>
/*
<xs:element name="IDPProvidedNameIdentifier" type="saml:NameIdentifierType"/>
*/
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
lasso_lib_idp_provided_name_identifier_instance_init(LassoLibIDPProvidedNameIdentifier *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
class->set_ns(LASSO_NODE(node), lassoLibHRef, lassoLibPrefix);
class->set_name(LASSO_NODE(node), "IDPProvidedNameIdentifier");
}
static void
lasso_lib_idp_provided_name_identifier_class_init(LassoLibIDPProvidedNameIdentifierClass *klass)
{
}
GType lasso_lib_idp_provided_name_identifier_get_type() {
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibIDPProvidedNameIdentifierClass),
NULL,
NULL,
(GClassInitFunc) lasso_lib_idp_provided_name_identifier_class_init,
NULL,
NULL,
sizeof(LassoLibIDPProvidedNameIdentifierClass),
0,
(GInstanceInitFunc) lasso_lib_idp_provided_name_identifier_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_SAML_NAME_IDENTIFIER,
"LassoLibIDPProvidedNameIdentifier",
&this_info, 0);
}
return this_type;
}
LassoNode*
lasso_lib_idp_provided_name_identifier_new(const xmlChar *content)
{
LassoNode *node;
g_assert(content != NULL);
node = LASSO_NODE(g_object_new(LASSO_TYPE_LIB_IDP_PROVIDED_NAME_IDENTIFIER,
NULL));
xmlNodeSetContent(LASSO_NODE_GET_CLASS(node)->get_xmlNode(node),
content);
return node;
}

View File

@ -1,61 +0,0 @@
/* $Id$
*
* Lasso - A free implementation of the Liberty Alliance specifications.
*
* Copyright (C) 2004 Entr'ouvert
* http://lasso.entrouvert.org
*
* Authors: Nicolas Clapies <nclapies@entrouvert.com>
* Valery Febvre <vfebvre@easter-eggs.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __LASSO_LIB_IDP_PROVIDED_NAME_IDENTIFIER_H__
#define __LASSO_LIB_IDP_PROVIDED_NAME_IDENTIFIER_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <lasso/xml/saml_name_identifier.h>
#define LASSO_TYPE_LIB_IDP_PROVIDED_NAME_IDENTIFIER (lasso_lib_idp_provided_name_identifier_get_type())
#define LASSO_LIB_IDP_PROVIDED_NAME_IDENTIFIER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_LIB_IDP_PROVIDED_NAME_IDENTIFIER, LassoLibIDPProvidedNameIdentifier))
#define LASSO_LIB_IDP_PROVIDED_NAME_IDENTIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), LASSO_TYPE_LIB_IDP_PROVIDED_NAME_IDENTIFIER, LassoLibIDPProvidedNameIdentifierClass))
#define LASSO_IS_LIB_IDP_PROVIDED_NAME_IDENTIFIER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), LASSO_TYPE_LIB_IDP_PROVIDED_NAME_IDENTIFIER))
#define LASSO_IS_LIB_IDP_PROVIDED_NAME_IDENTIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LASSO_TYPE_LIB_IDP_PROVIDED_NAME_IDENTIFIER))
#define LASSO_LIB_IDP_PROVIDED_NAME_IDENTIFIER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), LASSO_TYPE_LIB_IDP_PROVIDED_NAME_IDENTIFIER, LassoLibIDPProvidedNameIdentifierClass))
typedef struct _LassoLibIDPProvidedNameIdentifier LassoLibIDPProvidedNameIdentifier;
typedef struct _LassoLibIDPProvidedNameIdentifierClass LassoLibIDPProvidedNameIdentifierClass;
struct _LassoLibIDPProvidedNameIdentifier {
LassoSamlNameIdentifier parent;
/*< private >*/
};
struct _LassoLibIDPProvidedNameIdentifierClass {
LassoSamlNameIdentifierClass parent;
};
LASSO_EXPORT GType lasso_lib_idp_provided_name_identifier_get_type(void);
LASSO_EXPORT LassoNode* lasso_lib_idp_provided_name_identifier_new(const xmlChar *content);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __LASSO_LIB_IDP_PROVIDED_NAME_IDENTIFIER_H__ */

View File

@ -23,6 +23,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <libxml/uri.h>
#include <lasso/xml/lib_logout_request.h>
/*
@ -57,111 +58,231 @@ From liberty-metadata-v1.0.xsd:
*/
/*****************************************************************************/
/* public methods */
/* private methods */
/*****************************************************************************/
void
lasso_lib_logout_request_set_consent(LassoLibLogoutRequest *node,
const xmlChar *consent)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_LOGOUT_REQUEST(node));
g_assert(consent != NULL);
class = LASSO_NODE_GET_CLASS(node);
class->set_prop(LASSO_NODE (node), "consent", consent);
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
LassoLibLogoutRequest *request = LASSO_LIB_LOGOUT_REQUEST(node);
xmlNode *xmlnode;
xmlnode = parent_class->get_xmlNode(node);
xmlNodeSetName(xmlnode, "LogoutRequest");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
if (request->Extension)
xmlNewTextChild(xmlnode, NULL, "Extension", request->Extension);
if (request->ProviderID)
xmlNewTextChild(xmlnode, NULL, "ProviderID", request->ProviderID);
if (request->NameIdentifier)
xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(request->NameIdentifier)));
if (request->SessionIndex)
xmlNewTextChild(xmlnode, NULL, "SessionIndex", request->SessionIndex);
if (request->RelayState)
xmlNewTextChild(xmlnode, NULL, "RelayState", request->RelayState);
if (request->consent)
xmlSetProp(xmlnode, "consent", request->consent);
return xmlnode;
}
void
lasso_lib_logout_request_set_nameIdentifier(LassoLibLogoutRequest *node,
LassoSamlNameIdentifier *nameIdentifier)
static gchar*
build_query(LassoNode *node)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_LOGOUT_REQUEST(node));
g_assert(LASSO_IS_SAML_NAME_IDENTIFIER(nameIdentifier));
char *str, *t;
GString *s;
LassoLibLogoutRequest *request = LASSO_LIB_LOGOUT_REQUEST(node);
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE (node), LASSO_NODE (nameIdentifier), FALSE);
str = parent_class->build_query(node);
s = g_string_new(str);
g_free(str);
/* XXX Extension */
if (request->ProviderID) {
t = xmlURIEscapeStr(request->ProviderID, NULL);
g_string_append_printf(s, "&ProviderID=%s", t);
xmlFree(t);
}
if (request->NameIdentifier) {
t = lasso_node_build_query(LASSO_NODE(request->NameIdentifier));
g_string_append_printf(s, "&%s", t);
g_free(t);
}
if (request->SessionIndex)
g_string_append_printf(s, "&SessionIndex=%s", request->SessionIndex);
if (request->RelayState)
g_string_append_printf(s, "&RelayState=%s", request->RelayState);
if (request->consent)
g_string_append_printf(s, "&consent=%s", request->consent);
str = s->str;
g_string_free(s, FALSE);
return str;
}
void
lasso_lib_logout_request_set_providerID(LassoLibLogoutRequest *node,
const xmlChar *providerID)
static void
init_from_query(LassoNode *node, char **query_fields)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_LOGOUT_REQUEST(node));
g_assert(providerID != NULL);
/* FIXME : providerID length SHOULD be <= 1024 */
LassoLibLogoutRequest *request = LASSO_LIB_LOGOUT_REQUEST(node);
int i;
char *t;
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "ProviderID", providerID, FALSE);
request->NameIdentifier = lasso_saml_name_identifier_new();
for (i=0; (t=query_fields[i]); i++) {
if (g_str_has_prefix(t, "ProviderID=")) {
request->ProviderID = g_strdup(t+11);
continue;
}
if (g_str_has_prefix(t, "SessionIndex=")) {
request->SessionIndex = g_strdup(t+16);
continue;
}
if (g_str_has_prefix(t, "RelayState=")) {
request->RelayState = g_strdup(t+11);
continue;
}
if (g_str_has_prefix(t, "consent=")) {
request->consent = g_strdup(t+8);
continue;
}
if (g_str_has_prefix(t, "NameIdentifier=")) {
request->NameIdentifier->content = g_strdup(t+15);
continue;
}
if (g_str_has_prefix(t, "NameFormat=")) {
request->NameIdentifier->Format = g_strdup(t+11);
continue;
}
if (g_str_has_prefix(t, "NameQualifier=")) {
request->NameIdentifier->NameQualifier = g_strdup(t+14);
continue;
}
}
parent_class->init_from_query(node, query_fields);
}
void
lasso_lib_logout_request_set_relayState(LassoLibLogoutRequest *node,
const xmlChar *relayState)
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_LOGOUT_REQUEST(node));
g_assert(relayState != NULL);
LassoLibLogoutRequest *request = LASSO_LIB_LOGOUT_REQUEST(node);
xmlNode *t, *n;
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "RelayState", relayState, FALSE);
parent_class->init_from_xml(node, xmlnode);
t = xmlnode->children;
while (t) {
n = t;
t = t->next;
if (n->type != XML_ELEMENT_NODE) {
continue;
}
if (strcmp(n->name, "ProviderID") == 0) {
request->ProviderID = xmlNodeGetContent(n);
continue;
}
if (strcmp(n->name, "NameIdentifier") == 0) {
request->NameIdentifier = LASSO_SAML_NAME_IDENTIFIER(
lasso_node_new_from_xmlNode(n));
continue;
}
if (strcmp(n->name, "SessionIndex") == 0) {
request->SessionIndex = xmlNodeGetContent(n);
continue;
}
if (strcmp(n->name, "RelayState") == 0) {
request->RelayState = xmlNodeGetContent(n);
continue;
}
}
request->consent = xmlGetProp(xmlnode, "consent");
}
void
lasso_lib_logout_request_set_sessionIndex(LassoLibLogoutRequest *node,
const xmlChar *sessionIndex)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_LOGOUT_REQUEST(node));
g_assert(sessionIndex != NULL);
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "SessionIndex", sessionIndex, FALSE);
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
lasso_lib_logout_request_instance_init(LassoLibLogoutRequest *node)
instance_init(LassoLibLogoutRequest *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
class->set_ns(LASSO_NODE(node), lassoLibHRef, lassoLibPrefix);
class->set_name(LASSO_NODE(node), "LogoutRequest");
node->Extension = NULL;
node->ProviderID = NULL;
node->NameIdentifier = NULL;
node->SessionIndex = NULL;
node->RelayState = NULL;
node->consent = NULL;
}
static void
lasso_lib_logout_request_class_init(LassoLibLogoutRequestClass *klass)
class_init(LassoLibLogoutRequestClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
LASSO_NODE_CLASS(klass)->build_query = build_query;
LASSO_NODE_CLASS(klass)->init_from_query = init_from_query;
}
GType lasso_lib_logout_request_get_type() {
static GType this_type = 0;
GType
lasso_lib_logout_request_get_type()
{
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibLogoutRequestClass),
NULL,
NULL,
(GClassInitFunc) lasso_lib_logout_request_class_init,
NULL,
NULL,
sizeof(LassoLibLogoutRequest),
0,
(GInstanceInitFunc) lasso_lib_logout_request_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_SAMLP_REQUEST_ABSTRACT,
"LassoLibLogoutRequest",
&this_info, 0);
}
return this_type;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibLogoutRequestClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoLibLogoutRequest),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_SAMLP_REQUEST_ABSTRACT,
"LassoLibLogoutRequest", &this_info, 0);
}
return this_type;
}
LassoNode* lasso_lib_logout_request_new() {
return LASSO_NODE(g_object_new(LASSO_TYPE_LIB_LOGOUT_REQUEST,
NULL));
LassoNode*
lasso_lib_logout_request_new()
{
return LASSO_NODE(g_object_new(LASSO_TYPE_LIB_LOGOUT_REQUEST, NULL));
}
LassoNode*
lasso_lib_logout_request_new_full(char *providerID, LassoSamlNameIdentifier *nameIdentifier,
lassoSignatureType sign_type, lassoSignatureMethod sign_method)
{
LassoSamlpRequestAbstract *request;
request = g_object_new(LASSO_TYPE_LIB_LOGOUT_REQUEST, NULL);
request->RequestID = lasso_build_unique_id(32);
request->MajorVersion = LASSO_LIB_MAJOR_VERSION_N;
request->MinorVersion = LASSO_LIB_MINOR_VERSION_N;
request->IssueInstant = lasso_get_current_time();
/* set the signature template */
if (sign_type != LASSO_SIGNATURE_TYPE_NONE) {
#if 0 /* XXX: signatures are done differently */
lasso_samlp_request_abstract_set_signature_tmpl(
request, sign_type, sign_method, NULL);
#endif
}
/* ProviderID */
LASSO_LIB_LOGOUT_REQUEST(request)->ProviderID = g_strdup(providerID);
LASSO_LIB_LOGOUT_REQUEST(request)->NameIdentifier = g_object_ref(nameIdentifier);
return LASSO_NODE(request);
}

View File

@ -44,8 +44,19 @@ typedef struct _LassoLibLogoutRequest LassoLibLogoutRequest;
typedef struct _LassoLibLogoutRequestClass LassoLibLogoutRequestClass;
struct _LassoLibLogoutRequest {
LassoSamlpRequestAbstract parent;
/*< private >*/
LassoSamlpRequestAbstract parent;
/* <xs:element ref="Extension" minOccurs="0" maxOccurs="unbounded"/> */
char *Extension;
/* <xs:element ref="ProviderID"/> */
char *ProviderID;
/* <xs:element ref="saml:NameIdentifier"/> */
LassoSamlNameIdentifier *NameIdentifier;
/* <xs:element name="SessionIndex" type="xs:string" minOccurs="0"/> */
char *SessionIndex;
/* <xs:element ref="RelayState" minOccurs="0"/> */
char *RelayState;
/* <xs:attribute ref="consent" use="optional"/> */
char *consent;
};
struct _LassoLibLogoutRequestClass {
@ -55,20 +66,9 @@ struct _LassoLibLogoutRequestClass {
LASSO_EXPORT GType lasso_lib_logout_request_get_type(void);
LASSO_EXPORT LassoNode* lasso_lib_logout_request_new(void);
LASSO_EXPORT void lasso_lib_logout_request_set_consent (LassoLibLogoutRequest *,
const xmlChar *);
LASSO_EXPORT void lasso_lib_logout_request_set_nameIdentifier (LassoLibLogoutRequest *,
LassoSamlNameIdentifier *);
LASSO_EXPORT void lasso_lib_logout_request_set_providerID (LassoLibLogoutRequest *,
const xmlChar *);
LASSO_EXPORT void lasso_lib_logout_request_set_relayState (LassoLibLogoutRequest *,
const xmlChar *);
LASSO_EXPORT void lasso_lib_logout_request_set_sessionIndex (LassoLibLogoutRequest *,
const xmlChar *);
LASSO_EXPORT LassoNode* lasso_lib_logout_request_new_full(
char *providerID, LassoSamlNameIdentifier *nameIdentifier,
lassoSignatureType sign_type, lassoSignatureMethod sign_method);
#ifdef __cplusplus
}

View File

@ -32,48 +32,104 @@ The Schema fragment (liberty-idff-protocols-schema-v1.2.xsd):
*/
/*****************************************************************************/
/* private methods */
/*****************************************************************************/
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
xmlnode = parent_class->get_xmlNode(node);
xmlNodeSetName(xmlnode, "LogoutResponse");
return xmlnode;
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
lasso_lib_logout_response_instance_init(LassoLibLogoutResponse *node)
instance_init(LassoLibLogoutResponse *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
/* namespace herited from lib:StatusResponse */
class->set_name(LASSO_NODE(node), "LogoutResponse");
}
static void
lasso_lib_logout_response_class_init(LassoLibLogoutResponseClass *klass)
class_init(LassoLibLogoutResponseClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
#if 0 /* could be used to check QName */
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
#endif
}
GType lasso_lib_logout_response_get_type() {
static GType logout_response_type = 0;
if (!logout_response_type) {
static const GTypeInfo logout_response_info = {
sizeof (LassoLibLogoutResponseClass),
NULL,
NULL,
(GClassInitFunc) lasso_lib_logout_response_class_init,
NULL,
NULL,
sizeof(LassoLibLogoutResponse),
0,
(GInstanceInitFunc) lasso_lib_logout_response_instance_init,
};
logout_response_type = g_type_register_static(LASSO_TYPE_LIB_STATUS_RESPONSE,
"LassoLibLogoutResponse",
&logout_response_info, 0);
}
return logout_response_type;
}
LassoNode* lasso_lib_logout_response_new()
GType
lasso_lib_logout_response_get_type()
{
return LASSO_NODE(g_object_new(LASSO_TYPE_LIB_LOGOUT_RESPONSE, NULL));
static GType logout_response_type = 0;
if (!logout_response_type) {
static const GTypeInfo logout_response_info = {
sizeof (LassoLibLogoutResponseClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoLibLogoutResponse),
0,
(GInstanceInitFunc) instance_init,
};
logout_response_type = g_type_register_static(LASSO_TYPE_LIB_STATUS_RESPONSE,
"LassoLibLogoutResponse", &logout_response_info, 0);
}
return logout_response_type;
}
LassoNode*
lasso_lib_logout_response_new()
{
return LASSO_NODE(g_object_new(LASSO_TYPE_LIB_LOGOUT_RESPONSE, NULL));
}
LassoNode*
lasso_lib_logout_response_new_full(char *providerID, const char *statusCodeValue,
LassoLibLogoutRequest *request,
lassoSignatureType sign_type, lassoSignatureMethod sign_method)
{
LassoSamlpResponseAbstract *response;
response = g_object_new(LASSO_TYPE_LIB_LOGOUT_RESPONSE, NULL);
response->ResponseID = lasso_build_unique_id(32);
response->MajorVersion = LASSO_LIB_MAJOR_VERSION_N;
response->MinorVersion = LASSO_LIB_MINOR_VERSION_N;
response->IssueInstant = lasso_get_current_time();
response->InResponseTo = LASSO_SAMLP_REQUEST_ABSTRACT(request)->RequestID;
response->Recipient = request->ProviderID;
#if 0 /* XXX: signature to do */
/* set the signature template */
if (sign_type != LASSO_SIGNATURE_TYPE_NONE) {
lasso_samlp_response_abstract_set_signature_tmpl(response, sign_type, sign_method);
}
#endif
LASSO_LIB_STATUS_RESPONSE(response)->ProviderID = g_strdup(providerID);
if (request->RelayState)
LASSO_LIB_STATUS_RESPONSE(response)->RelayState = g_strdup(request->RelayState);
LASSO_LIB_STATUS_RESPONSE(response)->Status = lasso_samlp_status_new();
LASSO_LIB_STATUS_RESPONSE(response)->Status->StatusCode = lasso_samlp_status_code_new();
LASSO_LIB_STATUS_RESPONSE(response)->Status->StatusCode->Value = g_strdup(statusCodeValue);
return LASSO_NODE(response);
}

View File

@ -31,6 +31,7 @@ extern "C" {
#endif /* __cplusplus */
#include <lasso/xml/lib_status_response.h>
#include <lasso/xml/lib_logout_request.h>
#define LASSO_TYPE_LIB_LOGOUT_RESPONSE (lasso_lib_logout_response_get_type())
#define LASSO_LIB_LOGOUT_RESPONSE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_LIB_LOGOUT_RESPONSE, LassoLibLogoutResponse))
@ -43,17 +44,21 @@ typedef struct _LassoLibLogoutResponse LassoLibLogoutResponse;
typedef struct _LassoLibLogoutResponseClass LassoLibLogoutResponseClass;
struct _LassoLibLogoutResponse {
LassoLibStatusResponse parent;
/*< private >*/
LassoLibStatusResponse parent;
};
struct _LassoLibLogoutResponseClass {
LassoLibStatusResponseClass parent;
LassoLibStatusResponseClass parent;
};
LASSO_EXPORT GType lasso_lib_logout_response_get_type(void);
LASSO_EXPORT LassoNode* lasso_lib_logout_response_new(void);
LASSO_EXPORT LassoNode* lasso_lib_logout_response_new_full(
char *providerID, const char *statusCodeValue,
LassoLibLogoutRequest *request,
lassoSignatureType sign_type, lassoSignatureMethod sign_method);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -55,55 +55,66 @@ From liberty-metadata-v1.0.xsd:
*/
/*****************************************************************************/
/* public methods */
/* private methods */
/*****************************************************************************/
void
lasso_lib_name_identifier_mapping_request_set_consent(LassoLibNameIdentifierMappingRequest *node,
const xmlChar *consent)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_NAME_IDENTIFIER_MAPPING_REQUEST(node));
g_assert(consent != NULL);
class = LASSO_NODE_GET_CLASS(node);
class->set_prop(LASSO_NODE (node), "consent", consent);
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
LassoLibNameIdentifierMappingRequest *request;
request = LASSO_LIB_NAME_IDENTIFIER_MAPPING_REQUEST(node);
xmlnode = parent_class->get_xmlNode(node);
xmlNodeSetName(xmlnode, "NameIdentifierMappingRequest");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
if (request->ProviderID)
xmlNewTextChild(xmlnode, NULL, "ProviderID", request->ProviderID);
if (request->NameIdentifier)
xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(request->NameIdentifier)));
if (request->TargetNamespace)
xmlNewTextChild(xmlnode, NULL, "TargetNamespace", request->TargetNamespace);
if (request->consent)
xmlSetProp(xmlnode, "consent", request->consent);
return xmlnode;
}
void
lasso_lib_name_identifier_mapping_request_set_providerID(LassoLibNameIdentifierMappingRequest *node,
const xmlChar *providerID)
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_NAME_IDENTIFIER_MAPPING_REQUEST(node));
g_assert(providerID != NULL);
/* FIXME : providerId length SHOULD be <= 1024 */
LassoLibNameIdentifierMappingRequest *request;
xmlNode *t;
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "ProviderID", providerID, FALSE);
}
request = LASSO_LIB_NAME_IDENTIFIER_MAPPING_REQUEST(node);
void
lasso_lib_name_identifier_mapping_request_set_nameIdentifier(LassoLibNameIdentifierMappingRequest *node,
LassoSamlNameIdentifier *nameIdentifier)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_NAME_IDENTIFIER_MAPPING_REQUEST(node));
g_assert(LASSO_IS_SAML_NAME_IDENTIFIER(nameIdentifier));
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE (node), LASSO_NODE (nameIdentifier), FALSE);
}
void
lasso_lib_name_identifier_mapping_request_set_targetNameSpace(LassoLibNameIdentifierMappingRequest *node,
const xmlChar *targetNameSpace)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_NAME_IDENTIFIER_MAPPING_REQUEST(node));
g_assert(targetNameSpace != NULL);
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "TargetNameSpace", targetNameSpace, FALSE);
parent_class->init_from_xml(node, xmlnode);
t = xmlnode->children;
while (t) {
if (t->type != XML_ELEMENT_NODE) {
t = t->next;
continue;
}
if (strcmp(t->name, "ProviderID") == 0) {
request->ProviderID = xmlNodeGetContent(t);
}
if (strcmp(t->name, "NameIdentifier") == 0) {
request->NameIdentifier = LASSO_SAML_NAME_IDENTIFIER(
lasso_node_new_from_xmlNode(t));
}
if (strcmp(t->name, "TargetNamespace") == 0) {
request->TargetNamespace = xmlNodeGetContent(t);
}
t = t->next;
}
request->consent = xmlGetProp(xmlnode, "consent");
}
/*****************************************************************************/
@ -111,43 +122,85 @@ lasso_lib_name_identifier_mapping_request_set_targetNameSpace(LassoLibNameIdenti
/*****************************************************************************/
static void
lasso_lib_name_identifier_mapping_request_instance_init(LassoLibNameIdentifierMappingRequest *node)
instance_init(LassoLibNameIdentifierMappingRequest *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
class->set_ns(LASSO_NODE(node), lassoLibHRef, lassoLibPrefix);
class->set_name(LASSO_NODE(node), "NameIdentifierMappingRequest");
node->Extension = NULL;
node->ProviderID = NULL;
node->NameIdentifier = NULL;
node->TargetNamespace = NULL;
node->consent = NULL;
}
static void
lasso_lib_name_identifier_mapping_request_class_init(LassoLibNameIdentifierMappingRequestClass *klass)
class_init(LassoLibNameIdentifierMappingRequestClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
}
GType lasso_lib_name_identifier_mapping_request_get_type() {
static GType this_type = 0;
GType
lasso_lib_name_identifier_mapping_request_get_type()
{
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibNameIdentifierMappingRequestClass),
NULL,
NULL,
(GClassInitFunc) lasso_lib_name_identifier_mapping_request_class_init,
NULL,
NULL,
sizeof(LassoLibNameIdentifierMappingRequest),
0,
(GInstanceInitFunc) lasso_lib_name_identifier_mapping_request_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_SAMLP_REQUEST_ABSTRACT,
"LassoLibNameIdentifierMappingRequest",
&this_info, 0);
}
return this_type;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibNameIdentifierMappingRequestClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoLibNameIdentifierMappingRequest),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_SAMLP_REQUEST_ABSTRACT,
"LassoLibNameIdentifierMappingRequest", &this_info, 0);
}
return this_type;
}
LassoNode* lasso_lib_name_identifier_mapping_request_new() {
return LASSO_NODE(g_object_new(LASSO_TYPE_LIB_NAME_IDENTIFIER_MAPPING_REQUEST,
NULL));
LassoNode*
lasso_lib_name_identifier_mapping_request_new()
{
return g_object_new(LASSO_TYPE_LIB_NAME_IDENTIFIER_MAPPING_REQUEST, NULL);
}
LassoNode*
lasso_lib_name_identifier_mapping_request_new_full(char *providerID,
LassoSamlNameIdentifier *nameIdentifier, const char *targetNamespace,
lassoSignatureType sign_type, lassoSignatureMethod sign_method)
{
LassoSamlpRequestAbstract *request;
request = g_object_new(LASSO_TYPE_LIB_NAME_IDENTIFIER_MAPPING_REQUEST, NULL);
request->RequestID = lasso_build_unique_id(32);
request->MajorVersion = LASSO_LIB_MAJOR_VERSION_N;
request->MinorVersion = LASSO_LIB_MINOR_VERSION_N;
request->IssueInstant = lasso_get_current_time();
/* set the signature template */
if (sign_type != LASSO_SIGNATURE_TYPE_NONE) {
#if 0 /* XXX: signatures are done differently */
lasso_samlp_request_abstract_set_signature_tmpl(
request, sign_type, sign_method, NULL);
#endif
}
/* ProviderID */
LASSO_LIB_NAME_IDENTIFIER_MAPPING_REQUEST(request)->ProviderID = g_strdup(providerID);
LASSO_LIB_NAME_IDENTIFIER_MAPPING_REQUEST(request)->NameIdentifier =
g_object_ref(nameIdentifier);
LASSO_LIB_NAME_IDENTIFIER_MAPPING_REQUEST(request)->TargetNamespace =
g_strdup(targetNamespace);
/* XXX: consent ? */
return LASSO_NODE(request);
}

View File

@ -44,29 +44,31 @@ typedef struct _LassoLibNameIdentifierMappingRequest LassoLibNameIdentifierMappi
typedef struct _LassoLibNameIdentifierMappingRequestClass LassoLibNameIdentifierMappingRequestClass;
struct _LassoLibNameIdentifierMappingRequest {
LassoSamlpRequestAbstract parent;
/*< private >*/
LassoSamlpRequestAbstract parent;
/* <xs:element ref="Extension" minOccurs="0" maxOccurs="unbounded"/> */
LassoNode *Extension; /* XXX */
/* <xs:element ref="ProviderID"/> */
char *ProviderID;
/* <xs:element ref="saml:NameIdentifier"/> */
LassoSamlNameIdentifier *NameIdentifier;
/* <xs:element name="TargetNamespace" type="md:entityIDType"/> */
char *TargetNamespace;
/* <xs:attribute ref="consent" use="optional"/> */
char *consent;
};
struct _LassoLibNameIdentifierMappingRequestClass {
LassoSamlpRequestAbstractClass parent;
LassoSamlpRequestAbstractClass parent;
};
LASSO_EXPORT GType lasso_lib_name_identifier_mapping_request_get_type(void);
LASSO_EXPORT LassoNode* lasso_lib_name_identifier_mapping_request_new(void);
LASSO_EXPORT LassoNode* lasso_lib_name_identifier_mapping_request_new_full(
char *providerID, LassoSamlNameIdentifier *nameIdentifier,
const char *targetNamespace,
lassoSignatureType sign_type, lassoSignatureMethod sign_method);
LASSO_EXPORT void lasso_lib_name_identifier_mapping_request_set_consent (LassoLibNameIdentifierMappingRequest *,
const xmlChar *);
LASSO_EXPORT void lasso_lib_name_identifier_mapping_request_set_providerID (LassoLibNameIdentifierMappingRequest *,
const xmlChar *);
LASSO_EXPORT void lasso_lib_name_identifier_mapping_request_set_nameIdentifier (LassoLibNameIdentifierMappingRequest *,
LassoSamlNameIdentifier *);
LASSO_EXPORT void lasso_lib_name_identifier_mapping_request_set_targetNameSpace (LassoLibNameIdentifierMappingRequest *node,
const xmlChar *targetNameSpace);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -45,44 +45,60 @@ The Schema fragment (liberty-idff-protocols-schema-v1.2.xsd):
*/
/*****************************************************************************/
/* public methods */
/* private methods */
/*****************************************************************************/
void lasso_lib_name_identifier_mapping_response_set_nameIdentifier(LassoLibNameIdentifierMappingResponse *node,
LassoSamlNameIdentifier *nameIdentifier)
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_NAME_IDENTIFIER_MAPPING_RESPONSE(node));
g_assert(LASSO_IS_SAML_NAME_IDENTIFIER(nameIdentifier));
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE (node),
LASSO_NODE (nameIdentifier),
FALSE);
xmlNode *xmlnode;
LassoLibNameIdentifierMappingResponse *response;
response = LASSO_LIB_NAME_IDENTIFIER_MAPPING_RESPONSE(node);
xmlnode = parent_class->get_xmlNode(node);
xmlNodeSetName(xmlnode, "NameIdentifierMappingResponse");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
if (response->ProviderID)
xmlNewTextChild(xmlnode, NULL, "ProviderID", response->ProviderID);
if (response->Status)
xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(response->Status)));
if (response->NameIdentifier)
xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(response->NameIdentifier)));
return xmlnode;
}
void
lasso_lib_name_identifier_mapping_response_set_providerID(LassoLibNameIdentifierMappingResponse *node,
const xmlChar *providerID)
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_NAME_IDENTIFIER_MAPPING_RESPONSE(node));
g_assert(providerID != NULL);
/* FIXME : providerID length SHOULD be <= 1024 */
LassoLibNameIdentifierMappingResponse *response;
xmlNode *t;
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "ProviderID", providerID, FALSE);
}
response = LASSO_LIB_NAME_IDENTIFIER_MAPPING_RESPONSE(node);
void lasso_lib_name_identifier_mapping_response_set_status(LassoLibNameIdentifierMappingResponse *node,
LassoSamlpStatus *status)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_NAME_IDENTIFIER_MAPPING_RESPONSE(node));
g_assert(LASSO_IS_SAMLP_STATUS(status));
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE (node), LASSO_NODE(status), FALSE);
parent_class->init_from_xml(node, xmlnode);
t = xmlnode->children;
while (t) {
if (t->type != XML_ELEMENT_NODE) {
t = t->next;
continue;
}
if (strcmp(t->name, "ProviderID") == 0) {
response->ProviderID = xmlNodeGetContent(t);
}
if (strcmp(t->name, "Status") == 0) {
response->Status = LASSO_SAMLP_STATUS(lasso_node_new_from_xmlNode(t));
}
if (strcmp(t->name, "NameIdentifier") == 0) {
response->NameIdentifier = LASSO_SAML_NAME_IDENTIFIER(
lasso_node_new_from_xmlNode(t));
}
t = t->next;
}
}
/*****************************************************************************/
@ -90,43 +106,84 @@ void lasso_lib_name_identifier_mapping_response_set_status(LassoLibNameIdentifie
/*****************************************************************************/
static void
lasso_lib_name_identifier_mapping_response_instance_init(LassoLibNameIdentifierMappingResponse *node)
instance_init(LassoLibNameIdentifierMappingResponse *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
class->set_ns(LASSO_NODE(node), lassoLibHRef, lassoLibPrefix);
class->set_name(LASSO_NODE(node), "NameIdentifierMappingResponse");
node->Extension = NULL;
node->ProviderID = NULL;
node->Status = NULL;
node->NameIdentifier = NULL;
}
static void
lasso_lib_name_identifier_mapping_response_class_init(LassoLibNameIdentifierMappingResponseClass *klass)
class_init(LassoLibNameIdentifierMappingResponseClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
}
GType lasso_lib_name_identifier_mapping_response_get_type() {
static GType name_identifier_mapping_response_type = 0;
if (!name_identifier_mapping_response_type) {
static const GTypeInfo name_identifier_mapping_response_info = {
sizeof (LassoLibNameIdentifierMappingResponseClass),
NULL,
NULL,
(GClassInitFunc) lasso_lib_name_identifier_mapping_response_class_init,
NULL,
NULL,
sizeof(LassoLibNameIdentifierMappingResponse),
0,
(GInstanceInitFunc) lasso_lib_name_identifier_mapping_response_instance_init,
};
name_identifier_mapping_response_type = g_type_register_static(LASSO_TYPE_SAMLP_RESPONSE_ABSTRACT,
"LassoLibNameIdentifierMappingResponse",
&name_identifier_mapping_response_info, 0);
}
return name_identifier_mapping_response_type;
}
LassoNode* lasso_lib_name_identifier_mapping_response_new()
GType
lasso_lib_name_identifier_mapping_response_get_type()
{
return LASSO_NODE(g_object_new(LASSO_TYPE_LIB_NAME_IDENTIFIER_MAPPING_RESPONSE, NULL));
static GType name_identifier_mapping_response_type = 0;
if (!name_identifier_mapping_response_type) {
static const GTypeInfo name_identifier_mapping_response_info = {
sizeof (LassoLibNameIdentifierMappingResponseClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoLibNameIdentifierMappingResponse),
0,
(GInstanceInitFunc) instance_init,
};
name_identifier_mapping_response_type = g_type_register_static
(LASSO_TYPE_SAMLP_RESPONSE_ABSTRACT,
"LassoLibNameIdentifierMappingResponse",
&name_identifier_mapping_response_info, 0);
}
return name_identifier_mapping_response_type;
}
LassoNode*
lasso_lib_name_identifier_mapping_response_new()
{
return g_object_new(LASSO_TYPE_LIB_NAME_IDENTIFIER_MAPPING_RESPONSE, NULL);
}
LassoNode*
lasso_lib_name_identifier_mapping_response_new_full(char *providerID, const char *statusCodeValue,
LassoLibNameIdentifierMappingRequest *request,
lassoSignatureType sign_type, lassoSignatureMethod sign_method)
{
LassoSamlpResponseAbstract *response_base;
LassoLibNameIdentifierMappingResponse *response;
response = g_object_new(LASSO_TYPE_LIB_NAME_IDENTIFIER_MAPPING_RESPONSE, NULL);
response_base = LASSO_SAMLP_RESPONSE_ABSTRACT(response);
response_base->ResponseID = lasso_build_unique_id(32);
response_base->MajorVersion = LASSO_LIB_MAJOR_VERSION_N;
response_base->MinorVersion = LASSO_LIB_MINOR_VERSION_N;
response_base->IssueInstant = lasso_get_current_time();
response_base->InResponseTo = LASSO_SAMLP_REQUEST_ABSTRACT(request)->RequestID;
response_base->Recipient = request->ProviderID;
#if 0 /* XXX: signature to do */
/* set the signature template */
if (sign_type != LASSO_SIGNATURE_TYPE_NONE) {
lasso_samlp_response_abstract_set_signature_tmpl(response, sign_type, sign_method);
}
#endif
response->ProviderID = g_strdup(providerID);
response->Status = lasso_samlp_status_new();
response->Status->StatusCode = lasso_samlp_status_code_new();
response->Status->StatusCode->Value = g_strdup(statusCodeValue);
return LASSO_NODE(response);
}

View File

@ -33,6 +33,7 @@ extern "C" {
#include <lasso/xml/samlp_response_abstract.h>
#include <lasso/xml/saml_name_identifier.h>
#include <lasso/xml/samlp_status.h>
#include <lasso/xml/lib_name_identifier_mapping_request.h>
#define LASSO_TYPE_LIB_NAME_IDENTIFIER_MAPPING_RESPONSE (lasso_lib_name_identifier_mapping_response_get_type())
#define LASSO_LIB_NAME_IDENTIFIER_MAPPING_RESPONSE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_LIB_NAME_IDENTIFIER_MAPPING_RESPONSE, LassoLibNameIdentifierMappingResponse))
@ -45,26 +46,30 @@ typedef struct _LassoLibNameIdentifierMappingResponse LassoLibNameIdentifierMapp
typedef struct _LassoLibNameIdentifierMappingResponseClass LassoLibNameIdentifierMappingResponseClass;
struct _LassoLibNameIdentifierMappingResponse {
LassoSamlpResponseAbstract parent;
/*< private >*/
LassoSamlpResponseAbstract parent;
/* <xs:element ref="Extension" minOccurs="0" maxOccurs="unbounded"/> */
LassoNode *Extension;
/* <xs:element ref="ProviderID"/> */
char *ProviderID;
/* <xs:element ref="samlp:Status"/> */
LassoSamlpStatus *Status;
/* <xs:element ref="saml:NameIdentifier" minOccurs="0"/> */
LassoSamlNameIdentifier *NameIdentifier;
};
struct _LassoLibNameIdentifierMappingResponseClass {
LassoSamlpResponseAbstractClass parent;
LassoSamlpResponseAbstractClass parent;
};
LASSO_EXPORT GType lasso_lib_name_identifier_mapping_response_get_type(void);
LASSO_EXPORT LassoNode* lasso_lib_name_identifier_mapping_response_new(void);
LASSO_EXPORT void lasso_lib_name_identifier_mapping_response_set_nameIdentifier (LassoLibNameIdentifierMappingResponse *node,
LassoSamlNameIdentifier *nameIdentifier);
LASSO_EXPORT LassoNode* lasso_lib_name_identifier_mapping_response_new_full(
char *provideRID, const char *statusCodeValue,
LassoLibNameIdentifierMappingRequest *request,
lassoSignatureType sign_type, lassoSignatureMethod sign_method);
LASSO_EXPORT void lasso_lib_name_identifier_mapping_response_set_providerID (LassoLibNameIdentifierMappingResponse *node,
const xmlChar *providerID);
LASSO_EXPORT void lasso_lib_name_identifier_mapping_response_set_status (LassoLibNameIdentifierMappingResponse *node,
LassoSamlpStatus *status);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -1,88 +0,0 @@
/* $Id$
*
* Lasso - A free implementation of the Samlerty Alliance specifications.
*
* Copyright (C) 2004 Entr'ouvert
* http://lasso.entrouvert.org
*
* Authors: Nicolas Clapies <nclapies@entrouvert.com>
* Valery Febvre <vfebvre@easter-eggs.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <lasso/xml/lib_old_provided_name_identifier.h>
/*
The Schema fragment (liberty-idff-protocols-schema-v1.2.xsd):
<xs:element name="OldProvidedNameIdentifier" type="saml:NameIdentifierType"/>
*/
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
lasso_lib_old_provided_name_identifier_instance_init(LassoLibOLDProvidedNameIdentifier *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
class->set_ns(LASSO_NODE(node), lassoLibHRef, lassoLibPrefix);
class->set_name(LASSO_NODE(node), "OldProvidedNameIdentifier");
}
static void
lasso_lib_old_provided_name_identifier_class_init(LassoLibOLDProvidedNameIdentifierClass *klass)
{
}
GType lasso_lib_old_provided_name_identifier_get_type() {
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibOLDProvidedNameIdentifierClass),
NULL,
NULL,
(GClassInitFunc) lasso_lib_old_provided_name_identifier_class_init,
NULL,
NULL,
sizeof(LassoLibOLDProvidedNameIdentifierClass),
0,
(GInstanceInitFunc) lasso_lib_old_provided_name_identifier_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_SAML_NAME_IDENTIFIER,
"LassoLibOLDProvidedNameIdentifier",
&this_info, 0);
}
return this_type;
}
LassoNode* lasso_lib_old_provided_name_identifier_new(const xmlChar *content) {
LassoNode *node;
g_assert(content != NULL);
node = LASSO_NODE(g_object_new(LASSO_TYPE_LIB_OLD_PROVIDED_NAME_IDENTIFIER,
NULL));
xmlNodeSetContent(LASSO_NODE_GET_CLASS(node)->get_xmlNode(node),
content);
return node;
}

View File

@ -1,61 +0,0 @@
/* $Id$
*
* Lasso - A free implementation of the Liberty Alliance specifications.
*
* Copyright (C) 2004 Entr'ouvert
* http://lasso.entrouvert.org
*
* Authors: Nicolas Clapies <nclapies@entrouvert.com>
* Valery Febvre <vfebvre@easter-eggs.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __LASSO_LIB_OLD_PROVIDED_NAME_IDENTIFIER_H__
#define __LASSO_LIB_OLD_PROVIDED_NAME_IDENTIFIER_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <lasso/xml/saml_name_identifier.h>
#define LASSO_TYPE_LIB_OLD_PROVIDED_NAME_IDENTIFIER (lasso_lib_old_provided_name_identifier_get_type())
#define LASSO_LIB_OLD_PROVIDED_NAME_IDENTIFIER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_LIB_OLD_PROVIDED_NAME_IDENTIFIER, LassoLibOLDProvidedNameIdentifier))
#define LASSO_LIB_OLD_PROVIDED_NAME_IDENTIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), LASSO_TYPE_LIB_OLD_PROVIDED_NAME_IDENTIFIER, LassoLibOLDProvidedNameIdentifierClass))
#define LASSO_IS_LIB_OLD_PROVIDED_NAME_IDENTIFIER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), LASSO_TYPE_LIB_OLD_PROVIDED_NAME_IDENTIFIER))
#define LASSO_IS_LIB_OLD_PROVIDED_NAME_IDENTIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LASSO_TYPE_LIB_OLD_PROVIDED_NAME_IDENTIFIER))
#define LASSO_LIB_OLD_PROVIDED_NAME_IDENTIFIER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), LASSO_TYPE_LIB_OLD_PROVIDED_NAME_IDENTIFIER, LassoLibOLDProvidedNameIdentifierClass))
typedef struct _LassoLibOLDProvidedNameIdentifier LassoLibOLDProvidedNameIdentifier;
typedef struct _LassoLibOLDProvidedNameIdentifierClass LassoLibOLDProvidedNameIdentifierClass;
struct _LassoLibOLDProvidedNameIdentifier {
LassoSamlNameIdentifier parent;
/*< private >*/
};
struct _LassoLibOLDProvidedNameIdentifierClass {
LassoSamlNameIdentifierClass parent;
};
LASSO_EXPORT GType lasso_lib_old_provided_name_identifier_get_type(void);
LASSO_EXPORT LassoNode* lasso_lib_old_provided_name_identifier_new(const xmlChar *content);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __LASSO_LIB_OLD_PROVIDED_NAME_IDENTIFIER_H__ */

View File

@ -23,6 +23,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <libxml/uri.h>
#include <lasso/xml/lib_register_name_identifier_request.h>
/*
@ -36,7 +37,7 @@ The Schema fragment (liberty-idff-protocols-schema-v1.2.xsd):
<xs:element ref="Extension" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="ProviderID"/>
<xs:element ref="IDPProvidedNameIdentifier"/>
<xs:element ref="SPProvidedNameIdentifier"/>
<xs:element ref="SPProvidedNameIdentifier" minOccurs="0"/>
<xs:element ref="OldProvidedNameIdentifier"/>
<xs:element ref="RelayState" minOccurs="0"/>
</xs:sequence>
@ -60,118 +61,302 @@ From liberty-metadata-v1.0.xsd:
*/
/*****************************************************************************/
/* public methods */
/* private methods */
/*****************************************************************************/
void
lasso_lib_register_name_identifier_request_set_idpProvidedNameIdentifier(LassoLibRegisterNameIdentifierRequest *node,
LassoLibIDPProvidedNameIdentifier *idpProvidedNameIdentifier)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_REGISTER_NAME_IDENTIFIER_REQUEST(node));
g_assert(LASSO_IS_LIB_IDP_PROVIDED_NAME_IDENTIFIER(idpProvidedNameIdentifier));
static LassoNodeClass *parent_class = NULL;
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE (node),
LASSO_NODE (idpProvidedNameIdentifier),
FALSE);
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode, *t;
LassoLibRegisterNameIdentifierRequest *request;
xmlNs *xmlns;
request = LASSO_LIB_REGISTER_NAME_IDENTIFIER_REQUEST(node);
xmlnode = parent_class->get_xmlNode(node);
xmlNodeSetName(xmlnode, "RegisterNameIdentifierRequest");
xmlns = xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX);
xmlSetNs(xmlnode, xmlns);
if (request->Extension)
xmlAddChild(xmlnode, lasso_node_get_xmlNode(request->Extension));
if (request->ProviderID)
xmlNewTextChild(xmlnode, NULL, "ProviderID", request->ProviderID);
if (request->IDPProvidedNameIdentifier) {
t = xmlAddChild(xmlnode, lasso_node_get_xmlNode(
LASSO_NODE(request->IDPProvidedNameIdentifier)));
xmlNodeSetName(t, "IDPProvidedNameIdentifier");
xmlSetNs(t, xmlns);
}
if (request->SPProvidedNameIdentifier) {
t = xmlAddChild(xmlnode, lasso_node_get_xmlNode(
LASSO_NODE(request->SPProvidedNameIdentifier)));
xmlNodeSetName(t, "SPProvidedNameIdentifier");
xmlSetNs(t, xmlns);
}
if (request->OldProvidedNameIdentifier) {
t = xmlAddChild(xmlnode, lasso_node_get_xmlNode(
LASSO_NODE(request->OldProvidedNameIdentifier)));
xmlNodeSetName(t, "OldProvidedNameIdentifier");
xmlSetNs(t, xmlns);
}
if (request->RelayState)
xmlNewTextChild(xmlnode, NULL, "RelayState", request->RelayState);
return xmlnode;
}
void
lasso_lib_register_name_identifier_request_set_oldProvidedNameIdentifier(LassoLibRegisterNameIdentifierRequest *node,
LassoLibOLDProvidedNameIdentifier *oldProvidedNameIdentifier)
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_REGISTER_NAME_IDENTIFIER_REQUEST(node));
g_assert(LASSO_IS_LIB_OLD_PROVIDED_NAME_IDENTIFIER(oldProvidedNameIdentifier));
xmlNode *t, *n;
LassoLibRegisterNameIdentifierRequest *request;
request = LASSO_LIB_REGISTER_NAME_IDENTIFIER_REQUEST(node);
parent_class->init_from_xml(node, xmlnode);
t = xmlnode->children;
while (t) {
n = t;
t = t->next;
if (n->type != XML_ELEMENT_NODE)
continue;
if (strcmp(n->name, "ProviderID") == 0) {
request->ProviderID = xmlNodeGetContent(n);
continue;
}
if (strcmp(n->name, "IDPProvidedNameIdentifier") == 0) {
request->IDPProvidedNameIdentifier =
lasso_saml_name_identifier_new_from_xmlNode(n);
continue;
}
if (strcmp(n->name, "SPProvidedNameIdentifier") == 0) {
request->SPProvidedNameIdentifier =
lasso_saml_name_identifier_new_from_xmlNode(n);
continue;
}
if (strcmp(n->name, "OldProvidedNameIdentifier") == 0) {
request->OldProvidedNameIdentifier =
lasso_saml_name_identifier_new_from_xmlNode(n);
continue;
}
if (strcmp(n->name, "RelayState") == 0) {
request->RelayState = xmlNodeGetContent(n);
continue;
}
}
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE (node),
LASSO_NODE (oldProvidedNameIdentifier),
FALSE);
}
void
lasso_lib_register_name_identifier_request_set_providerID(LassoLibRegisterNameIdentifierRequest *node,
const xmlChar *providerID)
static gchar*
build_query(LassoNode *node)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_REGISTER_NAME_IDENTIFIER_REQUEST(node));
g_assert(providerID != NULL);
/* FIXME : providerID length SHOULD be <= 1024 */
char *str, *t;
GString *s;
LassoLibRegisterNameIdentifierRequest *request;
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "ProviderID", providerID, FALSE);
request = LASSO_LIB_REGISTER_NAME_IDENTIFIER_REQUEST(node);
str = parent_class->build_query(node);
s = g_string_new(str);
g_free(str);
/* XXX Extension */
if (request->ProviderID) {
t = xmlURIEscapeStr(request->ProviderID, NULL);
g_string_append_printf(s, "&ProviderID=%s", t);
xmlFree(t);
}
if (request->IDPProvidedNameIdentifier) {
t = lasso_saml_name_identifier_build_query(
request->IDPProvidedNameIdentifier, "IDP", "IDPProvided");
g_string_append_printf(s, "&%s", t);
g_free(t);
}
if (request->SPProvidedNameIdentifier) {
t = lasso_saml_name_identifier_build_query(
request->SPProvidedNameIdentifier, "SP", "SPProvided");
g_string_append_printf(s, "&%s", t);
g_free(t);
}
if (request->OldProvidedNameIdentifier) {
t = lasso_saml_name_identifier_build_query(
request->OldProvidedNameIdentifier, "Old", "OldProvided");
g_string_append_printf(s, "&%s", t);
g_free(t);
}
if (request->RelayState)
g_string_append_printf(s, "&RelayState=%s", request->RelayState);
str = s->str;
g_string_free(s, FALSE);
return str;
}
void
lasso_lib_register_name_identifier_request_set_relayState(LassoLibRegisterNameIdentifierRequest *node,
const xmlChar *relayState)
static void
init_from_query(LassoNode *node, char **query_fields)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_REGISTER_NAME_IDENTIFIER_REQUEST(node));
g_assert(relayState != NULL);
LassoLibRegisterNameIdentifierRequest *request;
int i;
char *t;
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "RelayState", relayState, FALSE);
request = LASSO_LIB_REGISTER_NAME_IDENTIFIER_REQUEST(node);
request->IDPProvidedNameIdentifier = lasso_saml_name_identifier_new();
request->SPProvidedNameIdentifier = lasso_saml_name_identifier_new();
request->OldProvidedNameIdentifier = lasso_saml_name_identifier_new();
for (i=0; (t=query_fields[i]); i++) {
if (g_str_has_prefix(t, "ProviderID=")) {
request->ProviderID = g_strdup(t+11);
continue;
}
if (g_str_has_prefix(t, "RelayState=")) {
request->RelayState = g_strdup(t+11);
continue;
}
if (g_str_has_prefix(t, "IDPProvidedNameIdentifier=")) {
request->IDPProvidedNameIdentifier->content = g_strdup(t+26);
continue;
}
if (g_str_has_prefix(t, "IDPNameFormat=")) {
request->IDPProvidedNameIdentifier->Format = g_strdup(t+14);
continue;
}
if (g_str_has_prefix(t, "IDPNameQualifier=")) {
request->IDPProvidedNameIdentifier->NameQualifier = g_strdup(t+17);
continue;
}
if (g_str_has_prefix(t, "SPProvidedNameIdentifier=")) {
request->SPProvidedNameIdentifier->content = g_strdup(t+25);
continue;
}
if (g_str_has_prefix(t, "SPNameFormat=")) {
request->SPProvidedNameIdentifier->Format = g_strdup(t+13);
continue;
}
if (g_str_has_prefix(t, "SPNameQualifier=")) {
request->SPProvidedNameIdentifier->NameQualifier = g_strdup(t+16);
continue;
}
if (g_str_has_prefix(t, "OldProvidedNameIdentifier=")) {
request->OldProvidedNameIdentifier->content = g_strdup(t+26);
continue;
}
if (g_str_has_prefix(t, "OldNameFormat=")) {
request->OldProvidedNameIdentifier->Format = g_strdup(t+14);
continue;
}
if (g_str_has_prefix(t, "OldNameQualifier=")) {
request->OldProvidedNameIdentifier->NameQualifier = g_strdup(t+17);
continue;
}
}
parent_class->init_from_query(node, query_fields);
if (request->IDPProvidedNameIdentifier->content == NULL) {
g_object_unref(request->IDPProvidedNameIdentifier);
request->IDPProvidedNameIdentifier = NULL;
}
if (request->SPProvidedNameIdentifier->content == NULL) {
g_object_unref(request->SPProvidedNameIdentifier);
request->SPProvidedNameIdentifier = NULL;
}
if (request->OldProvidedNameIdentifier->content == NULL) {
g_object_unref(request->OldProvidedNameIdentifier);
request->OldProvidedNameIdentifier = NULL;
}
}
void
lasso_lib_register_name_identifier_request_set_spProvidedNameIdentifier(LassoLibRegisterNameIdentifierRequest *node,
LassoLibSPProvidedNameIdentifier *spProvidedNameIdentifier)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_REGISTER_NAME_IDENTIFIER_REQUEST(node));
g_assert(LASSO_IS_LIB_SP_PROVIDED_NAME_IDENTIFIER(spProvidedNameIdentifier));
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE (node),
LASSO_NODE (spProvidedNameIdentifier),
FALSE);
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
lasso_lib_register_name_identifier_request_instance_init(LassoLibRegisterNameIdentifierRequest *node)
instance_init(LassoLibRegisterNameIdentifierRequest *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
class->set_ns(LASSO_NODE(node), lassoLibHRef, lassoLibPrefix);
class->set_name(LASSO_NODE(node), "RegisterNameIdentifierRequest");
node->ProviderID = NULL;
node->IDPProvidedNameIdentifier = NULL;
node->SPProvidedNameIdentifier = NULL;
node->OldProvidedNameIdentifier = NULL;
node->RelayState = NULL;
}
static void
lasso_lib_register_name_identifier_request_class_init(LassoLibRegisterNameIdentifierRequestClass *klass)
class_init(LassoLibRegisterNameIdentifierRequestClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
LASSO_NODE_CLASS(klass)->build_query = build_query;
LASSO_NODE_CLASS(klass)->init_from_query = init_from_query;
}
GType lasso_lib_register_name_identifier_request_get_type() {
static GType this_type = 0;
GType
lasso_lib_register_name_identifier_request_get_type()
{
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibRegisterNameIdentifierRequestClass),
NULL,
NULL,
(GClassInitFunc) lasso_lib_register_name_identifier_request_class_init,
NULL,
NULL,
sizeof(LassoLibRegisterNameIdentifierRequest),
0,
(GInstanceInitFunc) lasso_lib_register_name_identifier_request_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_SAMLP_REQUEST_ABSTRACT,
"LassoLibRegisterNameIdentifierRequest",
&this_info, 0);
}
return this_type;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibRegisterNameIdentifierRequestClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoLibRegisterNameIdentifierRequest),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_SAMLP_REQUEST_ABSTRACT,
"LassoLibRegisterNameIdentifierRequest", &this_info, 0);
}
return this_type;
}
LassoNode* lasso_lib_register_name_identifier_request_new() {
return LASSO_NODE(g_object_new(LASSO_TYPE_LIB_REGISTER_NAME_IDENTIFIER_REQUEST,
NULL));
LassoNode*
lasso_lib_register_name_identifier_request_new()
{
return g_object_new(LASSO_TYPE_LIB_REGISTER_NAME_IDENTIFIER_REQUEST, NULL);
}
LassoNode*
lasso_lib_register_name_identifier_request_new_full(char *providerID,
LassoSamlNameIdentifier *idpNameIdentifier,
LassoSamlNameIdentifier *spNameIdentifier,
LassoSamlNameIdentifier *oldNameIdentifier)
{
LassoLibRegisterNameIdentifierRequest *request;
LassoSamlpRequestAbstract *request_base;
request = g_object_new(LASSO_TYPE_LIB_REGISTER_NAME_IDENTIFIER_REQUEST, NULL);
request_base = LASSO_SAMLP_REQUEST_ABSTRACT(request);
request_base->RequestID = lasso_build_unique_id(32);
request_base->MajorVersion = LASSO_LIB_MAJOR_VERSION_N;
request_base->MinorVersion = LASSO_LIB_MINOR_VERSION_N;
request_base->IssueInstant = lasso_get_current_time();
request->ProviderID = g_strdup(providerID);
request->IDPProvidedNameIdentifier = idpNameIdentifier;
request->SPProvidedNameIdentifier = spNameIdentifier;
request->OldProvidedNameIdentifier = oldNameIdentifier;
return LASSO_NODE(request);
}

View File

@ -30,10 +30,8 @@
extern "C" {
#endif /* __cplusplus */
#include <lasso/xml/saml_name_identifier.h>
#include <lasso/xml/samlp_request_abstract.h>
#include <lasso/xml/lib_idp_provided_name_identifier.h>
#include <lasso/xml/lib_old_provided_name_identifier.h>
#include <lasso/xml/lib_sp_provided_name_identifier.h>
#define LASSO_TYPE_LIB_REGISTER_NAME_IDENTIFIER_REQUEST (lasso_lib_register_name_identifier_request_get_type())
#define LASSO_LIB_REGISTER_NAME_IDENTIFIER_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_LIB_REGISTER_NAME_IDENTIFIER_REQUEST, LassoLibRegisterNameIdentifierRequest))
@ -46,31 +44,34 @@ typedef struct _LassoLibRegisterNameIdentifierRequest LassoLibRegisterNameIdenti
typedef struct _LassoLibRegisterNameIdentifierRequestClass LassoLibRegisterNameIdentifierRequestClass;
struct _LassoLibRegisterNameIdentifierRequest {
LassoSamlpRequestAbstract parent;
/*< private >*/
LassoSamlpRequestAbstract parent;
/* <xs:element ref="Extension" minOccurs="0" maxOccurs="unbounded"/> */
LassoNode *Extension; /* TODO */
/* <xs:element ref="ProviderID"/> */
char *ProviderID;
/* <xs:element ref="IDPProvidedNameIdentifier"/> */
LassoSamlNameIdentifier *IDPProvidedNameIdentifier;
/* <xs:element ref="SPProvidedNameIdentifier"/> */
LassoSamlNameIdentifier *SPProvidedNameIdentifier;
/* <xs:element ref="OldProvidedNameIdentifier"/> */
LassoSamlNameIdentifier *OldProvidedNameIdentifier;
/* <xs:element ref="RelayState" minOccurs="0"/> */
char *RelayState;
};
struct _LassoLibRegisterNameIdentifierRequestClass {
LassoSamlpRequestAbstractClass parent;
LassoSamlpRequestAbstractClass parent;
};
LASSO_EXPORT GType lasso_lib_register_name_identifier_request_get_type(void);
LASSO_EXPORT LassoNode* lasso_lib_register_name_identifier_request_new(void);
LASSO_EXPORT void lasso_lib_register_name_identifier_request_set_relayState (LassoLibRegisterNameIdentifierRequest *,
const xmlChar *);
LASSO_EXPORT void lasso_lib_register_name_identifier_request_set_providerID (LassoLibRegisterNameIdentifierRequest *,
const xmlChar *);
LASSO_EXPORT void lasso_lib_register_name_identifier_request_set_idpProvidedNameIdentifier (LassoLibRegisterNameIdentifierRequest *,
LassoLibIDPProvidedNameIdentifier *);
LASSO_EXPORT void lasso_lib_register_name_identifier_request_set_oldProvidedNameIdentifier (LassoLibRegisterNameIdentifierRequest *,
LassoLibOLDProvidedNameIdentifier *);
LASSO_EXPORT void lasso_lib_register_name_identifier_request_set_spProvidedNameIdentifier (LassoLibRegisterNameIdentifierRequest *,
LassoLibSPProvidedNameIdentifier *);
LASSO_EXPORT LassoNode* lasso_lib_register_name_identifier_request_new_full(
char *providerID,
LassoSamlNameIdentifier *idpNameIdentifier,
LassoSamlNameIdentifier *spNameIdentifier,
LassoSamlNameIdentifier *oldNameIdentifier);
#ifdef __cplusplus
}

View File

@ -32,48 +32,96 @@ The Schema fragment (liberty-idff-protocols-schema-v1.2.xsd):
*/
/*****************************************************************************/
/* private methods */
/*****************************************************************************/
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
xmlnode = parent_class->get_xmlNode(node);
xmlNodeSetName(xmlnode, "RegisterNameIdentifierResponse");
return xmlnode;
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
lasso_lib_register_name_identifier_response_instance_init(LassoLibRegisterNameIdentifierResponse *node)
instance_init(LassoLibRegisterNameIdentifierResponse *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
/* namespace herited from lib:StatusResponse */
class->set_name(LASSO_NODE(node), "RegisterNameIdentifierResponse");
}
static void
lasso_lib_register_name_identifier_response_class_init(LassoLibRegisterNameIdentifierResponseClass *klass)
class_init(LassoLibRegisterNameIdentifierResponseClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
}
GType lasso_lib_register_name_identifier_response_get_type() {
static GType register_name_identifier_response_type = 0;
if (!register_name_identifier_response_type) {
static const GTypeInfo register_name_identifier_response_info = {
sizeof (LassoLibRegisterNameIdentifierResponseClass),
NULL,
NULL,
(GClassInitFunc) lasso_lib_register_name_identifier_response_class_init,
NULL,
NULL,
sizeof(LassoLibRegisterNameIdentifierResponse),
0,
(GInstanceInitFunc) lasso_lib_register_name_identifier_response_instance_init,
};
register_name_identifier_response_type = g_type_register_static(LASSO_TYPE_LIB_STATUS_RESPONSE,
"LassoLibRegisterNameIdentifierResponse",
&register_name_identifier_response_info, 0);
}
return register_name_identifier_response_type;
}
LassoNode* lasso_lib_register_name_identifier_response_new()
GType
lasso_lib_register_name_identifier_response_get_type()
{
return LASSO_NODE(g_object_new(LASSO_TYPE_LIB_REGISTER_NAME_IDENTIFIER_RESPONSE, NULL));
static GType register_name_identifier_response_type = 0;
if (!register_name_identifier_response_type) {
static const GTypeInfo register_name_identifier_response_info = {
sizeof (LassoLibRegisterNameIdentifierResponseClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoLibRegisterNameIdentifierResponse),
0,
(GInstanceInitFunc) instance_init,
};
register_name_identifier_response_type = g_type_register_static(
LASSO_TYPE_LIB_STATUS_RESPONSE,
"LassoLibRegisterNameIdentifierResponse",
&register_name_identifier_response_info, 0);
}
return register_name_identifier_response_type;
}
LassoNode*
lasso_lib_register_name_identifier_response_new()
{
return g_object_new(LASSO_TYPE_LIB_REGISTER_NAME_IDENTIFIER_RESPONSE, NULL);
}
LassoNode*
lasso_lib_register_name_identifier_response_new_full(char *providerID,
const char *statusCodeValue, LassoLibRegisterNameIdentifierRequest *request)
{
LassoSamlpResponseAbstract *response;
response = g_object_new(LASSO_TYPE_LIB_REGISTER_NAME_IDENTIFIER_RESPONSE, NULL);
response->ResponseID = lasso_build_unique_id(32);
response->MajorVersion = LASSO_LIB_MAJOR_VERSION_N;
response->MinorVersion = LASSO_LIB_MINOR_VERSION_N;
response->IssueInstant = lasso_get_current_time();
response->InResponseTo = LASSO_SAMLP_REQUEST_ABSTRACT(request)->RequestID;
response->Recipient = request->ProviderID;
LASSO_LIB_STATUS_RESPONSE(response)->ProviderID = g_strdup(providerID);
if (request->RelayState)
LASSO_LIB_STATUS_RESPONSE(response)->RelayState = g_strdup(request->RelayState);
LASSO_LIB_STATUS_RESPONSE(response)->Status = lasso_samlp_status_new();
LASSO_LIB_STATUS_RESPONSE(response)->Status->StatusCode = lasso_samlp_status_code_new();
LASSO_LIB_STATUS_RESPONSE(response)->Status->StatusCode->Value = g_strdup(statusCodeValue);
return LASSO_NODE(response);
}

View File

@ -30,6 +30,7 @@
extern "C" {
#endif /* __cplusplus */
#include <lasso/xml/lib_register_name_identifier_request.h>
#include <lasso/xml/lib_status_response.h>
#define LASSO_TYPE_LIB_REGISTER_NAME_IDENTIFIER_RESPONSE (lasso_lib_register_name_identifier_response_get_type())
@ -43,16 +44,19 @@ typedef struct _LassoLibRegisterNameIdentifierResponse LassoLibRegisterNameIdent
typedef struct _LassoLibRegisterNameIdentifierResponseClass LassoLibRegisterNameIdentifierResponseClass;
struct _LassoLibRegisterNameIdentifierResponse {
LassoLibStatusResponse parent;
/*< private >*/
LassoLibStatusResponse parent;
};
struct _LassoLibRegisterNameIdentifierResponseClass {
LassoLibStatusResponseClass parent;
LassoLibStatusResponseClass parent;
};
LASSO_EXPORT GType lasso_lib_register_name_identifier_response_get_type(void);
LASSO_EXPORT LassoNode* lasso_lib_register_name_identifier_response_new(void);
LASSO_EXPORT LassoNode* lasso_lib_register_name_identifier_response_new_full(
char *providerID,
const char *statusCodeValue,
LassoLibRegisterNameIdentifierRequest *request);
#ifdef __cplusplus
}

View File

@ -45,89 +45,110 @@ Schema fragment (liberty-idff-protocols-schema-v1.2.xsd):
*/
/*****************************************************************************/
/* public methods */
/* private methods */
/*****************************************************************************/
void
lasso_lib_request_authn_context_add_authnContextClassRef(LassoLibRequestAuthnContext *node,
const xmlChar *authnContextClassRef)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_REQUEST_AUTHN_CONTEXT(node));
g_assert(authnContextClassRef != NULL);
static LassoNodeClass *parent_class = NULL;
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "AuthnContextClassRef",
authnContextClassRef, TRUE);
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
LassoLibRequestAuthnContext *context = LASSO_LIB_REQUEST_AUTHN_CONTEXT(node);
xmlnode = parent_class->get_xmlNode(node);
xmlNodeSetName(xmlnode, "RequestAuthnContext");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
if (context->AuthnContextClassRef)
xmlNewTextChild(xmlnode, NULL,
"AuthnContextClassRef", context->AuthnContextClassRef);
if (context->AuthnContextStatementRef)
xmlNewTextChild(xmlnode, NULL,
"AuthnContextStatementRef", context->AuthnContextStatementRef);
if (context->AuthnContextComparisonType)
xmlNewTextChild(xmlnode, NULL,
"AuthnContextComparisonType", context->AuthnContextComparisonType);
return xmlnode;
}
void
lasso_lib_request_authn_context_add_authnContextStatementRef(LassoLibRequestAuthnContext *node,
const xmlChar *authnContextStatementRef)
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_REQUEST_AUTHN_CONTEXT(node));
g_assert(authnContextStatementRef != NULL);
LassoLibRequestAuthnContext *context = LASSO_LIB_REQUEST_AUTHN_CONTEXT(node);
xmlNode *t, *n;
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "AuthnContextStatementRef",
authnContextStatementRef, TRUE);
parent_class->init_from_xml(node, xmlnode);
t = xmlnode->children;
while (t) {
n = t;
t = t->next;
if (n->type != XML_ELEMENT_NODE)
continue;
if (strcmp(n->name, "AuthnContextClassRef") == 0) {
context->AuthnContextClassRef = xmlNodeGetContent(n);
continue;
}
if (strcmp(n->name, "AuthnContextStatementRef") == 0) {
context->AuthnContextStatementRef = xmlNodeGetContent(n);
continue;
}
if (strcmp(n->name, "AuthnContextComparisonType") == 0) {
context->AuthnContextComparisonType = xmlNodeGetContent(n);
continue;
}
}
}
void
lasso_lib_request_authn_context_set_authnContextComparison(LassoLibRequestAuthnContext *node,
const xmlChar *authnContextComparison)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_REQUEST_AUTHN_CONTEXT(node));
g_assert(authnContextComparison != NULL);
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "AuthnContextComparison",
authnContextComparison, FALSE);
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
lasso_lib_request_authn_context_instance_init(LassoLibRequestAuthnContext *node)
instance_init(LassoLibRequestAuthnContext *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
class->set_ns(LASSO_NODE(node), lassoLibHRef, lassoLibPrefix);
class->set_name(LASSO_NODE(node), "RequestAuthnContext");
node->AuthnContextClassRef = NULL;
node->AuthnContextStatementRef = NULL;
node->AuthnContextComparisonType = NULL;
}
static void
lasso_lib_request_authn_context_class_init(LassoLibRequestAuthnContextClass *klass)
class_init(LassoLibRequestAuthnContextClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
}
GType lasso_lib_request_authn_context_get_type() {
static GType this_type = 0;
GType
lasso_lib_request_authn_context_get_type()
{
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibRequestAuthnContextClass),
NULL,
NULL,
(GClassInitFunc) lasso_lib_request_authn_context_class_init,
NULL,
NULL,
sizeof(LassoLibRequestAuthnContext),
0,
(GInstanceInitFunc) lasso_lib_request_authn_context_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoLibRequestAuthnContext",
&this_info, 0);
}
return this_type;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibRequestAuthnContextClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoLibRequestAuthnContext),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoLibRequestAuthnContext", &this_info, 0);
}
return this_type;
}
LassoNode* lasso_lib_request_authn_context_new() {
return LASSO_NODE(g_object_new(LASSO_TYPE_LIB_REQUEST_AUTHN_CONTEXT, NULL));
LassoNode*
lasso_lib_request_authn_context_new()
{
return LASSO_NODE(g_object_new(LASSO_TYPE_LIB_REQUEST_AUTHN_CONTEXT, NULL));
}

View File

@ -43,26 +43,22 @@ typedef struct _LassoLibRequestAuthnContext LassoLibRequestAuthnContext;
typedef struct _LassoLibRequestAuthnContextClass LassoLibRequestAuthnContextClass;
struct _LassoLibRequestAuthnContext {
LassoNode parent;
/*< private >*/
LassoNode parent;
/* <xs:element name="AuthnContextClassRef" type="xs:anyURI" maxOccurs="unbounded"/> */
char *AuthnContextClassRef; /* XXX: should actually be a list */
/* <xs:element name="AuthnContextStatementRef" type="xs:anyURI" maxOccurs="unbounded"/> */
char *AuthnContextStatementRef; /* XXX: idem */
/* <xs:element name="AuthnContextComparison" type="AuthnContextComparisonType" minOccurs="0"/> */
char *AuthnContextComparisonType; /* XXX should be enum ? */
};
struct _LassoLibRequestAuthnContextClass {
LassoNodeClass parent;
LassoNodeClass parent;
};
LASSO_EXPORT GType lasso_lib_request_authn_context_get_type(void);
LASSO_EXPORT LassoNode* lasso_lib_request_authn_context_new(void);
LASSO_EXPORT void lasso_lib_request_authn_context_add_authnContextClassRef (LassoLibRequestAuthnContext *node,
const xmlChar *authnContextClassRef);
LASSO_EXPORT void lasso_lib_request_authn_context_add_authnContextStatementRef (LassoLibRequestAuthnContext *node,
const xmlChar *authnContextStatementRef);
LASSO_EXPORT void lasso_lib_request_authn_context_set_authnContextComparison (LassoLibRequestAuthnContext *node,
const xmlChar *authnContextComparison);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -41,97 +41,95 @@ Schema fragment (liberty-idff-protocols-schema-v1.2.xsd):
*/
/*****************************************************************************/
/* public methods */
/* private methods */
/*****************************************************************************/
/**
* lasso_lib_scoping_set_proxyCount:
* @node : the pointer to <lib:Scoping/> node object
* @proxyCount: the value of "ProxyCount" element (should be superior or equal
* to 0).
*
* Sets the "ProxyCount" element [optional].
*
* It's the upper limit on the number of proxying steps the requester wishes to
* specify for the authentication request.
**/
void
lasso_lib_scoping_set_proxyCount(LassoLibScoping *node,
gint proxyCount)
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
gchar str[6];
LassoNodeClass *class;
xmlNode *xmlnode;
LassoLibScoping *scoping = LASSO_LIB_SCOPING(node);
char s[20];
g_assert(LASSO_IS_LIB_SCOPING(node));
g_assert(proxyCount >= 0);
xmlnode = xmlNewNode(NULL, "Scoping");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
g_snprintf(str, 6, "%d", proxyCount);
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "ProxyCount", str, FALSE);
if (scoping->ProxyCount) {
snprintf(s, 19, "%d", scoping->ProxyCount);
xmlNewTextChild(xmlnode, NULL, "ProxyCount", s);
}
if (scoping->IDPList)
xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(scoping->IDPList)));
return xmlnode;
}
/**
* lasso_lib_scoping_set_idpList:
* @node : the pointer to <lib:Scoping/> node object
* @idpList: the value of "IDPList" element
*
* Sets the "IDPList" element [optional].
*
* It's an ordered list of identity providers which the requester prefers to
* use in authenticating the Principal. This list is a suggestion only, and may
* be ignored or added to by the recipient of the message.
**/
void
lasso_lib_scoping_set_idpList(LassoLibScoping *node,
LassoLibIDPList *idpList)
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_SCOPING(node));
g_assert(LASSO_IS_LIB_IDP_LIST(idpList));
LassoLibScoping *scoping = LASSO_LIB_SCOPING(node);
xmlNode *t;
char *s;
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE (node), LASSO_NODE(idpList), FALSE);
parent_class->init_from_xml(node, xmlnode);
t = xmlnode->children;
while (t) {
if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "ProxyCount") == 0) {
s = xmlNodeGetContent(t);
scoping->ProxyCount = atoi(s);
xmlFree(s);
}
if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "IDPList") == 0)
scoping->IDPList = LASSO_LIB_IDP_LIST(lasso_node_new_from_xmlNode(t));
t = t->next;
}
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
lasso_lib_scoping_instance_init(LassoLibScoping *node)
instance_init(LassoLibScoping *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
class->set_ns(LASSO_NODE(node), lassoLibHRef, lassoLibPrefix);
class->set_name(LASSO_NODE(node), "Scoping");
node->ProxyCount = 0;
node->IDPList = NULL;
}
static void
lasso_lib_scoping_class_init(LassoLibScopingClass *klass)
class_init(LassoLibScopingClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
}
GType lasso_lib_scoping_get_type() {
static GType this_type = 0;
GType
lasso_lib_scoping_get_type()
{
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibScopingClass),
NULL,
NULL,
(GClassInitFunc) lasso_lib_scoping_class_init,
NULL,
NULL,
sizeof(LassoLibScoping),
0,
(GInstanceInitFunc) lasso_lib_scoping_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoLibScoping",
&this_info, 0);
}
return this_type;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibScopingClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoLibScoping),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoLibScoping",
&this_info, 0);
}
return this_type;
}
/**
@ -146,7 +144,9 @@ GType lasso_lib_scoping_get_type() {
*
* Return value: a new @LassoLibScoping
**/
LassoNode* lasso_lib_scoping_new()
LassoLibScoping*
lasso_lib_scoping_new()
{
return LASSO_NODE(g_object_new(LASSO_TYPE_LIB_SCOPING, NULL));
return g_object_new(LASSO_TYPE_LIB_SCOPING, NULL);
}

View File

@ -44,22 +44,19 @@ typedef struct _LassoLibScoping LassoLibScoping;
typedef struct _LassoLibScopingClass LassoLibScopingClass;
struct _LassoLibScoping {
LassoNode parent;
/*< private >*/
LassoNode parent;
/* <xs:element name="ProxyCount" type="xs:nonNegativeInteger" minOccurs="0"/> */
int ProxyCount;
/* <xs:element ref="IDPList" minOccurs="0"/> */
LassoLibIDPList *IDPList;
};
struct _LassoLibScopingClass {
LassoNodeClass parent;
LassoNodeClass parent;
};
LASSO_EXPORT GType lasso_lib_scoping_get_type(void);
LASSO_EXPORT LassoNode* lasso_lib_scoping_new(void);
LASSO_EXPORT void lasso_lib_scoping_set_proxyCount (LassoLibScoping *node,
gint proxyCount);
LASSO_EXPORT void lasso_lib_scoping_set_idpList (LassoLibScoping *node,
LassoLibIDPList *idpList);
LASSO_EXPORT LassoLibScoping* lasso_lib_scoping_new(void);
#ifdef __cplusplus
}

View File

@ -1,88 +0,0 @@
/* $Id$
*
* Lasso - A free implementation of the Samlerty Alliance specifications.
*
* Copyright (C) 2004 Entr'ouvert
* http://lasso.entrouvert.org
*
* Authors: Nicolas Clapies <nclapies@entrouvert.com>
* Valery Febvre <vfebvre@easter-eggs.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <lasso/xml/lib_sp_provided_name_identifier.h>
/*
The Schema fragment (liberty-idff-protocols-schema-v1.2.xsd):
<xs:element name="SPProvidedNameIdentifier" type="saml:NameIdentifierType"/>
*/
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
lasso_lib_sp_provided_name_identifier_instance_init(LassoLibSPProvidedNameIdentifier *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
class->set_ns(LASSO_NODE(node), lassoLibHRef, lassoLibPrefix);
class->set_name(LASSO_NODE(node), "SPProvidedNameIdentifier");
}
static void
lasso_lib_sp_provided_name_identifier_class_init(LassoLibSPProvidedNameIdentifierClass *klass)
{
}
GType lasso_lib_sp_provided_name_identifier_get_type() {
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibSPProvidedNameIdentifierClass),
NULL,
NULL,
(GClassInitFunc) lasso_lib_sp_provided_name_identifier_class_init,
NULL,
NULL,
sizeof(LassoLibSPProvidedNameIdentifierClass),
0,
(GInstanceInitFunc) lasso_lib_sp_provided_name_identifier_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_SAML_NAME_IDENTIFIER,
"LassoLibSPProvidedNameIdentifier",
&this_info, 0);
}
return this_type;
}
LassoNode* lasso_lib_sp_provided_name_identifier_new(const xmlChar *content) {
LassoNode *node;
g_assert(content != NULL);
node = LASSO_NODE(g_object_new(LASSO_TYPE_LIB_SP_PROVIDED_NAME_IDENTIFIER,
NULL));
xmlNodeSetContent(LASSO_NODE_GET_CLASS(node)->get_xmlNode(node),
content);
return node;
}

View File

@ -1,61 +0,0 @@
/* $Id$
*
* Lasso - A free implementation of the Liberty Alliance specifications.
*
* Copyright (C) 2004 Entr'ouvert
* http://lasso.entrouvert.org
*
* Authors: Nicolas Clapies <nclapies@entrouvert.com>
* Valery Febvre <vfebvre@easter-eggs.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __LASSO_LIB_SP_PROVIDED_NAME_IDENTIFIER_H__
#define __LASSO_LIB_SP_PROVIDED_NAME_IDENTIFIER_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <lasso/xml/saml_name_identifier.h>
#define LASSO_TYPE_LIB_SP_PROVIDED_NAME_IDENTIFIER (lasso_lib_sp_provided_name_identifier_get_type())
#define LASSO_LIB_SP_PROVIDED_NAME_IDENTIFIER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_LIB_SP_PROVIDED_NAME_IDENTIFIER, LassoLibSPProvidedNameIdentifier))
#define LASSO_LIB_SP_PROVIDED_NAME_IDENTIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), LASSO_TYPE_LIB_SP_PROVIDED_NAME_IDENTIFIER, LassoLibSPProvidedNameIdentifierClass))
#define LASSO_IS_LIB_SP_PROVIDED_NAME_IDENTIFIER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), LASSO_TYPE_LIB_SP_PROVIDED_NAME_IDENTIFIER))
#define LASSO_IS_LIB_SP_PROVIDED_NAME_IDENTIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LASSO_TYPE_LIB_SP_PROVIDED_NAME_IDENTIFIER))
#define LASSO_LIB_SP_PROVIDED_NAME_IDENTIFIER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), LASSO_TYPE_LIB_SP_PROVIDED_NAME_IDENTIFIER, LassoLibSPProvidedNameIdentifierClass))
typedef struct _LassoLibSPProvidedNameIdentifier LassoLibSPProvidedNameIdentifier;
typedef struct _LassoLibSPProvidedNameIdentifierClass LassoLibSPProvidedNameIdentifierClass;
struct _LassoLibSPProvidedNameIdentifier {
LassoSamlNameIdentifier parent;
/*< private >*/
};
struct _LassoLibSPProvidedNameIdentifierClass {
LassoSamlNameIdentifierClass parent;
};
LASSO_EXPORT GType lasso_lib_sp_provided_name_identifier_get_type(void);
LASSO_EXPORT LassoNode* lasso_lib_sp_provided_name_identifier_new(const xmlChar *content);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __LASSO_LIB_SP_PROVIDED_NAME_IDENTIFIER_H__ */

View File

@ -24,6 +24,7 @@
*/
#include <lasso/xml/lib_status_response.h>
#include <libxml/uri.h>
/*
Schema fragment (liberty-idff-protocols-schema-v1.2.xsd):
@ -54,88 +55,162 @@ From liberty-metadata-v1.0.xsd:
*/
/*****************************************************************************/
/* public methods */
/* private methods */
/*****************************************************************************/
void
lasso_lib_status_response_set_providerID(LassoLibStatusResponse *node,
const xmlChar *providerID)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_STATUS_RESPONSE(node));
g_assert(providerID != NULL);
/* FIXME : providerID length SHOULD be <= 1024 */
static LassoNodeClass *parent_class = NULL;
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "ProviderID", providerID, FALSE);
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
LassoLibStatusResponse *response = LASSO_LIB_STATUS_RESPONSE(node);
xmlnode = parent_class->get_xmlNode(node);
xmlNodeSetName(xmlnode, "StatusResponse");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
if (response->ProviderID)
xmlNewTextChild(xmlnode, NULL, "ProviderID", response->ProviderID);
if (response->Status)
xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(response->Status)));
if (response->RelayState)
xmlNewTextChild(xmlnode, NULL, "RelayState", response->RelayState);
return xmlnode;
}
void
lasso_lib_status_response_set_relayState(LassoLibStatusResponse *node,
const xmlChar *relayState)
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_STATUS_RESPONSE(node));
g_assert(relayState != NULL);
LassoLibStatusResponse *response = LASSO_LIB_STATUS_RESPONSE(node);
xmlNode *t;
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "RelayState", relayState, FALSE);
parent_class->init_from_xml(node, xmlnode);
t = xmlnode->children;
while (t) {
if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "ProviderID") == 0)
response->ProviderID = xmlNodeGetContent(t);
if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "Status") == 0)
response->Status = LASSO_SAMLP_STATUS(lasso_node_new_from_xmlNode(t));
if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "RelayState") == 0)
response->RelayState = xmlNodeGetContent(t);
t = t->next;
}
}
void
lasso_lib_status_response_set_status(LassoLibStatusResponse *node,
LassoSamlpStatus *status)
static gchar*
build_query(LassoNode *node)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_STATUS_RESPONSE(node));
g_assert(LASSO_IS_SAMLP_STATUS(status));
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE (node), LASSO_NODE (status), FALSE);
char *str, *t;
GString *s;
LassoLibStatusResponse *response = LASSO_LIB_STATUS_RESPONSE(node);
str = parent_class->build_query(node);
s = g_string_new(str);
g_free(str);
/* XXX Extension */
if (response->ProviderID) {
t = xmlURIEscapeStr(response->ProviderID, NULL);
g_string_append_printf(s, "&ProviderID=%s", t);
xmlFree(t);
}
if (response->RelayState) {
t = xmlURIEscapeStr(response->RelayState, NULL);
g_string_append_printf(s, "&RelayState=%s", t);
xmlFree(t);
}
if (response->Status) {
t = xmlURIEscapeStr(response->Status->StatusCode->Value, NULL);
g_string_append_printf(s, "&Value=%s", t);
xmlFree(t);
}
str = s->str;
g_string_free(s, FALSE);
return str;
}
static void
init_from_query(LassoNode *node, char **query_fields)
{
LassoLibStatusResponse *response = LASSO_LIB_STATUS_RESPONSE(node);
int i;
char *t;
for (i=0; (t=query_fields[i]); i++) {
if (g_str_has_prefix(t, "ProviderID=")) {
response->ProviderID = g_strdup(t+11);
continue;
}
if (g_str_has_prefix(t, "RelayState=")) {
response->RelayState = g_strdup(t+11);
continue;
}
if (g_str_has_prefix(t, "Value=")) {
response->Status = lasso_samlp_status_new();
response->Status->StatusCode = lasso_samlp_status_code_new();
response->Status->StatusCode->Value = g_strdup(t+6);
continue;
}
}
parent_class->init_from_query(node, query_fields);
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
lasso_lib_status_response_instance_init(LassoLibStatusResponse *node)
instance_init(LassoLibStatusResponse *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
class->set_ns(LASSO_NODE(node), lassoLibHRef, lassoLibPrefix);
class->set_name(LASSO_NODE(node), "StatusResponse");
node->ProviderID = NULL;
node->Status = NULL;
node->RelayState = NULL;
}
static void
lasso_lib_status_response_class_init(LassoLibStatusResponseClass *klass)
class_init(LassoLibStatusResponseClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
LASSO_NODE_CLASS(klass)->build_query = build_query;
LASSO_NODE_CLASS(klass)->init_from_query = init_from_query;
}
GType lasso_lib_status_response_get_type() {
static GType status_response_type = 0;
GType
lasso_lib_status_response_get_type()
{
static GType status_response_type = 0;
if (!status_response_type) {
static const GTypeInfo status_response_info = {
sizeof (LassoLibStatusResponseClass),
NULL,
NULL,
(GClassInitFunc) lasso_lib_status_response_class_init,
NULL,
NULL,
sizeof(LassoLibStatusResponse),
0,
(GInstanceInitFunc) lasso_lib_status_response_instance_init,
};
status_response_type = g_type_register_static(LASSO_TYPE_SAMLP_RESPONSE_ABSTRACT,
"LassoLibStatusResponse",
&status_response_info, 0);
}
return status_response_type;
if (!status_response_type) {
static const GTypeInfo status_response_info = {
sizeof (LassoLibStatusResponseClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoLibStatusResponse),
0,
(GInstanceInitFunc) instance_init,
};
status_response_type = g_type_register_static(LASSO_TYPE_SAMLP_RESPONSE_ABSTRACT,
"LassoLibStatusResponse", &status_response_info, 0);
}
return status_response_type;
}
LassoNode* lasso_lib_status_response_new()
{
return LASSO_NODE(g_object_new(LASSO_TYPE_LIB_STATUS_RESPONSE, NULL));
return LASSO_NODE(g_object_new(LASSO_TYPE_LIB_STATUS_RESPONSE, NULL));
}

View File

@ -44,26 +44,23 @@ typedef struct _LassoLibStatusResponse LassoLibStatusResponse;
typedef struct _LassoLibStatusResponseClass LassoLibStatusResponseClass;
struct _LassoLibStatusResponse {
LassoSamlpResponseAbstract parent;
/*< private >*/
LassoSamlpResponseAbstract parent;
/* <xs:element ref="ProviderID"/> */
char *ProviderID;
/* <xs:element ref="samlp:Status"/> */
LassoSamlpStatus *Status;
/* <xs:element ref="RelayState" minOccurs="0"/> */
char *RelayState;
};
struct _LassoLibStatusResponseClass {
LassoSamlpResponseAbstractClass parent;
LassoSamlpResponseAbstractClass parent;
};
LASSO_EXPORT GType lasso_lib_status_response_get_type(void);
LASSO_EXPORT LassoNode* lasso_lib_status_response_new(void);
LASSO_EXPORT void lasso_lib_status_response_set_providerID (LassoLibStatusResponse *node,
const xmlChar *providerID);
LASSO_EXPORT void lasso_lib_status_response_set_relayState (LassoLibStatusResponse *node,
const xmlChar *relayState);
LASSO_EXPORT void lasso_lib_status_response_set_status (LassoLibStatusResponse *node,
LassoSamlpStatus *status);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -42,117 +42,98 @@ The schema fragment (liberty-idff-protocols-schema-v1.2.xsd):
*/
/*****************************************************************************/
/* public methods */
/* private methods */
/*****************************************************************************/
void
lasso_lib_subject_set_idpProvidedNameIdentifier(LassoLibSubject *node,
LassoLibIDPProvidedNameIdentifier *idpProvidedNameIdentifier)
{
LassoNodeClass *class;
g_assert(LASSO_IS_LIB_SUBJECT(node));
g_assert(LASSO_IS_LIB_IDP_PROVIDED_NAME_IDENTIFIER(idpProvidedNameIdentifier));
static LassoNodeClass *parent_class = NULL;
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE (node), LASSO_NODE(idpProvidedNameIdentifier), FALSE);
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode, *t;
LassoLibSubject *subject = LASSO_LIB_SUBJECT(node);
xmlnode = parent_class->get_xmlNode(node);
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
if (subject->IDPProvidedNameIdentifier) {
t = xmlAddChild(xmlnode, lasso_node_get_xmlNode(
LASSO_NODE(subject->IDPProvidedNameIdentifier)));
xmlNodeSetName(xmlnode, "IDPProvidedNameIdentifier");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
}
return xmlnode;
}
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibSubject *subject = LASSO_LIB_SUBJECT(node);
xmlNode *t;
parent_class->init_from_xml(node, xmlnode);
t = xmlnode->children;
while (t) {
if (t->type != XML_ELEMENT_NODE) {
t = t->next;
continue;
}
if (strcmp(t->name, "IDPProvidedNameIdentifier") != 0) {
t = t->next;
continue;
}
subject->IDPProvidedNameIdentifier = lasso_saml_name_identifier_new_from_xmlNode(t);
break;
}
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
enum {
LASSO_LIB_SUBJECT_USE_XSITYPE = 1
};
static void
lasso_lib_subject_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
instance_init(LassoLibSubject *node)
{
LassoLibSubject *self = LASSO_LIB_SUBJECT(object);
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(object));
switch (property_id) {
case LASSO_LIB_SUBJECT_USE_XSITYPE:
self->use_xsitype = g_value_get_boolean (value);
if (self->use_xsitype == TRUE) {
/* namespace and name were already set in parent class
LassoSamlAssertion */
class->new_ns_prop(LASSO_NODE(object),
"type", "lib:SubjectType",
lassoXsiHRef, lassoXsiPrefix);
}
else {
/* node name was already set in parent class LassoSamlAssertion
just change ns */
class->set_ns(LASSO_NODE(object), lassoLibHRef, lassoLibPrefix);
}
break;
default:
/* We don't have any other property... */
g_assert (FALSE);
break;
}
node->IDPProvidedNameIdentifier = NULL;
}
static void
lasso_lib_subject_instance_init(LassoLibSubject *node)
class_init(LassoLibSubjectClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
}
static void
lasso_lib_subject_class_init(LassoLibSubjectClass *g_class,
gpointer g_class_data)
GType
lasso_lib_subject_get_type()
{
GObjectClass *gobject_class = G_OBJECT_CLASS (g_class);
GParamSpec *pspec;
static GType this_type = 0;
/* override parent class methods */
gobject_class->set_property = lasso_lib_subject_set_property;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibSubjectClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoLibSubject),
0,
(GInstanceInitFunc) instance_init,
};
pspec = g_param_spec_boolean ("use_xsitype",
"use_xsitype",
"using xsi:type",
FALSE,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE);
g_object_class_install_property (gobject_class,
LASSO_LIB_SUBJECT_USE_XSITYPE,
pspec);
this_type = g_type_register_static(LASSO_TYPE_SAML_SUBJECT,
"LassoLibSubject", &this_info, 0);
}
return this_type;
}
GType lasso_lib_subject_get_type() {
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoLibSubjectClass),
NULL,
NULL,
(GClassInitFunc) lasso_lib_subject_class_init,
NULL,
NULL,
sizeof(LassoLibSubject),
0,
(GInstanceInitFunc) lasso_lib_subject_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_SAML_SUBJECT,
"LassoLibSubject",
&this_info, 0);
}
return this_type;
}
LassoNode*
lasso_lib_subject_new(gboolean use_xsitype)
LassoLibSubject*
lasso_lib_subject_new()
{
LassoNode *node;
node = LASSO_NODE(g_object_new(LASSO_TYPE_LIB_SUBJECT,
"use_xsitype", use_xsitype,
NULL));
return node;
return g_object_new(LASSO_TYPE_LIB_SUBJECT, NULL);
}

View File

@ -31,7 +31,7 @@ extern "C" {
#endif /* __cplusplus */
#include <lasso/xml/saml_subject.h>
#include <lasso/xml/lib_idp_provided_name_identifier.h>
#include <lasso/xml/saml_name_identifier.h>
#define LASSO_TYPE_LIB_SUBJECT (lasso_lib_subject_get_type())
#define LASSO_LIB_SUBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_LIB_SUBJECT, LassoLibSubject))
@ -44,21 +44,18 @@ typedef struct _LassoLibSubject LassoLibSubject;
typedef struct _LassoLibSubjectClass LassoLibSubjectClass;
struct _LassoLibSubject {
LassoSamlSubject parent;
/*< private >*/
gboolean use_xsitype;
LassoSamlSubject parent;
/* <xs:element ref="IDPProvidedNameIdentifier"/> */
LassoSamlNameIdentifier *IDPProvidedNameIdentifier;
};
struct _LassoLibSubjectClass {
LassoSamlSubjectClass parent;
LassoSamlSubjectClass parent;
};
LASSO_EXPORT GType lasso_lib_subject_get_type(void);
LASSO_EXPORT LassoLibSubject* lasso_lib_subject_new(void);
LASSO_EXPORT LassoNode* lasso_lib_subject_new(gboolean use_xsitype);
LASSO_EXPORT void lasso_lib_subject_set_idpProvidedNameIdentifier(LassoLibSubject *node,
LassoLibIDPProvidedNameIdentifier *idpProvidedNameIdentifier);
#ifdef __cplusplus
}

View File

@ -1,58 +0,0 @@
/* $Id$
*
* Lasso - A free implementation of the Liberty Alliance specifications.
*
* Copyright (C) 2004 Entr'ouvert
* http://lasso.entrouvert.org
*
* Authors: Nicolas Clapies <nclapies@entrouvert.com>
* Valery Febvre <vfebvre@easter-eggs.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __LASSO_SAML_H__
#define __LASSO_SAML_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <lasso/xml/saml_advice.h>
#include <lasso/xml/saml_assertion.h>
#include <lasso/xml/saml_audience_restriction_condition.h>
#include <lasso/xml/saml_authentication_statement.h>
#include <lasso/xml/saml_authority_binding.h>
#include <lasso/xml/saml_condition_abstract.h>
#include <lasso/xml/saml_conditions.h>
#include <lasso/xml/saml_name_identifier.h>
#include <lasso/xml/saml_statement_abstract.h>
#include <lasso/xml/saml_subject.h>
#include <lasso/xml/saml_subject_confirmation.h>
#include <lasso/xml/saml_subject_locality.h>
#include <lasso/xml/saml_subject_statement_abstract.h>
#include <lasso/xml/samlp_request.h>
#include <lasso/xml/samlp_response_abstract.h>
#include <lasso/xml/samlp_response.h>
#include <lasso/xml/samlp_request_abstract.h>
#include <lasso/xml/samlp_status.h>
#include <lasso/xml/samlp_status_code.h>
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __LASSO_SAML_H__ */

View File

@ -24,6 +24,7 @@
*/
#include <lasso/xml/saml_advice.h>
#include <lasso/xml/saml_assertion.h>
/*
The schema fragment (oasis-sstc-saml-schema-assertion-1.0.xsd):
@ -44,75 +45,86 @@ The schema fragment (oasis-sstc-saml-schema-assertion-1.0.xsd):
*/
/*****************************************************************************/
/* public methods */
/* private methods */
/*****************************************************************************/
void
lasso_saml_advice_add_assertionIDReference(LassoSamlAdvice *node,
const xmlChar *assertionIDReference)
{
LassoNodeClass *class;
g_assert(LASSO_IS_SAML_ADVICE(node));
g_assert(assertionIDReference != NULL);
static LassoNodeClass *parent_class = NULL;
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node),
"AssertionIDReference",
assertionIDReference,
TRUE);
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
LassoSamlAdvice *advice = LASSO_SAML_ADVICE(node);
xmlnode = xmlNewNode(NULL, "Advice");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX));
if (advice->AssertionIDReference)
xmlNewTextChild(xmlnode, NULL, "AssertionIDReference", advice->AssertionIDReference);
if (advice->Assertion)
xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(advice->Assertion)));
return xmlnode;
}
void
lasso_saml_advice_add_assertion(LassoSamlAdvice *node,
gpointer *assertion)
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoNodeClass *class;
g_assert(LASSO_IS_SAML_ADVICE(node));
/* g_assert(LASSO_IS_SAML_ASSERTION(assertion)); */
LassoSamlAdvice *advice = LASSO_SAML_ADVICE(node);
xmlNode *t;
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE (node), LASSO_NODE (assertion), TRUE);
parent_class->init_from_xml(node, xmlnode);
t = xmlnode->children;
while (t) {
if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "AssertionIDReference") == 0)
advice->AssertionIDReference = xmlNodeGetContent(t);
if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "Assertion") == 0)
advice->Assertion = lasso_node_new_from_xmlNode(t);
t = t->next;
}
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
lasso_saml_advice_instance_init(LassoSamlAdvice *node)
instance_init(LassoSamlAdvice *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
class->set_ns(LASSO_NODE(node), lassoSamlAssertionHRef,
lassoSamlAssertionPrefix);
class->set_name(LASSO_NODE(node), "Advice");
node->AssertionIDReference = NULL;
node->Assertion = NULL;
}
static void
lasso_saml_advice_class_init(LassoSamlAdviceClass *klass) {
class_init(LassoSamlAdviceClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
}
GType lasso_saml_advice_get_type() {
static GType this_type = 0;
GType
lasso_saml_advice_get_type()
{
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoSamlAdviceClass),
NULL,
NULL,
(GClassInitFunc) lasso_saml_advice_class_init,
NULL,
NULL,
sizeof(LassoSamlAdvice),
0,
(GInstanceInitFunc) lasso_saml_advice_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoSamlAdvice",
&this_info, 0);
}
return this_type;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoSamlAdviceClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoSamlAdvice),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoSamlAdvice", &this_info, 0);
}
return this_type;
}
/**
@ -138,7 +150,9 @@ GType lasso_saml_advice_get_type() {
*
* Return value: the new @LassoSamlAdvice
**/
LassoNode* lasso_saml_advice_new()
LassoNode*
lasso_saml_advice_new()
{
return LASSO_NODE(g_object_new(LASSO_TYPE_SAML_ADVICE, NULL));
return LASSO_NODE(g_object_new(LASSO_TYPE_SAML_ADVICE, NULL));
}

View File

@ -43,23 +43,21 @@ typedef struct _LassoSamlAdvice LassoSamlAdvice;
typedef struct _LassoSamlAdviceClass LassoSamlAdviceClass;
struct _LassoSamlAdvice {
LassoNode parent;
/*< private >*/
LassoNode parent;
/* XXX: unbounded; both should be GList */
/* <element ref="saml:AssertionIDReference"/> */
char *AssertionIDReference;
/* <element ref="saml:Assertion"/> */
LassoNode *Assertion; /* actually LassoSamlAssertion* but it recurses */
};
struct _LassoSamlAdviceClass {
LassoNodeClass parent;
LassoNodeClass parent;
};
LASSO_EXPORT GType lasso_saml_advice_get_type(void);
LASSO_EXPORT LassoNode* lasso_saml_advice_new(void);
LASSO_EXPORT void lasso_saml_advice_add_assertionIDReference (LassoSamlAdvice *node,
const xmlChar *assertionIDReference);
LASSO_EXPORT void lasso_saml_advice_add_assertion (LassoSamlAdvice *node,
gpointer *assertion);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -57,204 +57,130 @@ From oasis-sstc-saml-schema-assertion-1.0.xsd:
</simpleType>
*/
/*****************************************************************************/
/* public methods */
/* private methods */
/*****************************************************************************/
void
lasso_saml_assertion_add_authenticationStatement(LassoSamlAssertion *node,
LassoSamlAuthenticationStatement *authenticationStatement)
{
LassoNodeClass *class;
g_assert(LASSO_IS_SAML_ASSERTION(node));
g_assert(LASSO_IS_SAML_AUTHENTICATION_STATEMENT(authenticationStatement));
static LassoNodeClass *parent_class = NULL;
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE (node), LASSO_NODE(authenticationStatement), TRUE);
static void
insure_namespace(xmlNode *xmlnode, xmlNs *ns)
{
/* insure children are kept in saml namespace */
char *typename;
xmlNode *t;
xmlNs *xsi_ns;
xsi_ns = xmlNewNs(xmlnode, LASSO_XSI_HREF, LASSO_XSI_PREFIX);
t = xmlnode->children;
while (t) {
if (t->type != XML_ELEMENT_NODE) {
t = t->next;
continue;
}
if (xmlnode->ns && strcmp(xmlnode->ns->href, LASSO_LIB_HREF) == 0) {
typename = g_strdup_printf("lib:%sType", xmlnode->name);
xmlSetNs(xmlnode, ns);
xmlNewNsProp(xmlnode, xsi_ns, "type", typename);
g_free(typename);
}
insure_namespace(t, ns);
t = t->next;
}
}
void
lasso_saml_assertion_add_statement(LassoSamlAssertion *node,
LassoSamlStatementAbstract *statement)
{
LassoNodeClass *class;
g_assert(LASSO_IS_SAML_ASSERTION(node));
g_assert(LASSO_IS_SAML_STATEMENT_ABSTRACT(statement));
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE (node), LASSO_NODE(statement), TRUE);
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
LassoSamlAssertion *assertion = LASSO_SAML_ASSERTION(node);
xmlNs *ns;
char s[10];
xmlnode = xmlNewNode(NULL, "Assertion");
xmlSetProp(xmlnode, "AssertionID", assertion->AssertionID);
ns = xmlNewNs(xmlnode, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX);
xmlSetNs(xmlnode, ns);
snprintf(s, 9, "%d", assertion->MajorVersion);
xmlSetProp(xmlnode, "MajorVersion", s);
snprintf(s, 9, "%d", assertion->MinorVersion);
xmlSetProp(xmlnode, "MinorVersion", s);
if (assertion->Issuer)
xmlSetProp(xmlnode, "Issuer", assertion->Issuer);
if (assertion->IssueInstant)
xmlSetProp(xmlnode, "IssueInstant", assertion->IssueInstant);
if (assertion->Conditions)
xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(assertion->Conditions)));
if (assertion->Advice)
xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(assertion->Advice)));
if (assertion->AuthenticationStatement)
xmlAddChild(xmlnode, lasso_node_get_xmlNode(
LASSO_NODE(assertion->AuthenticationStatement)));
if (assertion->SubjectStatement)
xmlAddChild(xmlnode, lasso_node_get_xmlNode(
LASSO_NODE(assertion->SubjectStatement)));
insure_namespace(xmlnode, ns);
return xmlnode;
}
void
lasso_saml_assertion_add_subjectStatement(LassoSamlAssertion *node,
LassoSamlSubjectStatementAbstract *subjectStatement)
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoNodeClass *class;
g_assert(LASSO_IS_SAML_ASSERTION(node));
g_assert(LASSO_IS_SAML_SUBJECT_STATEMENT_ABSTRACT(subjectStatement));
char *s;
xmlNode *t;
LassoSamlAssertion *assertion = LASSO_SAML_ASSERTION(node);
parent_class->init_from_xml(node, xmlnode);
assertion->AssertionID = xmlGetProp(xmlnode, "AssertionID");
assertion->Issuer = xmlGetProp(xmlnode, "Issuer");
assertion->IssueInstant = xmlGetProp(xmlnode, "IssueInstant");
s = xmlGetProp(xmlnode, "MajorVersion");
if (s) {
assertion->MajorVersion = atoi(s);
xmlFree(s);
}
s = xmlGetProp(xmlnode, "MinorVersion");
if (s) {
assertion->MinorVersion = atoi(s);
xmlFree(s);
}
t = xmlnode->children;
while (t) {
if (t->type != XML_ELEMENT_NODE) {
t = t->next;
continue;
}
if (strcmp(t->name, "Conditions") == 0)
assertion->Conditions = LASSO_SAML_CONDITIONS(
lasso_node_new_from_xmlNode(t));
if (strcmp(t->name, "Advice") == 0)
assertion->Advice = LASSO_SAML_ADVICE(
lasso_node_new_from_xmlNode(t));
if (strcmp(t->name, "SubjectStatement") == 0)
assertion->SubjectStatement = LASSO_SAML_SUBJECT_STATEMENT(
lasso_node_new_from_xmlNode(t));
if (strcmp(t->name, "AuthenticationStatement") == 0)
assertion->AuthenticationStatement = LASSO_SAML_AUTHENTICATION_STATEMENT(
lasso_node_new_from_xmlNode(t));
t = t->next;
}
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE (node), LASSO_NODE(subjectStatement), TRUE);
}
/**
* lasso_saml_assertion_set_advice:
* @node: the <saml:Assertion> node object
* @advice: the <saml:Advice> node object
*
* Sets the <Advice> element [optional].
*
* Additional information related to the assertion that assists processing in
* certain situations but which MAY be ignored by applications that do not
* support its use.
**/
void
lasso_saml_assertion_set_advice(LassoSamlAssertion *node,
LassoSamlAdvice *advice)
{
LassoNodeClass *class;
g_assert(LASSO_IS_SAML_ASSERTION(node));
g_assert(LASSO_IS_SAML_ADVICE(advice));
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE (node), LASSO_NODE(advice), FALSE);
}
/**
* lasso_saml_assertion_set_assertionID:
* @node: the <saml:Assertion> node object
* @assertionID: the value of "AssertionID" attribute
*
* Sets the "AssertionID" attribute [required].
*
* The identifier for this assertion. It is of type IDType, and MUST follow the
* requirements specified by that type for identifier uniqueness.
**/
void
lasso_saml_assertion_set_assertionID(LassoSamlAssertion *node,
const xmlChar *assertionID)
{
LassoNodeClass *class;
g_assert(LASSO_IS_SAML_ASSERTION(node));
g_assert(assertionID != NULL);
class = LASSO_NODE_GET_CLASS(node);
class->set_prop(LASSO_NODE (node), "AssertionID", assertionID);
}
/**
* lasso_saml_assertion_set_conditions:
* @node: the <saml:Assertion> node object
* @conditions: the <saml:Conditions> node object
*
* Sets the <Conditions> element [optional].
*
* Conditions that MUST be taken into account in assessing the validity of the
* assertion.
**/
void
lasso_saml_assertion_set_conditions(LassoSamlAssertion *node,
LassoSamlConditions *conditions)
{
LassoNodeClass *class;
g_assert(LASSO_IS_SAML_ASSERTION(node));
g_assert(LASSO_IS_SAML_CONDITIONS(conditions));
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE (node), LASSO_NODE(conditions), FALSE);
}
/**
* lasso_saml_assertion_set_issueInstant:
* @node: the <saml:Assertion> node object
* @issueInstant: the value of "IssueInstant" attribute
*
* Sets the "IssueInstant" attribute [required].
*
* The time instant of issue in UTC as described in Section 1.2.2
* (oasis-sstc-saml-core-1.0.pdf).
**/
void
lasso_saml_assertion_set_issueInstant(LassoSamlAssertion *node,
const xmlChar *issueInstant)
{
LassoNodeClass *class;
g_assert(LASSO_IS_SAML_ASSERTION(node));
g_assert(issueInstant != NULL);
class = LASSO_NODE_GET_CLASS(node);
class->set_prop(LASSO_NODE (node), "IssueInstant", issueInstant);
}
/**
* lasso_saml_assertion_set_issuer:
* @node: the <saml:Assertion> node object
* @issuer: the value of "Issuer" attribute
*
* Sets the "Issuer" attribute [required].
*
* The issuer of the assertion. The name of the issuer is provided as a string.
* The issuer name SHOULD be unambiguous to the intended relying parties. SAML
* authorities may use an identifier such as a URI reference that is designed
* to be unambiguous regardless of context.
**/
void
lasso_saml_assertion_set_issuer(LassoSamlAssertion *node,
const xmlChar *issuer)
{
LassoNodeClass *class;
g_assert(LASSO_IS_SAML_ASSERTION(node));
g_assert(issuer != NULL);
class = LASSO_NODE_GET_CLASS(node);
class->set_prop(LASSO_NODE (node), "Issuer", issuer);
}
/**
* lasso_saml_assertion_set_majorVersion:
* @node: the <saml:Assertion> node object
* @majorVersion: the value of "MajorVersion" attribute
*
* Sets the "MajorVersion" attribute [required].
*
* The major version of the assertion. The identifier for the version of SAML
* defined in this specification is 1. Processing of this attribute is
* specified in Section 3.4.4 (oasis-sstc-saml-core-1.0.pdf).
**/
void
lasso_saml_assertion_set_majorVersion(LassoSamlAssertion *node,
const xmlChar *majorVersion)
{
LassoNodeClass *class;
g_assert(LASSO_IS_SAML_ASSERTION(node));
g_assert(majorVersion != NULL);
class = LASSO_NODE_GET_CLASS(node);
class->set_prop(LASSO_NODE (node), "MajorVersion", majorVersion);
}
/**
* lasso_saml_assertion_set_minorVersion:
* @node: the <saml:Assertion> node object
* @minorVersion: the value of "MinorVersion" attribute
*
* Sets the "MinorVersion" attribute [required].
*
* The minor version of the assertion. The identifier for the version of SAML
* defined in this specification is 0. Processing of this attribute is
* specified in Section 3.4.4 (oasis-sstc-saml-core-1.0.pdf).
**/
void
lasso_saml_assertion_set_minorVersion(LassoSamlAssertion *node,
const xmlChar *minorVersion)
{
LassoNodeClass *class;
g_assert(LASSO_IS_SAML_ASSERTION(node));
g_assert(minorVersion != NULL);
class = LASSO_NODE_GET_CLASS(node);
class->set_prop(LASSO_NODE (node), "MinorVersion", minorVersion);
}
gint
lasso_saml_assertion_set_signature(LassoSamlAssertion *node,
@ -262,6 +188,8 @@ lasso_saml_assertion_set_signature(LassoSamlAssertion *node,
const xmlChar *private_key_file,
const xmlChar *certificate_file)
{
return 0;
#if 0 /* XXX: signatures are done differently */
gint ret;
LassoNodeClass *class;
@ -274,6 +202,7 @@ lasso_saml_assertion_set_signature(LassoSamlAssertion *node,
private_key_file, certificate_file);
return ret;
#endif
}
/*****************************************************************************/
@ -281,41 +210,40 @@ lasso_saml_assertion_set_signature(LassoSamlAssertion *node,
/*****************************************************************************/
static void
lasso_saml_assertion_instance_init(LassoSamlAssertion *node)
instance_init(LassoSamlAssertion *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
class->set_ns(LASSO_NODE(node), lassoSamlAssertionHRef,
lassoSamlAssertionPrefix);
class->set_name(LASSO_NODE(node), "Assertion");
}
static void
lasso_saml_assertion_class_init(LassoSamlAssertionClass *klass)
class_init(LassoSamlAssertionClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
}
GType lasso_saml_assertion_get_type() {
static GType this_type = 0;
GType
lasso_saml_assertion_get_type()
{
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoSamlAssertionClass),
NULL,
NULL,
(GClassInitFunc) lasso_saml_assertion_class_init,
NULL,
NULL,
sizeof(LassoSamlAssertion),
0,
(GInstanceInitFunc) lasso_saml_assertion_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoSamlAssertion",
&this_info, 0);
}
return this_type;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoSamlAssertionClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoSamlAssertion),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoSamlAssertion", &this_info, 0);
}
return this_type;
}
/**
@ -325,7 +253,9 @@ GType lasso_saml_assertion_get_type() {
*
* Return value: the new @LassoSamlAssertion
**/
LassoNode* lasso_saml_assertion_new()
LassoNode*
lasso_saml_assertion_new()
{
return LASSO_NODE(g_object_new(LASSO_TYPE_SAML_ASSERTION, NULL));
return LASSO_NODE(g_object_new(LASSO_TYPE_SAML_ASSERTION, NULL));
}

View File

@ -35,7 +35,7 @@ extern "C" {
#include <lasso/xml/saml_authentication_statement.h>
#include <lasso/xml/saml_conditions.h>
#include <lasso/xml/saml_statement_abstract.h>
#include <lasso/xml/saml_subject_statement_abstract.h>
#include <lasso/xml/saml_subject_statement.h>
#define LASSO_TYPE_SAML_ASSERTION (lasso_saml_assertion_get_type())
#define LASSO_SAML_ASSERTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_SAML_ASSERTION, LassoSamlAssertion))
@ -48,51 +48,40 @@ typedef struct _LassoSamlAssertion LassoSamlAssertion;
typedef struct _LassoSamlAssertionClass LassoSamlAssertionClass;
struct _LassoSamlAssertion {
LassoNode parent;
/*< private >*/
LassoNode parent;
/* <element ref="saml:Conditions" minOccurs="0"/> */
LassoSamlConditions *Conditions;
/* <element ref="saml:Advice" minOccurs="0"/> */
LassoSamlAdvice *Advice;
#if 0 /* missing from lasso */
LassoSamlStatement *Statement;
#endif
LassoSamlSubjectStatement *SubjectStatement;
LassoSamlAuthenticationStatement *AuthenticationStatement;
#if 0
LassoAuthorizationDecisionsStatement *AuthorizationDecisionStatement;
LassoAttributeStatement *AttributeStatement;
#endif
int MajorVersion;
int MinorVersion;
char *AssertionID;
char *Issuer;
char *IssueInstant;
};
struct _LassoSamlAssertionClass {
LassoNodeClass parent;
LassoNodeClass parent;
};
LASSO_EXPORT GType lasso_saml_assertion_get_type(void);
LASSO_EXPORT LassoNode* lasso_saml_assertion_new(void);
LASSO_EXPORT void lasso_saml_assertion_add_authenticationStatement (LassoSamlAssertion *node,
LassoSamlAuthenticationStatement *authenticationStatement);
LASSO_EXPORT void lasso_saml_assertion_add_statement (LassoSamlAssertion *node,
LassoSamlStatementAbstract *statement);
LASSO_EXPORT void lasso_saml_assertion_add_subjectStatement (LassoSamlAssertion *node,
LassoSamlSubjectStatementAbstract *subjectStatement);
LASSO_EXPORT void lasso_saml_assertion_set_advice (LassoSamlAssertion *node,
LassoSamlAdvice *advice);
LASSO_EXPORT void lasso_saml_assertion_set_assertionID (LassoSamlAssertion *node,
const xmlChar *assertionID);
LASSO_EXPORT void lasso_saml_assertion_set_conditions (LassoSamlAssertion *node,
LassoSamlConditions *conditions);
LASSO_EXPORT void lasso_saml_assertion_set_issueInstant (LassoSamlAssertion *node,
const xmlChar *issueInstant);
LASSO_EXPORT void lasso_saml_assertion_set_issuer (LassoSamlAssertion *node,
const xmlChar *issuer);
LASSO_EXPORT void lasso_saml_assertion_set_majorVersion (LassoSamlAssertion *node,
const xmlChar *majorVersion);
LASSO_EXPORT void lasso_saml_assertion_set_minorVersion (LassoSamlAssertion *node,
const xmlChar *minorVersion);
LASSO_EXPORT gint lasso_saml_assertion_set_signature (LassoSamlAssertion *node,
gint sign_method,
const xmlChar *private_key_file,
const xmlChar *certificate_file);
LASSO_EXPORT gint lasso_saml_assertion_set_signature(LassoSamlAssertion *node,
gint sign_method,
const xmlChar *private_key_file,
const xmlChar *certificate_file);
#ifdef __cplusplus
}

View File

@ -43,71 +43,87 @@ The schema fragment (oasis-sstc-saml-schema-assertion-1.0.xsd):
*/
/*****************************************************************************/
/* publics methods */
/* private methods */
/*****************************************************************************/
/**
* lasso_saml_audience_restriction_condition_add_audience:
* @node: the <saml:AudienceRestrictionCondition> node object
* @audience: the value of "Audience" element
*
* Adds an "Audience" element.
*
* A URI reference that identifies an intended audience. The URI reference MAY
* identify a document that describes the terms and conditions of audience
* membership.
**/
void
lasso_saml_audience_restriction_condition_add_audience(LassoSamlAudienceRestrictionCondition *node,
const xmlChar *audience)
{
LassoNodeClass *class;
g_assert(LASSO_IS_SAML_AUDIENCE_RESTRICTION_CONDITION(node));
g_assert(audience != NULL);
static LassoNodeClass *parent_class = NULL;
class = LASSO_NODE_GET_CLASS(node);
class->new_child(LASSO_NODE (node), "Audience", audience, TRUE);
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
LassoSamlAudienceRestrictionCondition *condition;
condition = LASSO_SAML_AUDIENCE_RESTRICTION_CONDITION(node);
xmlnode = parent_class->get_xmlNode(node);
xmlNodeSetName(xmlnode, "AudienceRestrictionCondition");
if (condition->Audience)
xmlNewTextChild(xmlnode, NULL, "Audience", condition->Audience);
return xmlnode;
}
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoSamlAudienceRestrictionCondition *condition;
xmlNode *t;
parent_class->init_from_xml(node, xmlnode);
t = xmlnode->children;
while (t) {
if (t->type == XML_ELEMENT_NODE) {
if (strcmp(t->name, "Audience") == 0)
condition->Audience = xmlNodeGetContent(t);
}
t = t->next;
}
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
lasso_saml_audience_restriction_condition_instance_init(LassoSamlAudienceRestrictionCondition *node)
instance_init(LassoSamlAudienceRestrictionCondition *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
/* namespace herited from saml:ConditionAbstract */
class->set_name(LASSO_NODE(node), "AudienceRestrictionCondition");
node->Audience = NULL;
}
static void
lasso_saml_audience_restriction_condition_class_init(LassoSamlAudienceRestrictionConditionClass *klass)
class_init(LassoSamlAudienceRestrictionConditionClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
}
GType lasso_saml_audience_restriction_condition_get_type() {
static GType this_type = 0;
GType
lasso_saml_audience_restriction_condition_get_type()
{
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoSamlAudienceRestrictionConditionClass),
NULL,
NULL,
(GClassInitFunc) lasso_saml_audience_restriction_condition_class_init,
NULL,
NULL,
sizeof(LassoSamlAudienceRestrictionCondition),
0,
(GInstanceInitFunc) lasso_saml_audience_restriction_condition_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_SAML_CONDITION_ABSTRACT,
"LassoSamlAudienceRestrictionCondition",
&this_info, 0);
}
return this_type;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoSamlAudienceRestrictionConditionClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoSamlAudienceRestrictionCondition),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_SAML_CONDITION_ABSTRACT,
"LassoSamlAudienceRestrictionCondition", &this_info, 0);
}
return this_type;
}
/**
@ -133,7 +149,9 @@ GType lasso_saml_audience_restriction_condition_get_type() {
*
* Return value: the new @LassoSamlAudienceRestrictionCondition
**/
LassoNode* lasso_saml_audience_restriction_condition_new()
LassoSamlAudienceRestrictionCondition*
lasso_saml_audience_restriction_condition_new()
{
return LASSO_NODE(g_object_new(LASSO_TYPE_SAML_AUDIENCE_RESTRICTION_CONDITION, NULL));
return g_object_new(LASSO_TYPE_SAML_AUDIENCE_RESTRICTION_CONDITION, NULL);
}

View File

@ -43,20 +43,18 @@ typedef struct _LassoSamlAudienceRestrictionCondition LassoSamlAudienceRestricti
typedef struct _LassoSamlAudienceRestrictionConditionClass LassoSamlAudienceRestrictionConditionClass;
struct _LassoSamlAudienceRestrictionCondition {
LassoSamlConditionAbstract parent;
/*< private >*/
LassoSamlConditionAbstract parent;
/* <element ref="saml:Audience" maxOccurs="unbounded"/> */
char *Audience; /* XXX: unbounded -> GList */
};
struct _LassoSamlAudienceRestrictionConditionClass {
LassoSamlConditionAbstractClass parent;
/*< vtable >*/
LassoSamlConditionAbstractClass parent;
};
LASSO_EXPORT GType lasso_saml_audience_restriction_condition_get_type(void);
LASSO_EXPORT LassoNode* lasso_saml_audience_restriction_condition_new(void);
LASSO_EXPORT void lasso_saml_audience_restriction_condition_add_audience (LassoSamlAudienceRestrictionCondition *node,
const xmlChar *audience);
LASSO_EXPORT LassoSamlAudienceRestrictionCondition*
lasso_saml_audience_restriction_condition_new(void);
#ifdef __cplusplus
}

View File

@ -44,96 +44,103 @@ The schema fragment (oasis-sstc-saml-schema-assertion-1.0.xsd):
*/
/*****************************************************************************/
/* public methods */
/* private methods */
/*****************************************************************************/
void
lasso_saml_authentication_statement_add_authorityBinding(LassoSamlAuthenticationStatement *node,
LassoSamlAuthorityBinding *authorityBinding)
{
LassoNodeClass *class;
g_assert(LASSO_IS_SAML_AUTHENTICATION_STATEMENT(node));
g_assert(LASSO_IS_SAML_AUTHORITY_BINDING(authorityBinding));
static LassoNodeClass *parent_class = NULL;
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE (node), LASSO_NODE(authorityBinding), TRUE);
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
LassoSamlAuthenticationStatement *statement = LASSO_SAML_AUTHENTICATION_STATEMENT(node);
xmlnode = parent_class->get_xmlNode(node);
xmlNodeSetName(xmlnode, "AuthenticationStatement");
if (statement->SubjectLocality)
xmlAddChild(xmlnode, lasso_node_get_xmlNode(
LASSO_NODE(statement->SubjectLocality)));
if (statement->AuthorityBinding)
xmlAddChild(xmlnode, lasso_node_get_xmlNode(
LASSO_NODE(statement->AuthorityBinding)));
if (statement->AuthenticationMethod)
xmlSetProp(xmlnode, "AuthenticationMethod", statement->AuthenticationMethod);
if (statement->AuthenticationInstant)
xmlSetProp(xmlnode, "AuthenticationInstant", statement->AuthenticationInstant);
return xmlnode;
}
void
lasso_saml_authentication_statement_set_authenticationInstant(LassoSamlAuthenticationStatement *node,
const xmlChar *authenticationInstant)
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoNodeClass *class;
g_assert(LASSO_IS_SAML_AUTHENTICATION_STATEMENT(node));
g_assert(authenticationInstant != NULL);
LassoSamlAuthenticationStatement *statement = LASSO_SAML_AUTHENTICATION_STATEMENT(node);
xmlNode *t;
class = LASSO_NODE_GET_CLASS(node);
class->set_prop(LASSO_NODE (node), "AuthenticationInstant", authenticationInstant);
parent_class->init_from_xml(node, xmlnode);
statement->AuthenticationMethod = xmlGetProp(xmlnode, "AuthenticationMethod");
statement->AuthenticationInstant = xmlGetProp(xmlnode, "AuthenticationInstant");
t = xmlnode->children;
while (t) {
if (t->type == XML_ELEMENT_NODE) {
if (strcmp(t->name, "SubjectLocality") == 0) {
statement->SubjectLocality = LASSO_SAML_SUBJECT_LOCALITY(
lasso_node_new_from_xmlNode(t));
}
if (strcmp(t->name, "AuthorityBinding") == 0) {
statement->AuthorityBinding = LASSO_SAML_AUTHORITY_BINDING(
lasso_node_new_from_xmlNode(t));
}
}
t = t->next;
}
}
void
lasso_saml_authentication_statement_set_authenticationMethod(LassoSamlAuthenticationStatement *node,
const xmlChar *authenticationMethod)
{
LassoNodeClass *class;
g_assert(LASSO_IS_SAML_AUTHENTICATION_STATEMENT(node));
g_assert(authenticationMethod != NULL);
class = LASSO_NODE_GET_CLASS(node);
class->set_prop(LASSO_NODE (node), "AuthenticationMethod", authenticationMethod);
}
void
lasso_saml_authentication_statement_set_subjectLocality(LassoSamlAuthenticationStatement *node,
LassoSamlSubjectLocality *subjectLocality)
{
LassoNodeClass *class;
g_assert(LASSO_IS_SAML_AUTHENTICATION_STATEMENT(node));
g_assert(LASSO_IS_SAML_SUBJECT_LOCALITY(subjectLocality));
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE (node), LASSO_NODE(subjectLocality), FALSE);
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
lasso_saml_authentication_statement_instance_init(LassoSamlAuthenticationStatement *node)
instance_init(LassoSamlAuthenticationStatement *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
/* namespace herited from SubjectStatementAbstract -> StatementAbstract */
class->set_name(LASSO_NODE(node), "AuthenticationStatement");
node->SubjectLocality = NULL;
node->AuthorityBinding = NULL;
node->AuthenticationMethod = NULL;
node->AuthenticationInstant = NULL;
}
static void
lasso_saml_authentication_statement_class_init(LassoSamlAuthenticationStatementClass *klass)
class_init(LassoSamlAuthenticationStatementClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
}
GType lasso_saml_authentication_statement_get_type() {
static GType this_type = 0;
GType
lasso_saml_authentication_statement_get_type()
{
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoSamlAuthenticationStatementClass),
NULL,
NULL,
(GClassInitFunc) lasso_saml_authentication_statement_class_init,
NULL,
NULL,
sizeof(LassoSamlAuthenticationStatement),
0,
(GInstanceInitFunc) lasso_saml_authentication_statement_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_SAML_SUBJECT_STATEMENT_ABSTRACT,
"LassoSamlAuthenticationStatement",
&this_info, 0);
}
return this_type;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoSamlAuthenticationStatementClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoSamlAuthenticationStatement),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_SAML_SUBJECT_STATEMENT_ABSTRACT,
"LassoSamlAuthenticationStatement", &this_info, 0);
}
return this_type;
}
/**
@ -143,7 +150,9 @@ GType lasso_saml_authentication_statement_get_type() {
*
* Return value: the new @LassoSamlAuthenticationStatement
**/
LassoNode* lasso_saml_authentication_statement_new()
LassoNode*
lasso_saml_authentication_statement_new()
{
return LASSO_NODE(g_object_new(LASSO_TYPE_SAML_AUTHENTICATION_STATEMENT, NULL));
return LASSO_NODE(g_object_new(LASSO_TYPE_SAML_AUTHENTICATION_STATEMENT, NULL));
}

View File

@ -45,8 +45,16 @@ typedef struct _LassoSamlAuthenticationStatement LassoSamlAuthenticationStatemen
typedef struct _LassoSamlAuthenticationStatementClass LassoSamlAuthenticationStatementClass;
struct _LassoSamlAuthenticationStatement {
LassoSamlSubjectStatementAbstract parent;
/*< private >*/
LassoSamlSubjectStatementAbstract parent;
/* <element ref="saml:SubjectLocality" minOccurs="0"/> */
LassoSamlSubjectLocality *SubjectLocality;
/* <element ref="saml:AuthorityBinding" minOccurs="0" maxOccurs="unbounded"/> */
LassoSamlAuthorityBinding *AuthorityBinding; /* XXX unbounded */
/* <attribute name="AuthenticationMethod" type="anyURI" use="required"/> */
char *AuthenticationMethod;
/* <attribute name="AuthenticationInstant" type="dateTime" use="required"/> */
char *AuthenticationInstant;
};
struct _LassoSamlAuthenticationStatementClass {
@ -57,18 +65,6 @@ struct _LassoSamlAuthenticationStatementClass {
LASSO_EXPORT GType lasso_saml_authentication_statement_get_type(void);
LASSO_EXPORT LassoNode* lasso_saml_authentication_statement_new(void);
LASSO_EXPORT void lasso_saml_authentication_statement_add_authorityBinding (LassoSamlAuthenticationStatement *node,
LassoSamlAuthorityBinding *authorityBinding);
LASSO_EXPORT void lasso_saml_authentication_statement_set_authenticationInstant (LassoSamlAuthenticationStatement *node,
const xmlChar *authenticationInstant);
LASSO_EXPORT void lasso_saml_authentication_statement_set_authenticationMethod (LassoSamlAuthenticationStatement *node,
const xmlChar *authenticationMethod);
LASSO_EXPORT void lasso_saml_authentication_statement_set_subjectLocality (LassoSamlAuthenticationStatement *node,
LassoSamlSubjectLocality *subjectLocality);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -38,43 +38,38 @@ The schema fragment (oasis-sstc-saml-schema-assertion-1.0.xsd):
*/
/*****************************************************************************/
/* public methods */
/* private methods */
/*****************************************************************************/
void
lasso_saml_authority_binding_set_authorityKind(LassoSamlAuthorityBinding *node,
const xmlChar *authorityKind)
{
LassoNodeClass *class;
g_assert(LASSO_IS_SAML_AUTHORITY_BINDING(node));
g_assert(authorityKind != NULL);
static LassoNodeClass *parent_class = NULL;
class = LASSO_NODE_GET_CLASS(node);
class->set_prop(LASSO_NODE (node), "AuthorityKind", authorityKind);
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
LassoSamlAuthorityBinding *binding = LASSO_SAML_AUTHORITY_BINDING(node);
xmlnode = xmlNewNode(NULL, "AuthorityBinding");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX));
if (binding->AuthorityKind)
xmlSetProp(xmlnode, "AuthorityKind", binding->AuthorityKind);
if (binding->Location)
xmlSetProp(xmlnode, "Location", binding->Location);
if (binding->Binding)
xmlSetProp(xmlnode, "Binding", binding->Binding);
return xmlnode;
}
void
lasso_saml_authority_binding_set_binding(LassoSamlAuthorityBinding *node,
const xmlChar *binding)
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoNodeClass *class;
g_assert(LASSO_IS_SAML_AUTHORITY_BINDING(node));
g_assert(binding != NULL);
LassoSamlAuthorityBinding *binding = LASSO_SAML_AUTHORITY_BINDING(node);
class = LASSO_NODE_GET_CLASS(node);
class->set_prop(LASSO_NODE (node), "Binding", binding);
}
void
lasso_saml_authority_binding_set_location(LassoSamlAuthorityBinding *node,
const xmlChar *location)
{
LassoNodeClass *class;
g_assert(LASSO_IS_SAML_AUTHORITY_BINDING(node));
g_assert(location != NULL);
class = LASSO_NODE_GET_CLASS(node);
class->set_prop(LASSO_NODE (node), "Location", location);
parent_class->init_from_xml(node, xmlnode);
binding->AuthorityKind = xmlGetProp(xmlnode, "AuthorityKind");
binding->Location = xmlGetProp(xmlnode, "Location");
binding->Binding = xmlGetProp(xmlnode, "Binding");
}
/*****************************************************************************/
@ -82,41 +77,43 @@ lasso_saml_authority_binding_set_location(LassoSamlAuthorityBinding *node,
/*****************************************************************************/
static void
lasso_saml_authority_binding_instance_init(LassoSamlAuthorityBinding *node)
instance_init(LassoSamlAuthorityBinding *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
class->set_ns(LASSO_NODE(node), lassoSamlAssertionHRef,
lassoSamlAssertionPrefix);
class->set_name(LASSO_NODE(node), "AuthorityBinding");
node->AuthorityKind = NULL;
node->Location = NULL;
node->Binding = NULL;
}
static void
lasso_saml_authority_binding_class_init(LassoSamlAuthorityBindingClass *klass)
class_init(LassoSamlAuthorityBindingClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
}
GType lasso_saml_authority_binding_get_type() {
static GType this_type = 0;
GType
lasso_saml_authority_binding_get_type()
{
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoSamlAuthorityBindingClass),
NULL,
NULL,
(GClassInitFunc) lasso_saml_authority_binding_class_init,
NULL,
NULL,
sizeof(LassoSamlAuthorityBinding),
0,
(GInstanceInitFunc) lasso_saml_authority_binding_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoSamlAuthorityBinding",
&this_info, 0);
}
return this_type;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoSamlAuthorityBindingClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoSamlAuthorityBinding),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoSamlAuthorityBinding", &this_info, 0);
}
return this_type;
}
/**
@ -126,7 +123,9 @@ GType lasso_saml_authority_binding_get_type() {
*
* Return value: the new @LassoSamlAuthorityBinding
**/
LassoNode* lasso_saml_authority_binding_new()
LassoNode*
lasso_saml_authority_binding_new()
{
return LASSO_NODE(g_object_new(LASSO_TYPE_SAML_AUTHORITY_BINDING, NULL));
return LASSO_NODE(g_object_new(LASSO_TYPE_SAML_AUTHORITY_BINDING, NULL));
}

View File

@ -43,27 +43,23 @@ typedef struct _LassoSamlAuthorityBinding LassoSamlAuthorityBinding;
typedef struct _LassoSamlAuthorityBindingClass LassoSamlAuthorityBindingClass;
struct _LassoSamlAuthorityBinding {
LassoNode parent;
/*< private >*/
LassoNode parent;
/* <attribute name="AuthorityKind" type="QName" use="required"/> */
char *AuthorityKind;
/* <attribute name="Location" type="anyURI" use="required"/> */
char *Location;
/* <attribute name="Binding" type="anyURI" use="required"/> */
char *Binding;
};
struct _LassoSamlAuthorityBindingClass {
LassoNodeClass parent;
/*< vtable >*/
LassoNodeClass parent;
};
LASSO_EXPORT GType lasso_saml_authority_binding_get_type(void);
LASSO_EXPORT LassoNode* lasso_saml_authority_binding_new(void);
LASSO_EXPORT void lasso_saml_authority_binding_set_authorityKind (LassoSamlAuthorityBinding *node,
const xmlChar *authorityKind);
LASSO_EXPORT void lasso_saml_authority_binding_set_binding (LassoSamlAuthorityBinding *node,
const xmlChar *binding);
LASSO_EXPORT void lasso_saml_authority_binding_set_location (LassoSamlAuthorityBinding *node,
const xmlChar *location);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -32,65 +32,72 @@ The schema fragment (oasis-sstc-saml-schema-assertion-1.0.xsd):
<complexType name="ConditionAbstractType" abstract="true"/>
*/
/*****************************************************************************/
/* private methods */
/*****************************************************************************/
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
xmlnode = xmlNewNode(NULL, "ConditionAbstract");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX));
return xmlnode;
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
lasso_saml_condition_abstract_instance_init(LassoSamlConditionAbstract *node)
instance_init(LassoSamlConditionAbstract *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
class->set_ns(LASSO_NODE(node), lassoSamlAssertionHRef,
lassoSamlAssertionPrefix);
class->set_name(LASSO_NODE(node), "ConditionAbstract");
}
static void
lasso_saml_condition_abstract_class_init(LassoSamlConditionAbstractClass *klass)
class_init(LassoSamlConditionAbstractClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
}
GType lasso_saml_condition_abstract_get_type() {
static GType this_type = 0;
GType
lasso_saml_condition_abstract_get_type()
{
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoSamlConditionAbstractClass),
NULL,
NULL,
(GClassInitFunc) lasso_saml_condition_abstract_class_init,
NULL,
NULL,
sizeof(LassoSamlConditionAbstract),
0,
(GInstanceInitFunc) lasso_saml_condition_abstract_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoSamlConditionAbstract",
&this_info, 0);
}
return this_type;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoSamlConditionAbstractClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoSamlConditionAbstract),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoSamlConditionAbstract", &this_info, 0);
}
return this_type;
}
/**
* lasso_saml_condition_abstract_new:
* @name: the node's name. If @name is NULL or an empty string, default value
* "ConditionAbstract" will be used.
*
* Creates a new <saml:ConditionAbstract> node object.
*
* Return value: the new @LassoSamlConditionAbstract
**/
LassoNode* lasso_saml_condition_abstract_new(const xmlChar *name)
LassoNode*
lasso_saml_condition_abstract_new()
{
LassoNode *node;
node = LASSO_NODE(g_object_new(LASSO_TYPE_SAML_CONDITION_ABSTRACT, NULL));
if (name && *name)
LASSO_NODE_GET_CLASS(node)->set_name(node, name);
return node;
return LASSO_NODE(g_object_new(LASSO_TYPE_SAML_CONDITION_ABSTRACT, NULL));
}

View File

@ -43,17 +43,15 @@ typedef struct _LassoSamlConditionAbstract LassoSamlConditionAbstract;
typedef struct _LassoSamlConditionAbstractClass LassoSamlConditionAbstractClass;
struct _LassoSamlConditionAbstract {
LassoNode parent;
/*< private >*/
LassoNode parent;
};
struct _LassoSamlConditionAbstractClass {
LassoNodeClass parent;
/*< vtable >*/
LassoNodeClass parent;
};
LASSO_EXPORT GType lasso_saml_condition_abstract_get_type(void);
LASSO_EXPORT LassoNode* lasso_saml_condition_abstract_new(const xmlChar *name);
LASSO_EXPORT LassoNode* lasso_saml_condition_abstract_new(void);
#ifdef __cplusplus
}

View File

@ -40,134 +40,98 @@ The schema fragment (oasis-sstc-saml-schema-assertion-1.0.xsd):
*/
/*****************************************************************************/
/* public methods */
/* private methods */
/*****************************************************************************/
/**
* lasso_saml_conditions_add_condition:
* @node: the <saml:Conditions> node object
* @condition:
*
*
**/
void
lasso_saml_conditions_add_condition(LassoSamlConditions *node,
LassoSamlConditionAbstract *condition)
{
LassoNodeClass *class;
g_assert(LASSO_IS_SAML_CONDITIONS(node));
g_assert(LASSO_IS_SAML_CONDITION_ABSTRACT(condition));
static LassoNodeClass *parent_class = NULL;
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE (node), LASSO_NODE(condition), TRUE);
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
LassoSamlConditions *conditions = LASSO_SAML_CONDITIONS(node);
xmlnode = xmlNewNode(NULL, "Conditions");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX));
if (conditions->AudienceRestrictionCondition)
xmlAddChild(xmlnode, lasso_node_get_xmlNode(
LASSO_NODE(conditions->AudienceRestrictionCondition)));
if (conditions->NotBefore)
xmlSetProp(xmlnode, "NotBefore", conditions->NotBefore);
if (conditions->NotOnOrAfter)
xmlSetProp(xmlnode, "NotOnOrAfter", conditions->NotOnOrAfter);
return xmlnode;
}
/**
* lasso_saml_conditions_add_audienceRestrictionCondition:
* @node: the <saml:Conditions> node object
* @audienceRestrictionCondition:
*
*
**/
void
lasso_saml_conditions_add_audienceRestrictionCondition(LassoSamlConditions *node,
LassoSamlAudienceRestrictionCondition *audienceRestrictionCondition)
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoNodeClass *class;
g_assert(LASSO_IS_SAML_CONDITIONS(node));
g_assert(LASSO_IS_SAML_AUDIENCE_RESTRICTION_CONDITION(audienceRestrictionCondition));
LassoSamlConditions *conditions = LASSO_SAML_CONDITIONS(node);
xmlNode *t;
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE (node), LASSO_NODE(audienceRestrictionCondition), TRUE);
parent_class->init_from_xml(node, xmlnode);
conditions->NotBefore = xmlGetProp(xmlnode, "NotBefore");
conditions->NotOnOrAfter = xmlGetProp(xmlnode, "NotOnOrAfter");
t = xmlnode->children;
while (t) {
if (t->type != XML_ELEMENT_NODE) {
t = t->next;
continue;
}
if (strcmp(t->name, "AudienceRestrictionCondition") == 0) {
conditions->AudienceRestrictionCondition =
LASSO_SAML_AUDIENCE_RESTRICTION_CONDITION(
lasso_node_new_from_xmlNode(t));
}
t = t->next;
}
}
/**
* lasso_saml_conditions_set_notBefore:
* @node: the <saml:Conditions> node object
* @notBefore: the value of "NotBefore" attribute
*
* Sets the "NotBefore" attribute.
*
* Specifies the earliest time instant at which the assertion is valid. The
* time value is encoded in UTC as described in Section 1.2.2
* (oasis-sstc-saml-core-1.0.pdf).
**/
void
lasso_saml_conditions_set_notBefore(LassoSamlConditions *node,
const xmlChar *notBefore)
{
LassoNodeClass *class;
g_assert(LASSO_IS_SAML_CONDITIONS(node));
g_assert(notBefore != NULL);
class = LASSO_NODE_GET_CLASS(node);
class->set_prop(LASSO_NODE (node), "NotBefore", notBefore);
}
/**
* lasso_saml_conditions_set_notOnOrAfter:
* @node: the <saml:Conditions> node object
* @notOnOrAfter: the value of "NotOnOrAfter" attribute.
*
* Sets the "NotOnOrAfter" attribute.
*
* Specifies the time instant at which the assertion has expired. The time
* value is encoded in UTC as described in Section 1.2.2
* (oasis-sstc-saml-core-1.0.pdf).
**/
void
lasso_saml_conditions_set_notOnOrAfter(LassoSamlConditions *node,
const xmlChar *notOnOrAfter)
{
LassoNodeClass *class;
g_assert(LASSO_IS_SAML_CONDITIONS(node));
g_assert(notOnOrAfter != NULL);
class = LASSO_NODE_GET_CLASS(node);
class->set_prop(LASSO_NODE (node), "NotOnOrAfter", notOnOrAfter);
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
lasso_saml_conditions_instance_init(LassoSamlConditions *node)
instance_init(LassoSamlConditions *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
class->set_ns(LASSO_NODE(node), lassoSamlAssertionHRef,
lassoSamlAssertionPrefix);
class->set_name(LASSO_NODE(node), "Conditions");
node->AudienceRestrictionCondition = NULL;
node->NotBefore = NULL;
node->NotOnOrAfter = NULL;
}
static void
lasso_saml_conditions_class_init(LassoSamlConditionsClass *klass)
class_init(LassoSamlConditionsClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
}
GType lasso_saml_conditions_get_type()
GType
lasso_saml_conditions_get_type()
{
static GType this_type = 0;
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoSamlConditionsClass),
NULL,
NULL,
(GClassInitFunc) lasso_saml_conditions_class_init,
NULL,
NULL,
sizeof(LassoSamlConditions),
0,
(GInstanceInitFunc) lasso_saml_conditions_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoSamlConditions",
&this_info, 0);
}
return this_type;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoSamlConditionsClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoSamlConditions),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoSamlConditions", &this_info, 0);
}
return this_type;
}
/**
@ -177,7 +141,9 @@ GType lasso_saml_conditions_get_type()
*
* Return value: the new @LassoSamlConditions
**/
LassoNode* lasso_saml_conditions_new()
LassoSamlConditions*
lasso_saml_conditions_new()
{
return LASSO_NODE(g_object_new(LASSO_TYPE_SAML_CONDITIONS, NULL));
return g_object_new(LASSO_TYPE_SAML_CONDITIONS, NULL);
}

View File

@ -45,28 +45,24 @@ typedef struct _LassoSamlConditions LassoSamlConditions;
typedef struct _LassoSamlConditionsClass LassoSamlConditionsClass;
struct _LassoSamlConditions {
LassoNode parent;
/*< private >*/
LassoNode parent;
/* <element ref="saml:Condition"/> XXX: unbounded */
/* LassoSamlCondition *Condition; XXX missing from lasso */
/* <element ref="saml:AudienceRestrictionCondition"/> XXX: unbounded */
LassoSamlAudienceRestrictionCondition *AudienceRestrictionCondition;
/* <attribute name="NotBefore" type="dateTime" use="optional"/> */
char *NotBefore;
/* <attribute name="NotOnOrAfter" type="dateTime" use="optional"/> */
char *NotOnOrAfter;
};
struct _LassoSamlConditionsClass {
LassoNodeClass parent;
LassoNodeClass parent;
};
LASSO_EXPORT GType lasso_saml_conditions_get_type(void);
LASSO_EXPORT LassoNode* lasso_saml_conditions_new(void);
LASSO_EXPORT void lasso_saml_conditions_add_condition (LassoSamlConditions *node,
LassoSamlConditionAbstract *condition);
LASSO_EXPORT void lasso_saml_conditions_add_audienceRestrictionCondition(LassoSamlConditions *node,
LassoSamlAudienceRestrictionCondition *audienceRestrictionCondition);
LASSO_EXPORT void lasso_saml_conditions_set_notBefore (LassoSamlConditions *node,
const xmlChar *notBefore);
LASSO_EXPORT void lasso_saml_conditions_set_notOnOrAfter (LassoSamlConditions *node,
const xmlChar *notOnOrAfter);
LASSO_EXPORT LassoSamlConditions* lasso_saml_conditions_new(void);
#ifdef __cplusplus
}

View File

@ -24,6 +24,7 @@
*/
#include <lasso/xml/saml_name_identifier.h>
#include <libxml/uri.h>
/*
The schema fragment (oasis-sstc-saml-schema-assertion-1.0.xsd):
@ -43,28 +44,75 @@ The schema fragment (oasis-sstc-saml-schema-assertion-1.0.xsd):
/* public methods */
/*****************************************************************************/
void
lasso_saml_name_identifier_set_format(LassoSamlNameIdentifier *node,
const xmlChar *format)
gchar*
lasso_saml_name_identifier_build_query(LassoSamlNameIdentifier *identifier,
char *prefix, char *prefix_content)
{
LassoNodeClass *class;
g_assert(LASSO_IS_SAML_NAME_IDENTIFIER(node));
g_assert(format != NULL);
GString *s;
char *str;
xmlChar *t;
class = LASSO_NODE_GET_CLASS(node);
class->set_prop(LASSO_NODE (node), "Format", format);
s = g_string_new("");
if (identifier->NameQualifier) {
t = xmlURIEscapeStr(identifier->NameQualifier, NULL);
g_string_append_printf(s, "&%sNameQualifier=%s", prefix, t);
xmlFree(t);
}
if (identifier->Format) {
t = xmlURIEscapeStr(identifier->Format, NULL);
g_string_append_printf(s, "&%sNameFormat=%s", prefix, t);
xmlFree(t);
}
if (identifier->content) {
t = xmlURIEscapeStr(identifier->content, NULL);
g_string_append_printf(s, "&%sNameIdentifier=%s", prefix_content, t);
xmlFree(t);
}
str = s->str;
g_string_free(s, FALSE);
return str;
}
void
lasso_saml_name_identifier_set_nameQualifier(LassoSamlNameIdentifier *node,
const xmlChar *nameQualifier)
{
LassoNodeClass *class;
g_assert(LASSO_IS_SAML_NAME_IDENTIFIER(node));
g_assert(nameQualifier != NULL);
/*****************************************************************************/
/* private methods */
/*****************************************************************************/
class = LASSO_NODE_GET_CLASS(node);
class->set_prop(LASSO_NODE (node), "NameQualifier", nameQualifier);
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
LassoSamlNameIdentifier *identifier = LASSO_SAML_NAME_IDENTIFIER(node);
xmlnode = xmlNewNode(NULL, "NameIdentifier");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX));
xmlNodeSetContent(xmlnode, identifier->content);
if (identifier->Format)
xmlSetProp(xmlnode, "Format", identifier->Format);
if (identifier->NameQualifier)
xmlSetProp(xmlnode, "NameQualifier", identifier->NameQualifier);
return xmlnode;
}
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoSamlNameIdentifier *identifier = LASSO_SAML_NAME_IDENTIFIER(node);
parent_class->init_from_xml(node, xmlnode);
identifier->content = xmlNodeGetContent(xmlnode);
identifier->Format = xmlGetProp(xmlnode, "Format");
identifier->NameQualifier = xmlGetProp(xmlnode, "NameQualifier");
}
static gchar*
build_query(LassoNode *node)
{
return lasso_saml_name_identifier_build_query(LASSO_SAML_NAME_IDENTIFIER(node), "", "");
}
/*****************************************************************************/
@ -72,59 +120,67 @@ lasso_saml_name_identifier_set_nameQualifier(LassoSamlNameIdentifier *node,
/*****************************************************************************/
static void
lasso_saml_name_identifier_instance_init(LassoSamlNameIdentifier *node)
instance_init(LassoSamlNameIdentifier *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
class->set_ns(LASSO_NODE(node), lassoSamlAssertionHRef,
lassoSamlAssertionPrefix);
class->set_name(LASSO_NODE(node), "NameIdentifier");
node->NameQualifier = NULL;
node->Format = NULL;
node->content = NULL;
}
static void
lasso_saml_name_identifier_class_init(LassoSamlNameIdentifierClass *klass)
class_init(LassoSamlNameIdentifierClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
LASSO_NODE_CLASS(klass)->build_query = build_query;
}
GType lasso_saml_name_identifier_get_type() {
static GType this_type = 0;
GType
lasso_saml_name_identifier_get_type()
{
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoSamlNameIdentifierClass),
NULL,
NULL,
(GClassInitFunc) lasso_saml_name_identifier_class_init,
NULL,
NULL,
sizeof(LassoSamlNameIdentifier),
0,
(GInstanceInitFunc) lasso_saml_name_identifier_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoSamlNameIdentifier",
&this_info, 0);
}
return this_type;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoSamlNameIdentifierClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoSamlNameIdentifier),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoSamlNameIdentifier", &this_info, 0);
}
return this_type;
}
/**
* lasso_saml_name_identifier_new:
* @content: the node content
*
* Creates a new <saml:NameIdentifier> node object.
*
* Return value: the new @LassoSamlNameIdentifier
**/
LassoNode* lasso_saml_name_identifier_new(const xmlChar *content)
LassoSamlNameIdentifier*
lasso_saml_name_identifier_new()
{
LassoNode *node;
g_assert(content != NULL);
node = LASSO_NODE(g_object_new(LASSO_TYPE_SAML_NAME_IDENTIFIER, NULL));
xmlNodeSetContent(LASSO_NODE_GET_CLASS(node)->get_xmlNode(node),
content);
return node;
return g_object_new(LASSO_TYPE_SAML_NAME_IDENTIFIER, NULL);
}
LassoSamlNameIdentifier*
lasso_saml_name_identifier_new_from_xmlNode(xmlNode *xmlnode)
{
LassoNode *node;
node = g_object_new(LASSO_TYPE_SAML_NAME_IDENTIFIER, NULL);
lasso_node_init_from_xml(node, xmlnode);
return LASSO_SAML_NAME_IDENTIFIER(node);
}

View File

@ -43,23 +43,23 @@ typedef struct _LassoSamlNameIdentifier LassoSamlNameIdentifier;
typedef struct _LassoSamlNameIdentifierClass LassoSamlNameIdentifierClass;
struct _LassoSamlNameIdentifier {
LassoNode parent;
/*< private >*/
LassoNode parent;
char *NameQualifier;
char *Format;
char *content;
};
struct _LassoSamlNameIdentifierClass {
LassoNodeClass parent;
/*< vtable >*/
LassoNodeClass parent;
};
LASSO_EXPORT GType lasso_saml_name_identifier_get_type(void);
LASSO_EXPORT LassoNode* lasso_saml_name_identifier_new(const xmlChar *content);
LASSO_EXPORT LassoSamlNameIdentifier* lasso_saml_name_identifier_new(void);
LASSO_EXPORT void lasso_saml_name_identifier_set_format (LassoSamlNameIdentifier *node,
const xmlChar *format);
LASSO_EXPORT LassoSamlNameIdentifier* lasso_saml_name_identifier_new_from_xmlNode(xmlNode*);
LASSO_EXPORT void lasso_saml_name_identifier_set_nameQualifier (LassoSamlNameIdentifier *node,
const xmlChar *nameQualifier);
LASSO_EXPORT char* lasso_saml_name_identifier_build_query(
LassoSamlNameIdentifier *identifier, char *prefix, char *prefix_content);
#ifdef __cplusplus
}

View File

@ -32,65 +32,71 @@ The schema fragment (oasis-sstc-saml-schema-assertion-1.0.xsd):
<complexType name="StatementAbstractType" abstract="true"/>
*/
/*****************************************************************************/
/* private methods */
/*****************************************************************************/
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
xmlnode = xmlNewNode(NULL, "StatementAbstract");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX));
return xmlnode;
}
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
static void
lasso_saml_statement_abstract_instance_init(LassoSamlStatementAbstract *node)
instance_init(LassoSamlStatementAbstract *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
class->set_ns(LASSO_NODE(node), lassoSamlAssertionHRef,
lassoSamlAssertionPrefix);
class->set_name(LASSO_NODE(node), "StatementAbstract");
}
static void
lasso_saml_statement_abstract_class_init(LassoSamlStatementAbstractClass *klass)
class_init(LassoSamlStatementAbstractClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
}
GType lasso_saml_statement_abstract_get_type() {
static GType this_type = 0;
GType
lasso_saml_statement_abstract_get_type()
{
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoSamlStatementAbstractClass),
NULL,
NULL,
(GClassInitFunc) lasso_saml_statement_abstract_class_init,
NULL,
NULL,
sizeof(LassoSamlStatementAbstract),
0,
(GInstanceInitFunc) lasso_saml_statement_abstract_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoSamlStatementAbstract",
&this_info, 0);
}
return this_type;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoSamlStatementAbstractClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoSamlStatementAbstract),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoSamlStatementAbstract", &this_info, 0);
}
return this_type;
}
/**
* lasso_saml_statement_abstract_new:
* @name: the node's name. If @name is NULL or an empty string, default value
* "StatementAbstract" will be used.
*
* Creates a new <saml:StatementAbstract> node object.
*
* Return value: the new @LassoSamlStatementAbstract
**/
LassoNode* lasso_saml_statement_abstract_new(const xmlChar *name)
LassoNode* lasso_saml_statement_abstract_new()
{
LassoNode *node;
node = LASSO_NODE(g_object_new(LASSO_TYPE_SAML_STATEMENT_ABSTRACT, NULL));
if (name && *name)
LASSO_NODE_GET_CLASS(node)->set_name(node, name);
return node;
return LASSO_NODE(g_object_new(LASSO_TYPE_SAML_STATEMENT_ABSTRACT, NULL));
}

View File

@ -43,17 +43,15 @@ typedef struct _LassoSamlStatementAbstract LassoSamlStatementAbstract;
typedef struct _LassoSamlStatementAbstractClass LassoSamlStatementAbstractClass;
struct _LassoSamlStatementAbstract {
LassoNode parent;
/*< private >*/
LassoNode parent;
};
struct _LassoSamlStatementAbstractClass {
LassoNodeClass parent;
/*< vtable >*/
LassoNodeClass parent;
};
LASSO_EXPORT GType lasso_saml_statement_abstract_get_type(void);
LASSO_EXPORT LassoNode* lasso_saml_statement_abstract_new(const xmlChar *name);
LASSO_EXPORT LassoNode* lasso_saml_statement_abstract_new(void);
#ifdef __cplusplus
}

View File

@ -41,31 +41,57 @@ The schema fragment (oasis-sstc-saml-schema-assertion-1.0.xsd):
*/
/*****************************************************************************/
/* public methods */
/* private methods */
/*****************************************************************************/
void
lasso_saml_subject_set_nameIdentifier(LassoSamlSubject *node,
LassoSamlNameIdentifier *nameIdentifier)
{
LassoNodeClass *class;
g_assert(LASSO_IS_SAML_SUBJECT(node));
g_assert(LASSO_IS_SAML_NAME_IDENTIFIER(nameIdentifier));
static LassoNodeClass *parent_class = NULL;
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE (node), LASSO_NODE(nameIdentifier), FALSE);
static xmlNode*
get_xmlNode(LassoNode *node)
{
LassoSamlSubject *subject = LASSO_SAML_SUBJECT(node);
xmlNode *xmlnode;
xmlnode = xmlNewNode(NULL, "Subject");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX));
if (subject->NameIdentifier)
xmlAddChild(xmlnode, lasso_node_get_xmlNode(
LASSO_NODE(subject->NameIdentifier)));
if (subject->SubjectConfirmation)
xmlAddChild(xmlnode, lasso_node_get_xmlNode(
LASSO_NODE(subject->SubjectConfirmation)));
return xmlnode;
}
void
lasso_saml_subject_set_subjectConfirmation(LassoSamlSubject *node,
LassoSamlSubjectConfirmation *subjectConfirmation)
static void
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoNodeClass *class;
g_assert(LASSO_IS_SAML_SUBJECT(node));
g_assert(LASSO_IS_SAML_SUBJECT_CONFIRMATION(subjectConfirmation));
xmlNode *t;
LassoSamlSubject *subject = LASSO_SAML_SUBJECT(node);
class = LASSO_NODE_GET_CLASS(node);
class->add_child(LASSO_NODE (node), LASSO_NODE (subjectConfirmation), FALSE);
parent_class->init_from_xml(node, xmlnode);
t = xmlnode->children;
while (t) {
if (t->type != XML_ELEMENT_NODE) {
t = t->next;
continue;
}
if (strcmp(t->name, "NameIdentifier") == 0) {
subject->NameIdentifier = LASSO_SAML_NAME_IDENTIFIER(
lasso_saml_name_identifier_new());
lasso_node_init_from_xml(LASSO_NODE(subject->NameIdentifier), t);
}
if (strcmp(t->name, "SubjectConfirmation") == 0) {
subject->SubjectConfirmation = LASSO_SAML_SUBJECT_CONFIRMATION(
lasso_saml_subject_confirmation_new());
lasso_node_init_from_xml(LASSO_NODE(subject->SubjectConfirmation), t);
}
t = t->next;
}
}
/*****************************************************************************/
@ -73,40 +99,42 @@ lasso_saml_subject_set_subjectConfirmation(LassoSamlSubject *node,
/*****************************************************************************/
static void
lasso_saml_subject_instance_init(LassoSamlSubject *node)
instance_init(LassoSamlSubject *node)
{
LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(node));
class->set_ns(LASSO_NODE(node), lassoSamlAssertionHRef,
lassoSamlAssertionPrefix);
class->set_name(LASSO_NODE(node), "Subject");
node->NameIdentifier = NULL;
node->SubjectConfirmation = NULL;
}
static void
lasso_saml_subject_class_init(LassoSamlSubjectClass *klass) {
class_init(LassoSamlSubjectClass *klass)
{
parent_class = g_type_class_peek_parent(klass);
LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
}
GType lasso_saml_subject_get_type() {
static GType this_type = 0;
GType
lasso_saml_subject_get_type()
{
static GType this_type = 0;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoSamlSubjectClass),
NULL,
NULL,
(GClassInitFunc) lasso_saml_subject_class_init,
NULL,
NULL,
sizeof(LassoSamlSubject),
0,
(GInstanceInitFunc) lasso_saml_subject_instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoSamlSubject",
&this_info, 0);
}
return this_type;
if (!this_type) {
static const GTypeInfo this_info = {
sizeof (LassoSamlSubjectClass),
NULL,
NULL,
(GClassInitFunc) class_init,
NULL,
NULL,
sizeof(LassoSamlSubject),
0,
(GInstanceInitFunc) instance_init,
};
this_type = g_type_register_static(LASSO_TYPE_NODE,
"LassoSamlSubject", &this_info, 0);
}
return this_type;
}
/**
@ -118,5 +146,6 @@ GType lasso_saml_subject_get_type() {
**/
LassoNode* lasso_saml_subject_new()
{
return LASSO_NODE(g_object_new(LASSO_TYPE_SAML_SUBJECT, NULL));
return LASSO_NODE(g_object_new(LASSO_TYPE_SAML_SUBJECT, NULL));
}

Some files were not shown because too many files have changed in this diff Show More