diff options
| author | Frederic Peters <fpeters@entrouvert.com> | 2005-08-08 11:31:17 +0000 |
|---|---|---|
| committer | Frederic Peters <fpeters@entrouvert.com> | 2005-08-08 11:31:17 +0000 |
| commit | c848b6b6f792fd586c29c860edd758128b9e8b68 (patch) | |
| tree | cdcf7d03993af4d81026a7cab95cc9abfd02c634 | |
| parent | 6394077ec8400f3fa1a44a43226012eaff321162 (diff) | |
added session and identity to LassoWsfProfile, much like LassoProfile. Exposed
them via SWIG inherited into LassoDiscovery object
| -rw-r--r-- | lasso/id-wsf/wsf_profile.c | 117 | ||||
| -rw-r--r-- | lasso/id-wsf/wsf_profile.h | 15 | ||||
| -rw-r--r-- | swig/Lasso-wsf.i | 45 |
3 files changed, 177 insertions, 0 deletions
diff --git a/lasso/id-wsf/wsf_profile.c b/lasso/id-wsf/wsf_profile.c index fff4239d..b756926b 100644 --- a/lasso/id-wsf/wsf_profile.c +++ b/lasso/id-wsf/wsf_profile.c @@ -62,6 +62,123 @@ lasso_wsf_profile_build_soap_envelope(const char *refToMessageId) /* public methods */ /*****************************************************************************/ + +/** + * lasso_wsf_profile_get_identity: + * @profile: a #LassoWsfProfile + * + * Gets the identity bound to @profile. + * + * Return value: the identity or NULL if it none was found. The #LassoIdentity + * object is internally allocated and must not be freed by the caller. + **/ +LassoIdentity* +lasso_wsf_profile_get_identity(LassoWsfProfile *profile) +{ + if (profile->identity && g_hash_table_size(profile->identity->federations)) + return profile->identity; + return NULL; +} + + +/** + * lasso_wsf_profile_get_session: + * @profile: a #LassoWsfProfile + * + * Gets the session bound to @profile. + * + * Return value: the session or NULL if it none was found. The #LassoSession + * object is internally allocated and must not be freed by the caller. + **/ +LassoSession* +lasso_wsf_profile_get_session(LassoWsfProfile *profile) +{ + if (profile->session == NULL) + return NULL; + + if (lasso_session_is_empty(profile->session)) + return NULL; + + return profile->session; +} + + +/** + * lasso_wsf_profile_is_identity_dirty: + * @profile: a #LassoWsfProfile + * + * Checks whether identity has been modified (and should therefore be saved). + * + * Return value: %TRUE if identity has changed + **/ +gboolean +lasso_wsf_profile_is_identity_dirty(LassoWsfProfile *profile) +{ + return (profile->identity && profile->identity->is_dirty); +} + + +/** + * lasso_wsf_profile_is_session_dirty: + * @profile: a #LassoWsfProfile + * + * Checks whether session has been modified (and should therefore be saved). + * + * Return value: %TRUE if session has changed + **/ +gboolean +lasso_wsf_profile_is_session_dirty(LassoWsfProfile *profile) +{ + return (profile->session && profile->session->is_dirty); +} + + +/** + * lasso_wsf_profile_set_identity_from_dump: + * @profile: a #LassoWsfProfile + * @dump: XML identity dump + * + * Builds a new #LassoIdentity object from XML dump and binds it to @profile. + * + * Return value: 0 on success; or a negative value otherwise. + **/ +gint +lasso_wsf_profile_set_identity_from_dump(LassoWsfProfile *profile, const gchar *dump) +{ + g_return_val_if_fail(dump != NULL, LASSO_PARAM_ERROR_INVALID_VALUE); + + profile->identity = lasso_identity_new_from_dump(dump); + if (profile->identity == NULL) + return critical_error(LASSO_PROFILE_ERROR_BAD_IDENTITY_DUMP); + + return 0; +} + + +/** + * lasso_wsf_profile_set_session_from_dump: + * @profile: a #LassoWsfProfile + * @dump: XML session dump + * + * Builds a new #LassoSession object from XML dump and binds it to @profile. + * + * Return value: 0 on success; or a negative value otherwise. + **/ +gint +lasso_wsf_profile_set_session_from_dump(LassoWsfProfile *profile, const gchar *dump) +{ + g_return_val_if_fail(dump != NULL, LASSO_PARAM_ERROR_INVALID_VALUE); + + profile->session = lasso_session_new_from_dump(dump); + if (profile->session == NULL) + return critical_error(LASSO_PROFILE_ERROR_BAD_SESSION_DUMP); + profile->session->is_dirty = FALSE; + + return 0; +} + + + gint lasso_wsf_profile_init_soap_request(LassoWsfProfile *profile, LassoNode *request) { diff --git a/lasso/id-wsf/wsf_profile.h b/lasso/id-wsf/wsf_profile.h index fb9b71c3..67a7cfb1 100644 --- a/lasso/id-wsf/wsf_profile.h +++ b/lasso/id-wsf/wsf_profile.h @@ -31,6 +31,8 @@ extern "C" { #endif /* __cplusplus */ #include <lasso/id-ff/server.h> +#include <lasso/id-ff/identity.h> +#include <lasso/id-ff/session.h> #include <lasso/xml/soap_envelope.h> #include <lasso/xml/soap_binding_provider.h> @@ -63,6 +65,9 @@ struct _LassoWsfProfile { gchar *msg_url; gchar *msg_body; + /*< private >*/ + LassoIdentity *identity; + LassoSession *session; }; struct _LassoWsfProfileClass { @@ -71,6 +76,16 @@ struct _LassoWsfProfileClass { LASSO_EXPORT GType lasso_wsf_profile_get_type(void); +LASSO_EXPORT LassoIdentity* lasso_wsf_profile_get_identity(LassoWsfProfile *profile); +LASSO_EXPORT LassoSession* lasso_wsf_profile_get_session(LassoWsfProfile *profile); +LASSO_EXPORT gboolean lasso_wsf_profile_is_identity_dirty(LassoWsfProfile *profile); +LASSO_EXPORT gboolean lasso_wsf_profile_is_session_dirty(LassoWsfProfile *profile); + +LASSO_EXPORT gint lasso_wsf_profile_set_identity_from_dump(LassoWsfProfile *profile, + const gchar *dump); +LASSO_EXPORT gint lasso_wsf_profile_set_session_from_dump(LassoWsfProfile *profile, + const gchar *dump); + /* FIXME: must be private method */ LASSO_EXPORT LassoSoapEnvelope* lasso_wsf_profile_build_soap_envelope(const char *refToMessageId); diff --git a/swig/Lasso-wsf.i b/swig/Lasso-wsf.i index c864e4ed..782af18b 100644 --- a/swig/Lasso-wsf.i +++ b/swig/Lasso-wsf.i @@ -3428,6 +3428,15 @@ typedef struct { %extend LassoDiscovery { /* Attributes inherited from WsfProfile */ + %newobject identity_get; + LassoIdentity *identity; + + %immutable isIdentityDirty; + gboolean isIdentityDirty; + + %immutable isSessionDirty; + gboolean isSessionDirty; + %immutable msgBody; char *msgBody; @@ -3462,6 +3471,14 @@ typedef struct { /* Methods inherited from WsfProfile */ + THROW_ERROR + int setIdentityFromDump(char *dump); + END_THROW_ERROR + + THROW_ERROR + int setSessionFromDump(char *dump); + END_THROW_ERROR + THROW_ERROR int buildRequestMsg(); END_THROW_ERROR @@ -3517,6 +3534,26 @@ typedef struct { /* Attributes inherited from WsfProfile implementations */ +/* identity */ +#define LassoDiscovery_get_identity(self) lasso_wsf_profile_get_identity(LASSO_WSF_PROFILE(self)) +#define LassoDiscovery_identity_get(self) lasso_wsf_profile_get_identity(LASSO_WSF_PROFILE(self)) +#define LassoDiscovery_set_identity(self, value) set_node((gpointer *) &LASSO_WSF_PROFILE(self)->identity, (value)) +#define LassoDiscovery_identity_set(self, value) set_node((gpointer *) &LASSO_WSF_PROFILE(self)->identity, (value)) + +/* isIdentityDirty */ +#define LassoDiscovery_get_isIdentityDirty(self) lasso_wsf_profile_is_identity_dirty(LASSO_WSF_PROFILE(self)) +#define LassoDiscovery_isIdentityDirty_get(self) lasso_wsf_profile_is_identity_dirty(LASSO_WSF_PROFILE(self)) + +/* session */ +#define LassoDiscovery_get_session(self) lasso_wsf_profile_get_session(LASSO_WSF_PROFILE(self)) +#define LassoDiscovery_session_get(self) lasso_wsf_profile_get_session(LASSO_WSF_PROFILE(self)) +#define LassoDiscovery_set_session(self, value) set_node((gpointer *) &LASSO_WSF_PROFILE(self)->session, (value)) +#define LassoDiscovery_session_set(self, value) set_node((gpointer *) &LASSO_WSF_PROFILE(self)->session, (value)) + +/* isSessionDirty */ +#define LassoDiscovery_get_isSessionDirty(self) lasso_wsf_profile_is_session_dirty(LASSO_WSF_PROFILE(self)) +#define LassoDiscovery_isSessionDirty_get(self) lasso_wsf_profile_is_session_dirty(LASSO_WSF_PROFILE(self)) + /* msgBody */ #define LassoDiscovery_get_msgBody(self) LASSO_WSF_PROFILE(self)->msg_body #define LassoDiscovery_msgBody_get(self) LASSO_WSF_PROFILE(self)->msg_body @@ -3566,6 +3603,14 @@ typedef struct { /* Implementations of methods inherited from WsfProfile */ +int LassoDiscovery_setIdentityFromDump(LassoDiscovery *self, char *dump) { + return lasso_wsf_profile_set_identity_from_dump(LASSO_WSF_PROFILE(self), dump); +} + +int LassoDiscovery_setSessionFromDump(LassoDiscovery *self, char *dump) { + return lasso_wsf_profile_set_session_from_dump(LASSO_WSF_PROFILE(self), dump); +} + #define LassoDiscovery_buildRequestMsg(self) lasso_wsf_profile_build_soap_request_msg(LASSO_WSF_PROFILE(self)) #define LassoDiscovery_buildResponseMsg(self) lasso_wsf_profile_build_soap_response_msg(LASSO_WSF_PROFILE(self)) |
