1 /* $Id$
2  *
3  * Lasso - A free implementation of the Liberty Alliance specifications.
4  *
5  * Copyright (C) 2004-2007 Entr'ouvert
6  * http://lasso.entrouvert.org
7  *
8  * Authors: See AUTHORS file in top-level directory.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 #ifndef __LASSO_SESSION_H__
25 #define __LASSO_SESSION_H__
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif /* __cplusplus */
30 
31 #include "../xml/xml.h"
32 
33 #define LASSO_TYPE_SESSION (lasso_session_get_type())
34 #define LASSO_SESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_SESSION, LassoSession))
35 #define LASSO_SESSION_CLASS(klass) \
36 	(G_TYPE_CHECK_CLASS_CAST((klass), LASSO_TYPE_SESSION, LassoSessionClass))
37 #define LASSO_IS_SESSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), LASSO_TYPE_SESSION))
38 #define LASSO_IS_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LASSO_TYPE_SESSION))
39 #define LASSO_SESSION_GET_CLASS(o) \
40 	(G_TYPE_INSTANCE_GET_CLASS ((o), LASSO_TYPE_SESSION, LassoSessionClass))
41 
42 typedef struct _LassoSession LassoSession;
43 typedef struct _LassoSessionClass LassoSessionClass;
44 typedef struct _LassoSessionPrivate LassoSessionPrivate;
45 
46 /**
47  * LassoSession:
48  * @assertions:(element-type string LassoNode): a hashtable of #LassoSamlAssertion or #LassoSaml2Assertion, indexed by provider ids,
49  * @is_dirty: whether this session object has been modified since its creation.
50  *
51  * #LassoSession stores the assertions received or emitted during the current session. It stores
52  * state for using profiles like #LassoLogin or #LassoLogout.
53  */
54 struct _LassoSession {
55 	LassoNode parent;
56 
57 	/* Can actually contain LassoSamlAssertion or LassoSaml2Assertion */
58 	GHashTable *assertions; /* of LassoNode */
59 	gboolean is_dirty;
60 
61 	/*< private >*/
62 	LassoSessionPrivate *private_data;
63 };
64 
65 struct _LassoSessionClass {
66 	LassoNodeClass parent;
67 };
68 
69 LASSO_EXPORT GType lasso_session_get_type(void);
70 
71 LASSO_EXPORT LassoSession* lasso_session_new(void);
72 LASSO_EXPORT LassoSession* lasso_session_new_from_dump(const gchar *dump);
73 LASSO_EXPORT gchar* lasso_session_dump(LassoSession *session);
74 LASSO_EXPORT void lasso_session_destroy(LassoSession *session);
75 
76 LASSO_EXPORT GList* lasso_session_get_assertions(
77 	LassoSession *session, const char* provider_id);
78 LASSO_EXPORT gchar* lasso_session_get_provider_index(LassoSession *session, gint index);
79 LASSO_EXPORT gboolean lasso_session_is_empty(LassoSession *session);
80 LASSO_EXPORT lasso_error_t lasso_session_remove_assertion(LassoSession *session, const gchar *providerID);
81 LASSO_EXPORT LassoNode* lasso_session_get_assertion(
82 		LassoSession *session, const gchar *providerID);
83 LASSO_EXPORT lasso_error_t lasso_session_add_assertion(LassoSession *session,
84 		const char *providerID, LassoNode *assertion);
85 
86 LASSO_EXPORT GList *lasso_session_get_name_ids(LassoSession *session, const gchar *providerID);
87 
88 LASSO_EXPORT GList *lasso_session_get_session_indexes(LassoSession *session,
89 		const gchar *providerID, LassoNode *name_id);
90 
91 LASSO_EXPORT GList* lasso_session_get_assertion_ids(LassoSession *session, const gchar *providerID);
92 
93 #ifdef __cplusplus
94 }
95 #endif /* __cplusplus */
96 
97 #endif /* __LASSO_SESSION_H__ */
98