summaryrefslogtreecommitdiffstats
path: root/php
diff options
context:
space:
mode:
authorChristophe Nowicki <cnowicki@easter-eggs.com>2004-08-20 09:45:38 +0000
committerChristophe Nowicki <cnowicki@easter-eggs.com>2004-08-20 09:45:38 +0000
commit42e6495ad11c6b6a4265e7ad378ba4dfde0e6df8 (patch)
tree170e5f06fd0c08204297c8a9e3bfde8f57290473 /php
parent7b462495723b08e965d6077fc57604c4617a414a (diff)
downloadlasso-42e6495ad11c6b6a4265e7ad378ba4dfde0e6df8.tar.gz
lasso-42e6495ad11c6b6a4265e7ad378ba4dfde0e6df8.tar.xz
lasso-42e6495ad11c6b6a4265e7ad378ba4dfde0e6df8.zip
new setup system
Diffstat (limited to 'php')
-rw-r--r--php/Attic/examples/sample-sp/admin_user.php4
-rw-r--r--php/Attic/examples/sample-sp/assertionConsumer.php6
-rw-r--r--php/Attic/examples/sample-sp/config.php.inc27
-rw-r--r--php/Attic/examples/sample-sp/index.php43
-rw-r--r--php/Attic/examples/sample-sp/login.php5
-rw-r--r--php/Attic/examples/sample-sp/logout.php6
-rw-r--r--php/Attic/examples/sample-sp/register.php6
-rw-r--r--php/Attic/examples/sample-sp/setup.php140
8 files changed, 162 insertions, 75 deletions
diff --git a/php/Attic/examples/sample-sp/admin_user.php b/php/Attic/examples/sample-sp/admin_user.php
index 83e9b7b1..6893ad72 100644
--- a/php/Attic/examples/sample-sp/admin_user.php
+++ b/php/Attic/examples/sample-sp/admin_user.php
@@ -22,12 +22,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
- include "config.php.inc";
+ $config = unserialize(file_get_contents('config.inc'));
require_once 'DB.php';
- $db = &DB::connect($dsn);
+ $db = &DB::connect($config['dsn']);
if (DB::isError($db))
die($db->getMessage());
diff --git a/php/Attic/examples/sample-sp/assertionConsumer.php b/php/Attic/examples/sample-sp/assertionConsumer.php
index 7f19994a..2f434e24 100644
--- a/php/Attic/examples/sample-sp/assertionConsumer.php
+++ b/php/Attic/examples/sample-sp/assertionConsumer.php
@@ -22,7 +22,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
- include "config.php.inc";
+ $config = unserialize(file_get_contents('config.inc'));
require_once 'DB.php';
@@ -35,7 +35,7 @@
lasso_init();
- $server_dump = file_get_contents($server_dump_filename);
+ $server_dump = file_get_contents($config['server_dump_filename']);
$server = lasso_server_new_from_dump($server_dump);
@@ -81,7 +81,7 @@
$options = array(
'debug' => 2,
);
- $db = &DB::connect($dsn, $options);
+ $db = &DB::connect($config['dsn'], $options);
if (DB::isError($db))
die($db->getMessage());
diff --git a/php/Attic/examples/sample-sp/config.php.inc b/php/Attic/examples/sample-sp/config.php.inc
deleted file mode 100644
index baf26b4a..00000000
--- a/php/Attic/examples/sample-sp/config.php.inc
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-/*
- * Service Provider Example -- Configuration File
- *
- * 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
- */
- $server_dump_filename = "lasso_server_dump.xml";
-
- $dsn = "pgsql://sp:sp@localhost/sp";
-?>
diff --git a/php/Attic/examples/sample-sp/index.php b/php/Attic/examples/sample-sp/index.php
index 0b36a188..b0e82797 100644
--- a/php/Attic/examples/sample-sp/index.php
+++ b/php/Attic/examples/sample-sp/index.php
@@ -26,15 +26,28 @@
$ret = @dl('lasso.' . PHP_SHLIB_SUFFIX);
if ($ret == FALSE)
{
- print "<p align='center'><b>The Lasso Extension is not available</b><br>";
- print "Please check your PHP extensions<br>";
- print "You can get more informations about <b>Lasso</b> at <br>";
- print "<a href='http://lasso.entrouvert.org/'>http://lasso.entrouvert.org/</a></p>";
- exit();
+?>
+<p align='center'><b>The Lasso Extension is not available</b><br>
+Please check your PHP extensions<br>
+You can get more informations about <b>Lasso</b> at <br>
+<a href='http://lasso.entrouvert.org/'>http://lasso.entrouvert.org/</a></p>
+<?php
+ exit();
}
}
-
- include 'config.php.inc';
+
+ if (!file_exists('config.inc'))
+ {
+?>
+<p align='center'><b>Service Provider Configuration file is not available</b><br>
+Please run the setup script :<br>
+<a href='setup.php'>Lasso Service Provider Setup</a><br>
+You can get more informations about <b>Lasso</b> at <br>
+<a href='http://lasso.entrouvert.org/'>http://lasso.entrouvert.org/</a></p>
+<?php
+ }
+
+ $config = unserialize(file_get_contents('config.inc'));
require_once 'DB.php';
@@ -56,22 +69,15 @@
<tr>
<td><b>Service Provider Administration</b></td>
</tr>
-<?php
- if (!file_exists($server_dump_filename)) {
-?>
<tr>
<td><a href="setup.php">Setup</a></td>
</tr>
-</table>
-<?php
-} else {
-?>
<tr>
<td><a href="admin_user.php">Users Management</a></td>
</tr>
-<tr>
+<!--<tr>
<td><a href="admin_fed.php">Federation Administration</a></td>
-</tr>
+</tr> -->
<tr>
<td><b>Serice Provider Fonctionnality</b></td>
</tr>
@@ -109,7 +115,7 @@
<td><b>UserID:</b></td><td><?php echo $_SESSION["user_id"]; ?></td>
</tr>
<?php
- $db = &DB::connect($dsn);
+ $db = &DB::connect($config['dsn']);
if (DB::isError($db))
die($db->getMessage());
@@ -144,9 +150,6 @@
</tr>
</table>
</p>
-<?php
-}
-?>
<p>Lasso Version : <?php echo lasso_version(); ?></p>
<br>
diff --git a/php/Attic/examples/sample-sp/login.php b/php/Attic/examples/sample-sp/login.php
index 4b70c095..b1594fae 100644
--- a/php/Attic/examples/sample-sp/login.php
+++ b/php/Attic/examples/sample-sp/login.php
@@ -23,11 +23,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
- include "config.php.inc";
+
+ $config = unserialize(file_get_contents('config.inc'));
lasso_init();
- $server_dump = file_get_contents($server_dump_filename);
+ $server_dump = file_get_contents($config['server_dump_filename']);
$server = lasso_server_new_from_dump($server_dump);
diff --git a/php/Attic/examples/sample-sp/logout.php b/php/Attic/examples/sample-sp/logout.php
index e55b6ba1..7662bbc6 100644
--- a/php/Attic/examples/sample-sp/logout.php
+++ b/php/Attic/examples/sample-sp/logout.php
@@ -22,7 +22,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
- include "config.php.inc";
+ $config = unserialize(file_get_contents('config.inc'));
require_once 'DB.php';
@@ -38,12 +38,12 @@
lasso_init();
- $db = &DB::connect($dsn);
+ $db = &DB::connect($config['dsn']);
if (DB::isError($db))
die($db->getMessage());
- $server_dump = file_get_contents($server_dump_filename);
+ $server_dump = file_get_contents($config['server_dump_filename']);
$server = lasso_server_new_from_dump($server_dump);
diff --git a/php/Attic/examples/sample-sp/register.php b/php/Attic/examples/sample-sp/register.php
index 76b43380..427fefb5 100644
--- a/php/Attic/examples/sample-sp/register.php
+++ b/php/Attic/examples/sample-sp/register.php
@@ -22,8 +22,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
- include "config.php.inc";
-
+ $config = unserialize(file_get_contents('config.inc'));
+
require_once 'DB.php';
session_start();
@@ -35,7 +35,7 @@
switch($_POST['action']) {
case "submit":
- $db = &DB::connect($dsn);
+ $db = &DB::connect($config['dsn']);
if (DB::isError($db))
die($db->getMessage());
diff --git a/php/Attic/examples/sample-sp/setup.php b/php/Attic/examples/sample-sp/setup.php
index e475d74a..ea0fd03c 100644
--- a/php/Attic/examples/sample-sp/setup.php
+++ b/php/Attic/examples/sample-sp/setup.php
@@ -22,7 +22,9 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<?php
if(!extension_loaded('lasso')) {
$ret = @dl('lasso.' . PHP_SHLIB_SUFFIX);
if ($ret == FALSE)
@@ -37,11 +39,43 @@
require_once 'DB.php';
- $config = unserialize(file_get_contents('config.inc'));
+ # default config
+ if (!file_exists('config.inc'))
+ {
+ $cwd = getcwd();
+ $config = array(
+ 'dsn' => "pgsql://sp:sp@localhost/sp",
+ 'server_dump_filename' => "lasso_server_dump.xml",
+ 'sp-metadata' => "/home/cnowicki/mcvs/lasso/tests/data/sp1-la/metadata.xml",
+ 'sp-public_key' => "/home/cnowicki/mcvs/lasso/tests/data/sp1-la/public-key.pem",
+ 'sp-private_key' => "/home/cnowicki/mcvs/lasso/tests/data/sp1-la/private-key-raw.pem",
+ 'sp-ca' => "/home/cnowicki/mcvs/lasso/tests/data/sp1-la/certificate.pem",
+ 'idp-metadata' => "/home/cnowicki/mcvs/lasso/tests/data/idp1-la/metadata.xml",
+ 'idp-public_key' => "/home/cnowicki/mcvs/lasso/tests/data/idp1-la/public-key.pem",
+ 'idp-ca' => "/home/cnowicki/mcvs/lasso/tests/data/ca1-la/certificate.pem",
+ );
+
+ $config_ser = serialize($config);
+
+ if (($fd = fopen(getcwd()."/config.inc", "w")))
+ {
+ fwrite($fd, $config_ser);
+ fclose($fd);
+ }
+ else
+ die("Could not write default config file");
+ }
+ else
+ {
+ $config = unserialize(file_get_contents('config.inc'));
+ }
- switch($_POST['action'])
+ if ($_POST['action'] == 'setup')
{
- case 'setup' :
+ ob_start();
+
+ $setup = FALSE;
+
print "<b>Lasso Service Provider Setup</b><br>";
unset($_POST['action']);
@@ -83,6 +117,7 @@
identity_dump text,
first_name varchar(50),
last_name varchar(50),
+ last_login timestamp,
created timestamp)";
$res =& $db->query($query);
if (DB::isError($res))
@@ -131,8 +166,7 @@
if (empty($server))
{
- print "Failed";
- break;
+ die("Failed");
}
else
print "OK";
@@ -161,23 +195,51 @@
print "OK";
}
else
- print "Failed";
+ die("Failed");
lasso_shutdown();
+ print "<br>Save configuration file : ";
+
# Save configuration file
$config_ser = serialize($config);
if (($fd = fopen("config.inc", "w")))
{
fwrite($fd, $config_ser);
fclose($fd);
+ print "OK";
+ }
+ else
+ {
+ print("Failed");
+ break;
}
-
- break;
- default:
+ $setup = TRUE;
+ }
+ ob_start();
+?>
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+<head>
+<title>Setup script for Lasso (Liberty Alliance Single Sign On)</title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" />
+<?php
+ if ($setup == TRUE) {
+?>
+<meta http-equiv="Refresh" CONTENT="3; URL=index.php">
+<?php } ?>
+</head>
+<body>
+<?php
+ ob_end_flush();
+ ob_end_flush();
+ ?>
+</body>
+</html>
+<?php
+ if (empty($setup))
+ {
?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Setup script for Lasso (Liberty Alliance Single Sign On)</title>
@@ -188,16 +250,64 @@
<table>
<caption>Lasso Service Provider Setup</caption>
<tr>
- <td>DSN:</td><td><input type='text' name='dsn' value='<?php echo $config['dsn']; ?>' maxlength='100'></td>
+ <td colspan='3' align='center'>Database Configuration</td>
+</tr>
+<tr>
+ <td>DSN (Data Source Name) :</td><td><input type='text' name='dsn' size='50' value='<?php echo $config['dsn']; ?>' maxlength='100'></td><td><a href='http://pear.php.net/manual/en/package.database.db.intro-dsn.php' target='_new'>Help</a></td>
+</tr>
+<tr>
+ <td>Server XML Dump:</td><td><input type='text' name='server_dump_filename' size='50' value='<?php echo $config['server_dump_filename']; ?>' maxlength='100'></td><td>&nbsp;</td>
+
+</tr>
+<tr>
+ <td colspan='3' align='center'>Service Provider</td>
+</tr>
+
+<tr>
+ <td>Metadata</td><td><input type='text' name='sp-metadata' size='50' value='<?php echo $config['sp-metadata']; ?>'></td><td>&nbsp;</td>
+
+</tr>
+
+<tr>
+ <td>Public Key</td><td><input type='text' name='sp-public_key' size='50' value='<?php echo $config['sp-public_key']; ?>'></td><td>&nbsp;</td>
+
</tr>
+
<tr>
- <td>Server XML Dump:</td><td><input type='text' name='server_dump_filename' value='<?php echo $config['server_dump_filename']; ?>' maxlength='100'></td>
+ <td>Private Key</td><td><input type='text' name='sp-private_key' size='50' value='<?php echo $config['sp-private_key']; ?>'></td><td>&nbsp;</td>
+
</tr>
+
+<tr>
+ <td>Certificate</td><td><input type='text' name='sp-ca' size='50' value='<?php echo $config['sp-ca']; ?>'></td><td>&nbsp;</td>
+
+</tr>
+
+<tr>
+ <td colspan='3' align='center'>Identity Provider</td>
+</tr>
+
+<tr>
+ <td>Metadata</td><td><input type='text' name='idp-metadata' size='50' value='<?php echo $config['idp-metadata']; ?>'></td><td>&nbsp;</td>
+
+</tr>
+<tr>
+ <td>Public Key</td><td><input type='text' name='idp-public_key' size='50' value='<?php echo $config['idp-public_key']; ?>'></td><td>&nbsp;</td>
+
+</tr>
+<tr>
+ <td>Certificate</td><td><input type='text' name='idp-ca' size='50' value='<?php echo $config['idp-ca']; ?>'></td><td>&nbsp;</td>
+</tr>
+
+<tr>
+ <td colspan='3'>&nbsp;</td>
+</tr>
+
<tr>
- <td><input type='hidden' name='action' value='setup'></td>
- <td><input type='submit' value='setup'></td>
+ <td align='center' colspan='3'><input type='submit' value='setup'></td>
</tr>
</table>
+<input type='hidden' name='action' value='setup'>
</form>
</body>
</html>