incubator-heraldry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ket...@apache.org
Subject svn commit: r463021 [11/12] - in /incubator/heraldry/libraries/php: ./ openid/ openid/trunk/ openid/trunk/Auth/ openid/trunk/Auth/OpenID/ openid/trunk/Services/ openid/trunk/Services/Yadis/ openid/trunk/Tests/ openid/trunk/Tests/Auth/ openid/trunk/Test...
Date Wed, 11 Oct 2006 22:49:59 GMT
Added: incubator/heraldry/libraries/php/openid/trunk/admin/longlines.pl
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/admin/longlines.pl?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/admin/longlines.pl (added)
+++ incubator/heraldry/libraries/php/openid/trunk/admin/longlines.pl Wed Oct 11 15:49:50 2006
@@ -0,0 +1,46 @@
+#!/usr/bin/env perl -w
+
+use strict;
+
+my $filename = $ARGV[0];
+
+if (!$filename) {
+    print "Usage: longlines.pl <filename> [length]\n";
+    exit(1);
+}
+
+# Set a default maximum line length.
+my $max_length = $ARGV[1] || 80;
+
+my @lines = ();
+my $line_num = 0;
+
+open(HANDLE, "<", $filename) or die "Cannot open $filename\n";
+
+# Read the file and track the lines with length > $max_length.
+while (<HANDLE>) {
+    $line_num++;
+    # Subtract one because the newline doesn't count toward the
+    # length.
+    if (length($_) - 1 > $max_length) {
+        push @lines, $line_num;
+    }
+}
+
+# If more than five long lines were found, truncate to five and
+# indicate that others were present, too.
+if (@lines > 5) {
+    @lines = @lines[0..4];
+    push @lines, "and others";
+}
+
+# If any long lines were found, notify and exit(1); otherwise,
+# exit(0).
+if (@lines) {
+    print $filename." (line".((@lines > 1) ? "s" : "")." ".
+        join(", ", @lines)." exceed".((@lines == 1) ? "s" : "").
+        " length $max_length)\n";
+    exit(1);
+} else {
+    exit(0);
+}

Propchange: incubator/heraldry/libraries/php/openid/trunk/admin/longlines.pl
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/heraldry/libraries/php/openid/trunk/admin/makedoc.sh
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/admin/makedoc.sh?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/admin/makedoc.sh (added)
+++ incubator/heraldry/libraries/php/openid/trunk/admin/makedoc.sh Wed Oct 11 15:49:50 2006
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -v
+phpdoc -p -t doc -d Auth,admin/tutorials,Services -ti "JanRain OpenID Library" \
+    --ignore \*~,BigMath.php,Discover.php,CryptUtil.php,DiffieHellman.php,HMACSHA1.php,KVForm.php,Parse.php,TrustRoot.php,HTTPFetcher.php,ParanoidHTTPFetcher.php,PlainHTTPFetcher.php,ParseHTML.php,URINorm.php,XRI.php,XRIRes.php,Misc.php \
+    -dn "OpenID" -o "HTML:frames:phphtmllib"

Propchange: incubator/heraldry/libraries/php/openid/trunk/admin/makedoc.sh
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/heraldry/libraries/php/openid/trunk/admin/mathlib
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/admin/mathlib?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/admin/mathlib (added)
+++ incubator/heraldry/libraries/php/openid/trunk/admin/mathlib Wed Oct 11 15:49:50 2006
@@ -0,0 +1,18 @@
+#!/usr/bin/env php
+<?php
+
+require_once 'adminutil.php';
+includeAdd(getParent());
+
+require_once 'Auth/OpenID/CryptUtil.php';
+
+$lib =& Auth_OpenID_MathLibrary::getLibWrapper();
+
+if ($lib === null) {
+    fwrite(STDERR, 'No math library present\n');
+    exit(1);
+} else {
+    print $lib->type;
+}
+
+?>

Propchange: incubator/heraldry/libraries/php/openid/trunk/admin/mathlib
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/heraldry/libraries/php/openid/trunk/admin/nobadbraces
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/admin/nobadbraces?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/admin/nobadbraces (added)
+++ incubator/heraldry/libraries/php/openid/trunk/admin/nobadbraces Wed Oct 11 15:49:50 2006
@@ -0,0 +1,4 @@
+#!/usr/bin/env bash
+set -e
+
+./admin/findphp | xargs -l1 /usr/bin/env perl admin/brace_style.pl

Propchange: incubator/heraldry/libraries/php/openid/trunk/admin/nobadbraces
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/heraldry/libraries/php/openid/trunk/admin/nobadcase
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/admin/nobadcase?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/admin/nobadcase (added)
+++ incubator/heraldry/libraries/php/openid/trunk/admin/nobadcase Wed Oct 11 15:49:50 2006
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+
+bad=$(./admin/findphp | xargs egrep -n '\b(TRUE|FALSE|NULL)\b')
+
+if [ ! -z "$bad" ]
+    then
+    cat <<EOF 1>&2
+These files contain wrongly capitalized constants:
+
+$bad
+
+EOF
+    exit 1
+fi

Propchange: incubator/heraldry/libraries/php/openid/trunk/admin/nobadcase
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/heraldry/libraries/php/openid/trunk/admin/nolonglines
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/admin/nolonglines?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/admin/nolonglines (added)
+++ incubator/heraldry/libraries/php/openid/trunk/admin/nolonglines Wed Oct 11 15:49:50 2006
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+
+files_with_long_lines=$(./admin/findphp |
+            xargs -l1 wc -L |
+            awk '$1 > 80 { print $2 }' |
+            xargs -l1 --replace=FILENAME /usr/bin/env perl admin/longlines.pl FILENAME 80)
+
+if [ "$files_with_long_lines" ]
+    then
+    cat <<EOF 1>&2
+Found lines > 80 characters in:
+
+$files_with_long_lines
+EOF
+    exit 1
+fi

Propchange: incubator/heraldry/libraries/php/openid/trunk/admin/nolonglines
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/heraldry/libraries/php/openid/trunk/admin/notabs
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/admin/notabs?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/admin/notabs (added)
+++ incubator/heraldry/libraries/php/openid/trunk/admin/notabs Wed Oct 11 15:49:50 2006
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+#
+# Look in the local directory for PHP files that have tabs in them. If
+# there are files with tabs, print the list of files and exit with
+# non-zero status.
+
+tabs=$(./admin/findphp | xargs egrep -n '	' | sort)
+
+if [ ! -z "$tabs" ]
+    then
+    cat <<EOF 1>&2
+Found tabs in:
+$tabs
+EOF
+    exit 1
+fi

Propchange: incubator/heraldry/libraries/php/openid/trunk/admin/notabs
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/heraldry/libraries/php/openid/trunk/admin/open_tag
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/admin/open_tag?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/admin/open_tag (added)
+++ incubator/heraldry/libraries/php/openid/trunk/admin/open_tag Wed Oct 11 15:49:50 2006
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+
+bad_files=$(./admin/findphp |
+      xargs -l1 grep -H -m 1 "<?php" -c |
+      grep ":0" |
+      awk -F: '{ print $1 }')
+
+if [ "$bad_files" ]
+    then
+    cat <<EOF 1>&2
+These PHP files do NOT begin with <?php :
+
+$bad_files
+
+EOF
+    exit 1
+fi

Propchange: incubator/heraldry/libraries/php/openid/trunk/admin/open_tag
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/heraldry/libraries/php/openid/trunk/admin/otb_test.php
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/admin/otb_test.php?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/admin/otb_test.php (added)
+++ incubator/heraldry/libraries/php/openid/trunk/admin/otb_test.php Wed Oct 11 15:49:50 2006
@@ -0,0 +1,20 @@
+<?php
+
+function fail1() {
+}
+
+function pass1()
+{
+}
+
+function fail2(
+   ) {
+
+}
+
+function pass2(
+   )
+{
+}
+
+?>
\ No newline at end of file

Added: incubator/heraldry/libraries/php/openid/trunk/admin/package.xml
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/admin/package.xml?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/admin/package.xml (added)
+++ incubator/heraldry/libraries/php/openid/trunk/admin/package.xml Wed Oct 11 15:49:50 2006
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<package version="1.0">
+ <name>%(package_name)s</name>
+ <summary>%(package_summary)s</summary>
+ <description>
+ %(package_description)s
+ </description>
+ <license>%(license_name)s</license>
+ %(maintainers)s
+ <release>
+  <version>%(version)s</version>
+  <date>%(date)s</date>
+  <state>%(release_stability)s</state>
+  <notes>
+  %(release_notes)s
+  </notes>
+  %(contents_version_1)s
+ </release>
+ <deps>
+  <dep type="php" rel="ge" version="4.3.0" />
+ </deps>
+</package>

Added: incubator/heraldry/libraries/php/openid/trunk/admin/package2.xml
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/admin/package2.xml?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/admin/package2.xml (added)
+++ incubator/heraldry/libraries/php/openid/trunk/admin/package2.xml Wed Oct 11 15:49:50 2006
@@ -0,0 +1,72 @@
+<?xml version="1.0"?>
+<package version="2.0" xmlns="http://pear.php.net/dtd/package-2.0"
+    xmlns:tasks="http://pear.php.net/dtd/tasks-1.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
+http://pear.php.net/dtd/tasks-1.0.xsd
+http://pear.php.net/dtd/package-2.0
+http://pear.php.net/dtd/package-2.0.xsd">
+ <name>%(package_name)s</name>
+ <uri>%(uri)s</uri>
+ <summary>%(package_summary)s</summary>
+ <description>
+   %(package_description)s
+ </description>
+ %(leads)s
+ <date>%(date)s</date>
+ <version>
+   <release>%(version)s</release>
+   <api>%(version)s</api>
+ </version>
+ <stability>
+   <release>%(release_stability)s</release>
+   <api>%(release_stability)s</api>
+ </stability>
+ <license uri="%(license_uri)s">%(license_name)s</license>
+ <notes>
+ %(release_notes)s
+ </notes>
+ <contents>
+ %(contents)s
+ </contents>
+ <dependencies>
+   <required>
+     <php>
+       <min>4.3.0</min>
+     </php>
+     <pearinstaller>
+       <min>1.4.5</min>
+     </pearinstaller>
+   </required>
+   <optional>
+     <package>
+       <name>PHPUnit</name>
+       <channel>pear.php.net</channel>
+       <min>1.1.1</min>
+     </package>
+     <package>
+       <name>PEAR_DB</name>
+       <channel>pear.php.net</channel>
+       <min>1.80</min>
+     </package>
+     <extension>
+       <name>pgsql</name>
+     </extension>
+     <extension>
+       <name>mysql</name>
+     </extension>
+     <extension>
+       <name>sqlite</name>
+     </extension>
+     <extension>
+       <name>bcmath</name>
+     </extension>
+     <extension>
+       <name>gmp</name>
+     </extension>
+   </optional>
+ </dependencies>
+ <!-- There really isn't much we should put in the phprelease tag,
+ although we should probably make a windows-specific release tag. -->
+ <phprelease/>
+</package>

