diff options
| -rw-r--r-- | lasso/Attic/protocols/Makefile.am | 2 | ||||
| -rw-r--r-- | lasso/Attic/protocols/artifact.c | 148 | ||||
| -rw-r--r-- | lasso/Attic/protocols/artifact.h | 71 | ||||
| -rw-r--r-- | lasso/xml/tools.h | 1 |
4 files changed, 221 insertions, 1 deletions
diff --git a/lasso/Attic/protocols/Makefile.am b/lasso/Attic/protocols/Makefile.am index b81eccbe..4d1fbf26 100644 --- a/lasso/Attic/protocols/Makefile.am +++ b/lasso/Attic/protocols/Makefile.am @@ -23,6 +23,7 @@ liblasso_protocols_la_LIBADD = \ liblasso_protocols_la_SOURCES = \ protocols.c \ + artifact.c \ authn_request.c \ authn_response.c \ federation_termination_notification.c \ @@ -39,6 +40,7 @@ liblasso_protocols_la_SOURCES = \ liblassoinclude_HEADERS = \ protocols.h \ + artifact.h \ authn_request.h \ authn_response.h \ federation_termination_notification.h \ diff --git a/lasso/Attic/protocols/artifact.c b/lasso/Attic/protocols/artifact.c new file mode 100644 index 00000000..048dbaaf --- /dev/null +++ b/lasso/Attic/protocols/artifact.c @@ -0,0 +1,148 @@ +/* $Id$ + * + * Lasso - A free implementation of the Liberty Alliance specifications. + * + * Copyright (C) 2004 Entr'ouvert + * http://lasso.entrouvert.org + * + * Authors: Valery Febvre <vfebvre@easter-eggs.com> + * Nicolas Clapies <nclapies@entrouvert.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/protocols/artifact.h> + +/*****************************************************************************/ +/* functions */ +/*****************************************************************************/ + +/*****************************************************************************/ +/* public methods */ +/*****************************************************************************/ + +xmlChar* +lasso_artifact_get_assertionHandle(LassoArtifact *artifact) +{ + return (lasso_node_get_child_content(LASSO_NODE(artifact), "AssertionHandle", NULL)); +} + +gint +lasso_artifact_get_byteCode(LassoArtifact *artifact) +{ + xmlChar *byteCode; + + byteCode = lasso_node_get_child_content(LASSO_NODE(artifact), "ByteCode", NULL); + return ((gint)g_strtod(byteCode, NULL)); +} + +xmlChar* +lasso_artifact_get_identityProviderSuccinctID(LassoArtifact *artifact) +{ + return (lasso_node_get_child_content(LASSO_NODE(artifact), "IdentityProviderSuccinctID", NULL)); +} + +xmlChar* +lasso_artifact_get_relayState(LassoArtifact *artifact) +{ + return (lasso_node_get_child_content(LASSO_NODE(artifact), "RelayState", NULL)); +} + +/*****************************************************************************/ +/* instance and class init functions */ +/*****************************************************************************/ + +static void +lasso_artifact_instance_init(LassoArtifact *artifact) +{ + LassoNodeClass *class = LASSO_NODE_GET_CLASS(LASSO_NODE(artifact)); + + class->set_name(LASSO_NODE(artifact), "Artifact"); +} + +static void +lasso_artifact_class_init(LassoArtifactClass *class) +{ +} + +GType lasso_artifact_get_type() { + static GType this_type = 0; + + if (!this_type) { + static const GTypeInfo this_info = { + sizeof (LassoArtifactClass), + NULL, + NULL, + (GClassInitFunc) lasso_artifact_class_init, + NULL, + NULL, + sizeof(LassoArtifact), + 0, + (GInstanceInitFunc) lasso_artifact_instance_init, + }; + + this_type = g_type_register_static(LASSO_TYPE_NODE, + "LassoArtifact", + &this_info, 0); + } + return this_type; +} + +LassoNode* +lasso_artifact_new(const xmlChar *query) +{ + LassoNode *artifact; + LassoNodeClass *class; + GData *gd; + gchar *b64_samlArt, *samlArt, *relayState, *byteCode, *identityProviderSuccinctID, *assertionHandle; + gint i, j, byte_code=0; + + artifact = LASSO_NODE(g_object_new(LASSO_TYPE_ARTIFACT, NULL)); + + gd = lasso_query_to_dict(query); + b64_samlArt = g_strdup(lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "SAMLArt"), 0)); + relayState = g_strdup(lasso_g_ptr_array_index((GPtrArray *)g_datalist_get_data(&gd, "RelayState"), 0)); + g_datalist_clear(&gd); + + /* extract ByteCode, IdentityProviderSuccinctID and AssertionHandle */ + samlArt = (gchar *) g_new0(gchar, 42+1); + byteCode = (gchar *) g_new0(gchar, 5+1); + identityProviderSuccinctID = (gchar *) g_new0(gchar, 20+1); + assertionHandle = (gchar *) g_new0(gchar, 20+1); + + i = xmlSecBase64Decode(b64_samlArt, samlArt, 42+1); + xmlFree(b64_samlArt); + for(j=0; j<42; j++) { + if (j<2) { + byte_code += (gint)samlArt[j]; + } + else if (j>=2 && j<22) { + identityProviderSuccinctID[j-2] = samlArt[j]; + } + else if (j>=22) { + assertionHandle[j-22] = samlArt[j]; + } + } + sprintf(byteCode, "%d", byte_code); + xmlFree(samlArt); + + class = LASSO_NODE_GET_CLASS(artifact); + class->new_child(artifact, "RelayState", relayState, FALSE); + class->new_child(artifact, "ByteCode", byteCode, FALSE); + class->new_child(artifact, "IdentityProviderSuccinctID", identityProviderSuccinctID, FALSE); + class->new_child(artifact, "AssertionHandle", assertionHandle, FALSE); + + return (artifact); +} diff --git a/lasso/Attic/protocols/artifact.h b/lasso/Attic/protocols/artifact.h new file mode 100644 index 00000000..434a0566 --- /dev/null +++ b/lasso/Attic/protocols/artifact.h @@ -0,0 +1,71 @@ +/* $Id$ + * + * Lasso - A free implementation of the Liberty Alliance specifications. + * + * Copyright (C) 2004 Entr'ouvert + * http://lasso.entrouvert.org + * + * Authors: Valery Febvre <vfebvre@easter-eggs.com> + * Nicolas Clapies <nclapies@entrouvert.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_ARTIFACT_H__ +#define __LASSO_ARTIFACT_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <lasso/xml/xml.h> + +#define LASSO_TYPE_ARTIFACT (lasso_artifact_get_type()) +#define LASSO_ARTIFACT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_ARTIFACT, LassoArtifact)) +#define LASSO_ARTIFACT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), LASSO_TYPE_ARTIFACT, LassoArtifactClass)) +#define LASSO_IS_ARTIFACT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), LASSO_TYPE_ARTIFACT)) +#define LASSP_IS_ARTIFACT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LASSO_TYPE_ARTIFACT)) +#define LASSO_ARTIFACT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), LASSO_TYPE_ARTIFACT, LassoArtifactClass)) + +typedef struct _LassoArtifact LassoArtifact; +typedef struct _LassoArtifactClass LassoArtifactClass; + +struct _LassoArtifact { + LassoNode parent; + /*< public >*/ + /*< private >*/ +}; + +struct _LassoArtifactClass { + LassoNodeClass parent; +}; + +LASSO_EXPORT GType lasso_artifact_get_type (void); + +LASSO_EXPORT LassoNode* lasso_artifact_new (const xmlChar *query); + +LASSO_EXPORT xmlChar* lasso_artifact_get_assertionHandle (LassoArtifact *artifact); + +LASSO_EXPORT gint lasso_artifact_get_byteCode (LassoArtifact *artifact); + +LASSO_EXPORT xmlChar* lasso_artifact_get_identityProviderSuccinctID (LassoArtifact *artifact); + +LASSO_EXPORT xmlChar* lasso_artifact_get_relayState (LassoArtifact *artifact); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __LASSO_ARTIFACT_H__ */ diff --git a/lasso/xml/tools.h b/lasso/xml/tools.h index f1a9bc82..61f7e387 100644 --- a/lasso/xml/tools.h +++ b/lasso/xml/tools.h @@ -42,7 +42,6 @@ extern "C" { typedef enum { lassoSignatureMethodRsaSha1 = 1, lassoSignatureMethodDsaSha1, - lassoSignatureMethodSha1 } lassoSignatureMethod; LASSO_EXPORT xmlChar* lasso_build_random_sequence (guint8 size); |
