summaryrefslogtreecommitdiffstats
path: root/php
diff options
context:
space:
mode:
authorChristophe Nowicki <cnowicki@easter-eggs.com>2004-08-04 16:12:49 +0000
committerChristophe Nowicki <cnowicki@easter-eggs.com>2004-08-04 16:12:49 +0000
commitf3e2bfbb4f3243bc82caa57eb922ba414909ee37 (patch)
tree2f0b56c8a0e9f021a9bc068287fde47fe367079d /php
parent59073ea1dde142312d2dec01e14f1607501e8cd9 (diff)
downloadlasso-f3e2bfbb4f3243bc82caa57eb922ba414909ee37.tar.gz
lasso-f3e2bfbb4f3243bc82caa57eb922ba414909ee37.tar.xz
lasso-f3e2bfbb4f3243bc82caa57eb922ba414909ee37.zip
first php binding import
Diffstat (limited to 'php')
-rw-r--r--php/Attic/examples/leak.php30
-rw-r--r--php/Attic/examples/login.php43
-rw-r--r--php/Attic/examples/test.php93
-rw-r--r--php/environs/lasso_federation.c58
-rw-r--r--php/environs/lasso_identity.c127
-rw-r--r--php/environs/lasso_login.c209
-rw-r--r--php/environs/lasso_profile.c261
-rw-r--r--php/environs/lasso_server.c187
-rw-r--r--php/environs/lasso_session.c33
-rw-r--r--php/lasso.c332
-rw-r--r--php/lasso.h7
-rw-r--r--php/php_lasso.h145
-rw-r--r--php/xml/lasso_lib_authn_request.c235
13 files changed, 1760 insertions, 0 deletions
diff --git a/php/Attic/examples/leak.php b/php/Attic/examples/leak.php
new file mode 100644
index 00000000..7701c270
--- /dev/null
+++ b/php/Attic/examples/leak.php
@@ -0,0 +1,30 @@
+#!/usr/bin/php
+<?php
+
+ if(!extension_loaded('lasso')) {
+ dl('lasso.' . PHP_SHLIB_SUFFIX);
+ }
+
+ /*
+ *
+ */
+
+ lasso_init();
+
+ $server = lasso_server_new("./sp.xml", "./rsapub.pem",
+ "./rsakey.pem", "./rsacert.pem", lassoSignatureMethodRsaSha1);
+ lasso_server_add_provider($server, "./idp.xml", "", "");
+
+ $login = lasso_login_new($server);
+
+ lasso_login_init_authn_request($login,
+ "https://identity-provider:2003/liberty-alliance/metadata");
+
+ $profile = lasso_cast_to_profile($login);
+ lasso_profile_get_request($profile);
+
+ $profile2 = lasso_cast_to_profile($login);
+ lasso_profile_get_request($profile2);
+
+ lasso_shutdown();
+?>
diff --git a/php/Attic/examples/login.php b/php/Attic/examples/login.php
new file mode 100644
index 00000000..31f8651b
--- /dev/null
+++ b/php/Attic/examples/login.php
@@ -0,0 +1,43 @@
+#!/usr/bin/php
+<?php
+ if(!extension_loaded('lasso')) {
+ dl('lasso.' . PHP_SHLIB_SUFFIX);
+ }
+
+ lasso_init();
+
+ print "Lasso version : " . lasso_version() . "\n";
+
+ $server = lasso_server_new(
+ "./sp.xml",
+ "./rsapub.pem",
+ "./rsakey.pem",
+ "./rsacert.pem", lassoSignatureMethodRsaSha1);
+
+ lasso_server_add_provider($server, "./idp.xml", "", "");
+
+ $splogin = lasso_login_new($server);
+
+ # Create AuthnRequest
+
+ lasso_login_init_authn_request($splogin, "https://identity-provider:2003/liberty-alliance/metadata");
+
+ $profile = lasso_cast_to_profile($splogin);
+
+ $node = lasso_profile_get_request($profile);
+
+ $lib_authn_request = lasso_cast_to_lib_authn_request($node);
+
+ lasso_lib_authn_request_set_ispassive($lib_authn_request, FALSE);
+ lasso_lib_authn_request_set_forceauthn($lib_authn_request, TRUE);
+ lasso_lib_authn_request_set_nameidpolicy($lib_authn_request, lassoLibNameIDPolicyTypeFederated);
+ lasso_lib_authn_request_set_relaystate($lib_authn_request, "fake");
+ lasso_lib_authn_request_set_protocolprofile($lib_authn_request, lassoLibProtocolProfileBrwsArt);
+
+ lasso_login_build_authn_request_msg($splogin);
+
+ print "msg_url : " . lasso_profile_get_msg_url($profile) . "\n";
+ print "msg_body : " . lasso_profile_get_msg_body($profile) . "\n";
+
+ lasso_shutdown();
+?>
diff --git a/php/Attic/examples/test.php b/php/Attic/examples/test.php
new file mode 100644
index 00000000..487ee58c
--- /dev/null
+++ b/php/Attic/examples/test.php
@@ -0,0 +1,93 @@
+#!/usr/bin/php
+<?php
+ if(!extension_loaded('lasso')) {
+ dl('lasso.' . PHP_SHLIB_SUFFIX);
+ }
+
+ $module = 'lasso';
+ $functions = get_extension_funcs($module);
+ echo "Functions available in the lasso extension:<br>\n";
+ foreach($functions as $func) {
+ echo $func."<br>\n";
+ }
+
+
+ echo "\n";
+
+ lasso_init();
+
+
+ print lasso_version() . "\n";
+
+ $identity = lasso_identity_new();
+
+ var_dump($identity);
+
+ $dump = lasso_identity_dump($identity);
+
+ var_dump($identity);
+
+ $server = lasso_server_new("./sp.xml", "./rsapub.pem", "./rsakey.pem", "./rsacert.pem", lassoSignatureMethodRsaSha1);
+ lasso_server_add_provider($server, "./idp.xml", "", "");
+
+ var_dump($server);
+
+ $dump = lasso_server_dump($server);
+
+ print $dump;
+
+ lasso_server_destroy($server);
+
+ var_dump($server);
+
+ $new_server = lasso_server_new_from_dump($dump);
+
+ var_dump($new_server);
+
+ $spsession = lasso_login_new($new_server);
+
+ var_dump($spsession);
+
+ lasso_login_init_authn_request($spsession,
+ "https://identity-provider:2003/liberty-alliance/metadata");
+
+
+
+ $profile = lasso_cast_to_profile($spsession);
+
+ var_dump($profile);
+
+ $node = lasso_profile_get_request($profile);
+
+ var_dump($node);
+
+ $lib_authn_request = lasso_cast_to_lib_authn_request($node);
+
+ var_dump($lib_authn_request);
+
+ lasso_lib_authn_request_set_consent($lib_authn_request, lassoLibConsentObtained);
+ lasso_lib_authn_request_set_ispassive($lib_authn_request, FALSE);
+ lasso_lib_authn_request_set_forceauthn($lib_authn_request, TRUE);
+ lasso_lib_authn_request_set_nameidpolicy($lib_authn_request, lassoLibNameIDPolicyTypeFederated);
+ lasso_lib_authn_request_set_relaystate($lib_authn_request, "fake");
+ lasso_lib_authn_request_set_protocolprofile($lib_authn_request, lassoLibProtocolProfileBrwsArt);
+
+ lasso_login_build_authn_request_msg($spsession);
+
+ $ret = lasso_login_init_authn_request($spsession, "https://identity-provider:1998/liberty-alliance/metadata");
+ if (!$ret) {
+ print("lasso_login_init_authn_request failed");
+ }
+
+ /* $dump = lasso_user_dump($user);
+ print ($dump);
+
+ $identity = lasso_identity_new("http://remote-provider-id.com");
+
+ var_dump($identity);
+
+ lasso_login_destroy($spsession); */
+
+ lasso_shutdown();
+
+?>
diff --git a/php/environs/lasso_federation.c b/php/environs/lasso_federation.c
new file mode 100644
index 00000000..ba461f68
--- /dev/null
+++ b/php/environs/lasso_federation.c
@@ -0,0 +1,58 @@
+/*
+ * PHP lasso -- PHP bindings for Lasso library
+ *
+ * Copyright (C) 2004 Entr'ouvert
+ * http://lasso.entrouvert.org
+ *
+ * Authors: Christophe Nowicki <cnowicki@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
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "php_ini.h"
+#include "ext/standard/info.h"
+#include "php_lasso.h"
+
+#include "lasso.h"
+
+/* {{{ proto resource lasso_federation_new(string remote_providerID) */
+PHP_FUNCTION(lasso_federation_new) {
+ LassoFederation *federation;
+ char *remote_providerID;
+ int remote_providerID_len;
+
+ int num_args;
+
+ zend_printf("DEBUG: lasso_federation_new\n");
+
+ if ((num_args = ZEND_NUM_ARGS()) != 1)
+ WRONG_PARAM_COUNT
+
+ if (zend_parse_parameters(num_args TSRMLS_CC, "s",
+ &remote_providerID, &remote_providerID_len) == FAILURE) {
+ return;
+ }
+
+
+ federation = lasso_federation_new(remote_providerID);
+
+ ZEND_REGISTER_RESOURCE(return_value, federation, le_lassofederation);
+}
+/* }}} */
diff --git a/php/environs/lasso_identity.c b/php/environs/lasso_identity.c
new file mode 100644
index 00000000..d61b924b
--- /dev/null
+++ b/php/environs/lasso_identity.c
@@ -0,0 +1,127 @@
+/*
+ * PHP lasso -- PHP bindings for Lasso library
+ *
+ * Copyright (C) 2004 Entr'ouvert
+ * http://lasso.entrouvert.org
+ *
+ * Authors: Christophe Nowicki <cnowicki@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
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "php_ini.h"
+#include "ext/standard/info.h"
+#include "php_lasso.h"
+
+#include "lasso.h"
+
+/* {{{ proto resource lasso_identity_new() */
+PHP_FUNCTION(lasso_identity_new) {
+ LassoIdentity *identity;
+
+ zend_printf("DEBUG: lasso_identity_new\n");
+
+ identity = lasso_identity_new();
+
+ ZEND_REGISTER_RESOURCE(return_value, identity, le_lassoidentity);
+}
+/* }}} */
+
+/* {{{ proto lasso_identity_destroy(resource identity) */
+PHP_FUNCTION(lasso_identity_destroy) {
+
+ LassoIdentity *identity;
+ zval *param;
+
+ zend_printf("DEBUG: lasso_identity_destroy\n");
+
+ int num_args;
+
+ if ((num_args = ZEND_NUM_ARGS()) != 1)
+ WRONG_PARAM_COUNT
+
+ if (zend_parse_parameters(num_args TSRMLS_CC, "z", &param) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(identity, LassoIdentity *, &param, -1, le_lassoidentity_name, le_lassoidentity);
+
+ zend_printf("DEBUG: identity at 0x%p\n", identity);
+
+ lasso_identity_destroy(identity);
+
+ zend_list_delete(Z_RESVAL_PP(&param));
+}
+/* }}} */
+
+/* {{{ proto lasso_identity_dump(resource identity) */
+PHP_FUNCTION(lasso_identity_dump) {
+ LassoIdentity *identity;
+ zval *param;
+ char *identity_dump;
+
+ int num_args;
+
+ zend_printf("DEBUG: lasso_identity_dump\n");
+
+ if ((num_args = ZEND_NUM_ARGS()) != 1)
+ WRONG_PARAM_COUNT
+
+ if (zend_parse_parameters(num_args TSRMLS_CC, "z", &param) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(identity, LassoIdentity *, &param, -1, le_lassoidentity_name, le_lassoidentity);
+
+ zend_printf("DEBUG: identity at 0x%p\n", identity);
+
+ identity_dump = lasso_identity_dump(identity);
+
+ RETURN_STRING(identity_dump, 1);
+
+}
+/* }}} */
+
+/* {{{ proto resource lasso_identity_get_next_providerID(resource identity) */
+PHP_FUNCTION(lasso_identity_get_next_providerid)
+{
+ LassoIdentity *identity;
+ char *providerID;
+ zval *param;
+
+ zend_printf("DEBUG: lasso_identity_get_next_providerID\n");
+
+ int num_args;
+
+ if ((num_args = ZEND_NUM_ARGS()) != 1)
+ WRONG_PARAM_COUNT
+
+ if (zend_parse_parameters(num_args TSRMLS_CC, "z", &param) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(identity, LassoIdentity *, &param, -1, le_lassoidentity_name, le_lassoidentity);
+
+ zend_printf("DEBUG: identity at 0x%p\n", identity);
+
+ providerID = (char *) lasso_identity_get_next_providerID(identity);
+ RETURN_STRING(providerID, 1);
+}
+/* }}} */
diff --git a/php/environs/lasso_login.c b/php/environs/lasso_login.c
new file mode 100644
index 00000000..cebaca3f
--- /dev/null
+++ b/php/environs/lasso_login.c
@@ -0,0 +1,209 @@
+/*
+ * PHP lasso -- PHP bindings for Lasso library
+ *
+ * Copyright (C) 2004 Entr'ouvert
+ * http://lasso.entrouvert.org
+ *
+ * Authors: Christophe Nowicki <cnowicki@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
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "php_ini.h"
+#include "ext/standard/info.h"
+#include "php_lasso.h"
+
+#include "lasso.h"
+
+/* {{{ proto resource lasso_login_new(resource server) */
+PHP_FUNCTION(lasso_login_new) {
+
+ LassoLogin *login;
+ LassoServer *server;
+ zval *param;
+
+ zend_printf("DEBUG: lasso_login_new\n");
+
+ int num_args;
+
+ if ((num_args = ZEND_NUM_ARGS()) != 1)
+ WRONG_PARAM_COUNT
+
+ if (zend_parse_parameters(num_args TSRMLS_CC, "z", &param) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(server, LassoServer *, &param, -1, le_lassoserver_name, le_lassoserver);
+
+ zend_printf("DEBUG: server at 0x%p\n", server);
+
+ login = lasso_login_new(server);
+
+ ZEND_REGISTER_RESOURCE(return_value, login, le_lassologin);
+}
+/* }}} */
+
+/* {{{ proto resource lasso_login_init_authn_request(resource login, string metadata) */
+PHP_FUNCTION(lasso_login_init_authn_request) {
+ LassoLogin *login;
+ zval *param;
+ char *meta;
+ int meta_len;
+
+ zend_printf("DEBUG: lasso_login_new\n");
+
+ int num_args;
+ int ret;
+
+ if ((num_args = ZEND_NUM_ARGS()) != 2)
+ WRONG_PARAM_COUNT
+
+ if (zend_parse_parameters(num_args TSRMLS_CC, "zs", &param,
+ &meta, &meta_len) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(login, LassoLogin *, &param, -1,
+ le_lassologin_name, le_lassologin);
+
+ zend_printf("DEBUG: login at 0x%p\n", login);
+
+ ret = lasso_login_init_authn_request(login, meta);
+
+ (ret) ? (RETURN_FALSE) : (RETURN_TRUE);
+}
+/* }}} */
+
+
+
+/* {{{ proto lasso_login_destroy(resource login) */
+PHP_FUNCTION(lasso_login_destroy) {
+
+ LassoLogin *login;
+ zval *param;
+
+ zend_printf("DEBUG: lasso_login_destroy\n");
+
+ int num_args;
+
+ if ((num_args = ZEND_NUM_ARGS()) != 1)
+ WRONG_PARAM_COUNT
+
+ if (zend_parse_parameters(num_args TSRMLS_CC, "z", &param) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(login, LassoLogin *, &param, -1, le_lassologin_name, le_lassologin);
+
+ zend_printf("DEBUG: login at 0x%p\n", login);
+
+ lasso_login_destroy(login);
+
+ zend_list_delete(Z_RESVAL_PP(&param));
+}
+/* }}} */
+
+/* {{{ proto resource lasso_login_new_from_dump(resource server, string dump) */
+PHP_FUNCTION(lasso_login_new_from_dump) {
+
+ LassoServer *server;
+ LassoLogin *login;
+ char *dump;
+ int dump_len;
+
+ zend_printf("DEBUG: lasso_login_new_from_dump\n");
+
+ zval *parm_server, *parm_user;
+
+ int num_args;
+
+ if ((num_args = ZEND_NUM_ARGS()) != 2)
+ WRONG_PARAM_COUNT
+
+ if (zend_parse_parameters(num_args TSRMLS_CC, "zs", &parm_server,
+ &dump, &dump_len) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(server, LassoServer *, &parm_server, -1, le_lassoserver_name, le_lassoserver);
+
+ zend_printf("DEBUG: server at 0x%p\n", server);
+
+
+ login = lasso_login_new_from_dump(server, dump);
+
+ ZEND_REGISTER_RESOURCE(return_value, login, le_lassologin);
+}
+/* }}} */
+
+
+/* {{{ proto lasso_login_build_request_msg(resource login) */
+PHP_FUNCTION(lasso_login_build_request_msg) {
+
+ LassoLogin *login;
+
+ zend_printf("DEBUG: lasso_login_build_request_msg\n");
+
+ zval *parm;
+
+ int num_args;
+ int ret;
+
+ if ((num_args = ZEND_NUM_ARGS()) != 1)
+ WRONG_PARAM_COUNT
+
+ if (zend_parse_parameters(num_args TSRMLS_CC, "z", &parm) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(login, LassoLogin *, &parm, -1, le_lassologin_name, le_lassologin);
+
+ zend_printf("DEBUG: login at 0x%p\n", login);
+
+ lasso_login_build_request_msg(login);
+}
+/* }}} */
+
+/* {{{ proto lasso_login_build_authn_request_msg(resource login) */
+PHP_FUNCTION(lasso_login_build_authn_request_msg) {
+
+ LassoLogin *login;
+
+ zend_printf("DEBUG: lasso_login_build_authn_request_msg\n");
+
+ zval *parm;
+
+ int num_args;
+ int ret;
+
+ if ((num_args = ZEND_NUM_ARGS()) != 1)
+ WRONG_PARAM_COUNT
+
+ if (zend_parse_parameters(num_args TSRMLS_CC, "z", &parm) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(login, LassoLogin *, &parm, -1, le_lassologin_name, le_lassologin);
+
+ zend_printf("DEBUG: login at 0x%p\n", login);
+
+ lasso_login_build_authn_request_msg(login);
+}
+/* }}} */
diff --git a/php/environs/lasso_profile.c b/php/environs/lasso_profile.c
new file mode 100644
index 00000000..9f835cd8
--- /dev/null
+++ b/php/environs/lasso_profile.c
@@ -0,0 +1,261 @@
+/*
+ *
+ * PHP lasso -- PHP bindings for Lasso library
+ *
+ * Copyright (C) 2004 Entr'ouvert
+ * http://lasso.entrouvert.org
+ *
+ * Authors: Christophe Nowicki <cnowicki@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
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "php_ini.h"
+#include "ext/standard/info.h"
+#include "php_lasso.h"
+
+#include "lasso.h"
+
+/* {{{ proto lasso_profile_new(resource server, resource identity, resource session) */
+PHP_FUNCTION(lasso_profile_new)
+{
+ LassoServer *server;
+ LassoIdentity *identity;
+ LassoSession *session;
+ LassoProfile *ctx;
+
+ zval *parm_server, *parm_identity, *parm_session;
+
+ zend_printf("DEBUG: lasso_profile_new\n");
+
+ int num_args;
+
+ if ((num_args = ZEND_NUM_ARGS()) != 3)
+ WRONG_PARAM_COUNT
+
+ if (zend_parse_parameters(num_args TSRMLS_CC, "zzz",
+ &parm_server, &parm_identity, &parm_session) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(server, LassoServer *, &parm_server, -1, le_lassoserver_name, le_lassoserver);
+
+ zend_printf("DEBUG: server at 0x%p\n", server);
+
+
+ ZEND_FETCH_RESOURCE(identity, LassoIdentity *, &parm_identity, -1, le_lassoidentity_name, le_lassoidentity);
+
+ zend_printf("DEBUG: identity at 0x%p\n", identity);
+
+ ZEND_FETCH_RESOURCE(session, LassoSession *, &parm_session, -1, le_lassosession_name, le_lassosession);
+
+ zend_printf("DEBUG: session at 0x%p\n", session);
+
+ ctx = lasso_profile_new(server, identity, session);
+
+ ZEND_REGISTER_RESOURCE(return_value, ctx, le_lassoprofile);
+
+}
+/* }}} */
+
+/* {{{ proto lasso_profile_dump() */
+PHP_FUNCTION(lasso_profile_dump)
+{
+ zend_printf("DEBUG: lasso_profile_dump\n");
+}
+/* }}} */
+
+/* {{{ proto lasso_profile_set_remote_providerid() */
+PHP_FUNCTION(lasso_profile_set_remote_providerid)
+{
+ zend_printf("DEBUG: lasso_profile_set_remote_providerid\n");
+}
+/* }}} */
+
+/* {{{ proto lasso_profile_set_response_status() */
+PHP_FUNCTION(lasso_profile_set_response_status)
+{
+ zend_printf("DEBUG: lasso_profile_set_response_status\n");
+}
+/* }}} */
+
+/* {{{ proto lasso_profile_user_from_dump() */
+PHP_FUNCTION(lasso_profile_user_from_dump)
+{
+ zend_printf("DEBUG: lasso_profile_user_from_dump\n");
+}
+/* }}} */
+
+/* {{{ proto lasso_profile_get_request_type_from_soap_msg() */
+PHP_FUNCTION(lasso_profile_get_request_type_from_soap_msg)
+{
+ zend_printf("DEBUG: lasso_profile_get_request_type_from_soap_msg\n");
+}
+/* }}} */
+
+/* {{{ proto resource lasso_cast_to_profile(resource login) */
+PHP_FUNCTION(lasso_cast_to_profile)
+{
+ LassoProfile *ctx;
+ LassoLogin *login;
+
+ zend_printf("DEBUG: lasso_cast_to_profile\n");
+
+ zval *parm;
+
+ int num_args;
+ int ret;
+
+ if ((num_args = ZEND_NUM_ARGS()) != 1)
+ WRONG_PARAM_COUNT
+
+ if (zend_parse_parameters(num_args TSRMLS_CC, "z", &parm) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(login, LassoLogin *, &parm, -1, le_lassologin_name, le_lassologin);
+
+ zend_printf("DEBUG: login at 0x%p\n", login);
+
+ ctx = LASSO_PROFILE(login);
+
+ ZEND_REGISTER_RESOURCE(return_value, ctx, le_lassoprofile);
+}
+/* }}} */
+
+/* {{{ proto resource lasso_profile_get_request(resource ctx) */
+PHP_FUNCTION(lasso_profile_get_request) {
+ LassoProfile *ctx;
+ LassoNode *node;
+
+ zend_printf("DEBUG: lasso_profile_get_request\n");
+
+ zval *parm;
+
+ int num_args;
+ int ret;
+
+ if ((num_args = ZEND_NUM_ARGS()) != 1)
+ WRONG_PARAM_COUNT
+
+ if (zend_parse_parameters(num_args TSRMLS_CC, "z", &parm) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(ctx, LassoProfile *, &parm, -1, le_lassoprofile_name, le_lassoprofile);
+
+ zend_printf("DEBUG: profile at 0x%p\n", ctx);
+
+ zend_printf("DEBUG: ctx->request at 0x%p\n", ctx->request);
+ node = ctx->request;
+
+ ZEND_REGISTER_RESOURCE(return_value, node, le_lassonode);
+}
+
+/* {{{ proto string lasso_profile_get_msg_url(resource ctx) */
+PHP_FUNCTION(lasso_profile_get_msg_url) {
+ LassoProfile *ctx;
+ LassoNode *node;
+
+ zend_printf("DEBUG: lasso_profile_get_msg_url\n");
+
+ zval *parm;
+
+ int num_args;
+ int ret;
+
+ if ((num_args = ZEND_NUM_ARGS()) != 1)
+ WRONG_PARAM_COUNT
+
+ if (zend_parse_parameters(num_args TSRMLS_CC, "z", &parm) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(ctx, LassoProfile *, &parm, -1, le_lassoprofile_name, le_lassoprofile);
+
+ zend_printf("DEBUG: profile at 0x%p\n", ctx);
+
+ zend_printf("DEBUG: ctx->msg_url at 0x%p\n", ctx->msg_url);
+
+ if (ctx->msg_url)
+ RETURN_STRING(ctx->msg_url, 1);
+}
+
+/* }}} */
+
+/* {{{ proto string lasso_profile_get_msg_body(resource ctx) */
+PHP_FUNCTION(lasso_profile_get_msg_body) {
+ LassoProfile *ctx;
+ LassoNode *node;
+
+ zend_printf("DEBUG: lasso_profile_get_msg_body\n");
+
+ zval *parm;
+
+ int num_args;
+ int ret;
+
+ if ((num_args = ZEND_NUM_ARGS()) != 1)
+ WRONG_PARAM_COUNT
+
+ if (zend_parse_parameters(num_args TSRMLS_CC, "z", &parm) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(ctx, LassoProfile *, &parm, -1, le_lassoprofile_name, le_lassoprofile);
+
+ zend_printf("DEBUG: profile at 0x%p\n", ctx);
+
+ zend_printf("DEBUG: ctx->msg_body at 0x%p\n", ctx->msg_body);
+
+ if (ctx->msg_body)
+ RETURN_STRING(ctx->msg_body, 1);
+}
+/* }}} */
+
+/* {{{ proto string lasso_profile_get_msg_relaystate(resource ctx) */
+PHP_FUNCTION(lasso_profile_get_msg_relaystate) {
+ LassoProfile *ctx;
+ LassoNode *node;
+
+ zend_printf("DEBUG: lasso_profile_get_msg_relaystate\n");
+
+ zval *parm;
+
+ int num_args;
+ int ret;
+
+ if ((num_args = ZEND_NUM_ARGS()) != 1)
+ WRONG_PARAM_COUNT
+
+ if (zend_parse_parameters(num_args TSRMLS_CC, "z", &parm) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(ctx, LassoProfile *, &parm, -1, le_lassoprofile_name, le_lassoprofile);
+
+ zend_printf("DEBUG: profile at 0x%p\n", ctx);
+
+ zend_printf("DEBUG: ctx->msg_relayState at 0x%p\n", ctx->msg_relayState);
+
+ if (ctx->msg_relayState)
+ RETURN_STRING(ctx->msg_relayState, 1);
+}
+/* }}} */
diff --git a/php/environs/lasso_server.c b/php/environs/lasso_server.c
new file mode 100644
index 00000000..2ec37d48
--- /dev/null
+++ b/php/environs/lasso_server.c
@@ -0,0 +1,187 @@
+/*
+ * PHP lasso -- PHP bindings for Lasso library
+ *
+ * Copyright (C) 2004 Entr'ouvert
+ * http://lasso.entrouvert.org
+ *
+ * Authors: Christophe Nowicki <cnowicki@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
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "php_ini.h"
+#include "ext/standard/info.h"
+#include "php_lasso.h"
+
+#include "lasso.h"
+
+
+/* {{{ proto lasso_server_new(string sp, string rsapub, string rsakey,
+ * string rsacert, long signaturemethod) */
+PHP_FUNCTION(lasso_server_new) {
+
+ LassoServer *server;
+
+ char *sp;
+ int sp_len;
+ char *rsapub;
+ int rsapub_len;
+ char *rsakey;
+ int rsakey_len;
+ char *rsacert;
+ int rsacert_len;
+ long signaturemethod;
+
+ int num_args;
+
+ zend_printf("DEBUG: lasso_server_new\n");
+
+ if ((num_args = ZEND_NUM_ARGS()) != 5)
+ WRONG_PARAM_COUNT
+
+ if (zend_parse_parameters(num_args TSRMLS_CC, "ssssl",
+ &sp, &sp_len, &rsapub, &rsapub_len,
+ &rsakey, &rsakey_len, &rsacert, &rsacert_len,
+ &signaturemethod) == FAILURE) {
+ return;
+ }
+
+ server = lasso_server_new(sp, rsapub, rsakey, rsacert, signaturemethod);
+
+ zend_printf("DEBUG: server at 0x%p\n", server);
+
+ ZEND_REGISTER_RESOURCE(return_value, server, le_lassoserver);
+}
+/* }}} */
+
+/* {{{ proto lasso_server_add_provider(resource server, string idp, string a, string b) */
+PHP_FUNCTION(lasso_server_add_provider) {
+
+ LassoServer *server;
+ zval *param;
+ char *idp;
+ int idp_len;
+ char *a;
+ int a_len;
+ char *b;
+ int b_len;
+
+ zend_printf("DEBUG: lasso_server_add_provider\n");
+
+ int num_args;
+
+ if ((num_args = ZEND_NUM_ARGS()) != 4)
+ WRONG_PARAM_COUNT
+
+ if (zend_parse_parameters(num_args TSRMLS_CC, "zsss", &param,
+ &idp, &idp_len, &a, &a_len, &b, &b_len) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(server, LassoServer *, &param, -1, le_lassoserver_name, le_lassoserver);
+
+ zend_printf("DEBUG: server at 0x%p\n", server);
+
+ lasso_server_add_provider(server, idp, a, b);
+
+
+}
+/* }}} */
+
+/* {{{ proto string lasso_server_new(resource server) */
+PHP_FUNCTION(lasso_server_dump) {
+
+ LassoServer *server;
+ zval *param;
+ char *server_dump;
+
+ int num_args;
+
+ zend_printf("DEBUG: lasso_server_dump\n");
+
+ if ((num_args = ZEND_NUM_ARGS()) != 1)
+ WRONG_PARAM_COUNT
+
+ if (zend_parse_parameters(num_args TSRMLS_CC, "z", &param) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(server, LassoServer *, &param, -1, le_lassoserver_name, le_lassoserver);
+
+ zend_printf("DEBUG: server at 0x%p\n", server);
+
+ server_dump = lasso_server_dump(server);
+
+ RETURN_STRING(server_dump, 1);
+}
+/* }}} */
+
+/* {{{ proto lasso_server_destroy(resource server) */
+PHP_FUNCTION(lasso_server_destroy) {
+
+ LassoServer *server;
+ zval *param;
+
+ zend_printf("DEBUG: lasso_server_destroy\n");
+
+ int num_args;
+
+ if ((num_args = ZEND_NUM_ARGS()) != 1)
+ WRONG_PARAM_COUNT
+
+ if (zend_parse_parameters(num_args TSRMLS_CC, "z", &param) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(server, LassoServer *, &param, -1, le_lassoserver_name, le_lassoserver);
+
+ zend_printf("DEBUG: server at 0x%p\n", server);
+
+ lasso_server_destroy(server);
+
+ zend_list_delete(Z_RESVAL_PP(&param));
+}
+/* }}} */
+
+/* {{{ proto resource lasso_server_new_from_dump(string dump) */
+PHP_FUNCTION(lasso_server_new_from_dump) {
+
+ LassoServer *server;
+ char *dump;
+ int dump_len;
+ int num_args;
+
+ zend_printf("DEBUG: lasso_server_new_from_dump\n");
+
+ if ((num_args = ZEND_NUM_ARGS()) != 1)
+ WRONG_PARAM_COUNT
+
+ if (zend_parse_parameters(num_args TSRMLS_CC, "s",
+ &dump, &dump_len) == FAILURE) {
+ return;
+ }
+
+ server = lasso_server_new_from_dump(dump);
+
+ ZEND_REGISTER_RESOURCE(return_value, server, le_lassoserver);
+}
+/* }}} */
+
+
diff --git a/php/environs/lasso_session.c b/php/environs/lasso_session.c
new file mode 100644
index 00000000..38787897
--- /dev/null
+++ b/php/environs/lasso_session.c
@@ -0,0 +1,33 @@
+/*
+ * PHP lasso -- PHP bindings for Lasso library
+ *
+ * Copyright (C) 2004 Entr'ouvert
+ * http://lasso.entrouvert.org
+ *
+ * Authors: Christophe Nowicki <cnowicki@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
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "php_ini.h"
+#include "ext/standard/info.h"
+#include "php_lasso.h"
+
+#include "lasso.h"
diff --git a/php/lasso.c b/php/lasso.c
new file mode 100644
index 00000000..cd413afe
--- /dev/null
+++ b/php/lasso.c
@@ -0,0 +1,332 @@
+/*
+ *
+ * PHP lasso -- PHP bindings for Lasso library
+ *
+ * Copyright (C) 2004 Entr'ouvert
+ * http://lasso.entrouvert.org
+ *
+ * Authors: Christophe Nowicki <cnowicki@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
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "php_ini.h"
+#include "ext/standard/info.h"
+#include "php_lasso.h"
+
+#include "lasso.h"
+
+/* True global resources - no need for thread safety here */
+int le_lasso;
+int le_lassonode;
+int le_lassoserver;
+int le_lassologin;
+int le_lassouser;
+int le_lassofederation;
+int le_lassosession;
+int le_lassoidentity;
+int le_lassoprofile;
+int le_lassolibauthnrequest;
+
+ZEND_DECLARE_MODULE_GLOBALS(lasso)
+
+/* {{{ lasso_functions[]
+ *
+ * Every user visible function must have an entry in lasso_functions[].
+ */
+function_entry lasso_functions[] = {
+ PHP_FE(lasso_init, NULL)
+ PHP_FE(lasso_version, NULL)
+ PHP_FE(lasso_shutdown, NULL)
+
+ /* lasso_server.c */
+ PHP_FE(lasso_server_new, NULL)
+ PHP_FE(lasso_server_dump, NULL)
+ PHP_FE(lasso_server_add_provider, NULL)
+ PHP_FE(lasso_server_destroy, NULL)
+ PHP_FE(lasso_server_new_from_dump, NULL)
+
+ /* lasso_login.c */
+ PHP_FE(lasso_login_new, NULL)
+ PHP_FE(lasso_login_new_from_dump, NULL)
+ PHP_FE(lasso_login_init_authn_request, NULL)
+ PHP_FE(lasso_login_destroy, NULL)
+ PHP_FE(lasso_login_build_request_msg, NULL)
+ PHP_FE(lasso_login_build_authn_request_msg, NULL)
+
+ /* lasso_user.c */
+ PHP_FE(lasso_identity_new, NULL)
+ PHP_FE(lasso_identity_dump, NULL)
+ PHP_FE(lasso_identity_get_next_providerid, NULL)
+ PHP_FE(lasso_identity_destroy, NULL)
+
+ /* lasso_profile_.c */
+ PHP_FE(lasso_profile_new, NULL)
+ PHP_FE(lasso_profile_dump, NULL)
+ PHP_FE(lasso_profile_set_remote_providerid, NULL)
+ PHP_FE(lasso_profile_set_response_status, NULL)
+ PHP_FE(lasso_profile_user_from_dump, NULL)
+ PHP_FE(lasso_profile_get_request_type_from_soap_msg, NULL)
+ PHP_FE(lasso_cast_to_profile, NULL)
+ PHP_FE(lasso_profile_get_request, NULL)
+ PHP_FE(lasso_profile_get_msg_url, NULL)
+ PHP_FE(lasso_profile_get_msg_body, NULL)
+
+ /* lasso_lib_authn_request.c */
+ PHP_FE(lasso_cast_to_lib_authn_request, NULL)
+ PHP_FE(lasso_lib_authn_request_set_consent, NULL)
+ PHP_FE(lasso_lib_authn_request_set_ispassive, NULL)
+ PHP_FE(lasso_lib_authn_request_set_forceauthn, NULL)
+ PHP_FE(lasso_lib_authn_request_set_nameidpolicy, NULL)
+ PHP_FE(lasso_lib_authn_request_set_relaystate, NULL)
+ PHP_FE(lasso_lib_authn_request_set_protocolprofile, NULL)
+
+ /* lasso_identity */
+ PHP_FE(lasso_federation_new, NULL)
+ {NULL, NULL, NULL}
+};
+/* }}} */
+
+/* {{{ lasso_module_entry
+ */
+zend_module_entry lasso_module_entry = {
+#if ZEND_MODULE_API_NO >= 20010901
+ STANDARD_MODULE_HEADER,
+#endif
+ "lasso",
+ lasso_functions,
+ PHP_MINIT(lasso),
+ PHP_MSHUTDOWN(lasso),
+ PHP_RINIT(lasso), /* Replace with NULL if there's nothing to do at request start */
+ PHP_RSHUTDOWN(lasso), /* Replace with NULL if there's nothing to do at request end */
+ PHP_MINFO(lasso),
+#if ZEND_MODULE_API_NO >= 20010901
+ "0.1", /* Replace with version number for your extension */
+#endif
+ STANDARD_MODULE_PROPERTIES
+};
+/* }}} */
+
+#ifdef COMPILE_DL_LASSO
+ZEND_GET_MODULE(lasso)
+#endif
+
+/* {{{ PHP_INI
+ */
+/* Remove comments and fill if you need to have entries in php.ini
+PHP_INI_BEGIN()
+ STD_PHP_INI_ENTRY("lasso.global_value", "42", PHP_INI_ALL, OnUpdateInt, global_value, zend_lasso_globals, lasso_globals)
+ STD_PHP_INI_ENTRY("lasso.global_string", "foobar", PHP_INI_ALL, OnUpdateString, global_string, zend_lasso_globals, lasso_globals)
+PHP_INI_END()
+*/
+/* }}} */
+
+/* {{{ */
+void lassonode_destruction_handler(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
+ LassoNode *my_rsrc = (LassoNode *) rsrc->ptr;
+ // do_whatever_needs_to_be_done_with_the_resource(my_rsrc);
+}
+/* }}} */
+
+/* {{{ */
+void lassoserver_destruction_handler(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
+ LassoServer *my_rsrc = (LassoServer *) rsrc->ptr;
+ // do_whatever_needs_to_be_done_with_the_resource(my_rsrc);
+}
+/* }}} */
+
+/* {{{ */
+void lassologin_destruction_handler(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
+ LassoLogin *my_rsrc = (LassoLogin *) rsrc->ptr;
+ // do_whatever_needs_to_be_done_with_the_resource(my_rsrc);
+}
+/* }}} */
+
+/* {{{ */
+void lassoidentity_destruction_handler(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
+ LassoIdentity *my_rsrc = (LassoIdentity *) rsrc->ptr;
+ // do_whatever_needs_to_be_done_with_the_resource(my_rsrc);
+}
+/* }}} */
+
+/* {{{ */
+void lassosession_destruction_handler(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
+ LassoSession *my_rsrc = (LassoSession *) rsrc->ptr;
+ // do_whatever_needs_to_be_done_with_the_resource(my_rsrc);
+}
+/* }}} */
+
+
+/* {{{ */
+void lassoprofile_destruction_handler(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
+ LassoProfile *my_rsrc = (LassoProfile *) rsrc->ptr;
+ // do_whatever_needs_to_be_done_with_the_resource(my_rsrc);
+}
+/* }}} */
+
+/* {{{ */
+void lassofederation_destruction_handler(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
+ LassoFederation *my_rsrc = (LassoFederation *) rsrc->ptr;
+ // do_whatever_needs_to_be_done_with_the_resource(my_rsrc);
+}
+/* }}} */
+
+/* {{{ */
+void lassolibauthnrequest_destruction_handler(zend_rsrc_list_entry *rsrc TSRMLS_DC) {
+ LassoLibAuthnRequest *my_rsrc = (LassoLibAuthnRequest *) rsrc->ptr;
+ // do_whatever_needs_to_be_done_with_the_resource(my_rsrc);
+}
+/* }}} */
+
+
+/* {{{ php_lasso_init_globals
+ */
+static void php_lasso_init_globals(zend_lasso_globals *lasso_globals)
+{
+ lasso_globals->global_value = 0;
+ lasso_globals->global_string = NULL;
+}
+/* }}} */
+
+/* {{{ PHP_MINIT_FUNCTION
+ */
+PHP_MINIT_FUNCTION(lasso)
+{
+ ZEND_INIT_MODULE_GLOBALS(lasso, php_lasso_init_globals, NULL);
+/* REGISTER_INI_ENTRIES(); */
+
+ /* Resources */
+ le_lassonode = zend_register_list_destructors_ex(lassonode_destruction_handler, NULL, le_lassonode_name, module_number);
+ le_lassoserver = zend_register_list_destructors_ex(lassoserver_destruction_handler, NULL, le_lassoserver_name, module_number);
+ le_lassologin = zend_register_list_destructors_ex(lassologin_destruction_handler, NULL, le_lassologin_name, module_number);
+ le_lassoidentity = zend_register_list_destructors_ex(lassoidentity_destruction_handler, NULL, le_lassoidentity_name, module_number);
+ le_lassosession = zend_register_list_destructors_ex(lassosession_destruction_handler, NULL, le_lassosession_name, module_number);
+ le_lassofederation = zend_register_list_destructors_ex(lassofederation_destruction_handler, NULL, le_lassofederation_name, module_number);
+ le_lassoprofile = zend_register_list_destructors_ex(lassoprofile_destruction_handler, NULL, le_lassoprofile_name, module_number);
+ le_lassolibauthnrequest = zend_register_list_destructors_ex(lassolibauthnrequest_destruction_handler, NULL, le_lassolibauthnrequest_name, module_number);
+
+
+ /* Constants */
+ REGISTER_LONG_CONSTANT("lassoSignatureMethodRsaSha1", 1, CONST_CS | CONST_PERSISTENT);
+ REGISTER_STRING_CONSTANT("lassoLibConsentObtained", lassoLibConsentObtained, CONST_CS | CONST_PERSISTENT);
+ REGISTER_STRING_CONSTANT("lassoLibNameIDPolicyTypeFederated", lassoLibNameIDPolicyTypeFederated, CONST_CS | CONST_PERSISTENT);
+ REGISTER_STRING_CONSTANT("lassoLibProtocolProfileBrwsArt", lassoLibProtocolProfileBrwsArt, CONST_CS | CONST_PERSISTENT);
+
+
+ return SUCCESS;
+}
+/* }}} */
+
+/* {{{ PHP_MSHUTDOWN_FUNCTION
+ */
+PHP_MSHUTDOWN_FUNCTION(lasso)
+{
+ /* uncomment this line if you have INI entries
+ UNREGISTER_INI_ENTRIES();
+ */
+ return SUCCESS;
+}
+/* }}} */
+
+/* Remove if there's nothing to do at request start */
+/* {{{ PHP_RINIT_FUNCTION
+ */
+PHP_RINIT_FUNCTION(lasso)
+{
+ return SUCCESS;
+}
+/* }}} */
+
+/* Remove if there's nothing to do at request end */
+/* {{{ PHP_RSHUTDOWN_FUNCTION
+ */
+PHP_RSHUTDOWN_FUNCTION(lasso)
+{
+ return SUCCESS;
+}
+/* }}} */
+
+/* {{{ PHP_MINFO_FUNCTION
+ */
+PHP_MINFO_FUNCTION(lasso)
+{
+ php_info_print_table_start();
+ php_info_print_table_header(2, "L.A.S.O.O support", "enabled");
+ php_info_print_table_end();
+
+ /* Remove comments if you have entries in php.ini
+ DISPLAY_INI_ENTRIES();
+ */
+}
+/* }}} */
+
+
+
+/* Remove the following function when you have succesfully modified config.m4
+ so that your module can be compiled into PHP, it exists only for testing
+ purposes. */
+
+/* {{{ proto long lasso_init()
+ Initialise le bourdel */
+PHP_FUNCTION(lasso_init)
+{
+ zend_printf("DEBUG: lasso_init\n");
+ if (ZEND_NUM_ARGS() != 0)
+ WRONG_PARAM_COUNT
+
+ RETURN_LONG(lasso_init());
+
+}
+/* }}} */
+
+/* {{{ proto long lasso_shutdown() */
+PHP_FUNCTION(lasso_shutdown)
+{
+ zend_printf("DEBUG: lasso_shutdown\n");
+ if (ZEND_NUM_ARGS() != 0)
+ WRONG_PARAM_COUNT
+
+ RETURN_LONG(lasso_shutdown());
+
+}
+/* }}} */
+
+/* {{{ proto string lasso_version() */
+PHP_FUNCTION(lasso_version)
+{
+ char lasso_version[6];
+
+ zend_printf("DEBUG: lasso_version\n");
+
+ snprintf(lasso_version, 6, "%d.%d.%d", LASSO_VERSION_MAJOR,
+ LASSO_VERSION_MINOR, LASSO_VERSION_SUBMINOR);
+
+ RETURN_STRING(lasso_version, 1)
+}
+/* }}} */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
diff --git a/php/lasso.h b/php/lasso.h
new file mode 100644
index 00000000..5834545c
--- /dev/null
+++ b/php/lasso.h
@@ -0,0 +1,7 @@
+
+#ifndef LASSO_H
+#define LASSO_H
+
+#include <lasso/lasso.h>
+
+#endif /* LASSO_H */
diff --git a/php/php_lasso.h b/php/php_lasso.h
new file mode 100644
index 00000000..4e55ef5b
--- /dev/null
+++ b/php/php_lasso.h
@@ -0,0 +1,145 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 4 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2003 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 2.02 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available at through the world-wide-web at |
+ | http://www.php.net/license/2_02.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Author: |
+ +----------------------------------------------------------------------+
+
+ $Id$
+*/
+
+#ifndef PHP_LASSO_H
+#define PHP_LASSO_H
+
+extern zend_module_entry lasso_module_entry;
+#define phpext_lasso_ptr &lasso_module_entry
+
+#ifdef PHP_WIN32
+#define PHP_LASSO_API __declspec(dllexport)
+#else
+#define PHP_LASSO_API
+#endif
+
+#ifdef ZTS
+#include "TSRM.h"
+#endif
+
+/* Resource */
+#define le_lassonode_name "LASSO Node Resource"
+#define le_lassoserver_name "LASSO Server Resource"
+#define le_lassologin_name "LASSO Login Resource"
+#define le_lassoidentity_name "LASSO Identity Resource"
+#define le_lassosession_name "LASSO Session Resource"
+#define le_lassofederation_name "LASSO Federation Resource"
+#define le_lassoprofile_name "LASSO Profile Resource"
+#define le_lassolibauthnrequest_name "LASSO Lib Authn Request Resource"
+
+PHP_MINIT_FUNCTION(lasso);
+PHP_MSHUTDOWN_FUNCTION(lasso);
+PHP_RINIT_FUNCTION(lasso);
+PHP_RSHUTDOWN_FUNCTION(lasso);
+PHP_MINFO_FUNCTION(lasso);
+
+PHP_FUNCTION(lasso_init);
+PHP_FUNCTION(lasso_version);
+PHP_FUNCTION(lasso_shutdown);
+
+/* lasso_server.c */
+PHP_FUNCTION(lasso_server_new);
+PHP_FUNCTION(lasso_server_dump);
+PHP_FUNCTION(lasso_server_add_provider);
+PHP_FUNCTION(lasso_server_destroy);
+PHP_FUNCTION(lasso_server_new_from_dump);
+
+/* lasso_login.c */
+PHP_FUNCTION(lasso_login_new);
+PHP_FUNCTION(lasso_login_new_from_dump);
+PHP_FUNCTION(lasso_login_init_authn_request);
+PHP_FUNCTION(lasso_login_build_request_msg);
+PHP_FUNCTION(lasso_login_destroy);
+PHP_FUNCTION(lasso_login_build_authn_request_msg);
+
+/* lasso_user.c */
+PHP_FUNCTION(lasso_identity_new);
+PHP_FUNCTION(lasso_identity_get_next_providerid);
+PHP_FUNCTION(lasso_identity_dump);
+PHP_FUNCTION(lasso_identity_destroy);
+
+/* lasso_federation.c */
+PHP_FUNCTION(lasso_federation_new);
+
+/* lasso_profile_.c */
+PHP_FUNCTION(lasso_profile_new);
+PHP_FUNCTION(lasso_profile_dump);
+PHP_FUNCTION(lasso_profile_set_remote_providerid);
+PHP_FUNCTION(lasso_profile_set_response_status);
+PHP_FUNCTION(lasso_profile_user_from_dump);
+PHP_FUNCTION(lasso_profile_get_request_type_from_soap_msg);
+PHP_FUNCTION(lasso_cast_to_profile);
+PHP_FUNCTION(lasso_profile_get_request);
+PHP_FUNCTION(lasso_profile_get_msg_url);
+PHP_FUNCTION(lasso_profile_get_msg_body);
+PHP_FUNCTION(lasso_profile_get_msg_relaystate);
+
+/* lasso_lib_authn_request.c */
+PHP_FUNCTION(lasso_cast_to_lib_authn_request);
+PHP_FUNCTION(lasso_lib_authn_request_set_consent);
+PHP_FUNCTION(lasso_lib_authn_request_set_ispassive);
+PHP_FUNCTION(lasso_lib_authn_request_set_forceauthn);
+PHP_FUNCTION(lasso_lib_authn_request_set_nameidpolicy);
+PHP_FUNCTION(lasso_lib_authn_request_set_relaystate);
+PHP_FUNCTION(lasso_lib_authn_request_set_protocolprofile);
+
+/* GLOBALS */
+ZEND_BEGIN_MODULE_GLOBALS(lasso)
+ long global_value;
+ char *global_string;
+ZEND_END_MODULE_GLOBALS(lasso)
+
+/* global resoucres */
+extern int le_lasso;
+extern int le_lassonode;
+extern int le_lassoserver;
+extern int le_lassologin;
+extern int le_lassoidentity;
+extern int le_lassosession;
+extern int le_lassofederation;
+extern int le_lassoprofile;
+extern int le_lassolibauthnrequest;
+
+/* In every utility function you add that needs to use variables
+ in php_lasso_globals, call TSRMLS_FETCH(); after declaring other
+ variables used by that function, or better yet, pass in TSRMLS_CC
+ after the last function argument and declare your utility function
+ with TSRMLS_DC after the last declared argument. Always refer to
+ the globals in your function as LASSO_G(variable). You are
+ encouraged to rename these macros something shorter, see
+ examples in any other php module directory.
+*/
+
+#ifdef ZTS
+#define LASSO_G(v) TSRMG(lasso_globals_id, zend_lasso_globals *, v)
+#else
+#define LASSO_G(v) (lasso_globals.v)
+#endif
+
+#endif /* PHP_LASSO_H */
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * indent-tabs-mode: t
+ * End:
+ */
diff --git a/php/xml/lasso_lib_authn_request.c b/php/xml/lasso_lib_authn_request.c
new file mode 100644
index 00000000..64810e40
--- /dev/null
+++ b/php/xml/lasso_lib_authn_request.c
@@ -0,0 +1,235 @@
+/*
+ *
+ * PHP lasso -- PHP bindings for Lasso library
+ *
+ * Copyright (C) 2004 Entr'ouvert
+ * http://lasso.entrouvert.org
+ *
+ * Authors: Christophe Nowicki <cnowicki@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
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "php_ini.h"
+#include "ext/standard/info.h"
+#include "php_lasso.h"
+
+#include "lasso.h"
+
+/* {{{ proto resource lasso_cast_to_lib_authn_request(resource node) */
+PHP_FUNCTION(lasso_cast_to_lib_authn_request)
+{
+ LassoNode *node;
+ LassoLibAuthnRequest *lib_authn_request;
+ zval *param;
+ int num_args;
+
+
+ zend_printf("DEBUG: lasso_cast_to_lib_authn_request\n");
+
+ if ((num_args = ZEND_NUM_ARGS()) != 1)
+ WRONG_PARAM_COUNT
+
+ if (zend_parse_parameters(num_args TSRMLS_CC, "z", &param) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(node, LassoNode *, &param, -1,
+ le_lassonode_name, le_lassonode);
+
+ zend_printf("DEBUG: node at 0x%p\n", node);
+
+ lib_authn_request = LASSO_LIB_AUTHN_REQUEST(node);
+
+ ZEND_REGISTER_RESOURCE(return_value, lib_authn_request, le_lassolibauthnrequest);
+}
+/* }}} */
+
+/* {{{ proto lasso_lib_authn_request_set_consent(resource lib_authn_request, string consent) */
+PHP_FUNCTION(lasso_lib_authn_request_set_consent)
+{
+ LassoLibAuthnRequest *lib_authn_request;
+ zval *param;
+ char *consent;
+ int consent_len;
+ int num_args;
+
+ zend_printf("DEBUG: lasso_lib_authn_request_consent_set\n");
+
+ if ((num_args = ZEND_NUM_ARGS()) != 2)
+ WRONG_PARAM_COUNT
+
+ if (zend_parse_parameters(num_args TSRMLS_CC, "zs", &param,
+ &consent, &consent_len) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(lib_authn_request, LassoLibAuthnRequest *, &param, -1,
+ le_lassolibauthnrequest_name, le_lassolibauthnrequest);
+
+ lasso_lib_authn_request_set_consent(lib_authn_request, consent);
+}
+/* }}} */
+
+
+
+/* {{{ proto lasso_lib_authn_request_set_ispassive(resource lib_authn_request, string consent) */
+PHP_FUNCTION(lasso_lib_authn_request_set_ispassive)
+{
+ LassoLibAuthnRequest *lib_authn_request;
+ zval *param;
+ unsigned int isPassive;
+ int num_args;
+
+ zend_printf("DEBUG: lasso_lib_authn_request_ispassive_set\n");
+
+ if ((num_args = ZEND_NUM_ARGS()) != 2)
+ WRONG_PARAM_COUNT
+
+ if (zend_parse_parameters(num_args TSRMLS_CC, "zb", &param, &isPassive) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(lib_authn_request, LassoLibAuthnRequest *, &param, -1,
+ le_lassolibauthnrequest_name, le_lassolibauthnrequest);
+
+ zend_printf("DEBUG: lassolibauthnrequest at 0x%p\n", lib_authn_request);
+
+ zend_printf("DEBUG: isPassive %d\n", isPassive - 137311488);
+
+ lasso_lib_authn_request_set_isPassive(lib_authn_request, isPassive - 137311488);
+}
+/* }}} */
+
+/* {{{ proto lasso_lib_authn_request_set_forceauthn(resource lib_authn_request, string consent) */
+PHP_FUNCTION(lasso_lib_authn_request_set_forceauthn)
+{
+ LassoLibAuthnRequest *lib_authn_request;
+ zval *param;
+ unsigned int forceauthn;
+ int num_args;
+
+ zend_printf("DEBUG: lasso_lib_authn_request_set_forceauthn\n");
+
+ if ((num_args = ZEND_NUM_ARGS()) != 2)
+ WRONG_PARAM_COUNT
+
+ if (zend_parse_parameters(num_args TSRMLS_CC, "zb", &param, &forceauthn) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(lib_authn_request, LassoLibAuthnRequest *, &param, -1,
+ le_lassolibauthnrequest_name, le_lassolibauthnrequest);
+
+ zend_printf("DEBUG: lassolibauthnrequest at 0x%p\n", lib_authn_request);
+
+ zend_printf("DEBUG: forceAuthn %d\n", forceauthn - 137311488);
+
+ lasso_lib_authn_request_set_forceAuthn(lib_authn_request, forceauthn - 137311488);
+}
+/* }}} */
+
+/* {{{ proto lasso_lib_authn_request_set_nameidpolicy(resource lib_authn_request, string consent) */
+PHP_FUNCTION(lasso_lib_authn_request_set_nameidpolicy)
+{
+ LassoLibAuthnRequest *lib_authn_request;
+ zval *param;
+ char *nameidpolicy;
+ int nameidpolicy_len;
+ int num_args;
+
+ zend_printf("DEBUG: lasso_lib_authn_request_set_nameidpolicy\n");
+
+ if ((num_args = ZEND_NUM_ARGS()) != 2)
+ WRONG_PARAM_COUNT
+
+ if (zend_parse_parameters(num_args TSRMLS_CC, "zs", &param, &nameidpolicy, &nameidpolicy_len) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(lib_authn_request, LassoLibAuthnRequest *, &param, -1,
+ le_lassolibauthnrequest_name, le_lassolibauthnrequest);
+
+ zend_printf("DEBUG: lassolibauthnrequest at 0x%p\n", lib_authn_request);
+
+ zend_printf("DEBUG: nameIDPolicy %s\n", nameidpolicy);
+
+ lasso_lib_authn_request_set_nameIDPolicy(lib_authn_request, nameidpolicy);
+}
+/* }}} */
+
+/* {{{ proto lasso_lib_authn_request_set_relaystate(resource lib_authn_request, string relaystate) */
+PHP_FUNCTION(lasso_lib_authn_request_set_relaystate)
+{
+ LassoLibAuthnRequest *lib_authn_request;
+ zval *param;
+ char *relaystate;
+ int relaystate_len;
+ int num_args;
+
+ zend_printf("DEBUG: lasso_lib_authn_request_set_relaystate\n");
+
+ if ((num_args = ZEND_NUM_ARGS()) != 2)
+ WRONG_PARAM_COUNT
+
+ if (zend_parse_parameters(num_args TSRMLS_CC, "zs", &param, &relaystate, &relaystate_len) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(lib_authn_request, LassoLibAuthnRequest *, &param, -1,
+ le_lassolibauthnrequest_name, le_lassolibauthnrequest);
+
+ zend_printf("DEBUG: lassolibauthnrequest at 0x%p\n", lib_authn_request);
+
+ zend_printf("DEBUG: relaystate %s\n", relaystate);
+
+ lasso_lib_authn_request_set_relayState(lib_authn_request, relaystate);
+}
+/* }}} */
+
+
+/* {{{ proto lasso_lib_authn_request_set_protocolprofile(resource lib_authn_request, string protocolprofile) */
+PHP_FUNCTION(lasso_lib_authn_request_set_protocolprofile)
+{
+ LassoLibAuthnRequest *lib_authn_request;
+ zval *param;
+ char *protocolprofile;
+ int protocolprofile_len;
+ int num_args;
+
+ zend_printf("DEBUG: lasso_lib_authn_request_set_protocolprofile\n");
+
+ if ((num_args = ZEND_NUM_ARGS()) != 2)
+ WRONG_PARAM_COUNT
+
+ if (zend_parse_parameters(num_args TSRMLS_CC, "zs", &param, &protocolprofile, &protocolprofile_len) == FAILURE) {
+ return;
+ }
+
+ ZEND_FETCH_RESOURCE(lib_authn_request, LassoLibAuthnRequest *, &param, -1,
+ le_lassolibauthnrequest_name, le_lassolibauthnrequest);
+
+ zend_printf("DEBUG: lassolibauthnrequest at 0x%p\n", lib_authn_request);
+
+ zend_printf("DEBUG: protocolprofile %s\n", protocolprofile);
+
+ lasso_lib_authn_request_set_protocolProfile(lib_authn_request, protocolprofile);
+}
+/* }}} */