Added: incubator/heraldry/libraries/php/openid/trunk/admin/packagexml.py
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/admin/packagexml.py?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/admin/packagexml.py (added)
+++ incubator/heraldry/libraries/php/openid/trunk/admin/packagexml.py Wed Oct 11 15:49:50 2006
@@ -0,0 +1,155 @@
+#!/usr/bin/python
+
+import os
+import os.path
+
+def makeMaintainerXML(leads):
+    maintainer_template = """
+  <maintainer>
+   <user>%(user)s</user>
+   <name>%(name)s</name>
+   <email>%(email)s</email>
+   <role>lead</role>
+  </maintainer>
+  """
+
+    return "<maintainers>" + \
+           "".join([maintainer_template % l for l in leads]) + \
+           "</maintainers>"
+
+def makeLeadXML(leads):
+    lead_template = """
+<lead>
+  <name>%(name)s</name>
+  <user>%(user)s</user>
+  <email>%(email)s</email>
+  <active>%(active)s</active>
+</lead>
+    """
+
+    return "".join([lead_template % l for l in leads])
+
+INDENT_STRING = "  "
+
+def buildContentsXMLFordir(dir_or_file, roles, depth=0, dir_role=None,
+                           all_files=False):
+    """
+    Returns a list of strings, each of which is either a <file> XML
+    element for the given file or a <dir> element which contains other
+    <file> elements.
+    """
+
+    try:
+        entries = os.listdir(dir_or_file)
+        dir_role_s = ''
+        if dir_role:
+            dir_role_s = ' role="%s"' % (dir_role)
+        lines = ['%s<dir name="%s"%s>' % (INDENT_STRING * depth,
+                                          os.path.basename(dir_or_file),
+                                          dir_role_s)]
+
+        for entry in entries:
+            lines += buildContentsXMLFordir(dir_or_file + os.sep + entry, roles,
+                                            depth + 1, dir_role, all_files)
+
+        lines.append('%s</dir>' % (INDENT_STRING * depth))
+
+        return lines
+    except OSError:
+        try:
+            extension = dir_or_file.split(".")[-1]
+        except:
+            if not all_files:
+                return []
+
+        if all_files and dir_role:
+            return ['%s<file name="%s" role="%s" />' %
+                    (INDENT_STRING * depth, os.path.basename(dir_or_file), dir_role)]
+        elif extension in roles: # Ends in an extension we care about
+            return ['%s<file name="%s" role="%s" />' %
+                    (INDENT_STRING * depth, os.path.basename(dir_or_file),
+                     roles[extension])]
+        else:
+            return []
+
+def buildContentsXML(roles, *dirs):
+    lines = []
+
+    for directory in dirs:
+        lines.append("\n".join(buildContentsXMLFordir(directory, roles, 1)))
+
+    return "\n".join(lines)
+
+def buildDocsXML(*dirs):
+    lines = []
+
+    for directory in dirs:
+        lines.append("\n".join(buildContentsXMLFordir(directory, {}, 1, 'doc',
+                                                      all_files=True)))
+
+    return "\n".join(lines)
+
+if __name__ == "__main__":
+    def usage(progname):
+        print "Usage: %s <package version> <xml template file> <release notes file>" % (progname)
+
+    import sys
+    import time
+
+    try:
+        import xmlconfig
+    except:
+        print "Could not import XML configuration module xmlconfig"
+        sys.exit(1)
+
+    # Expect sys.argv[2] to be the name of the XML file template to
+    # use for processing.
+    try:
+        template_f = open(sys.argv[2], 'r')
+    except Exception, e:
+        usage(sys.argv[0])
+        print "Could not open template file:", str(e)
+        sys.exit(1)
+
+    # Expect sys.argv[1] to be the version number to include in the
+    # package.xml file.
+    try:
+        version = sys.argv[1]
+    except:
+        usage(sys.argv[0])
+        sys.exit(2)
+
+    # Expect sys.argv[3] to be the name of the release notes file.
+    try:
+        release_file = sys.argv[3]
+        release_file_h = open(release_file, 'r')
+        release_notes = release_file_h.read().strip()
+        release_file_h.close()
+    except Exception, e:
+        usage(sys.argv[0])
+        print str(e)
+        sys.exit(3)
+
+    data = xmlconfig.__dict__.copy()
+
+    contentsXml = buildContentsXML({'php': 'php'}, *xmlconfig.contents_dirs)
+    docsXml = buildDocsXML(*xmlconfig.docs_dirs)
+
+    contents = '<dir name="/">\n' + contentsXml + \
+               "\n" + docsXml + '\n  </dir>'
+
+    contents_v1 = '<filelist><dir name="/" baseinstalldir="Auth">\n' + contentsXml + \
+                  "\n" + docsXml + '\n  </dir></filelist>'
+
+    data['contents'] = contents
+    data['contents_version_1'] = contents_v1
+    data['leads'] = makeLeadXML(xmlconfig.leads)
+    data['maintainers'] = makeMaintainerXML(xmlconfig.leads)
+    data['date'] = time.strftime("%Y-%m-%d")
+    data['version'] = version
+    data['uri'] = "%s%s-%s.tgz" % (data['package_base_uri'], data['package_name'],
+                                   version)
+    data['release_notes'] = release_notes
+
+    template_data = template_f.read()
+    print template_data % data

Propchange: incubator/heraldry/libraries/php/openid/trunk/admin/packagexml.py
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/heraldry/libraries/php/openid/trunk/admin/phpaliases.py
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/admin/phpaliases.py?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/admin/phpaliases.py (added)
+++ incubator/heraldry/libraries/php/openid/trunk/admin/phpaliases.py Wed Oct 11 15:49:50 2006
@@ -0,0 +1,119 @@
+#!/usr/bin/env python
+
+"""This script searches files for functions that are just aliases in
+PHP source code. This is not 100% reliable, so it should not be
+automated, but it's useful to run once in a while to make sure that
+all of the matches it finds are not really legitimate aliases.
+
+Usage:
+
+  parse_aliases.py <name of alias file> [PHP source code filename]...
+"""
+
+import sys
+
+# Fetch this URL to get the file that is parsed into the aliases list
+alias_url = 'http://www.zend.com/phpfunc/all_aliases.php'
+
+header_tok = '<!-- END OF HEADER -->';
+footer_tok = '<!-- FOOTER -->';
+
+# Example line of the table that we parse:
+# '<tr bgcolor="#EFEFFF"><td><a href="function.bzclose.php">bzclose</a></td><td><a href="http://lxr.php.net/source/php-src/ext/bz2/bz2.c#48">php-src/ext/bz2/bz2.c</a></td><td><a href="function.fclose.php">fclose</a></td></tr>'
+
+import re
+
+line_re = re.compile(r'''
+\A
+
+<tr\ bgcolor="[^">]+">
+
+<td><a\ href="[^>"]+\.php">([^<>]+)</a></td>
+
+<td><a\ href="[^">]+">[^<>]+</a></td>
+
+<td>
+(?:
+    <a\ href="[^">]+\.php">
+    ( [^<>]+ )
+    </a>
+|   ( [^<>]+ )
+)
+</td>
+
+</tr>
+
+\Z
+''', re.VERBOSE)
+
+def parseString(s):
+    _, rest = s.split(header_tok, 1)
+    body, _ = rest.split(footer_tok, 1)
+
+    lines = body.split('\n')
+    assert [s.strip() for s in lines[-2:]] == ['</table>', '']
+    assert lines[0].strip().startswith('<table')
+    del lines[0], lines[-2:]
+    aliases = {}
+    for line in lines:
+        mo = line_re.match(line)
+        assert mo, line
+        alias, master1, master2 = mo.groups()
+        if master1:
+            master = master1
+        else:
+            assert master2
+            master = master2
+        aliases[alias] = master
+
+    return aliases
+
+def parseFile(f):
+    return parseString(f.read())
+
+def parseFileName(fn):
+    return parseFile(file(fn, 'r'))
+
+def parseURL(url):
+    return parseFile(urllib2.urlopen(url))
+
+def getAliasRE(aliases):
+    return re.compile(r'(->|\$|)\s*\b(%s)\b' % ('|'.join(aliases.keys())))
+
+def checkAliasesFile(alias_re, f):
+    found = []
+    line_num = 1
+    for line in f:
+        for mo in alias_re.finditer(line):
+            if mo.group(1):
+                continue
+            alias = mo.group(2)
+            found.append((line_num, alias))
+        line_num += 1
+    return found
+
+def checkAliases(alias_re, filename):
+    return checkAliasesFile(alias_re, file(filename, 'r'))
+
+def checkAliasesFiles(alias_re, filenames):
+    found = []
+    for filename in filenames:
+        file_found = checkAliases(alias_re, filename)
+        found.extend([(filename, n, a) for (n, a) in file_found])
+    return found
+
+def dumpResults(aliases, found, out=sys.stdout):
+    for filename, n, a in found:
+        print >>out, "%s:%d %s -> %s" % (filename, n, a, aliases[a])
+
+def main(alias_file, *filenames):
+    aliases = parseFileName(alias_file)
+    alias_re = getAliasRE(aliases)
+    found = checkAliasesFiles(alias_re, filenames)
+    dumpResults(aliases, found)
+    return found
+
+if __name__ == '__main__':
+    found = main(*sys.argv[1:])
+    if found:
+        sys.exit(1)

Propchange: incubator/heraldry/libraries/php/openid/trunk/admin/phpaliases.py
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/heraldry/libraries/php/openid/trunk/admin/prepare-release
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/admin/prepare-release?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/admin/prepare-release (added)
+++ incubator/heraldry/libraries/php/openid/trunk/admin/prepare-release Wed Oct 11 15:49:50 2006
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+#
+# Prepare this repository for release
+
+REPO_ROOT=$(dirname $(dirname $(readlink --canonicalize "$0")))
+cd "$REPO_ROOT"
+
+bash ./admin/fixperms
+
+./admin/makedoc.sh
+
+darcs changes --from-tag=. --summary > CHANGELOG

