summaryrefslogtreecommitdiffstats
path: root/examples/server/lib/render
diff options
context:
space:
mode:
authortailor <cygnus@janrain.com>2007-03-22 18:22:00 +0000
committertailor <cygnus@janrain.com>2007-03-22 18:22:00 +0000
commit8ab6cc345e221f1e931597faeadfd345baf3ffda (patch)
treecd2c33ecd8bd5602489d1d817fd1cc5cbaddb412 /examples/server/lib/render
parent900ae4d1d1cbdda4ce918ca8a813d1364fd73907 (diff)
downloadphp-openid-8ab6cc345e221f1e931597faeadfd345baf3ffda.zip
php-openid-8ab6cc345e221f1e931597faeadfd345baf3ffda.tar.gz
php-openid-8ab6cc345e221f1e931597faeadfd345baf3ffda.tar.bz2
[project @ Example server overhaul; add OpenID 2 features]
Diffstat (limited to 'examples/server/lib/render')
-rw-r--r--examples/server/lib/render/idpXrds.php28
-rw-r--r--examples/server/lib/render/idpage.php5
-rw-r--r--examples/server/lib/render/login.php2
-rw-r--r--examples/server/lib/render/sites.php83
-rw-r--r--examples/server/lib/render/trust.php37
5 files changed, 63 insertions, 92 deletions
diff --git a/examples/server/lib/render/idpXrds.php b/examples/server/lib/render/idpXrds.php
new file mode 100644
index 0000000..12ddd18
--- /dev/null
+++ b/examples/server/lib/render/idpXrds.php
@@ -0,0 +1,28 @@
+<?php
+
+require_once "lib/session.php";
+require_once "lib/render.php";
+
+define('xrds_pat', '<?xml version="1.0" encoding="UTF-8"?>
+<xrds:XRDS
+ xmlns:xrds="xri://$xrds"
+ xmlns="xri://$xrd*($v*2.0)">
+ <XRD>
+ <Service priority="0">
+ <Type>http://openid.net/server/2.0</Type>
+ <URI>%s</URI>
+ </Service>
+ </XRD>
+</xrds:XRDS>
+');
+
+function idpXrds_render()
+{
+ $headers = array('Content-type: application/xrds+xml');
+
+ $body = sprintf(xrds_pat, buildURL());
+
+ return array($headers, $body);
+}
+
+?> \ No newline at end of file
diff --git a/examples/server/lib/render/idpage.php b/examples/server/lib/render/idpage.php
index 103ec3c..a4893c2 100644
--- a/examples/server/lib/render/idpage.php
+++ b/examples/server/lib/render/idpage.php
@@ -9,7 +9,7 @@ define('idpage_pat',
<link rel="openid2.provider openid.server" href="%s"/>
</head>
<body>
- This is the identity page for %s.
+ This is the identity page for users of this server.
</body>
</html>');
@@ -18,8 +18,7 @@ define('login_needed_pat',
function idpage_render($identity)
{
- $esc_identity = htmlspecialchars($identity, ENT_QUOTES);
- $body = sprintf(idpage_pat, buildURL(), $esc_identity);
+ $body = sprintf(idpage_pat, buildURL());
return array(array(), $body);
}
diff --git a/examples/server/lib/render/login.php b/examples/server/lib/render/login.php
index 19a242a..c6fea21 100644
--- a/examples/server/lib/render/login.php
+++ b/examples/server/lib/render/login.php
@@ -13,7 +13,7 @@ define('login_form_pat',
<form method="post" action="%s">
<table>
<tr>
- <th><label for="openid_url">OpenID URL:</label></th>
+ <th><label for="openid_url">Name:</label></th>
<td><input type="text" name="openid_url"
value="%s" id="openid_url" /></td>
</tr>
diff --git a/examples/server/lib/render/sites.php b/examples/server/lib/render/sites.php
deleted file mode 100644
index 90b557f..0000000
--- a/examples/server/lib/render/sites.php
+++ /dev/null
@@ -1,83 +0,0 @@
-<?php
-
-require_once "lib/session.php";
-
-define('sites_form',
- '<p>These decisions have been remembered for this session. All decisions
-will be forgotten when the session ends.</p>
-<div class="form">
-<form method="post" action="%s">
-<table>
-<tbody>
-%s
-</tbody>
-</table>
-<input type="submit" name="remove" value="Remove Selected" />
-<input type="submit" name="refresh" value="Refresh List" />
-<input type="submit" name="forget" value="Forget All" />
-</form>
-</div>
-');
-
-define('sites_empty_message',
- '<p>
- No sites are remembered for this session. When you authenticate with a site,
- you can choose to add it to this list by choosing <q>Remember this
- decision</q>.
-</p>
-<p>%s</p>
-');
-
-define('sites_row',
- '<tr>
-<td><input type="checkbox" name=%s value="%s" id=%s /></td>
-<td><label for=%s><code>%s</code></label></td>
-</tr>');
-
-function siteListRow_render($i, $site)
-{
- $esc_site = htmlspecialchars($site, ENT_QUOTES);
- $id = sprintf('"site%s"', $i);
- return sprintf(sites_row, $id, $esc_site, $id, $id, $esc_site);
-}
-
-function siteList_render($sites)
-{
- $trusted_sites = array();
- $untrusted_sites = array();
- foreach ($sites as $site => $trusted) {
- if ($trusted) {
- $trusted_sites[] = $site;
- } else {
- $untrusted_sites[] = $site;
- }
- }
- $rows = '';
- $i = 0;
- foreach (array('Trusted Sites' => $trusted_sites,
- 'Untrusted Sites' => $untrusted_sites) as
- $name => $sites) {
- if ($sites) {
- $rows .= '<tr><th colspan="2">'. $name . '</th></tr>';
- foreach ($sites as $site) {
- $rows .= siteListRow_render($i, $site);
- $i += 1;
- }
- }
- }
- return $rows;
-}
-
-function sites_render($sites)
-{
- if ($sites) {
- $rows = siteList_render($sites);
- $form = sprintf(sites_form, buildURL('sites'), $rows);
- $body = $pre . $form;
- } else {
- $body = sprintf(sites_empty_message, link_render(buildURL(''), 'Return home'));
- }
- return page_render($body, getLoggedInUser(), 'Remembered Sites');
-}
-
-?> \ No newline at end of file
diff --git a/examples/server/lib/render/trust.php b/examples/server/lib/render/trust.php
index 9acfae7..681d456 100644
--- a/examples/server/lib/render/trust.php
+++ b/examples/server/lib/render/trust.php
@@ -5,25 +5,52 @@ require_once "lib/render.php";
define('trust_form_pat',
'<div class="form">
- <p>Do you wish to confirm your identity (<code>%s</code>) with <code>%s</code>?</p>
<form method="post" action="%s">
- <input type="checkbox" name="remember" value="on" id="remember"><label
- for="remember">Remember this decision</label>
- <br />
+ %s
<input type="submit" name="trust" value="Confirm" />
<input type="submit" value="Do not confirm" />
</form>
</div>
');
+define('normal_pat',
+ '<p>Do you wish to confirm your identity ' .
+ '(<code>%s</code>) with <code>%s</code>?</p>');
+
+define('id_select_pat',
+ '<p>You entered the server URL at the RP.
+Please choose the name you wish to use. If you enter nothing, the request will be cancelled.<br/>
+<input type="text" name="idSelect" /></p>
+');
+
+define('no_id_pat',
+'
+You did not send an identifier with the request,
+and it was not an identifier selection request.
+Please return to the relying party and try again.
+');
+
function trust_render($info)
{
$current_user = getLoggedInUser();
$lnk = link_render(idURL($current_user));
$trust_root = htmlspecialchars($info->trust_root);
$trust_url = buildURL('trust', true);
- $form = sprintf(trust_form_pat, $lnk, $trust_root, $trust_url);
+
+ if ($info->idSelect()) {
+ $prompt = id_select_pat;
+ } else {
+ $prompt = sprintf(normal_pat, $lnk, $trust_root);
+ }
+
+ $form = sprintf(trust_form_pat, $trust_url, $prompt);
+
return page_render($form, $current_user, 'Trust This Site');
}
+function noIdentifier_render()
+{
+ return page_render(no_id_pat, null, 'No Identifier Sent');
+}
+
?> \ No newline at end of file