Propchange: incubator/heraldry/libraries/php/openid/trunk/admin/prepare-release
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/heraldry/libraries/php/openid/trunk/admin/runtests
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/admin/runtests?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/admin/runtests (added)
+++ incubator/heraldry/libraries/php/openid/trunk/admin/runtests Wed Oct 11 15:49:50 2006
@@ -0,0 +1,64 @@
+#!/usr/bin/env bash
+
+HERE=$(readlink --canonicalize $(dirname "$0"))
+
+test_import () {
+    ./admin/checkimports
+}
+
+test_tabs () {
+    /usr/bin/env bash "$HERE/notabs"
+}
+
+test_longlines () {
+    /usr/bin/env bash "$HERE/nolonglines"
+}
+
+test_nobadbraces () {
+    /usr/bin/env bash "$HERE/nobadbraces"
+}
+
+test_nobadcase () {
+    /usr/bin/env bash "$HERE/nobadcase"
+}
+
+test_opentag () {
+    /usr/bin/env bash "$HERE/open_tag"
+}
+
+test_docblocks () {
+    /usr/bin/env bash "$HERE/docblocks"
+}
+
+test_php () {
+    if uname -a | grep -i cygwin >/dev/null 2>/dev/null ; then
+        /usr/bin/env php "$(dirname "$0")/texttest.php" --insecure-rand
+    else
+        /usr/bin/env php "$HERE/texttest.php"
+    fi
+}
+
+tests="tabs longlines nobadbraces nobadcase opentag docblocks php import"
+
+failures=
+
+# Run in repository root (parent of this directory)
+cd $(dirname "$HERE")
+
+chmod +x ./admin/fixperms
+./admin/fixperms
+
+for test_name in $tests
+  do
+  echo "Running test $test_name" 1>&2
+  if ! eval "test_$test_name"
+      then
+      failures="$failures $test_name"
+  fi
+done
+
+if [ ! -z "$failures" ]
+    then
+    echo "Failures in: $failures" 1>&2
+    exit 1
+fi

Propchange: incubator/heraldry/libraries/php/openid/trunk/admin/runtests
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/heraldry/libraries/php/openid/trunk/admin/texttest.php
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/admin/texttest.php?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/admin/texttest.php (added)
+++ incubator/heraldry/libraries/php/openid/trunk/admin/texttest.php Wed Oct 11 15:49:50 2006
@@ -0,0 +1,173 @@
+<?php
+
+require_once 'Tests/TestDriver.php';
+require_once 'PHPUnit/TestResult.php';
+require_once 'Console/Getopt.php';
+
+class TextTestResult extends PHPUnit_TestResult {
+    function addError(&$test, &$t)
+    {
+        parent::addError($test, $t);
+        echo "E";
+    }
+
+    function addFailure(&$test, &$t)
+    {
+        parent::addFailure($test, $t);
+        echo "F";
+    }
+
+    function addPassedTest(&$test)
+    {
+        parent::addPassedTest($test);
+        echo ".";
+    }
+
+    function dumpBadResults()
+    {
+        foreach ($this->failures() as $failure) {
+            echo $failure->toString();
+        }
+
+        foreach ($this->errors() as $failure) {
+            echo $failure->toString();
+        }
+    }
+}
+
+function microtime_float()
+{
+   list($usec, $sec) = explode(" ", microtime());
+   return ((float)$usec + (float)$sec);
+}
+
+$longopts = array('no-math',
+                  'math-lib=',
+                  'insecure-rand',
+                  'thorough');
+
+$con  = new Console_Getopt;
+$args = $con->readPHPArgv();
+array_shift($args);
+$options = $con->getopt2($args, "", $longopts);
+
+if (PEAR::isError($options)) {
+    print $options->message . "\n";
+    exit(1);
+}
+
+list($flags, $tests_to_run) = $options;
+
+$math_type = array();
+$thorough = false;
+foreach ($flags as $flag) {
+    list($option, $value) = $flag;
+    switch ($option) {
+    case '--insecure-rand':
+        define('Auth_OpenID_RAND_SOURCE', null);
+        break;
+    case '--no-math':
+        define('Auth_OpenID_NO_MATH_SUPPORT', true);
+        break;
+    case '--math-lib':
+        $math_type[] = $value;
+        break;
+    case '--thorough':
+        define('Tests_Auth_OpenID_thorough', true);
+        break;
+    default:
+        print "Unrecognized option: $option\n";
+        exit(1);
+    }
+}
+
+// ******** Math library selection ***********
+
+if ($math_type) {
+    if (defined('Auth_OpenID_NO_MATH_SUPPORT')) {
+        print "--no-math and --math-lib are mutually exclusive\n";
+        exit(1);
+    }
+    require_once('Auth/OpenID/BigMath.php');
+    $new_extensions = array();
+    foreach ($math_type as $lib) {
+        $found = false;
+        foreach ($_Auth_OpenID_math_extensions as $ext) {
+            if ($ext['extension'] == $lib) {
+                $new_extensions[] = $ext;
+                $found = true;
+                break;
+            }
+        }
+
+        if (!$found) {
+            print "Unknown math library specified: $lib\n";
+            exit(1);
+        }
+    }
+    $_Auth_OpenID_math_extensions = $new_extensions;
+}
+
+// ******** End math library selection **********
+
+$suites = loadSuite($argv);
+
+$totals = array(
+    'run' => 0,
+    'error' => 0,
+    'failure' => 0,
+    'time' => 0
+    );
+
+foreach ($suites as $suite) {
+    $name = $suite->getName();
+    echo "==========================================
+Test suite: $name
+------------------------------------------
+";
+
+    $result = new TextTestResult();
+    $before = microtime_float();
+    $suite->run($result);
+    $after = microtime_float();
+
+    $run = $result->runCount();
+    $error = $result->errorCount();
+    $failure = $result->failureCount();
+    $delta = $after - $before;
+    $totals['run'] += $run;
+    $totals['error'] += $error;
+    $totals['failure'] += $failure;
+    $totals['time'] += $delta;
+    $human_delta = round($delta, 3);
+    echo "\nRan $run tests in $human_delta seconds";
+    if ($error || $failure) {
+        echo " with $error errors, $failure failures";
+    }
+    echo "
+==========================================
+
+";
+
+    $failures = $result->failures();
+    foreach($failures as $failure) {
+        $test = $failure->failedTest();
+        $testName = $test->getName();
+        $exception = $failure->thrownException();
+        echo "* Failure in $testName: $exception
+
+";
+    }
+}
+
+$before = microtime_float();
+$run = $totals['run'];
+$error = $totals['error'];
+$failure = $totals['failure'];
+$time = round($totals['time'], 3);
+echo "Ran a total of $run tests in $time seconds with $error errors, $failure failures\n";
+if ($totals['error'] || $totals['failure']) {
+    exit(1);
+}
+
+?>
\ No newline at end of file

Added: incubator/heraldry/libraries/php/openid/trunk/admin/tutorials/OpenID/OpenID.pkg
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/admin/tutorials/OpenID/OpenID.pkg?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/admin/tutorials/OpenID/OpenID.pkg (added)
+++ incubator/heraldry/libraries/php/openid/trunk/admin/tutorials/OpenID/OpenID.pkg Wed Oct 11 15:49:50 2006
@@ -0,0 +1,91 @@
+<refentry id="{@id}">
+ <refnamediv>
+  <refname>PHP OpenID API</refname>
+
+ </refnamediv>
+ <refsynopsisdiv>
+  <author>
+   JanRain, Inc.
+   <authorblurb>
+    {@link mailto:openid@janrain.com openid@janrain.com}
+   </authorblurb>
+  </author>
+ </refsynopsisdiv>
+
+ <para>
+ This is a complete implementation of the OpenID authentication
+ protocol.  This package contains:
+
+   <itemizedlist>
+     <listitem>An OpenID server</listitem>
+     <listitem>An OpenID consumer</listitem>
+     <listitem>Stores for MySQL, PostgreSQL, SQLite, and filesystem-based OpenID data storage</listitem>
+     <listitem>PHPUnit unit tests</listitem>
+     <listitem>An example server and consumer</listitem>
+   </itemizedlist>
+ </para>
+
+ <refsect1 id="{@id users}">
+   <title>Dependencies</title>
+
+   <para>
+    This package depends on the JanRain, Inc. PHP Yadis library,
+    version 1.0.  You can download the PHP Yadis library
+    {@link http://www.openidenabled.com/yadis/libraries/php here}.
+   </para>
+ </refsect1>
+
+ <refsect1 id="{@id users}">
+   <title>For Package Users</title>
+
+   <para>
+    To install this package, copy the <literal>Auth/</literal>
+    directory in this package to a directory in your PHP include path.
+    Alternatively, modify your PHP include path to include the
+    directory that contains <literal>Auth/</literal>.  Any
+    applications that need this package will then be able to use it.
+   </para>
+
+ </refsect1>
+
+ <refsect1 id="{@id developers}">
+   <title>For Developers</title>
+
+   <para>
+
+    See the server and consumer examples in the
+    <literal>examples/</literal> directory of the package.  For
+    details on how to run the examples, see
+    <literal>examples/README</literal>.  If you want to create your
+    own OpenID data storage class, please see the {@link Auth_OpenID_OpenIDStore}
+    class.
+
+   </para>
+
+ </refsect1>
+
+ <refsect1 id="{@id references}">
+  <title>References</title>
+  <para>
+   <itemizedlist>
+    <listitem>
+     {@link http://www.openidenabled.com/openid/libraries/php PHP OpenID Library}
+    </listitem>
+
+    <listitem>
+     {@link http://www.janrain.com JanRain, Inc.}
+    </listitem>
+
+    <listitem>
+     {@link http://lists.openidenabled.com/mailman/listinfo/dev OpenID Development Discussion List}
+    </listitem>
+
+    <listitem>
+     {@link http://www.openidenabled.com/yadis/libraries/php PHP Yadis Library}
+    </listitem>
+   </itemizedlist>
+  </para>
+ </refsect1>
+
+</refentry>
+

Added: incubator/heraldry/libraries/php/openid/trunk/admin/webtest.php
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/admin/webtest.php?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/admin/webtest.php (added)
+++ incubator/heraldry/libraries/php/openid/trunk/admin/webtest.php Wed Oct 11 15:49:50 2006
@@ -0,0 +1,12 @@
+<?php
+
+require_once 'Tests/TestDriver.php';
+
+$suites = loadSuite();
+
+// Create and run the user interface
+$gui = new PHPUnit_GUI_HTML();
+$gui->addSuites($suites);
+$gui->show();
+
+?>

Added: incubator/heraldry/libraries/php/openid/trunk/admin/xmlconfig.py
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/admin/xmlconfig.py?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/admin/xmlconfig.py (added)
+++ incubator/heraldry/libraries/php/openid/trunk/admin/xmlconfig.py Wed Oct 11 15:49:50 2006
@@ -0,0 +1,55 @@
+
+"""
+This is the package.xml data needed for the PHP OpenID PEAR
+package.xml file.  Use the 'packagexml.py' program to generate a
+package.xml file for a release of this library.
+"""
+
+# This is a list of dicts describing the project leads.  This will be
+# used to generate <lead> XML elements.
+leads = [
+    {'name': 'Jonathan Daugherty',
+     'user': 'cygnus',
+     'email': 'cygnus@janrain.com',
+     'active': 'yes'},
+    {'name': 'Josh Hoyt',
+     'user': 'jhoyt',
+     'email': 'josh@janrain.com',
+     'active': 'yes'}
+    ]
+
+# The package name.
+package_name = 'Auth_OpenID'
+
+# The package description.
+package_description = 'An implementation of the OpenID single sign-on authentication protocol.'
+
+# Package summary.
+package_summary = 'PHP OpenID'
+
+# License string.
+license_name = 'LGPL'
+
+# License URI.
+license_uri = 'http://www.gnu.org/copyleft/lesser.txt'
+
+# Director(ies) containing package source, relative to the admin/
+# directory.  All .php files in these directories will be included in
+# the <contents> element of the output XML and will be assigned the
+# role 'php'.
+contents_dirs = ['../Auth']
+
+# Director(ies) containing package documentation.  All files and
+# subdirectories in these directories will be included in the
+# <contents> element in the output XML and will be assigned the role
+# 'doc'.
+docs_dirs = ['../doc', '../examples']
+
+# The HTTP package base URI.  This is the place on the web where the
+# PEAR-installable tarballs will live, and this (plus the package
+# tarball name) will be the URL that users pass to "pear install".
+package_base_uri = 'http://www.openidenabled.com/resources/downloads/php-openid/pear/'
+
+# The release stability.  Maybe this should be a commandline parameter
+# since it might differ from release to release.
+release_stability = 'pre-release'

Added: incubator/heraldry/libraries/php/openid/trunk/examples/README
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/examples/README?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/examples/README (added)
+++ incubator/heraldry/libraries/php/openid/trunk/examples/README Wed Oct 11 15:49:50 2006
@@ -0,0 +1,122 @@
+OpenID Example Code
+-------------------
+
+After you've installed this package (see ../README), you can use these
+example packages to get started.  They'll show you what this package
+can do, and you can use them as the basis for your own OpenID support.
+
+consumer/: OpenID Example Consumer
+==================================
+
+NOTE: If you want to try the example consumer without installing this
+package, just make sure you add the package's 'Auth' directory to your
+PHP include path.
+
+To try the example consumer implementation, just copy the consumer/
+directory into a place on your web server and point your browser at
+the new directory.
+
+1. Check to be sure that /tmp is in your "open_basedir" configuration,
+   if open_basedir is being used to restrict PHP's file I/O.  See
+   http://us2.php.net/features.safe-mode for more information.  For
+   example, in your php.ini, change
+
+   open_basedir = "..."
+
+   to
+
+   open_basedir = "/tmp:..."
+
+   (If you really don't want to add /tmp to your open_basedir, you can
+   modify consumer/common.php and change $store_path so it doesn't
+   create the store directory in /tmp.)
+
+2. Copy or symlink the consumer/ directory into a part of your
+   webserver's docroot.  For example, if your DocumentRoot is
+   /var/www/, do this:
+
+   # cd /var/www
+   # ln -s /path/to/PHP-OpenID-X.Y.Z/examples/consumer
+
+3. Navigate to http://www.example.com/consumer and enter an OpenID
+   into the form presented there and click "Verify".
+
+consumer/ Files
+===============
+
+The 'index.php' file will render a form and get you started.  These
+are the example consumer files:
+
+  consumer/index.php - Renders a form so you can begin the OpenID auth
+process.  The form submits the OpenID to try_auth.php.
+
+  consumer/try_auth.php - Starts the authentication with the OpenID
+server that manages your OpenID and redirects your browser to the
+server's login page.  Instructs the server to return to
+finish_auth.php when you're done authenticating.
+
+  consumer/finish_auth.php - Finishes the authentication by checking
+the server's response.  Tells you if the authentication was
+successful.
+
+  consumer/common.php - Includes the setup code you'll need to create
+a Consumer object and participate in an OpenID authentication.
+
+server/: OpenID Example Server
+==============================
+
+To try the example server, follow these steps:
+
+1. Customize server/config.php based on what your PHP installation
+   supports.  The documentation in the file describes what each value
+   is for.
+
+2. Copy or symlink the server/ directory into a part of your
+   webserver's docroot.  For example, if your DocumentRoot is
+   /var/www/, do this:
+
+   # cd /var/www
+   # ln -s /path/to/PHP-OpenID-X.Y.Z/examples/server
+
+3. For each of the identity URLs you added to the $openid_users array
+   in config.php, add the following to the <HEAD> tag of the pages at
+   those URLs:
+
+   <link rel="openid.server" href="http://www.example.com/server/server.php" />
+
+   Where "www.example.com/server" is the path to the server symlink
+   that you created in step (2).
+
+4. Navigate to http://www.example.com/server and click the "Log In"
+   link to test the OpenID(s) entered into the config file.
+
+5. Use the OpenID checkup tool to try authenticating with your OpenID:
+
+   http://www.openidenabled.com/resources/openid-test/checkup
+
+   If your OpenID server isn't on the public internet, you can use the
+   example consumer packaged with this library.  See the consumer
+   section above.
+
+server/ Files
+=============
+
+These files make up the server example code:
+
+  config.php - The configuration file you'll need to customize to run
+the example server.
+
+  server.php - The PHP rendering script that takes care of handling
+server requests from both regular user agents and consumers.
+
+  lib/actions.php - Handles the various types of requests that the
+server supports.
+
+  lib/common.php - Supplies functions that wrap the OpenID API calls
+to make them easier to use.
+
+  lib/render.php - Miscellaneous page rendering code.
+
+  lib/session.php - Code to handle session data for user settings.
+
+  lib/render/*.php - Files for each page presented by the server.

Added: incubator/heraldry/libraries/php/openid/trunk/examples/consumer/common.php
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/examples/consumer/common.php?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/examples/consumer/common.php (added)
+++ incubator/heraldry/libraries/php/openid/trunk/examples/consumer/common.php Wed Oct 11 15:49:50 2006
@@ -0,0 +1,41 @@
+<?php
+
+$path_extra = dirname(dirname(dirname(__FILE__)));
+$path = ini_get('include_path');
+$path = $path_extra . ':' . $path;
+ini_set('include_path', $path);
+
+/**
+ * Require the OpenID consumer code.
+ */
+require_once "Auth/OpenID/Consumer.php";
+
+/**
+ * Require the "file store" module, which we'll need to store OpenID
+ * information.
+ */
+require_once "Auth/OpenID/FileStore.php";
+
+/**
+ * This is where the example will store its OpenID information.  You
+ * should change this path if you want the example store to be created
+ * elsewhere.  After you're done playing with the example script,
+ * you'll have to remove this directory manually.
+ */
+$store_path = "/tmp/_php_consumer_test";
+
+if (!file_exists($store_path) &&
+    !mkdir($store_path)) {
+    print "Could not create the FileStore directory '$store_path'. ".
+        " Please check the effective permissions.";
+    exit(0);
+}
+
+$store = new Auth_OpenID_FileStore($store_path);
+
+/**
+ * Create a consumer object using the store object created earlier.
+ */
+$consumer = new Auth_OpenID_Consumer($store);
+
+?>
\ No newline at end of file

Added: incubator/heraldry/libraries/php/openid/trunk/examples/consumer/finish_auth.php
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/examples/consumer/finish_auth.php?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/examples/consumer/finish_auth.php (added)
+++ incubator/heraldry/libraries/php/openid/trunk/examples/consumer/finish_auth.php Wed Oct 11 15:49:50 2006
@@ -0,0 +1,38 @@
+<?php
+
+require_once "common.php";
+session_start();
+
+// Complete the authentication process using the server's response.
+$response = $consumer->complete($_GET);
+
+if ($response->status == Auth_OpenID_CANCEL) {
+    // This means the authentication was cancelled.
+    $msg = 'Verification cancelled.';
+} else if ($response->status == Auth_OpenID_FAILURE) {
+    $msg = "OpenID authentication failed: " . $response->message;
+} else if ($response->status == Auth_OpenID_SUCCESS) {
+    // This means the authentication succeeded.
+    $openid = $response->identity_url;
+    $esc_identity = htmlspecialchars($openid, ENT_QUOTES);
+    $success = sprintf('You have successfully verified ' .
+                       '<a href="%s">%s</a> as your identity.',
+                       $esc_identity, $esc_identity);
+
+    if ($response->endpoint->canonicalID) {
+        $success .= '  (XRI CanonicalID: '.$response->endpoint->canonicalID.') ';
+    }
+
+    $sreg = $response->extensionResponse('sreg');
+
+    if (@$sreg['email']) {
+        $success .= "  You also returned '".$sreg['email']."' as your email.";
+    }
+    if (@$sreg['postcode']) {
+        $success .= "  Your postal code is '".$sreg['postcode']."'";
+    }
+}
+
+include 'index.php';
+
+?>
\ No newline at end of file

Added: incubator/heraldry/libraries/php/openid/trunk/examples/consumer/index.php
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/examples/consumer/index.php?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/examples/consumer/index.php (added)
+++ incubator/heraldry/libraries/php/openid/trunk/examples/consumer/index.php Wed Oct 11 15:49:50 2006
@@ -0,0 +1,59 @@
+<html>
+  <head><title>PHP OpenID Authentication Example</title></head>
+  <style type="text/css">
+      * {
+        font-family: verdana,sans-serif;
+      }
+      body {
+        width: 50em;
+        margin: 1em;
+      }
+      div {
+        padding: .5em;
+      }
+      table {
+        margin: none;
+        padding: none;
+      }
+      .alert {
+        border: 1px solid #e7dc2b;
+        background: #fff888;
+      }
+      .success {
+        border: 1px solid #669966;
+        background: #88ff88;
+      }
+      .error {
+        border: 1px solid #ff0000;
+        background: #ffaaaa;
+      }
+      #verify-form {
+        border: 1px solid #777777;
+        background: #dddddd;
+        margin-top: 1em;
+        padding-bottom: 0em;
+      }
+  </style>
+  <body>
+    <h1>PHP OpenID Authentication Example</h1>
+    <p>
+      This example consumer uses the <a
+      href="http://www.openidenabled.com/openid/libraries/php/">PHP
+      OpenID</a> library. It just verifies that the URL that you enter
+      is your identity URL.
+    </p>
+
+    <?php if (isset($msg)) { print "<div class=\"alert\">$msg</div>"; } ?>
+    <?php if (isset($error)) { print "<div class=\"error\">$error</div>"; } ?>
+    <?php if (isset($success)) { print "<div class=\"success\">$success</div>"; } ?>
+
+    <div id="verify-form">
+      <form method="get" action="try_auth.php">
+        Identity&nbsp;URL:
+        <input type="hidden" name="action" value="verify" />
+        <input type="text" name="openid_url" value="" />
+        <input type="submit" value="Verify" />
+      </form>
+    </div>
+  </body>
+</html>

Added: incubator/heraldry/libraries/php/openid/trunk/examples/consumer/try_auth.php
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/examples/consumer/try_auth.php?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/examples/consumer/try_auth.php (added)
+++ incubator/heraldry/libraries/php/openid/trunk/examples/consumer/try_auth.php Wed Oct 11 15:49:50 2006
@@ -0,0 +1,43 @@
+<?php
+
+require_once "common.php";
+session_start();
+
+// Render a default page if we got a submission without an openid
+// value.
+if (empty($_GET['openid_url'])) {
+    $error = "Expected an OpenID URL.";
+    include 'index.php';
+    exit(0);
+}
+
+$openid = $_GET['openid_url'];
+$process_url = sprintf("http://%s:%s%s/finish_auth.php",
+                       $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'],
+                       dirname($_SERVER['PHP_SELF']));
+
+$trust_root = sprintf("http://%s:%s%s",
+                      $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'],
+                      dirname($_SERVER['PHP_SELF']));
+
+// Begin the OpenID authentication process.
+$auth_request = $consumer->begin($openid);
+
+// Handle failure status return values.
+if (!$auth_request) {
+    $error = "Authentication error.";
+    include 'index.php';
+    exit(0);
+}
+
+$auth_request->addExtensionArg('sreg', 'optional', 'email');
+
+// Redirect the user to the OpenID server for authentication.  Store
+// the token for this authentication so we can verify the response.
+
+$redirect_url = $auth_request->redirectURL($trust_root,
+                                           $process_url);
+
+header("Location: ".$redirect_url);
+
+?>
\ No newline at end of file

Added: incubator/heraldry/libraries/php/openid/trunk/examples/detect.php
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/examples/detect.php?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/examples/detect.php (added)
+++ incubator/heraldry/libraries/php/openid/trunk/examples/detect.php Wed Oct 11 15:49:50 2006
@@ -0,0 +1,482 @@
+<?php
+
+$path_extra = dirname(dirname(__FILE__));
+$path = ini_get('include_path');
+$path = $path_extra . ':' . $path;
+ini_set('include_path', $path);
+
+define('IS_WINDOWS', strtoupper(substr(PHP_OS, 0, 3)) === 'WIN');
+
+class PlainText {
+    function start($title)
+    {
+        return '';
+    }
+
+    function tt($text)
+    {
+        return $text;
+    }
+
+    function link($href, $text=null)
+    {
+        if ($text) {
+            return $text . ' <' . $href . '>';
+        } else {
+            return $href;
+        }
+    }
+
+    function b($text)
+    {
+        return '*' . $text . '*';
+    }
+
+    function contentType()
+    {
+        return 'text/plain';
+    }
+
+    function p($text)
+    {
+        return wordwrap($text) . "\n\n";
+    }
+
+    function pre($text)
+    {
+        $out = '';
+        $lines = array_map('trim', explode("\n", $text));
+        foreach ($lines as $line) {
+            $out .= '    ' . $line . "\n";
+        }
+        $out .= "\n";
+        return $out;
+    }
+
+    function ol($items)
+    {
+        $out = '';
+        $c = 1;
+        foreach ($items as $item) {
+            $item = wordwrap($item, 72);
+            $lines = array_map('trim', explode("\n", $item));
+            $out .= $c . '. ' . $lines[0] . "\n";
+            unset($lines[0]);
+            foreach ($lines as $line) {
+                $out .= '   ' . $line . "\n";
+            }
+            $out .= "\n";
+            $c += 1;
+        }
+        return $out;
+    }
+
+    function h2($text)
+    {
+        return $this->h($text, 2);
+    }
+
+    function h1($text)
+    {
+        return $this->h($text, 1);
+    }
+
+    function h($text, $n)
+    {
+        $chars = '#=+-.';
+        $c = $chars[$n - 1];
+        return "\n" . $text . "\n" . str_repeat($c, strlen($text)) . "\n\n";
+    }
+
+    function end()
+    {
+        return '';
+    }
+}
+
+class HTML {
+    function start($title)
+    {
+        return '<html><head><title>' . $title . '</title></head><body>' . "\n";
+    }
+
+    function tt($text)
+    {
+        return '<code>' . $text . '</code>';
+    }
+
+    function contentType()
+    {
+        return 'text/html';
+    }
+
+    function b($text)
+    {
+        return '<strong>' . $text . '</strong>';
+    }
+
+    function p($text)
+    {
+        return '<p>' . wordwrap($text) . "</p>\n";
+    }
+
+    function pre($text)
+    {
+        return '<pre>' . $text . "</pre>\n";
+    }
+
+    function ol($items)
+    {
+        $out = '<ol>';
+        foreach ($items as $item) {
+            $out .= '<li>' . wordwrap($item) . "</li>\n";
+        }
+        $out .= "</ol>\n";
+        return $out;
+    }
+
+    function h($text, $n)
+    {
+        return "<h$n>$text</h$n>\n";
+    }
+
+    function h2($text)
+    {
+        return $this->h($text, 2);
+    }
+
+    function h1($text)
+    {
+        return $this->h($text, 1);
+    }
+
+    function link($href, $text=null)
+    {
+        return '<a href="' . $href . '">' . ($text ? $text : $href) . '</a>';
+    }
+
+    function end()
+    {
+        return "</body>\n</html>\n";
+    }
+}
+
+if (isset($_SERVER['REQUEST_METHOD'])) {
+    $r = new HTML();
+} else {
+    $r = new PlainText();
+}
+
+function detect_math($r, &$out)
+{
+    global $_Auth_OpenID_math_extensions;
+    $out .= $r->h2('Math support');
+    $ext = Auth_OpenID_detectMathLibrary($_Auth_OpenID_math_extensions);
+    if (!isset($ext['extension']) || !isset($ext['class'])) {
+        $out .= $r->p(
+            'Your PHP installation does not include big integer math ' .
+            'support. This support is required if you wish to run a ' .
+            'secure OpenID server without using SSL.');
+        $out .= $r->p('To use this library, you have a few options:');
+
+        $gmp_lnk = $r->link('http://www.php.net/manual/en/ref.gmp.php', 'GMP');
+        $bc_lnk = $r->link('http://www.php.net/manual/en/ref.bc.php', 'bcmath');
+        $out .= $r->ol(array(
+            'Install the ' . $gmp_lnk . ' PHP extension',
+            'Install the ' . $bc_lnk . ' PHP extension',
+            'If your site is low-security, define ' .
+            'Auth_OpenID_NO_MATH_SUPPORT. The library will function, but ' .
+            'the security of your OpenID server will depend on the ' .
+            'security of the network links involved. If you are only ' .
+            'using consumer support, you should still be able to operate ' .
+            'securely when the users are communicating with a ' .
+            'well-implemented server.'));
+        return false;
+    } else {
+        switch ($ext['extension']) {
+        case 'bcmath':
+            $out .= $r->p('Your PHP installation has bcmath support. This is ' .
+                  'adequate for small-scale use, but can be CPU-intensive. ' .
+                  'You may want to look into installing the GMP extension.');
+            $lnk = $r->link('http://www.php.net/manual/en/ref.gmp.php');
+            $out .= $r->p('See ' . $lnk .' for more information ' .
+                          'about the GMP extension.');
+            break;
+        case 'gmp':
+            $out .= $r->p('Your PHP installation has gmp support. Good.');
+            break;
+        default:
+            $class = $ext['class'];
+            $lib = new $class();
+            $one = $lib->init(1);
+            $two = $lib->add($one, $one);
+            $t = $lib->toString($two);
+            $out .= $r->p('Uh-oh. I do not know about the ' .
+                          $ext['extension'] . ' extension!');
+            if ($t != '2') {
+                $out .= $r->p('It looks like it is broken. 1 + 1 = ' .
+                  var_export($t, false));
+                return false;
+            } else {
+                $out .= $r->p('But it seems to be able to add one and one.');
+            }
+        }
+        return true; // Math library is OK
+    }
+}
+
+function detect_random($r, &$out)
+{
+    $out .= $r->h2('Cryptographic-quality randomness source');
+    if (Auth_OpenID_RAND_SOURCE === null) {
+        $out .= $r->p('Using (insecure) pseudorandom number source, because ' .
+                      'Auth_OpenID_RAND_SOURCE has been defined as null.');
+        return false;
+    }
+
+    $msg = 'The library will try to access ' . Auth_OpenID_RAND_SOURCE
+        . ' as a source of random data. ';
+
+    $numbytes = 6;
+
+    $f = @fopen(Auth_OpenID_RAND_SOURCE, 'r');
+    if ($f !== false) {
+        $data = fread($f, $numbytes);
+        $stat = fstat($f);
+        $size = $stat['size'];
+        fclose($f);
+    } else {
+        $data = null;
+        $size = true;
+    }
+
+    if ($f !== false) {
+        $dataok = (strlen($data) == $numbytes);
+        $ok = $dataok && !$size;
+        $msg .= 'It seems to exist ';
+        if ($dataok) {
+            $msg .= 'and be readable. Here is some hex data: ' .
+                bin2hex($data) . '.';
+        } else {
+            $msg .= 'but reading data failed.';
+        }
+        if ($size) {
+            $msg .= ' This is a ' . $size . ' byte file. Unless you know ' .
+                'what you are doing, it is likely that you are making a ' .
+                'mistake by using a regular file as a randomness source.';
+        }
+    } else {
+        $msg .= Auth_OpenID_RAND_SOURCE .
+            ' could not be opened. This could be because of restrictions on' .
+            ' your PHP environment or that randomness source may not exist' .
+            ' on this platform.';
+        if (IS_WINDOWS) {
+            $msg .= ' You seem to be running Windows. This library does not' .
+                ' have access to a good source of randomness on Windows.';
+        }
+        $ok = false;
+    }
+
+    $out .= $r->p($msg);
+
+    if (!$ok) {
+        $out .= $r->p(
+            'To set a source of randomness, define Auth_OpenID_RAND_SOURCE ' .
+            'to the path to the randomness source. If your platform does ' .
+            'not provide a secure randomness source, the library can' .
+            'operate in pseudorandom mode, but it is then vulnerable to ' .
+            'theoretical attacks. If you wish to operate in pseudorandom ' .
+            'mode, define Auth_OpenID_RAND_SOURCE to null.');
+        $out .= $r->p('You are running on:');
+        $out .= $r->pre(php_uname());
+        $out .= $r->p('There does not seem to be an available source ' .
+                      'of randomness. On a Unix-like platform ' .
+                      '(including MacOS X), try /dev/random and ' .
+                      '/dev/urandom.');
+    }
+    return $ok;
+}
+
+function detect_stores($r, &$out)
+{
+    $out .= $r->h2('Data storage');
+
+    $found = array();
+    foreach (array('sqlite', 'mysql', 'pgsql') as $dbext) {
+        if (extension_loaded($dbext) || @dl($dbext . '.' . PHP_SHLIB_SUFFIX)) {
+            $found[] = $dbext;
+        }
+    }
+    if (count($found) == 0) {
+        $text = 'No SQL database support was found in this PHP ' .
+            'installation. See the PHP manual if you need to ' .
+            'use an SQL database.';
+    } else {
+        $text = 'Support was found for ';
+        if (count($found) == 1) {
+            $text .= $found[0];
+        } else {
+            $last = array_pop($found);
+            $text .= implode(', ', $found) . ' and ' . $last . '.';
+        }
+    }
+    $text .= ' The library supports the MySQL, PostgreSQL, and SQLite ' .
+        'database engines.';
+    $out .= $r->p($text);
+
+    if (function_exists('posix_getpwuid') &&
+        function_exists('posix_geteuid')) {
+        $processUser = posix_getpwuid(posix_geteuid());
+        $web_user = $r->tt($processUser['name']);
+    } else {
+        $web_user = 'the PHP process';
+    }
+
+    if (in_array('sqlite', $found)) {
+        $out .= $r->p('If you are using SQLite, your database must be ' .
+                      'writable by ' . $web_user . ' and not available over' .
+                      ' the web.');
+    }
+
+    $basedir_str = ini_get('open_basedir');
+    if (gettype($basedir_str) == 'string') {
+        $url = 'http://us3.php.net/manual/en/features.safe-mode.php' .
+            '#ini.open-basedir';
+        $lnk = $r->link($url, 'open_basedir');
+        $out .= $r->p('If you are using a filesystem-based store or SQLite, ' .
+                      'be aware that ' . $lnk . ' is in effect. This means ' .
+                      'that your data will have to be stored in one of the ' .
+                      'following locations:');
+        $out .= $r->pre(var_export($basedir_str, true));
+    }
+
+    $out .= $r->p('If you are using the filesystem store, your ' .
+                  'data directory must be readable and writable by ' .
+                  $web_user . ' and not availabe over the Web.');
+    return true;
+}
+
+function detect_xml($r, &$out)
+{
+    global $__Services_Yadis_xml_extensions;
+
+    $out .= $r->h2('XML Support');
+
+    // Try to get an XML extension.
+    $ext = Services_Yadis_getXMLParser();
+
+    if ($ext !== null) {
+        $out .= $r->p('XML parsing support is present using the '.
+                      $r->b(get_class($ext)).' interface.');
+        return true;
+    } else {
+        $out .= $r->p('XML parsing support is absent; please install one '.
+                      'of the following PHP extensions:');
+        foreach ($__Services_Yadis_xml_extensions as $name => $cls) {
+            $out .= "<li>" . $r->b($name) . "</li>";
+        }
+        return false;
+    }
+}
+
+function detect_fetcher($r, &$out)
+{
+    $out .= $r->h2('HTTP Fetching');
+    if (Services_Yadis_Yadis::curlPresent()) {
+        // XXX: actually fetch a URL.
+        $out .= $r->p('This PHP installation has support for libcurl. Good.');
+    } else {
+        $out .= $r->p('This PHP installation does not have support for ' .
+                      'libcurl. Some functionality, such as fetching ' .
+                      'https:// URLs, will be missing and performance ' .
+                      'will not be as good.');
+        $lnk = $r->link('http://us3.php.net/manual/en/ref.curl.php');
+        $out .= $r->p('See ' . $lnk . ' about enabling the libcurl support ' .
+                      'for PHP.');
+    }
+    $ok = true;
+    $fetcher = Services_Yadis_Yadis::getHTTPFetcher();
+    $fetch_url = 'http://www.openidenabled.com/resources/php-fetch-test';
+    $expected_url = $fetch_url . '.txt';
+    $result = $fetcher->get($fetch_url);
+    if (isset($result)) {
+        $parts = array('An HTTP request was completed.');
+        // list ($code, $url, $data) = $result;
+        if ($result->status != '200') {
+            $ok = false;
+            $parts[] = $r->b(
+                sprintf('Got %s instead of the expected HTTP status code ' .
+                        '(200).', $result->status));
+        }
+
+        $url = $result->final_url;
+        if ($url != $expected_url) {
+            $ok = false;
+            if ($url == $fetch_url) {
+                $msg = 'The redirected URL was not returned.';
+            } else {
+                $msg = 'An unexpected URL was returned: <' . $url . '>.';
+            }
+            $parts[] = $r->b($msg);
+        }
+
+        $data = $result->body;
+        if ($data != 'Hello World!') {
+            $ok = false;
+            $parts[] = $r->b('Unexpected data was returned.');
+        }
+        $out .= $r->p(implode(' ', $parts));
+    } else {
+        $ok = false;
+        $out .= $r->p('Fetching URL ' . $lnk . ' failed!');
+    }
+    return $ok;
+}
+
+header('Content-Type: ' . $r->contentType() . '; charset=us-ascii');
+
+$title = 'OpenID Library Support Report';
+$out = $r->start($title) .
+    $r->h1($title) .
+    $r->p('This script checks your PHP installation to determine if you ' .
+          'are set up to use the JanRain PHP OpenID library.');
+
+$body = '';
+
+$_file1 = include 'Auth/OpenID.php';
+$_file2 = include 'Auth/OpenID/BigMath.php';
+
+if (!($_file1 && $_file2)) {
+    $path = ini_get('include_path');
+    $body .= $r->p(
+        'Cannot find the OpenID library. It must be in your PHP include ' .
+        'path. Your PHP include path is currently:');
+    $body .= $r->pre($path);
+} else {
+    $status = array();
+
+    $status[] = detect_math($r, $body);
+    $status[] = detect_random($r, $body);
+    $status[] = detect_stores($r, $body);
+    $status[] = detect_fetcher($r, $body);
+    $status[] = detect_xml($r, $body);
+
+    $result = true;
+
+    foreach ($status as $v) {
+        if (!$v) {
+            $result = false;
+            break;
+        }
+    }
+
+    if ($result) {
+        $out .= $r->h2('<font color="green">Setup Complete!</font>');
+    } else {
+        $out .= $r->h2('<font color="red">Setup Incomplete.</font>');
+    }
+}
+
+$out .= $body . $r->end();
+print $out;
+?>
\ No newline at end of file

Added: incubator/heraldry/libraries/php/openid/trunk/examples/server/index.php
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/examples/server/index.php?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/examples/server/index.php (added)
+++ incubator/heraldry/libraries/php/openid/trunk/examples/server/index.php Wed Oct 11 15:49:50 2006
@@ -0,0 +1,5 @@
+<?php
+
+header("Location: server.php");
+
+?>
\ No newline at end of file

Added: incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/actions.php
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/actions.php?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/actions.php (added)
+++ incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/actions.php Wed Oct 11 15:49:50 2006
@@ -0,0 +1,169 @@
+<?php
+
+require_once "lib/common.php";
+require_once "lib/session.php";
+require_once "lib/render.php";
+
+require_once "lib/render/login.php";
+require_once "lib/render/sites.php";
+
+require_once "Auth/OpenID.php";
+
+/**
+ * Handle a standard OpenID server request
+ */
+function action_default()
+{
+    $server =& getServer();
+    $method = $_SERVER['REQUEST_METHOD'];
+    $request = null;
+    if ($method == 'GET') {
+        $request = $_GET;
+    } else {
+        $request = $_POST;
+    }
+
+    $request = Auth_OpenID::fixArgs($request);
+    $request = $server->decodeRequest($request);
+
+    if (!$request) {
+        return about_render();
+    }
+
+    setRequestInfo($request);
+
+    if (in_array($request->mode,
+                 array('checkid_immediate', 'checkid_setup'))) {
+
+        if (isTrusted($request->identity, $request->trust_root)) {
+            $response =& $request->answer(true);
+            $sreg = getSreg($request->identity);
+            if (is_array($sreg)) {
+                foreach ($sreg as $k => $v) {
+                    $response->addField('sreg', $k, 
+                                        $v);
+                }
+            }
+        } else if ($request->immediate) {
+            $response =& $request->answer(false, getServerURL());
+        } else {
+            if (!getLoggedInUser()) {
+                return login_render();
+            }
+            return trust_render($request);
+        }
+    } else {
+        $response =& $server->handleRequest($request);
+    }
+
+    $webresponse =& $server->encodeResponse($response);
+
+    foreach ($webresponse->headers as $k => $v) {
+        header("$k: $v");
+    }
+
+    header(header_connection_close);
+    print $webresponse->body;
+    exit(0);
+}
+
+/**
+ * Log out the currently logged in user
+ */
+function action_logout()
+{
+    setLoggedInUser(null);
+    setRequestInfo(null);
+    return authCancel(null);
+}
+
+/**
+ * Check the input values for a login request
+ */
+function login_checkInput($input)
+{
+    $openid_url = false;
+    $errors = array();
+
+    if (!isset($input['openid_url'])) {
+        $errors[] = 'Enter an OpenID URL to continue';
+    }
+    if (!isset($input['password'])) {
+        $errors[] = 'Enter a password to continue';
+    }
+    if (count($errors) == 0) {
+        $openid_url = $input['openid_url'];
+        $openid_url = Auth_OpenID::normalizeUrl($openid_url);
+        $password = $input['password'];
+        if (!checkLogin($openid_url, $password)) {
+            $errors[] = 'The entered password does not match the ' .
+                'entered identity URL.';
+        }
+    }
+    return array($errors, $openid_url);
+}
+
+/**
+ * Log in a user and potentially continue the requested identity approval
+ */
+function action_login()
+{
+    $method = $_SERVER['REQUEST_METHOD'];
+    switch ($method) {
+    case 'GET':
+        return login_render();
+    case 'POST':
+        $info = getRequestInfo();
+        $fields = $_POST;
+        if (isset($fields['cancel'])) {
+            return authCancel($info);
+        }
+
+        list ($errors, $openid_url) = login_checkInput($fields);
+        if (count($errors) || !$openid_url) {
+            $needed = $info ? $info->identity : false;
+            return login_render($errors, @$fields['openid_url'], $needed);
+        } else {
+            setLoggedInUser($openid_url);
+            return doAuth($info);
+        }
+    default:
+        return login_render(array('Unsupported HTTP method: $method'));
+    }
+}
+
+/**
+ * Ask the user whether he wants to trust this site
+ */
+function action_trust()
+{
+    $info = getRequestInfo();
+    $trusted = isset($_POST['trust']);
+    if ($info && isset($_POST['remember'])) {
+        $sites = getSessionSites();
+        $sites[$info->trust_root] = $trusted;
+        setSessionSites($sites);
+    }
+    return doAuth($info, $trusted, true);
+}
+
+function action_sites()
+{
+    $sites = getSessionSites();
+    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
+        if (isset($_POST['forget'])) {
+            $sites = null;
+            setSessionSites($sites);
+        } elseif (isset($_POST['remove'])) {
+            foreach ($_POST as $k => $v) {
+                if (preg_match('/^site[0-9]+$/', $k) && isset($sites[$v])) {
+                    unset($sites[$v]);
+                }
+            }
+            setSessionSites($sites);
+        }
+    }
+    return sites_render($sites);
+}
+
+?>
\ No newline at end of file

Added: incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/common.php
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/common.php?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/common.php (added)
+++ incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/common.php Wed Oct 11 15:49:50 2006
@@ -0,0 +1,63 @@
+<?php
+
+require_once "lib/render.php";
+require_once "lib/session.php";
+
+require_once "lib/render/login.php";
+require_once "lib/render/about.php";
+require_once "lib/render/trust.php";
+
+require_once "Auth/OpenID/Server.php";
+require_once "Auth/OpenID/HMACSHA1.php";
+
+function authCancel($info)
+{
+    if ($info) {
+        setRequestInfo();
+        $url = $info->getCancelURL();
+    } else {
+        $url = getServerURL();
+    }
+    return redirect_render($url);
+}
+
+function doAuth($info, $trusted=null, $fail_cancels=false)
+{
+    if (!$info) {
+        // There is no authentication information, so bail
+        return authCancel(null);
+    }
+
+    $req_url = $info->identity;
+    $user = getLoggedInUser();
+    setRequestInfo($info);
+
+    if ($req_url != $user) {
+        return login_render(array(), $req_url, $req_url);
+    }
+
+    $sites = getSessionSites();
+    $trust_root = $info->trust_root;
+    $fail_cancels = $fail_cancels || isset($sites[$trust_root]);
+    $trusted = isset($trusted) ? $trusted : isTrusted($req_url, $trust_root);
+    if ($trusted) {
+        setRequestInfo();
+        $server =& getServer();
+        $response =& $info->answer(true);
+        $webresponse =& $server->encodeResponse($response);
+
+        $new_headers = array();
+
+        foreach ($webresponse->headers as $k => $v) {
+            $new_headers[] = $k.": ".$v;
+        }
+
+        return array($new_headers, $webresponse->body);
+    } elseif ($fail_cancels) {
+        return authCancel($info);
+    } else {
+        return trust_render($info);
+    }
+}
+
+?>
\ No newline at end of file

Added: incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/render.php
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/render.php?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/render.php (added)
+++ incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/render.php Wed Oct 11 15:49:50 2006
@@ -0,0 +1,112 @@
+<?php
+
+define('page_template',
+'<html>
+  <head>
+    <title>%s</title>
+%s
+  </head>
+  <body>
+    %s
+<div id="content">
+    <h1>%s</h1>
+    %s
+</div>
+  </body>
+</html>');
+
+define('logged_in_pat', 'You are logged in as %s.');
+
+/**
+ * HTTP response line contstants
+ */
+define('http_bad_request', 'HTTP/1.1 400 Bad Request');
+define('http_found', 'HTTP/1.1 302 Found');
+define('http_ok', 'HTTP/1.1 200 OK');
+define('http_internal_error', 'HTTP/1.1 500 Internal Error');
+
+/**
+ * HTTP header constants
+ */
+define('header_connection_close', 'Connection: close');
+define('header_content_text', 'Content-Type: text/plain; charset=us-ascii');
+
+define('redirect_message',
+       'Please wait; you are being redirected to <%s>');
+
+
+/**
+ * Return a string containing an anchor tag containing the given URL
+ *
+ * The URL does not need to be quoted, but if text is passed in, then
+ * it does.
+ */
+function link_render($url, $text=null) {
+    $esc_url = htmlspecialchars($url, ENT_QUOTES);
+    $text = ($text === null) ? $esc_url : $text;
+    return sprintf('<a href="%s">%s</a>', $esc_url, $text);
+}
+
+/**
+ * Return an HTTP redirect response
+ */
+function redirect_render($redir_url)
+{
+    $headers = array(http_found,
+                     header_content_text,
+                     header_connection_close,
+                     'Location: ' . $redir_url,
+                     );
+    $body = sprintf(redirect_message, $redir_url);
+    return array($headers, $body);
+}
+
+function navigation_render($msg, $items)
+{
+    $what = link_render(buildURL(), 'PHP OpenID Server');
+    if ($msg) {
+        $what .= ' &mdash; ' . $msg;
+    }
+    if ($items) {
+        $s = '<p>' . $what . '</p><ul class="bottom">';
+        foreach ($items as $action => $text) {
+            $url = buildURL($action);
+            $s .= sprintf('<li>%s</li>', link_render($url, $text));
+        }
+        $s .= '</ul>';
+    } else {
+        $s = '<p class="bottom">' . $what . '</p>';
+    }
+    return sprintf('<div class="navigation">%s</div>', $s);
+}
+
+/**
+ * Render an HTML page
+ */
+function page_render($body, $user, $title, $h1=null, $login=false)
+{
+    $h1 = $h1 ? $h1 : $title;
+
+    if ($user) {
+        $msg = sprintf(logged_in_pat, link_render($user));
+        $nav = array('logout' => 'Log Out',
+                     'sites' => 'Remembered Sites',
+                     );
+        $navigation = navigation_render($msg, $nav);
+    } else {
+        if (!$login) {
+            $msg = link_render(buildURL('login'), 'Log In');
+            $navigation = navigation_render($msg, array());
+        } else {
+            $navigation = '';
+        }
+    }
+
+    $style = getStyle();
+    $text = sprintf(page_template, $title, $style, $navigation, $h1, $body);
+    // No special headers here
+    $headers = array();
+    return array($headers, $text);
+}
+
+?>
\ No newline at end of file

Added: incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/render/about.php
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/render/about.php?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/render/about.php (added)
+++ incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/render/about.php Wed Oct 11 15:49:50 2006
@@ -0,0 +1,58 @@
+<?php
+
+require_once "lib/session.php";
+require_once "lib/render.php";
+
+define('about_error_template',
+       '<div class="error">
+An error occurred when processing your request:
+<br />
+%s
+</div>');
+
+define('about_body',
+       '<p>
+  This is an <a href="http://www.openid.net/">OpenID</a> server
+  endpoint. This server is built on the <a
+  href="http://www.openidenabled.com/openid/libraries/php">JanRain PHP OpenID
+  library</a>. Since OpenID consumer sites will need to directly contact this
+  server, it must be accessible over the Internet (not behind a firewall).
+</p>
+<p>
+  To use this server, you will have to set up a URL to use as an identifier.
+  Insert the following markup into the <code>&lt;head&gt;</code> of the HTML
+  document at that URL:
+</p>
+<pre>&lt;link rel="openid.server" href="%s" /&gt;</pre>
+<p>
+  Then configure this server so that you can log in with that URL. Once you
+  have configured the server, and marked up your identity URL, you can verify
+  that it is working by using the <a href="http://www.openidenabled.com/"
+  >openidenabled.com</a>
+  <a href="http://www.openidenabled.com/resources/openid-test/checkup">OpenID
+  Checkup tool</a>:
+  <form method="post"
+        action="http://www.openidenabled.com/resources/openid-test/checkup/start">
+    <label for="checkup">OpenID URL:
+    </label><input id="checkup" type="text" name="openid_url" />
+    <input type="submit" value="Check" />
+  </form>
+</p>
+');
+
+/**
+ * Render the about page, potentially with an error message
+ */
+function about_render($error=false, $internal=true)
+{
+    $headers = array();
+    $body = sprintf(about_body, buildURL());
+    if ($error) {
+        $headers[] = $internal ? http_internal_error : http_bad_request;
+        $body .= sprintf(about_error_template, htmlspecialchars($error));
+    }
+    $current_user = getLoggedInUser();
+    return page_render($body, $current_user, 'OpenID Server Endpoint');
+}
+
+?>
\ No newline at end of file

Added: incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/render/login.php
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/render/login.php?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/render/login.php (added)
+++ incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/render/login.php Wed Oct 11 15:49:50 2006
@@ -0,0 +1,65 @@
+<?php
+
+require_once "lib/session.php";
+require_once "lib/render.php";
+
+define('login_form_pat',
+       '<div class="form">
+  <p>
+    Enter your identity URL and password into this form to log in to
+    this server. This server must be configured to accept your identity URL.
+  </p>
+
+  <form method="post" action="%s">
+    <table>
+      <tr>
+        <th><label for="openid_url">OpenID URL:</label></th>
+        <td><input type="text" name="openid_url"
+                   value="%s" id="openid_url" /></td>
+      </tr>
+      <tr>
+        <th><label for="password">Password:</label></th>
+        <td><input type="password" name="password" id="password" /></td>
+      </tr>
+      <tr>
+        <td colspan="2">
+          <input type="submit" value="Log in" />
+          <input type="submit" name="cancel" value="Cancel" />
+        </td>
+      </tr>
+    </table>
+  </form>
+</div>
+');
+
+define('login_needed_pat',
+       'You must be logged in as %s to approve this request.');
+
+function login_render($errors=null, $input=null, $needed=null)
+{
+    $current_user = getLoggedInUser();
+    if ($input === null) {
+        $input = $current_user;
+    }
+    if ($needed) {
+        $errors[] = sprintf(login_needed_pat, link_render($needed));
+    }
+
+    $esc_input = htmlspecialchars($input, ENT_QUOTES);
+    $login_url = buildURL('login', true);
+    $body = sprintf(login_form_pat, $login_url, $esc_input);
+    if ($errors) {
+        $body = loginError_render($errors) . $body;
+    }
+    return page_render($body, $current_user, 'Log In', null, true);
+}
+
+function loginError_render($errors)
+{
+    $text = '';
+    foreach ($errors as $error) {
+        $text .= sprintf("<li>%s</li>\n", $error);
+    }
+    return sprintf("<ul class=\"error\">\n%s</ul>\n", $text);
+}
+?>
\ No newline at end of file

Added: incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/render/sites.php
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/render/sites.php?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/render/sites.php (added)
+++ incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/render/sites.php Wed Oct 11 15:49:50 2006
@@ -0,0 +1,83 @@
+<?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

Added: incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/render/trust.php
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/render/trust.php?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/render/trust.php (added)
+++ incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/render/trust.php Wed Oct 11 15:49:50 2006
@@ -0,0 +1,29 @@
+<?php
+
+require_once "lib/session.php";
+require_once "lib/render.php";
+
+define('trust_form_pat',
+       '<div class="form">
+  <p>Do you wish to confirm your identity URL (<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 />
+    <input type="submit" name="trust" value="Confirm" />
+    <input type="submit" value="Do not confirm" />
+  </form>
+</div>
+');
+
+function trust_render($info)
+{
+    $current_user = getLoggedInUser();
+    $lnk = link_render($current_user);
+    $trust_root = htmlspecialchars($info->trust_root);
+    $trust_url = buildURL('trust', true);
+    $form = sprintf(trust_form_pat, $lnk, $trust_root, $trust_url);
+    return page_render($form, $current_user, 'Trust This Site');
+}
+
+?>
\ No newline at end of file

Added: incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/session.php
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/session.php?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/session.php (added)
+++ incubator/heraldry/libraries/php/openid/trunk/examples/server/lib/session.php Wed Oct 11 15:49:50 2006
@@ -0,0 +1,205 @@
+<?php
+
+require_once "config.php";
+require_once "lib/render.php";
+require_once "Auth/OpenID/Server.php";
+
+/**
+ * Set up the session
+ */
+function init()
+{
+    session_name('openid_server');
+    session_start();
+}
+
+/**
+ * Get the style markup
+ */
+function getStyle()
+{
+    $parent = rtrim(dirname(getServerURL()), '/');
+    $url = htmlspecialchars($parent . '/openid-server.css', ENT_QUOTES);
+    return sprintf('<link rel="stylesheet" type="text/css" href="%s" />', $url);
+}
+
+/**
+ * Get the URL of the current script
+ */
+function getServerURL()
+{
+    $path = $_SERVER['SCRIPT_NAME'];
+    $host = $_SERVER['HTTP_HOST'];
+    $port = $_SERVER['SERVER_PORT'];
+    $s = $_SERVER['HTTPS'] ? 's' : '';
+    if (($s && $port == "443") || (!$s && $port == "80")) {
+        $p = '';
+    } else {
+        $p = ':' . $port;
+    }
+    
+    return "http$s://$host$p$path";
+}
+
+/**
+ * Build a URL to a server action
+ */
+function buildURL($action=null, $escaped=true)
+{
+    $url = getServerURL();
+    if ($action) {
+        $url .= '/' . $action;
+    }
+    return $escaped ? htmlspecialchars($url, ENT_QUOTES) : $url;
+}
+
+/**
+ * Extract the current action from the request
+ */
+function getAction()
+{
+    $path_info = @$_SERVER['PATH_INFO'];
+    $action = ($path_info) ? substr($path_info, 1) : '';
+    $function_name = 'action_' . $action;
+    return $function_name;
+}
+
+/**
+ * Write the response to the request
+ */
+function writeResponse($resp)
+{
+    list ($headers, $body) = $resp;
+    array_walk($headers, 'header');
+    header(header_connection_close);
+    print $body;
+}
+
+/**
+ * Instantiate a new OpenID server object
+ */
+function getServer()
+{
+    static $server = null;
+    if (!isset($server)) {
+        $server =& new Auth_OpenID_Server(getOpenIDStore());
+    }
+    return $server;
+}
+
+/**
+ * Return whether the trust root is currently trusted
+ */
+function isTrusted($identity_url, $trust_root)
+{
+    // from config.php
+    global $trusted_sites;
+
+    if ($identity_url != getLoggedInUser()) {
+        return false;
+    }
+
+    if (in_array($trust_root, $trusted_sites)) {
+        return true;
+    }
+
+    $sites = getSessionSites();
+    return isset($sites[$trust_root]) && $sites[$trust_root];
+}
+
+/**
+ * Return a hashed form of the user's password
+ */
+function hashPassword($password)
+{
+    return bin2hex(Auth_OpenID_SHA1($password));
+}
+
+/**
+ * Check the user's login information
+ */
+function checkLogin($openid_url, $password)
+{
+    // from config.php
+    global $openid_users;
+    $hash = hashPassword($password);
+
+    return isset($openid_users[$openid_url])
+        && $hash == $openid_users[$openid_url];
+}
+
+/**
+ * Get the openid_url out of the cookie
+ *
+ * @return mixed $openid_url The URL that was stored in the cookie or
+ * false if there is none present or if the cookie is bad.
+ */
+function getLoggedInUser()
+{
+    return isset($_SESSION['openid_url'])
+        ? $_SESSION['openid_url']
+        : false;
+}
+
+/**
+ * Set the openid_url in the cookie
+ *
+ * @param mixed $identity_url The URL to set. If set to null, the
+ * value will be unset.
+ */
+function setLoggedInUser($identity_url=null)
+{
+    if (!isset($identity_url)) {
+        unset($_SESSION['openid_url']);
+    } else {
+        $_SESSION['openid_url'] = $identity_url;
+    }
+}
+
+function setSessionSites($sites=null)
+{
+    if (!isset($sites)) {
+        unset($_SESSION['session_sites']);
+    } else {
+        $_SESSION['session_sites'] = serialize($sites);
+    }
+}
+
+function getSessionSites()
+{
+    return isset($_SESSION['session_sites'])
+        ? unserialize($_SESSION['session_sites'])
+        : false;
+}
+
+function getRequestInfo()
+{
+    return isset($_SESSION['request'])
+        ? unserialize($_SESSION['request'])
+        : false;
+}
+
+function setRequestInfo($info=null)
+{
+    if (!isset($info)) {
+        unset($_SESSION['request']);
+    } else {
+        $_SESSION['request'] = serialize($info);
+    }
+}
+
+
+function getSreg($identity)
+{
+    // from config.php
+    global $openid_sreg;
+
+    if (!is_array($openid_sreg)) {
+        return null;
+    }
+
+    return $openid_sreg[$identity];
+
+}
+
+?>
\ No newline at end of file

Added: incubator/heraldry/libraries/php/openid/trunk/examples/server/openid-server.css
URL: http://svn.apache.org/viewvc/incubator/heraldry/libraries/php/openid/trunk/examples/server/openid-server.css?view=auto&rev=463021
==============================================================================
--- incubator/heraldry/libraries/php/openid/trunk/examples/server/openid-server.css (added)
+++ incubator/heraldry/libraries/php/openid/trunk/examples/server/openid-server.css Wed Oct 11 15:49:50 2006
@@ -0,0 +1,74 @@
+body {
+    padding: 0;
+    margin: 0;
+}
+
+#content {
+    padding: 0.5em;
+    max-width: 50em;
+}
+
+ul.error {
+    background: #ffaaaa;
+    border: 1px solid #ff0000;
+    padding: 0.5em;
+    padding-left: 1.5em;
+}
+
+.login th {
+    text-align: left;
+}
+
+div.form {
+    border: thin solid #777777;
+    background: #dddddd;
+    padding: 0.5em;
+    margin-top: 1em;
+}
+
+div.navigation {
+    border-bottom: thin solid #cccccc;
+    background: #eeeeee;
+    font-size: smaller;
+    padding: 0.5em;
+}
+
+div.navigation h2 {
+    margin-top: 0;
+}
+
+div.navigation p {
+    margin: 0;
+}
+
+div.navigation ul {
+    margin: 0;
+}
+
+div.login p {
+    margin-top: 0;
+}
+
+h1 {
+    margin-top: 0;
+}
+
+pre {
+    padding: 1em;
+    border: 1px solid black;
+    background: #ffeebb;
+}
+
+#checkup {
+    background: url('http://www.openidenabled.com/favicon.ico') no-repeat;
+    padding-left: 16px;
+}
+
+th {
+    text-align: left;
+}
+
+table {
+    border-collapse: collapse;
+    margin-bottom: 1em;
+}
\ No newline at end of file



Mime
View raw message