git-svn-id: https://svn.apache.org/repos/asf/tuscany/sca-cpp/branches/lightweight-sca@1381061 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/macos/Makefile.am b/macos/Makefile.am
deleted file mode 100644
index d1ddf03..0000000
--- a/macos/Makefile.am
+++ /dev/null
@@ -1,22 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-dist_macos_SCRIPTS = ip-redirect ip-redirect-all
-macosdir=$(prefix)/macos
-
-dist_noinst_SCRIPTS = macos-install
-
diff --git a/macos/ip-redirect b/macos/ip-redirect
deleted file mode 100755
index 965353c..0000000
--- a/macos/ip-redirect
+++ /dev/null
@@ -1,36 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Redirect TCP/IP traffic to a particular IP address from one port to another
-# port. This is useful to handle incoming traffic on a standard reserved port
-# like 80 or 443 for example in an unprivileged user process bound to a non
-# reserved port.
-# Example: ip-redirect 80 8090 10.1.1.1
-
-sport=$1
-tport=$2
-dest=$3
-if [ "$dest" = "" ]; then
- dest="127.0.0.1"
-fi
-
-# Delete existing rule
-sudo /sbin/ipfw list | grep "fwd $dest,$sport tcp from any" | awk '{ printf "sudo ipfw delete %s\n", $1 }' | /bin/sh
-
-# Redirect incoming traffic
-sudo /sbin/ipfw add $sport fwd $dest,$sport tcp from any to $dest $tport
-
diff --git a/macos/ip-redirect-all b/macos/ip-redirect-all
deleted file mode 100755
index c41c55f..0000000
--- a/macos/ip-redirect-all
+++ /dev/null
@@ -1,27 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Redirect TCP/IP traffic to all local addresses from one port to another
-# Example: ip-redirect-all 80 8090
-
-here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here`
-sport=$1
-tport=$2
-
-# Redirect traffic
-/sbin/ifconfig | grep "inet " | awk '{ print $2 }' | xargs -I {} $here/ip-redirect $sport $tport {}
-
diff --git a/macos/macos-install b/macos/macos-install
deleted file mode 100755
index 40eb21c..0000000
--- a/macos/macos-install
+++ /dev/null
@@ -1,301 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Install a complete distribution, the required system tools and libraries, the
-# runtime dependencies and the Tuscany SCA runtime on Mac OS X 10.6.7.
-
-# Display commands as they are executed
-set -x
-
-# Build and install in the current directory
-build=`pwd`
-
-# Install pkg-config
-curl -OL http://pkgconfig.freedesktop.org/releases/pkg-config-0.25.tar.gz
-tar xzf pkg-config-0.25.tar.gz
-cd pkg-config-0.25
-./configure --prefix=$build/pkg-config-0.25-bin
-make
-make install
-if [ "$?" != "0" ]; then
- exit $?
-fi
-cd $build
-
-# Build Libexpat
-curl -OL http://sourceforge.net/projects/expat/files/expat/2.0.1/expat-2.0.1.tar.gz/download
-mv download expat-2.0.1.tar.gz
-tar xzf expat-2.0.1.tar.gz
-cd expat-2.0.1
-./configure --prefix=$build/expat-2.0.1-bin
-make
-make install
-if [ "$?" != "0" ]; then
- exit $?
-fi
-cd $build
-
-# Build Libprce
-curl -OL http://downloads.sourceforge.net/project/pcre/pcre/8.12/pcre-8.12.zip
-unzip pcre-8.12.zip
-cd pcre-8.12
-./configure --prefix=$build/pcre-8.12-bin
-make
-make install
-if [ "$?" != "0" ]; then
- exit $?
-fi
-cd $build
-
-# Build Apache APR and APR util
-curl -OL http://archive.apache.org/dist/apr/apr-1.4.6.tar.gz
-tar xzf apr-1.4.6.tar.gz
-cd apr-1.4.6
-./buildconf
-./configure --prefix=$build/apr-1.4.6-bin
-make
-make install
-if [ "$?" != "0" ]; then
- exit $?
-fi
-cd $build
-
-curl -OL http://archive.apache.org/dist/apr/apr-util-1.4.1.tar.gz
-tar xzf apr-util-1.4.1.tar.gz
-cd apr-util-1.4.1
-curl -OL http://svn.apache.org/repos/asf/tuscany/sca-cpp/trunk/patches/apr-util-1.4.1.patch
-patch -p0 <apr-util-1.4.1.patch
-./buildconf --with-apr=$build/apr-1.4.6
-./configure --with-apr=$build/apr-1.4.6-bin --with-openssl --with-crypto --with-expat=$build/expat-2.0.1-bin --prefix=$build/apr-util-1.4.1-bin
-make
-make install
-if [ "$?" != "0" ]; then
- exit $?
-fi
-cd $build
-
-# Build HTTP server
-curl -OL http://archive.apache.org/dist/httpd/httpd-2.4.2.tar.gz
-tar xzf httpd-2.4.2.tar.gz
-cd httpd-2.4.2
-./configure --enable-ssl --enable-proxy --enable-usertrack --enable-cgi --enable-session-crypto --enable-mods-shared=most --enable-mpms-shared="prefork worker event" --with-mpm=prefork --with-apr=$build/apr-1.4.6-bin --with-apr-util=$build/apr-util-1.4.1-bin --with-pcre=$build/pcre-8.12-bin --with-expat=$build/expat-2.0.1-bin --prefix=$build/httpd-2.4.2-bin
-make
-make install
-if [ "$?" != "0" ]; then
- exit $?
-fi
-cd $build
-
-# Build libevent
-curl -OL http://www.monkey.org/~provos/libevent-2.0.13-stable.tar.gz
-tar xzf libevent-2.0.13-stable.tar.gz
-cd libevent-2.0.13-stable
-./configure --prefix=$build/libevent-2.0.13-stable-bin
-make
-make install
-if [ "$?" != "0" ]; then
- exit $?
-fi
-cd $build
-
-# Build Memcached
-curl -OL http://memcached.googlecode.com/files/memcached-1.4.13.tar.gz
-tar xzf memcached-1.4.13.tar.gz
-cd memcached-1.4.13
-autoreconf --install
-./configure --with-libevent=$build/libevent-2.0.13-stable-bin --prefix=$build/memcached-1.4.13-bin
-make
-make install
-if [ "$?" != "0" ]; then
- exit $?
-fi
-cd $build
-
-# Build Tinycdb
-git clone git://github.com/jsdelfino/tinycdb.git
-cd tinycdb
-make all shared
-make prefix=$build/tinycdb-bin install-all install-sharedlib
-install_name_tool -id $build/tinycdb-bin/lib/libcdb.so.1 $build/tinycdb-bin/lib/libcdb.so.1
-if [ "$?" != "0" ]; then
- exit $?
-fi
-cd $build
-
-# Build Libcurl
-curl -OL http://curl.haxx.se/download/curl-7.24.0.tar.gz
-tar xzf curl-7.24.0.tar.gz
-cd curl-7.24.0
-./configure --enable-threaded-resolver --prefix=$build/curl-7.24.0-bin --without-libidn
-make
-make install
-if [ "$?" != "0" ]; then
- exit $?
-fi
-cd $build
-
-# Build Libxml2
-curl -OL ftp://xmlsoft.org/libxml2/libxml2-sources-2.7.7.tar.gz
-tar xzf libxml2-sources-2.7.7.tar.gz
-cd libxml2-2.7.7
-./configure --prefix=$build/libxml2-2.7.7-bin
-make
-make install
-if [ "$?" != "0" ]; then
- exit $?
-fi
-cd $build
-
-# Build Mozilla Portable Runtime
-curl -OL http://ftp.mozilla.org/pub/mozilla.org/nspr/releases/v4.8.8/src/nspr-4.8.8.tar.gz
-tar xzf nspr-4.8.8.tar.gz
-cd nspr-4.8.8/mozilla/nsprpub
-./configure --prefix=$build/nspr-4.8.8-bin --enable-64bit
-make
-make install
-install_name_tool -id $build/nspr-4.8.8-bin/lib/libnspr4.dylib $build/nspr-4.8.8-bin/lib/libnspr4.dylib
-install_name_tool -id $build/nspr-4.8.8-bin/lib/libplc4.dylib $build/nspr-4.8.8-bin/lib/libplc4.dylib
-install_name_tool -id $build/nspr-4.8.8-bin/lib/libplds4.dylib $build/nspr-4.8.8-bin/lib/libplds4.dylib
-install_name_tool -change @executable_path/libnspr4.dylib $build/nspr-4.8.8-bin/lib/libnspr4.dylib $build/nspr-4.8.8-bin/lib/libplc4.dylib
-install_name_tool -change @executable_path/libnspr4.dylib $build/nspr-4.8.8-bin/lib/libnspr4.dylib $build/nspr-4.8.8-bin/lib/libplds4.dylib
-if [ "$?" != "0" ]; then
- exit $?
-fi
-cd $build
-
-# Build SpiderMonkey
-curl -OL http://ftp.mozilla.org/pub/mozilla.org/js/js185-1.0.0.tar.gz
-tar xzf js185-1.0.0.tar.gz
-cd js-1.8.5/js/src
-./configure --prefix=$build/js-1.8.5-bin --enable-threadsafe --with-system-nspr --with-nspr-prefix=$build/nspr-4.8.8-bin
-make
-make install
-ln -s $build/js-1.8.5-bin/lib/libmozjs185.dylib $build/js-1.8.5-bin/lib/libmozjs.dylib
-if [ "$?" != "0" ]; then
- exit $?
-fi
-cd $build
-
-# Build Libstrophe
-git clone git://github.com/jsdelfino/libstrophe.git
-cd libstrophe
-export ACLOCALFLAGS="-I $build/pkg-config-0.25-bin/share/aclocal"
-./bootstrap.sh
-unset ACLOCALFLAGS
-./configure --prefix=$build/libstrophe-bin --with-expat=$build/expat-2.0.1-bin
-make
-make install
-if [ "$?" != "0" ]; then
- exit $?
-fi
-cd $build
-
-# Build Liboauth
-curl -OL http://liboauth.sourceforge.net/pool/liboauth-0.9.1.tar.gz
-tar xzf liboauth-0.9.1.tar.gz
-cd liboauth-0.9.1
-./configure PKG_CONFIG="$build/pkg-config-0.25-bin/bin/pkg-config" --prefix=$build/liboauth-0.9.1-bin CURL_CFLAGS="-I$build/curl-7.24.0-bin/include" CURL_LIBS="-L$build/curl-7.24.0-bin/lib -lcurl"
-make
-make install
-if [ "$?" != "0" ]; then
- exit $?
-fi
-cd $build
-
-# Build mod_security
-curl -OL http://people.apache.org/~jsdelfino/tuscany/cpp/dependencies/modsecurity-apache_2.6.6.tar.gz
-tar xzf modsecurity-apache_2.6.6.tar.gz
-cd modsecurity-apache_2.6.6
-./configure --prefix=$build/modsecurity-apache-2.6.6-bin --with-apxs=$build/httpd-2.4.2-bin/bin/apxs --with-apr=$build/apr-1.4.6-bin/bin/apr-1-config --with-apu=$build/apr-util-1.4.1-bin/bin/apu-1-config --with-libxml=$build/libxml2-2.7.7-bin --with-curl=$build/curl-7.24.0-bin --with-pcre=$build/pcre-8.12-bin LIBS="-L$build/expat-2.0.1-bin/lib" CFLAGS="-I$build/pcre-8.12-bin/include"
-make
-make install
-if [ "$?" != "0" ]; then
- exit $?
-fi
-cd $build
-curl -OL http://people.apache.org/~jsdelfino/tuscany/cpp/dependencies/modsecurity-crs_2.2.5.tar.gz
-tar xzf modsecurity-crs_2.2.5.tar.gz
-cd modsecurity-crs_2.2.5
-#curl -OL http://svn.apache.org/repos/asf/tuscany/sca-cpp/trunk/patches/modsecurity-crs_2.2.2.patch
-#patch -p0 <modsecurity-crs_2.2.2.patch
-cp -R base_rules $build/modsecurity-apache-2.6.6-bin
-cp -R optional_rules $build/modsecurity-apache-2.6.6-bin
-if [ "$?" != "0" ]; then
- exit $?
-fi
-cd $build
-
-# Build PostgreSQL and PgBouncer
-curl -OL http://ftp.postgresql.org/pub/source/v9.1.2/postgresql-9.1.2.tar.gz
-tar xzf postgresql-9.1.2.tar.gz
-cd postgresql-9.1.2
-./configure --prefix=$build/postgresql-9.1.2-bin --enable-thread-safety
-make
-make install
-if [ "$?" != "0" ]; then
- exit $?
-fi
-cd $build
-curl -OL http://pgfoundry.org/frs/download.php/3197/pgbouncer-1.5.tar.gz
-tar xzf pgbouncer-1.5.tar.gz
-cd pgbouncer-1.5
-./configure --prefix=$build/pgbouncer-1.5-bin --with-libevent=$build/libevent-2.0.13-stable-bin
-make
-cp install-sh doc
-make install
-if [ "$?" != "0" ]; then
- exit $?
-fi
-cd $build
-
-# Build Python
-curl -OL http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
-tar xzf Python-2.7.3.tgz
-cd Python-2.7.3
-./configure --prefix=$build/python-2.7.3-bin --enable-shared --with-system-expat=$build/expat-2.0.1-bin
-make
-make install
-if [ "$?" != "0" ]; then
- exit $?
-fi
-cd $build
-
-# Build Apache Nuvem
-git clone git://git.apache.org/nuvem.git
-if [ "$?" != "0" ]; then
- exit $?
-fi
-cd $build
-
-# Build Tuscany SCA
-git clone git://git.apache.org/tuscany-sca-cpp.git
-cd tuscany-sca-cpp
-./bootstrap
-./configure --prefix=$build/tuscany-sca-cpp-bin --with-curl=$build/curl-7.24.0-bin --with-apr=$build/apr-1.4.6-bin --with-apr-util=$build/apr-util-1.4.1-bin --with-httpd=$build/httpd-2.4.2-bin --with-memcached=$build/memcached-1.4.13-bin --with-tinycdb=$build/tinycdb-bin --with-js-include=$build/js-1.8.5-bin/include/js --with-js-lib=$build/js-1.8.5-bin/lib --enable-threads --enable-python --with-python=$build/python-2.7.3-bin --enable-opencl --with-libxml2=$build/libxml2-2.7.7-bin --enable-chat --with-libstrophe=$build/libstrophe-bin --enable-sqldb --with-pgsql=$build/postgresql-9.1.2-bin --with-pgbouncer=$build/pgbouncer-1.5-bin --enable-oauth --with-liboauth=$build/liboauth-0.9.1-bin --enable-mod-security --with-mod-security=$build/modsecurity-apache-2.6.6-bin
-make
-make install
-if [ "$?" != "0" ]; then
- exit $?
-fi
-cd $build
-
-# Create src archive
-tar czf tuscany-sca-cpp-1.0-src.tar.gz apr-1.4.6 apr-1.4.6.tar.gz apr-1.4.6-bin apr-util-1.4.1 apr-util-1.4.1.tar.gz apr-util-1.4.1-bin autoconf-2.13 autoconf-2.13-bin autoconf-2.13.tar.gz curl-7.24.0 curl-7.24.0-bin curl-7.24.0.tar.gz expat-2.0.1 expat-2.0.1-bin expat-2.0.1.tar.gz httpd-2.4.2 httpd-2.4.2.tar.gz httpd-2.4.2-bin js-1.8.5-bin js-1.8.5 js185-1.0.0.tar.gz libevent-2.0.13-stable libevent-2.0.13-stable-bin libevent-2.0.13-stable.tar.gz liboauth-0.9.1 liboauth-0.9.1-bin liboauth-0.9.1.tar.gz libstrophe libstrophe-bin libxml2-2.7.7 libxml2-2.7.7-bin libxml2-sources-2.7.7.tar.gz memcached-1.4.13 memcached-1.4.13-bin memcached-1.4.13.tar.gz modsecurity-apache_2.6.6 modsecurity-apache-2.6.0-bin modsecurity-apache_2.6.0.tar.gz modsecurity-crs_2.2.5 modsecurity-crs_2.2.5.tar.gz nspr-4.8.8-bin nspr-4.8.8 nspr-4.8.8.tar.gz nuvem pcre-8.12 pcre-8.12-bin pcre-8.12.zip pkg-config-0.25 pkg-config-0.25-bin pkg-config-0.25.tar.gz pgbouncer-1.5 pgbouncer-1.5-bin pgbouncer-1.5.tar.gz postgresql-9.1.2 postgresql-9.1.2-bin postgresql-9.1.2.tar.gz Python-2.7.3 python-2.7.3-bin Python-2.7.3.tgz tinycdb tinycdb-bin tuscany-sca-cpp tuscany-sca-cpp-bin
-
-# Create bin archive
-tar czf tuscany-sca-cpp-1.0.tar.gz apr-1.4.6-bin apr-util-1.4.1-bin curl-7.24.0-bin expat-2.0.1-bin httpd-2.4.2-bin js-1.8.5-bin libevent-2.0.13-stable-bin liboauth-0.9.1-bin libstrophe-bin libxml2-2.7.7-bin memcached-1.4.13-bin modsecurity-apache-2.6.6-bin nspr-4.8.8-bin nuvem/nuvem-parallel pcre-8.12-bin pgbouncer-1.5-bin postgresql-9.1.2-bin python-2.7.3-bin tinycdb-bin tuscany-sca-cpp tuscany-sca-cpp-bin
-
diff --git a/modules/atom/Makefile.am b/modules/atom/Makefile.am
deleted file mode 100644
index 9a628ca..0000000
--- a/modules/atom/Makefile.am
+++ /dev/null
@@ -1,25 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-incl_HEADERS = *.hpp
-incldir = $(prefix)/include/modules/atom
-
-atom_test_SOURCES = atom-test.cpp
-atom_test_LDFLAGS = -lxml2
-
-noinst_PROGRAMS = atom-test
-TESTS = atom-test
diff --git a/modules/atom/atom-test.cpp b/modules/atom/atom-test.cpp
deleted file mode 100644
index 479ed64..0000000
--- a/modules/atom/atom-test.cpp
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-/**
- * Test ATOM data conversion functions.
- */
-
-#include <assert.h>
-#include "stream.hpp"
-#include "string.hpp"
-#include "atom.hpp"
-
-namespace tuscany {
-namespace atom {
-
-ostream* writer(const string& s, ostream* os) {
- (*os) << s;
- return os;
-}
-
-const string itemEntry(
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- "<entry xmlns=\"http://www.w3.org/2005/Atom\">\n"
- " <title type=\"text\">item</title>\n"
- " <id>cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b</id>\n"
- " <author>\n"
- " <email>jane@example.com</email>\n"
- " </author>\n"
- " <updated>Fri Jan 01 08:11:36 PDT 2012</updated>\n"
- " <content type=\"application/xml\">\n"
- " <item>\n"
- " <name>Apple</name>\n"
- " <price>$2.99</price>\n"
- " </item>\n"
- " </content>\n"
- " <link href=\"cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b\"/>\n"
- "</entry>\n");
-
-const string itemTextEntry("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- "<entry xmlns=\"http://www.w3.org/2005/Atom\">\n"
- " <title type=\"text\">item</title>\n"
- " <id>cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b</id>\n"
- " <author>\n"
- " <email>jane@example.com</email>\n"
- " </author>\n"
- " <updated>Fri Jan 01 08:11:36 PDT 2012</updated>\n"
- " <content type=\"text\">Apple</content>\n"
- " <link href=\"cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b\"/>\n"
- "</entry>\n");
-
-const string itemNoContentEntry("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- "<entry xmlns=\"http://www.w3.org/2005/Atom\">\n"
- " <title type=\"text\">item</title>\n"
- " <id>cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b</id>\n"
- " <author>\n"
- " <name>jane</name>\n"
- " </author>\n"
- " <updated>Fri Jan 01 08:11:36 PDT 2012</updated>\n"
- " <link href=\"cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b\"/>\n"
- "</entry>\n");
-
-const string incompleteEntry("<entry xmlns=\"http://www.w3.org/2005/Atom\">\n"
- " <title>item</title>\n"
- " <content type=\"text/xml\">\n"
- " <Item xmlns=\"http://services/\">\n"
- " <name xmlns=\"\">Orange</name>\n"
- " <price xmlns=\"\">3.55</price>\n"
- " </Item>\n"
- " </content>\n"
- "</entry>\n");
-
-const string completedEntry("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- "<entry xmlns=\"http://www.w3.org/2005/Atom\">\n"
- " <title type=\"text\">item</title>\n"
- " <id></id>\n"
- " <content type=\"application/xml\">\n"
- " <Item xmlns=\"http://services/\">\n"
- " <name xmlns=\"\">Orange</name>\n"
- " <price xmlns=\"\">3.55</price>\n"
- " </Item>\n"
- " </content>\n"
- " <link href=\"\"/>\n"
- "</entry>\n");
-
-bool testEntry() {
- {
- const list<value> i = list<value>() + element + value("item")
- + value(list<value>() + element + value("name") + value(string("Apple")))
- + value(list<value>() + element + value("price") + value(string("$2.99")));
- const list<value> a = list<value>() + (list<value>() + element + value("entry")
- + value(list<value>() + element + value("title") + value(string("item")))
- + value(list<value>() + element + value("id") + value(string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b")))
- + value(list<value>() + element + value("author") + value(string("jane@example.com")))
- + value(list<value>() + element + value("updated") + value(string("Fri Jan 01 08:11:36 PDT 2012")))
- + value(list<value>() + element + value("content") + value(i)));
- ostringstream os;
- writeATOMEntry<ostream*>(writer, &os, a);
- assert(str(os) == itemEntry);
- }
- {
- const list<value> a = list<value>() + (list<value>() + element + value("entry")
- + value(list<value>() + element + value("title") + value(string("item")))
- + value(list<value>() + element + value("id") + value(string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b")))
- + value(list<value>() + element + value("author") + value(string("jane@example.com")))
- + value(list<value>() + element + value("updated") + value(string("Fri Jan 01 08:11:36 PDT 2012")))
- + value(list<value>() + element + value("content") + value(string("Apple"))));
- ostringstream os;
- writeATOMEntry<ostream*>(writer, &os, a);
- assert(str(os) == itemTextEntry);
- }
- {
- const list<value> a = list<value>() + (list<value>() + element + value("entry")
- + value(list<value>() + element + value("title") + value(string("item")))
- + value(list<value>() + element + value("id") + value(string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b")))
- + value(list<value>() + element + value("author") + value(string("jane")))
- + value(list<value>() + element + value("updated") + value(string("Fri Jan 01 08:11:36 PDT 2012"))));
- ostringstream os;
- writeATOMEntry<ostream*>(writer, &os, a);
- assert(str(os) == itemNoContentEntry);
- }
- {
- const list<value> a = content(readATOMEntry(mklist(itemEntry)));
- ostringstream os;
- writeATOMEntry<ostream*>(writer, &os, a);
- assert(str(os) == itemEntry);
- }
- {
- const list<value> a = content(readATOMEntry(mklist(itemTextEntry)));
- ostringstream os;
- writeATOMEntry<ostream*>(writer, &os, a);
- assert(str(os) == itemTextEntry);
- }
- {
- const list<value> a = content(readATOMEntry(mklist(itemNoContentEntry)));
- ostringstream os;
- writeATOMEntry<ostream*>(writer, &os, a);
- assert(str(os) == itemNoContentEntry);
- }
- {
- const list<value> a = content(readATOMEntry(mklist(incompleteEntry)));
- ostringstream os;
- writeATOMEntry<ostream*>(writer, &os, a);
- assert(str(os) == completedEntry);
- }
- return true;
-}
-
-const string emptyFeed("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- "<feed xmlns=\"http://www.w3.org/2005/Atom\">\n"
- " <title type=\"text\">Feed</title>\n"
- " <id>1234</id>\n"
- "</feed>\n");
-
-const string itemFeed("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- "<feed xmlns=\"http://www.w3.org/2005/Atom\">\n"
- " <title type=\"text\">Feed</title>\n"
- " <id>1234</id>\n"
- " <entry xmlns=\"http://www.w3.org/2005/Atom\">\n"
- " <title type=\"text\">item</title>\n"
- " <id>cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b</id>\n"
- " <author>\n"
- " <email>jane@example.com</email>\n"
- " </author>\n"
- " <updated>Fri Jan 01 08:11:36 PDT 2012</updated>\n"
- " <content type=\"application/xml\">\n"
- " <item>\n"
- " <name>Apple</name>\n"
- " <price>$2.99</price>\n"
- " </item>\n"
- " </content>\n"
- " <link href=\"cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b\"/>\n"
- " </entry>\n"
- " <entry xmlns=\"http://www.w3.org/2005/Atom\">\n"
- " <title type=\"text\">item</title>\n"
- " <id>cart-53d67a61-aa5e-4e5e-8401-39edeba8b83c</id>\n"
- " <author>\n"
- " <email>jane@example.com</email>\n"
- " </author>\n"
- " <updated>Fri Jan 01 08:11:36 PDT 2012</updated>\n"
- " <content type=\"application/xml\">\n"
- " <item>\n"
- " <name>Orange</name>\n"
- " <price>$3.55</price>\n"
- " </item>\n"
- " </content>\n"
- " <link href=\"cart-53d67a61-aa5e-4e5e-8401-39edeba8b83c\"/>\n"
- " </entry>\n"
- "</feed>\n");
-
-bool testFeed() {
- {
- const list<value> a = list<value>() + (list<value>() + element + value("feed")
- + value(list<value>() + element + value("title") + value(string("Feed")))
- + value(list<value>() + element + value("id") + value(string("1234")))
- + value(list<value>() + element + value("author") + value(string("jane@example.com")))
- + value(list<value>() + element + value("updated") + value(string("Fri Jan 01 08:11:36 PDT 2012"))));
- ostringstream os;
- writeATOMFeed<ostream*>(writer, &os, a);
- assert(str(os) == emptyFeed);
- }
- {
- const list<value> a = content(readATOMFeed(mklist(emptyFeed)));
- ostringstream os;
- writeATOMFeed<ostream*>(writer, &os, a);
- assert(str(os) == emptyFeed);
- }
- {
- const list<value> i1 = list<value>() + element + "item"
- + (list<value>() + element + "name" + "Apple")
- + (list<value>() + element + "price" + "$2.99");
-
- const list<value> i2 = list<value>() + element + "item"
- + (list<value>() + element + "name" + "Orange")
- + (list<value>() + element + "price" + "$3.55");
-
- const list<value> i = list<value>()
- + value(list<value>() + element + value("entry")
- + value(list<value>() + element + value("title") + value(string("item")))
- + value(list<value>() + element + value("id") + value(string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b")))
- + value(list<value>() + element + value("author") + value(string("jane@example.com")))
- + value(list<value>() + element + value("updated") + value(string("Fri Jan 01 08:11:36 PDT 2012")))
- + value(list<value>() + element + value("content") + value(i1)))
- + value(list<value>() + element + value("entry")
- + value(list<value>() + element + value("title") + value(string("item")))
- + value(list<value>() + element + value("id") + value(string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83c")))
- + value(list<value>() + element + value("author") + value(string("jane@example.com")))
- + value(list<value>() + element + value("updated") + value(string("Fri Jan 01 08:11:36 PDT 2012")))
- + value(list<value>() + element + value("content") + value(i2)));
-
- const list<value> a = list<value>() + (append<value>(list<value>() + element + value("feed")
- + value(list<value>() + element + value("title") + value(string("Feed")))
- + value(list<value>() + element + value("id") + value("1234")),
- i));
-
- ostringstream os;
- writeATOMFeed<ostream*>(writer, &os, a);
- assert(str(os) == itemFeed);
- }
- {
- const list<value> a = content(readATOMFeed(mklist(itemFeed)));
- ostringstream os;
- writeATOMFeed<ostream*>(writer, &os, a);
- assert(str(os) == itemFeed);
- }
- {
- const list<value> a = elementsToValues(content(readATOMFeed(mklist(itemFeed))));
- ostringstream os;
- writeATOMFeed<ostream*>(writer, &os, valuesToElements(a));
- assert(str(os) == itemFeed);
- }
- return true;
-}
-
-}
-}
-
-int main() {
- tuscany::gc_scoped_pool p;
- tuscany::cout << "Testing..." << tuscany::endl;
-
- tuscany::atom::testEntry();
- tuscany::atom::testFeed();
-
- tuscany::cout << "OK" << tuscany::endl;
-
- return 0;
-}
diff --git a/modules/atom/atom.hpp b/modules/atom/atom.hpp
deleted file mode 100644
index 5de3894..0000000
--- a/modules/atom/atom.hpp
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef tuscany_atom_hpp
-#define tuscany_atom_hpp
-
-/**
- * ATOM data conversion functions.
- */
-
-#include "string.hpp"
-#include "list.hpp"
-#include "value.hpp"
-#include "monad.hpp"
-#include "xml.hpp"
-
-namespace tuscany {
-namespace atom {
-
-/**
- * Tags used to tag feed and entry elements.
- */
-const value feed("feed");
-const value entry("entry");
-
-/**
- * Convert a list of elements to a list of element values representing an ATOM entry.
- */
-const list<value> entryElementValues(const list<value>& e) {
- const list<value> lt = filter<value>(selector(mklist<value>(element, "title")), e);
- const list<value> t = list<value>() + element + value("title") + (isNil(lt)? value(emptyString) : elementValue(car(lt)));
-
- const list<value> li = filter<value>(selector(mklist<value>(element, "id")), e);
- const list<value> i = list<value>() + element + value("id") + (isNil(li)? value(emptyString) : elementValue(car(li)));
-
- const list<value> la = filter<value>(selector(mklist<value>(element, "author")), e);
- const list<value> lan = isNil(la)? list<value>() : filter<value>(selector(mklist<value>(element, "name")), car(la));
- const list<value> lae = isNil(la)? list<value>() : filter<value>(selector(mklist<value>(element, "email")), car(la));
- const list<value> laa = isNil(lan)? lae : lan;
- const list<value> a = isNil(laa)? list<value>() : mklist<value>(list<value>() + element + value("author") + elementValue(car(laa)));
-
- const list<value> lu = filter<value>(selector(mklist<value>(element, "updated")), e);
- const list<value> u = isNil(lu)? list<value>() : mklist<value>(list<value>() + element + value("updated") + elementValue(car(lu)));
-
- const list<value> lc = filter<value>(selector(mklist<value>(element, "content")), e);
- const list<value> c = isNil(lc)? list<value>() : mklist<value>(list<value>() + element + value("content") + elementValue(car(lc)));
-
- return append<value>(append<value>(append<value>(list<value>() + element + entry + value(t) + value(i), a), u), c);
-}
-
-/**
- * Convert a list of elements to a list of element values representing ATOM entries.
- */
-const list<value> entriesElementValues(const list<value>& e) {
- if (isNil(e))
- return e;
- return cons<value>(entryElementValues(car(e)), entriesElementValues(cdr(e)));
-}
-
-/**
- * Return true if a list of strings contains an ATOM feed.
- */
-const bool isATOMFeed(const list<string>& ls) {
- if (!isXML(ls))
- return false;
- return contains(car(ls), "<feed") && contains(car(ls), "=\"http://www.w3.org/2005/Atom\"");
-}
-
-/**
- * Return true if a list of strings contains an ATOM entry.
- */
-const bool isATOMEntry(const list<string>& ls) {
- if (!isXML(ls))
- return false;
- return contains(car(ls), "<entry") && !contains(car(ls), "<feed") && contains(car(ls), "=\"http://www.w3.org/2005/Atom\"");
-}
-
-/**
- * Convert a list of strings to a list of values representing an ATOM entry.
- */
-const failable<list<value> > readATOMEntry(const list<string>& ilist) {
- const list<value> e = readXML(ilist);
- if (isNil(e))
- return mkfailure<list<value> >("Empty entry");
- return mklist<value>(entryElementValues(car(e)));
-}
-
-/**
- * Convert a list of strings to a list of values representing an ATOM feed.
- */
-const failable<list<value> > readATOMFeed(const list<string>& ilist) {
- const list<value> f = readXML(ilist);
- if (isNil(f))
- return mkfailure<list<value> >("Empty feed");
- const list<value> t = filter<value>(selector(mklist<value>(element, "title")), car(f));
- const list<value> i = filter<value>(selector(mklist<value>(element, "id")), car(f));
- const list<value> e = filter<value>(selector(mklist<value>(element, entry)), car(f));
- return mklist<value>(append<value>(list<value>() + element + feed
- + value(list<value>() + element + value("title") + elementValue(car(t)))
- + value(list<value>() + element + value("id") + elementValue(car(i))),
- entriesElementValues(e)));
-}
-
-/**
- * Returns children of an ATOM content element.
- */
-struct filterContentElementChildren {
- const value type;
- filterContentElementChildren() : type("type") {
- }
- const bool operator()(const value& v) const {
- return !(isAttribute(v) && attributeName((list<value>)v) == type);
- }
-};
-
-const list<value> contentElementChildren(const value& content) {
- return filter<value>(filterContentElementChildren(), elementChildren(content));
-}
-
-/**
- * Convert a list of element values representing an ATOM entry to a list of elements.
- */
-const list<value> entryElement(const list<value>& l) {
- const value title = elementChild("title", l);
- const value id = elementChild("id", l);
- const value author = elementChild("author", l);
- const bool email = isNil(author)? false : contains(elementValue(author), "@");
- const value updated = elementChild("updated", l);
- const value content = elementChild("content", l);
- const bool text = isNil(content)? false : elementHasValue(content);
- return list<value>()
- + element + entry + (list<value>() + attribute + "xmlns" + "http://www.w3.org/2005/Atom")
- + (list<value>() + element + "title" + (list<value>() + attribute + "type" + "text") + elementValue(title))
- + (list<value>() + element + "id" + elementValue(id))
- + (isNil(author)? list<value>() : (list<value>() + element + "author" +
- (email? (list<value>() + element + "email" + elementValue(author)) : (list<value>() + element + "name" + elementValue(author)))))
- + (isNil(updated)? list<value>() : (list<value>() + element + "updated" + elementValue(updated)))
- + (isNil(content)?
- list<value>() :
- append<value>(list<value>() + element + "content" + (list<value>() + attribute + "type" + (text? "text" : "application/xml")),
- text? mklist<value>(elementValue(content)) : contentElementChildren(content)))
- + (list<value>() + element + "link" + (list<value>() + attribute + "href" + elementValue(id)));
-}
-
-/**
- * Convert a list of element values representing ATOM entries to a list of elements.
- */
-const list<value> entriesElements(const list<value>& l) {
- if (isNil(l))
- return l;
- return cons<value>(entryElement(car(l)), entriesElements(cdr(l)));
-}
-
-/**
- * Convert a list of element values representing an ATOM entry to an ATOM entry.
- */
-template<typename R> const failable<R> writeATOMEntry(const lambda<R(const string&, const R)>& reduce, const R& initial, const list<value>& ll) {
- const list<value> l = isNil(ll)? ll : (list<value>)car(ll);
- return writeXML<R>(reduce, initial, mklist<value>(entryElement(l)));
-}
-
-const failable<list<string> > writeATOMEntry(const list<value>& l) {
- const failable<list<string> > ls = writeATOMEntry<list<string> >(rcons<string>, list<string>(), l);
- if (!hasContent(ls))
- return ls;
- return reverse(list<string>(content(ls)));
-}
-
-/**
- * Convert a list of element values representing an ATOM feed to an ATOM feed.
- */
-template<typename R> const failable<R> writeATOMFeed(const lambda<R(const string&, const R)>& reduce, const R& initial, const list<value>& ll) {
- const list<value> l = isNil(ll)? ll : (list<value>)car(ll);
- const list<value> lt = filter<value>(selector(mklist<value>(element, "title")), l);
- const value t = isNil(lt)? value(emptyString) : elementValue(car(lt));
- const list<value> li = filter<value>(selector(mklist<value>(element, "id")), l);
- const value i = isNil(li)? value(emptyString) : elementValue(car(li));
- const list<value> f = list<value>()
- + element + feed + (list<value>() + attribute + "xmlns" + "http://www.w3.org/2005/Atom")
- + (list<value>() + element + "title" + (list<value>() + attribute + "type" + "text") + t)
- + (list<value>() + element + "id" + i);
-
- // Write ATOM entries
- const list<value> le = filter<value>(selector(mklist<value>(element, entry)), l);
- if (isNil(le))
- return writeXML<R>(reduce, initial, mklist<value>(f));
-
- // Write a single ATOM entry element with a list of values
- if (!isNil(le) && !isNil(car(le)) && isList(car<value>(caddr<value>(car(le))))) {
- const list<value> fe = append(f, entriesElements(caddr<value>(car(le))));
- return writeXML<R>(reduce, initial, mklist<value>(fe));
- }
-
- // Write separate ATOM entry elements
- const list<value> fe = append(f, entriesElements(le));
- return writeXML<R>(reduce, initial, mklist<value>(fe));
-}
-
-/**
- * Convert a list of element values representing an ATOM feed to a list of strings.
- */
-const failable<list<string> > writeATOMFeed(const list<value>& l) {
- const failable<list<string> > ls = writeATOMFeed<list<string>>(rcons<string>, list<string>(), l);
- if (!hasContent(ls))
- return ls;
- return reverse(list<string>(content(ls)));
-}
-
-}
-}
-
-#endif /* tuscany_atom_hpp */
diff --git a/modules/json/Makefile.am b/modules/json/Makefile.am
deleted file mode 100644
index 7b5b387..0000000
--- a/modules/json/Makefile.am
+++ /dev/null
@@ -1,25 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-incl_HEADERS = *.hpp
-incldir = $(prefix)/include/modules/json
-
-json_test_SOURCES = json-test.cpp
-json_test_LDFLAGS = -lmozjs
-
-noinst_PROGRAMS = json-test
-TESTS = json-test
diff --git a/modules/json/json-test.cpp b/modules/json/json-test.cpp
deleted file mode 100644
index 945b6c0..0000000
--- a/modules/json/json-test.cpp
+++ /dev/null
@@ -1,336 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-/**
- * Test JSON data conversion functions.
- */
-
-#include <assert.h>
-#include "stream.hpp"
-#include "string.hpp"
-#include "json.hpp"
-#include "perf.hpp"
-
-namespace tuscany {
-namespace json {
-
-ostream* jsonWriter(const string& s, ostream* os) {
- (*os) << s;
- return os;
-}
-
-const string jscustomer("{\n"
- " \"customer\": {\n"
- " \"@name\": \"jdoe\",\n"
- " \"address\": {\n"
- " \"@city\": \"san francisco\",\n"
- " \"@state\": \"ca\"\n"
- " },\n"
- " \"account\": {\n"
- " \"id\": \"1234\",\n"
- " \"@balance\": 1000\n"
- " }\n"
- " }\n"
- "}");
-
-const string jsphones("{\n"
- " \"phones\": [\n"
- " \"408-1234\",\n"
- " \"650-1234\"\n"
- " ],\n"
- " \"lastName\": \"test\\u0009tab\",\n"
- " \"@firstName\": \"test1\"\n"
- "}");
-
-const string jsecho("{\n"
- " \"ns1:echoString\": {\n"
- " \"@xmlns:ns1\": \"http://ws.apache.org/axis2/services/echo\",\n"
- " \"text\": \"Hello World!\"\n"
- " }\n"
- "}");
-
-const string jsarray("{\n"
- " \"fruit\": [\n"
- " \"Apple\",\n"
- " \"Orange\"\n"
- " ]\n"
- "}");
-
-bool testJSON() {
- gc_scoped_pool pool;
- const js::JSContext cx;
-
- {
- const list<value> ad = mklist<value>(mklist<value>(attribute, "city", string("san francisco")), mklist<value>(attribute, "state", string("ca")));
- const list<value> ac = mklist<value>(mklist<value>(element, "id", string("1234")), mklist<value>(attribute, "balance", 1000));
- const list<value> cr = mklist<value>(mklist<value> (attribute, "name", string("jdoe")), cons<value>(element, cons<value>("address", ad)), cons<value>(element, cons<value>("account", ac)));
- const list<value> c = mklist<value>(cons<value>(element, cons<value>("customer", cr)));
-
- ostringstream os;
- writeJSON<ostream*>(jsonWriter, &os, c, cx);
- assert(str(os) == jscustomer);
- }
- {
- const list<value> phones = mklist<value> (string("408-1234"), string("650-1234"));
- const list<value> l = mklist<value> (mklist<value> (element, "phones", phones), mklist<value> (element, "lastName", string("test\ttab")), mklist<value> (attribute, "firstName", string("test1")));
-
- ostringstream os;
- writeJSON<ostream*>(jsonWriter, &os, l, cx);
- assert(str(os) == jsphones);
-
- istringstream is(str(os));
- const list<string> il = streamList(is);
- const list<value> r = content(readJSON(il, cx));
- assert(r == l);
-
- ostringstream wos;
- write(content(writeJSON(r, cx)), wos);
- assert(str(wos) == str(os));
- }
- {
- const list<value> l = mklist<value>(list<value>() + "ns1:echoString" + (list<value>() + "@xmlns:ns1" + string("http://ws.apache.org/axis2/services/echo")) + (list<value>() + "text" + string("Hello World!")));
- ostringstream wos;
- write(content(writeJSON(valuesToElements(l), cx)), wos);
- assert(str(wos) == jsecho);
-
- istringstream is(str(wos));
- const list<string> il = streamList(is);
- const list<value> r = elementsToValues(content(readJSON(il, cx)));
- assert(r == l);
- }
- {
- const list<value> l = mklist<value>((list<value>() + "fruit" + string("Apple")), (list<value>() + "fruit" + string("Orange")));
- ostringstream wos;
- write(content(writeJSON(valuesToElements(l), cx)), wos);
- assert(str(wos) == jsarray);
-
- istringstream is(str(wos));
- const list<string> il = streamList(is);
- const list<value> r = elementsToValues(content(readJSON(il, cx)));
- const list<value> l2 = mklist<value>(list<value>() + "fruit" + (list<value>() + string("Apple") + string("Orange")));
- assert(r == l2);
- }
- return true;
-}
-
-const string jsitem("{\n"
- " \"id\": 3,\n"
- " \"result\": [\n"
- " {\n"
- " \"price\": \"$2.99\",\n"
- " \"name\": \"Apple\"\n"
- " },\n"
- " {\n"
- " \"price\": \"$3.55\",\n"
- " \"name\": \"Orange\"\n"
- " },\n"
- " {\n"
- " \"price\": \"$1.55\",\n"
- " \"name\": \"Pear\"\n"
- " }\n"
- " ]\n"
- "}");
-
-const string jsresult("{\n"
- " \"id\": 1,\n"
- " \"result\": [\n"
- " \"Service.get\",\n"
- " \"Service.getTotal\"\n"
- " ]\n"
- "}");
-
-const string jsfeed("{\n"
- " \"id\": 1,\n"
- " \"result\": [\n"
- " \"Sample Feed\",\n"
- " \"123456789\",\n"
- " [\n"
- " \"Item\",\n"
- " \"111\",\n"
- " {\n"
- " \"name\": \"Apple\",\n"
- " \"currencyCode\": \"USD\",\n"
- " \"currencySymbol\": \"$\",\n"
- " \"price\": 2.99\n"
- " }\n"
- " ],\n"
- " [\n"
- " \"Item\",\n"
- " \"222\",\n"
- " {\n"
- " \"name\": \"Orange\",\n"
- " \"currencyCode\": \"USD\",\n"
- " \"currencySymbol\": \"$\",\n"
- " \"price\": 3.55\n"
- " }\n"
- " ],\n"
- " [\n"
- " \"Item\",\n"
- " \"333\",\n"
- " {\n"
- " \"name\": \"Pear\",\n"
- " \"currencyCode\": \"USD\",\n"
- " \"currencySymbol\": \"$\",\n"
- " \"price\": 1.55\n"
- " }\n"
- " ]\n"
- " ]\n"
- "}");
-
-const string jsechoreq("{\n"
- " \"id\": 1,\n"
- " \"method\": \"echo\",\n"
- " \"params\": [\n"
- " {\n"
- " \"ns1:echoString\": {\n"
- " \"@xmlns:ns1\": \"http://ws.apache.org/axis2/services/echo\",\n"
- " \"text\": \"Hello World!\"\n"
- " }\n"
- " }\n"
- " ]\n"
- "}");
-
-const string jsechores("{\n"
- " \"id\": 1,\n"
- " \"result\": {\n"
- " \"ns1:echoString\": {\n"
- " \"@xmlns:ns1\": \"http://ws.apache.org/axis2/c/samples\",\n"
- " \"text\": \"Hello World!\"\n"
- " }\n"
- " }\n"
- "}");
-
-bool testJSONRPC() {
- gc_scoped_pool pool;
- js::JSContext cx;
- {
- const string lm("{\"id\": 1, \"method\": \"test\", \"params\": []}");
- const list<value> e = content(readJSON(mklist(lm), cx));
- const list<value> v = elementsToValues(e);
- assert(assoc<value>("id", v) == mklist<value>("id", 1));
- assert(assoc<value>("method", v) == mklist<value>("method", string("test")));
- assert(assoc<value>("params", v) == mklist<value>("params", list<value>()));
- }
- {
- const string i2 = "{\"id\": 3,\"result\": {\"0\": {\"price\": \"$2.99\",\"name\": \"Apple\"},\"1\": {\"price\": \"$3.55\",\"name\": \"Orange\"},\"2\": {\"price\": \"$1.55\",\"name\": \"Pear\"}}}";
- const list<value> e = content(readJSON(mklist(jsitem), cx));
- const list<value> e2 = content(readJSON(mklist(i2), cx));
- assert(e == e2);
- }
- {
- const list<value> e = content(readJSON(mklist(jsitem), cx));
- ostringstream os;
- write(content(writeJSON(e, cx)), os);
- assert(str(os) == jsitem);
- const list<value> v = elementsToValues(e);
- const list<value> r = valuesToElements(v);
- assert(r == e);
- }
- {
- const list<value> r = mklist<value>(mklist<value>("id", 1), mklist<value>("result", mklist<value>(string("Service.get"), string("Service.getTotal"))));
- const list<value> e = valuesToElements(r);
- ostringstream os;
- write(content(writeJSON(e, cx)), os);
- assert(str(os) == jsresult);
- }
- {
- const list<value> r = content(readJSON(mklist(jsfeed), cx));
- const list<value> v = elementsToValues(r);
- const list<value> e = valuesToElements(v);
- ostringstream os;
- write(content(writeJSON(e, cx)), os);
- assert(str(os) == jsfeed);
- }
- {
- const list<value> arg = mklist<value>(list<value>() + "ns1:echoString" + (list<value>() + "@xmlns:ns1" + string("http://ws.apache.org/axis2/services/echo")) + (list<value>() + "text" + string("Hello World!")));
- const failable<list<string> > r = jsonRequest(1, "echo", mklist<value>(arg), cx);
- ostringstream os;
- write(content(r), os);
- assert(str(os) == jsechoreq);
-
- istringstream is(str(os));
- const list<string> il = streamList(is);
- const list<value> ir = elementsToValues(content(readJSON(il, cx)));
- assert(car<value>(cadr<value>(caddr<value>(ir))) == arg);
- }
- {
- const list<value> res = mklist<value>(list<value>() + "ns1:echoString" + (list<value>() + "@xmlns:ns1" + string("http://ws.apache.org/axis2/c/samples")) + (list<value>() + "text" + string("Hello World!")));
- const failable<list<string> > r = jsonResult(1, res, cx);
- ostringstream os;
- write(content(r), os);
- assert(str(os) == jsechores);
-
- istringstream is(str(os));
- const list<string> il = streamList(is);
- const list<value> ir = elementsToValues(content(readJSON(il, cx)));
- assert(cdr<value>(cadr<value>(ir)) == res);
- }
- return true;
-}
-
-struct testReadWrite {
- testReadWrite() {
- }
- const bool operator()() const {
- gc_scoped_pool pool;
- js::JSContext cx;
-
- const list<value> ad = mklist<value>(mklist<value>(attribute, "city", string("san francisco")), mklist<value>(attribute, "state", string("ca")));
- const list<value> ac = mklist<value>(mklist<value>(element, "id", string("1234")), mklist<value>(attribute, "balance", 1000));
- const list<value> cr = mklist<value>(mklist<value> (attribute, "name", string("jdoe")), cons<value>(element, cons<value>("address", ad)), cons<value>(element, cons<value>("account", ac)));
- const list<value> c = mklist<value>(cons<value>(element, cons<value>("customer", cr)));
-
- ostringstream os;
- writeJSON<ostream*>(jsonWriter, &os, c, cx);
- assert(str(os) == jscustomer);
-
- istringstream is(jscustomer);
- const list<string> il = streamList(is);
- const list<value> r = content(readJSON(il, cx));
- assert(r == c);
- return true;
- }
-};
-
-bool testJSONPerf() {
- gc_scoped_pool pool;
-
- const lambda<bool()> rwl = lambda<bool()>(testReadWrite());
- cout << "JSON read + write test " << time(rwl, 5, 200) << " ms" << endl;
-
- return true;
-}
-
-}
-}
-
-int main() {
- tuscany::gc_scoped_pool p;
- tuscany::cout << "Testing..." << tuscany::endl;
-
- tuscany::json::testJSON();
- tuscany::json::testJSONRPC();
- tuscany::json::testJSONPerf();
-
- tuscany::cout << "OK" << tuscany::endl;
-
- return 0;
-}
diff --git a/modules/json/json.hpp b/modules/json/json.hpp
deleted file mode 100644
index 85579c1..0000000
--- a/modules/json/json.hpp
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef tuscany_json_hpp
-#define tuscany_json_hpp
-
-/**
- * JSON data conversion functions.
- */
-
-#include "string.hpp"
-#include "list.hpp"
-#include "value.hpp"
-#include "element.hpp"
-#include "monad.hpp"
-#include "../js/eval.hpp"
-
-namespace tuscany {
-namespace json {
-
-/**
- * Return true if a list of strings contains a JSON document.
- */
-const bool isJSON(const list<string>& ls) {
- if (isNil(ls))
- return false;
- const string s = substr(car(ls), 0, 1);
- return s == "[" || s == "{";
-}
-
-/**
- * Consumes JSON strings and populates a JS object.
- */
-failable<bool> consume(JSONParser* parser, const list<string>& ilist, const js::JSContext& cx) {
- if (isNil(ilist))
- return true;
- JSString* jstr = JS_NewStringCopyZ(cx, c_str(car(ilist)));
- if(!JS_ConsumeJSONText(cx, parser, JS_GetStringCharsZ(cx, jstr), (uint32)JS_GetStringLength(jstr)))
- return mkfailure<bool>("JS_ConsumeJSONText failed");
- return consume(parser, cdr(ilist), cx);
-}
-
-/**
- * Convert a list of strings representing a JSON document to a list of values.
- */
-const failable<list<value> > readJSON(const list<string>& ilist, const js::JSContext& cx) {
- jsval val;
- JSONParser* parser = JS_BeginJSONParse(cx, &val);
- if(parser == NULL)
- return mkfailure<list<value> >("JS_BeginJSONParse failed");
-
- const failable<bool> consumed = consume(parser, ilist, cx);
-
- if(!JS_FinishJSONParse(cx, parser, JSVAL_NULL))
- return mkfailure<list<value> >("JS_FinishJSONParse failed");
- if(!hasContent(consumed))
- return mkfailure<list<value> >(consumed);
-
- return list<value>(js::jsValToValue(val, cx));
-}
-
-/**
- * Context passed to the JSON write callback function.
- */
-template<typename R> class WriteContext {
-public:
- WriteContext(const lambda<R(const string&, const R)>& reduce, const R& accum, const js::JSContext& cx) : cx(cx), reduce(reduce), accum(accum) {
- }
- const js::JSContext& cx;
- const lambda<R(const string&, const R)> reduce;
- R accum;
-};
-
-/**
- * Called by JS_Stringify to write JSON out.
- */
-template<typename R> JSBool writeCallback(const jschar *buf, uint32 len, void *data) {
- WriteContext<R>& wcx = *(static_cast<WriteContext<R>*> (data));
- JSString* jstr = JS_NewUCStringCopyN(wcx.cx, buf, len);
- char* cstr = JS_EncodeString(wcx.cx, jstr);
- const string str(cstr, JS_GetStringLength(jstr));
- JS_free(wcx.cx, cstr);
- wcx.accum = wcx.reduce(str, wcx.accum);
- return JS_TRUE;
-}
-
-/**
- * Convert a list of values to a JSON document.
- */
-template<typename R> const failable<R> writeJSON(const lambda<R(const string&, const R)>& reduce, const R& initial, const list<value>& l, const js::JSContext& cx) {
- jsval val;
- if (js::isJSArray(l))
- val = OBJECT_TO_JSVAL(valuesToJSElements(JS_NewArrayObject(cx, 0, NULL), l, 0, cx));
- else
- val = OBJECT_TO_JSVAL(valuesToJSProperties(JS_NewObject(cx, NULL, NULL, NULL), l, cx));
-
- WriteContext<R> wcx(reduce, initial, cx);
- if (!JS_Stringify(cx, &val, NULL, INT_TO_JSVAL(1), writeCallback<R>, &wcx))
- return mkfailure<R>("JS_Stringify failed");
- return wcx.accum;
-}
-
-/**
- * Convert a list of values to a list of strings representing a JSON document.
- */
-const failable<list<string> > writeJSON(const list<value>& l, const js::JSContext& cx) {
- const failable<list<string> > ls = writeJSON<list<string>>(rcons<string>, list<string>(), valuesToElements(elementsToValues(l)), cx);
- if (!hasContent(ls))
- return ls;
- return reverse(list<string>(content(ls)));
-}
-
-/**
- * Convert a list of function + params to a JSON-RPC request.
- */
-const failable<list<string> > jsonRequest(const value& id, const value& func, const value& params, js::JSContext& cx) {
- const list<value> r = mklist<value>(mklist<value>("id", id), mklist<value>("method", string(func)), mklist<value>("params", params));
- return writeJSON(valuesToElements(r), cx);
-}
-
-/**
- * Convert a value to a JSON-RPC result.
- */
-const failable<list<string> > jsonResult(const value& id, const value& val, js::JSContext& cx) {
- return writeJSON(valuesToElements(mklist<value>(mklist<value>("id", id), mklist<value>("result", val))), cx);
-}
-
-/**
- * Convert a JSON-RPC result to a value.
- */
-const failable<value> jsonResultValue(const list<string>& s, js::JSContext& cx) {
- const failable<list<value> > jsres = json::readJSON(s, cx);
- if (!hasContent(jsres))
- return mkfailure<value>(jsres);
- const list<value> rval(cadr<value>(elementsToValues(content(jsres))));
- const value val = cadr(rval);
- if (isList(val) && !js::isJSArray(val))
- return value(mklist<value>(val));
- return val;
-}
-
-/**
- * Convert a JSON payload to a list of values.
- */
-const list<value> jsonValues(const list<value>& e) {
- return elementsToValues(e);
-}
-
-/**
- * Return a portable function name from a JSON-RPC function name.
- * Strip the ".", "system." and "Service." prefixes added by some JSON-RPC clients.
- */
-const string funcName(const string& f) {
- if (length(f) > 1 && find(f, ".", 0) == 0)
- return c_str(f) + 1;
- if (length(f) > 7 && find(f, "system.", 0) == 0)
- return c_str(f) + 7;
- if (length(f) > 8 && find(f, "Service.", 0) == 0)
- return c_str(f) + 8;
- return f;
-}
-
-/**
- * Returns a list of param values other than the id and method args from a list
- * of key value pairs.
- */
-const list<value> queryParams(const list<list<value> >& a) {
- if (isNil(a))
- return list<value>();
- const list<value> p = car(a);
- if (car(p) == value("id") || car(p) == value("method"))
- return queryParams(cdr(a));
- return cons(cadr(p), queryParams(cdr(a)));
-}
-
-}
-}
-
-#endif /* tuscany_json_hpp */
diff --git a/modules/oauth/Makefile.am b/modules/oauth/Makefile.am
deleted file mode 100644
index 9e8eb5a..0000000
--- a/modules/oauth/Makefile.am
+++ /dev/null
@@ -1,42 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-if WANT_OAUTH
-
-INCLUDES = -I${HTTPD_INCLUDE} -I${LIBOAUTH_INCLUDE}
-
-dist_mod_SCRIPTS = oauth-conf oauth12-conf oauth-memcached-conf oauth1-appkey-conf oauth2-appkey-conf
-moddir=$(prefix)/modules/oauth
-
-mod_LTLIBRARIES = libmod_tuscany_oauth1.la libmod_tuscany_oauth2.la
-noinst_DATA = libmod_tuscany_oauth1${libsuffix} libmod_tuscany_oauth2${libsuffix}
-
-libmod_tuscany_oauth1_la_SOURCES = mod-oauth1.cpp
-libmod_tuscany_oauth1_la_LDFLAGS = -L${LIBOAUTH_LIB} -R${LIBOAUTH_LIB} -loauth -lxml2 -lcurl -lmozjs
-libmod_tuscany_oauth1${libsuffix}:
- ln -s .libs/libmod_tuscany_oauth1${libsuffix}
-
-libmod_tuscany_oauth2_la_SOURCES = mod-oauth2.cpp
-libmod_tuscany_oauth2_la_LDFLAGS = -lxml2 -lcurl -lmozjs
-libmod_tuscany_oauth2${libsuffix}:
- ln -s .libs/libmod_tuscany_oauth2${libsuffix}
-
-EXTRA_DIST = oauth.composite user-info.scm htdocs/index.html htdocs/login/index.html htdocs/logout/index.html htdocs/public/index.html
-
-dist_noinst_SCRIPTS = start-test stop-test
-
-endif
diff --git a/modules/oauth/htdocs/index.html b/modules/oauth/htdocs/index.html
deleted file mode 100644
index 006aade..0000000
--- a/modules/oauth/htdocs/index.html
+++ /dev/null
@@ -1,67 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-
-<html>
-<head>
-<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0"/>
-<meta name="apple-mobile-web-app-capable" content="yes"/>
-<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
-<link rel="stylesheet" type="text/css" href="/ui-min.css"/>
-
-<script type="text/javascript" src="/all-min.js"></script>
-<script type="text/javascript">
-var protected = sca.component("Protected");
-var userInfo = sca.defun(sca.reference(protected, "userInfo"), "getuser", "getemail", "getnickname", "getfullname", "getfirstname", "getlastname", "getrealm");
-var user = userInfo.getuser();
-var email = userInfo.apply("getemail");
-var nickname = userInfo.apply("getnickname");
-var fullname = userInfo.apply("getfullname");
-var firstname = userInfo.apply("getfirstname");
-var lastname = userInfo.apply("getlastname");
-var realm = userInfo.apply("getrealm");
-</script>
-</head>
-
-<body>
-<h1>Protected area - It works!</h1>
-<p>The following info is returned by a JSONRPC service:</p>
-<div>User: <span id="user"></span></div>
-<div>Email: <span id="email"></span></div>
-<div>Nickname: <span id="nickname"></span></div>
-<div>Fullname: <span id="fullname"></span></div>
-<div>Firstname: <span id="firstname"></span></div>
-<div>Lastname: <span id="lastname"></span></div>
-<div>Realm: <span id="realm"></span></div>
-
-<script type="text/javascript">
-document.getElementById('user').innerHTML=user;
-document.getElementById('email').innerHTML=email;
-document.getElementById('nickname').innerHTML=nickname;
-document.getElementById('fullname').innerHTML=fullname;
-document.getElementById('firstname').innerHTML=firstname;
-document.getElementById('lastname').innerHTML=lastname;
-document.getElementById('realm').innerHTML=realm;
-</script>
-
-<p><a href="info">User info</a></p>
-<p><a href="login">Sign in</a></p>
-<p><a href="logout">Sign out</a></p>
-<p><a href="public">Public area</a></p>
-</body>
-</html>
diff --git a/modules/oauth/htdocs/login/index.html b/modules/oauth/htdocs/login/index.html
deleted file mode 100644
index 0740afd..0000000
--- a/modules/oauth/htdocs/login/index.html
+++ /dev/null
@@ -1,141 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-
-<html>
-<head>
-<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0"/>
-<meta name="apple-mobile-web-app-capable" content="yes"/>
-<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
-<link rel="stylesheet" type="text/css" href="/ui-min.css"/>
-<title>Sign in</title>
-</head>
-<body>
-<h1>Sign in with an OAuth provider</h1>
-<br/>
-
-<script type="text/javascript">
-function queryParams() {
- qp = new Array();
- qs = window.location.search.substring(1).split('&');
- for (i = 0; i < qs.length; i++) {
- e = qs[i].indexOf('=');
- if (e > 0)
- qp[qs[i].substring(0, e)] = unescape(qs[i].substring(e + 1));
- }
- return qp;
-}
-
-function oauthReferrer() {
- r = queryParams()['openauth_referrer'];
- if (typeof(r) == 'undefined')
- return '/';
- q = r.indexOf('?');
- if (q > 0)
- return r.substring(0, q);
- return r;
-}
-
-if (typeof(oauthReferrer()) == 'undefined') {
- document.location = '/';
-}
-
-function clearauthcookie() {
- document.cookie = 'TuscanyOpenAuth=; expires=' + new Date(1970,01,01).toGMTString() + '; domain=.' + domainname(window.location.hostname) + '; path=/';
- document.cookie = 'TuscanyOAuth1=; expires=' + new Date(1970,01,01).toGMTString() + '; domain=.' + domainname(window.location.hostname) + '; path=/';
- document.cookie = 'TuscanyOAuth2=; expires=' + new Date(1970,01,01).toGMTString() + '; domain=.' + domainname(window.location.hostname) + '; path=/';
- document.cookie = 'TuscanyOpenIDAuth=; expires=' + new Date(1970,01,01).toGMTString() + '; domain=.' + domainname(window.location.hostname) + '; path=/';
- return true;
-}
-
-function submitSignin2(w) {
- parms = w();
- clearauthcookie();
- document.signin2.oauth2_authorize.value = parms[0];
- document.signin2.oauth2_access_token.value = parms[1];
- document.signin2.oauth2_client_id.value = parms[2];
- document.signin2.oauth2_info.value = parms[3];
- document.signin2.oauth2_scope.value = parms[4];
- document.signin2.oauth2_display.value = parms[5];
- document.signin2.openauth_referrer.value = oauthReferrer();
- document.signin2.action = '/oauth2/authorize/';
- document.signin2.submit();
-}
-
-function withFacebook() {
- var parms = ['https://graph.facebook.com/oauth/authorize', 'https://graph.facebook.com/oauth/access_token', 'facebook.com', 'https://graph.facebook.com/me', 'email', 'page'];
- return parms;
-}
-
-function withGithub() {
- var parms = ['https://github.com/login/oauth/authorize', 'https://github.com/login/oauth/access_token', 'github.com', 'https://github.com/api/v2/json/user/show', 'email', ''];
- return parms;
-}
-
-function submitSignin1(w) {
- parms = w();
- clearauthcookie();
- document.signin1.oauth1_request_token.value = parms[0];
- document.signin1.oauth1_authorize.value = parms[1];
- document.signin1.oauth1_access_token.value = parms[2];
- document.signin1.oauth1_client_id.value = parms[3];
- document.signin1.oauth1_info.value = parms[4];
- document.signin1.openauth_referrer.value = oauthReferrer();
- document.signin1.action = '/oauth1/authorize/';
- document.signin1.submit();
-}
-
-function withLinkedin() {
- var parms = ['https://api.linkedin.com/uas/oauth/requestToken', 'https://www.linkedin.com/uas/oauth/authorize', 'https://api.linkedin.com/uas/oauth/accessToken', 'linkedin.com', 'https://api.linkedin.com/v1/people/~:(id,first-name,last-name,public-profile-url)'];
- return parms;
-}
-
-function withTwitter() {
- var parms = ['https://api.twitter.com/oauth/request_token', 'https://api.twitter.com/oauth/authorize', 'https://api.twitter.com/oauth/access_token', 'twitter.com', 'https://api.twitter.com/1/statuses/user_timeline.json'];
- return parms;
-}
-</script>
-
-<form name="fields">
-<p>Sign in with your Facebook account<br/><input type="button" onclick="submitSignin2(withFacebook)" value="Sign in"/></p>
-<p>Sign in with your Github account<br/><input type="button" onclick="submitSignin2(withGithub)" value="Sign in"/></p>
-<p>Sign in with your Linkedin account<br/><input type="button" onclick="submitSignin1(withLinkedin)" value="Sign in"/></p>
-<p>Sign in with your Twitter account<br/><input type="button" onclick="submitSignin1(withTwitter)" value="Sign in"/></p>
-</form>
-
-<form name="signin2" action="/" method="GET">
-<input type="hidden" name="oauth2_authorize" value=""/>
-<input type="hidden" name="oauth2_access_token" value=""/>
-<input type="hidden" name="oauth2_client_id" value=""/>
-<input type="hidden" name="oauth2_info" value=""/>
-<input type="hidden" name="oauth2_scope" value=""/>
-<input type="hidden" name="oauth2_display" value=""/>
-<input type="hidden" name="openauth_referrer" value=""/>
-</form>
-
-<form name="signin1" action="/" method="GET">
-<input type="hidden" name="oauth1_request_token" value=""/>
-<input type="hidden" name="oauth1_authorize" value=""/>
-<input type="hidden" name="oauth1_access_token" value=""/>
-<input type="hidden" name="oauth1_client_id" value=""/>
-<input type="hidden" name="oauth1_info" value=""/>
-<input type="hidden" name="openauth_referrer" value=""/>
-</form>
-
-</body>
-</html>
diff --git a/modules/oauth/htdocs/login/mixed.html b/modules/oauth/htdocs/login/mixed.html
deleted file mode 100644
index fdf2b64..0000000
--- a/modules/oauth/htdocs/login/mixed.html
+++ /dev/null
@@ -1,235 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-
-<html>
-<head>
-<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0"/>
-<meta name="apple-mobile-web-app-capable" content="yes"/>
-<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
-<link rel="stylesheet" type="text/css" href="/ui-min.css"/>
-<title>Sign in</title>
-</head>
-<body>
-<h1>Sign in with a Form, an OpenID provider or an OAuth provider</h1>
-
-<script type="text/javascript">
-function clearauthcookie() {
- document.cookie = 'TuscanyOpenAuth=; expires=' + new Date(1970,01,01).toGMTString() + '; domain=.' + domainname(window.location.hostname) + '; path=/';
- document.cookie = 'TuscanyOAuth1=; expires=' + new Date(1970,01,01).toGMTString() + '; domain=.' + domainname(window.location.hostname) + '; path=/';
- document.cookie = 'TuscanyOAuth2=; expires=' + new Date(1970,01,01).toGMTString() + '; domain=.' + domainname(window.location.hostname) + '; path=/';
- document.cookie = 'TuscanyOpenIDAuth=; expires=' + new Date(1970,01,01).toGMTString() + '; domain=.' + domainname(window.location.hostname) + '; path=/';
- return true;
-}
-
-function submitFormSignin() {
- clearauthcookie();
- document.formSignin.httpd_location.value = '/';
- document.formSignin.submit();
-}
-
-function queryParams() {
- qp = new Array();
- qs = window.location.search.substring(1).split('&');
- for (i = 0; i < qs.length; i++) {
- e = qs[i].indexOf('=');
- if (e > 0)
- qp[qs[i].substring(0, e)] = unescape(qs[i].substring(e + 1));
- }
- return qp;
-}
-
-function openauthReferrer() {
- r = queryParams()['openauth_referrer'];
- if (typeof(r) == 'undefined')
- return '/';
- q = r.indexOf('?');
- if (q > 0)
- return r.substring(0, q);
- return r;
-}
-
-if (typeof(openauthReferrer()) == 'undefined') {
- document.location = '/';
-}
-
-function submitOpenIDSignin(w) {
- clearauthcookie();
- document.openIDSignin.openid_identifier.value = w();
- document.openIDSignin.action = openauthReferrer();
- document.openIDSignin.submit();
-}
-
-function withGoogle() {
- return 'https://www.google.com/accounts/o8/id';
-}
-
-function withYahoo() {
- return 'https://me.yahoo.com/';
-}
-
-function withMyOpenID() {
- return 'http://www.myopenid.com/xrds';
-}
-
-function withVerisign() {
- return 'https://pip.verisignlabs.com/';
-}
-
-function withMySpace() {
- return 'https://api.myspace.com/openid';
-}
-
-function withGoogleApps() {
- return 'https://www.google.com/accounts/o8/site-xrds?ns=2&hd=' + document.fields.domain.value;
-}
-
-function withLivejournal() {
- return 'http://' + document.fields.ljuser.value + '.livejournal.com';
-}
-
-function withBlogspot() {
- return 'http://' + document.fields.bsuser.value + '.blogspot.com';
-}
-
-function withBlogger() {
- return 'http://' + document.fields.bguser.value + '.blogger.com';
-}
-
-function withXRDSEndpoint() {
- return document.fields.endpoint.value;
-}
-
-function submitOAuth2Signin(w) {
- parms = w();
- clearauthcookie();
- document.oauth2Signin.oauth2_authorize.value = parms[0];
- document.oauth2Signin.oauth2_access_token.value = parms[1];
- document.oauth2Signin.oauth2_client_id.value = parms[2];
- document.oauth2Signin.oauth2_info.value = parms[3];
- document.oauth2Signin.oauth2_scope.value = parms[4];
- document.oauth2Signin.oauth2_display.value = parms[5];
- document.oauth2Signin.openauth_referrer.value = openauthReferrer();
- document.oauth2Signin.action = '/oauth2/authorize/';
- document.oauth2Signin.submit();
-}
-
-function withFacebook() {
- var parms = ['https://graph.facebook.com/oauth/authorize', 'https://graph.facebook.com/oauth/access_token', 'facebook.com', 'https://graph.facebook.com/me', 'email', 'page'];
- return parms;
-}
-
-function withGithub() {
- var parms = ['https://github.com/login/oauth/authorize', 'https://github.com/login/oauth/access_token', 'github.com', 'https://github.com/api/v2/json/user/show', 'email', ''];
- return parms;
-}
-
-function submitOAuth1Signin(w) {
- parms = w();
- clearauthcookie();
- document.oauth1Signin.oauth1_request_token.value = parms[0];
- document.oauth1Signin.oauth1_authorize.value = parms[1];
- document.oauth1Signin.oauth1_access_token.value = parms[2];
- document.oauth1Signin.oauth1_client_id.value = parms[3];
- document.oauth1Signin.oauth1_info.value = parms[4];
- document.oauth1Signin.openauth_referrer.value = openauthReferrer();
- document.oauth1Signin.action = '/oauth1/authorize/';
- document.oauth1Signin.submit();
-}
-
-function withLinkedin() {
- var parms = ['https://api.linkedin.com/uas/oauth/requestToken', 'https://www.linkedin.com/uas/oauth/authorize', 'https://api.linkedin.com/uas/oauth/accessToken', 'linkedin.com', 'https://api.linkedin.com/v1/people/~:(id,first-name,last-name,public-profile-url)'];
- return parms;
-}
-
-function withTwitter() {
- var parms = ['https://api.twitter.com/oauth/request_token', 'https://api.twitter.com/oauth/authorize', 'https://api.twitter.com/oauth/access_token', 'twitter.com', 'https://api.twitter.com/1/statuses/user_timeline.json'];
- return parms;
-}
-</script>
-
-<form name="formSignin" method="POST" action="/login/dologin">
-<p>Sign in with your user id and password<br/>
-<table border="0">
-<tr><td>Username:</td><td><input type="text" name="httpd_username" value=""/></td></tr>
-<tr><td>Password:</td><td><input type="password" name="httpd_password" value=""/></td></tr>
-<tr><td><input type="button" onclick="submitFormSignin()" value="Sign in"/></td><td></td></tr>
-</table>
-</p>
-<input type="hidden" name="httpd_location" value="/"/>
-</form>
-
-<form name="fields">
-<p>Sign in with your Google account<br/><input type="button" onclick="submitOpenIDSignin(withGoogle)" value="Sign in"/></p>
-<p>Sign in with your Yahoo account<br/><input type="button" onclick="submitOpenIDSignin(withYahoo)" value="Sign in"/></p>
-<p>Sign in with your MyOpenID account<br/><input type="button" onclick="submitOpenIDSignin(withMyOpenID)" value="Sign in"/></p>
-<p>Sign in with your Verisign account<br/><input type="button" onclick="submitOpenIDSignin(withVerisign)" value="Sign in"/></p>
-<p>Sign in with your MySpace account<br/><input type="button" onclick="submitOpenIDSignin(withMySpace)" value="Sign in"/></p>
-
-<p>Sign in with a Google apps domain<br/>
-<input type="text" size="20" name="domain" value="example.com"/><br/>
-<input type="button" onclick="submitOpenIDSignin(withGoogleApps)" value="Sign in"/></p>
-
-<p>Sign in with your Livejournal account<br/>
-<input type="text" size="10" name="ljuser" value=""/><br/>
-<input type="button" onclick="submitOpenIDSignin(withLivejournal)" value="Sign in"/></p>
-
-<p>Sign in with your Blogspot account<br/>
-<input type="text" size="10" name="bsuser" value=""/><br/>
-<input type="button" onclick="submitOpenIDSignin(withBlogspot)" value="Sign in"/></p>
-
-<p>Sign in with your Blogger account<br/>
-<input type="text" size="10" name="bguser" value=""/><br/>
-<input type="button" onclick="submitOpenIDSignin(withBlogger)" value="Sign in"/></p>
-
-<p>Sign in with an OpenID endpoint<br/>
-<input type="text" size="50" name="endpoint" value="https://www.google.com/accounts/o8/id"/><br/>
-<input type="button" onclick="submitOpenIDSignin(withXRDSEndpoint)" value="Sign in"/></p>
-
-<p>Sign in with your Facebook account<br/><input type="button" onclick="submitOAuth2Signin(withFacebook)" value="Sign in"/></p>
-<p>Sign in with your Github account<br/><input type="button" onclick="submitOAuth2Signin(withGithub)" value="Sign in"/></p>
-
-<p>Sign in with your Linkedin account<br/><input type="button" onclick="submitOAuth1Signin(withLinkedin)" value="Sign in"/></p>
-<p>Sign in with your Twitter account<br/><input type="button" onclick="submitOAuth1Signin(withTwitter)" value="Sign in"/></p>
-</form>
-
-<form name="openIDSignin" action="/" method="GET">
-<input type="hidden" name="openid_identifier" value=""/>
-</form>
-
-<form name="oauth2Signin" action="/" method="GET">
-<input type="hidden" name="oauth2_authorize" value=""/>
-<input type="hidden" name="oauth2_access_token" value=""/>
-<input type="hidden" name="oauth2_client_id" value=""/>
-<input type="hidden" name="oauth2_info" value=""/>
-<input type="hidden" name="oauth2_scope" value=""/>
-<input type="hidden" name="oauth2_display" value=""/>
-<input type="hidden" name="openauth_referrer" value=""/>
-</form>
-
-<form name="oauth1Signin" action="/" method="GET">
-<input type="hidden" name="oauth1_request_token" value=""/>
-<input type="hidden" name="oauth1_authorize" value=""/>
-<input type="hidden" name="oauth1_access_token" value=""/>
-<input type="hidden" name="oauth1_client_id" value=""/>
-<input type="hidden" name="oauth1_info" value=""/>
-<input type="hidden" name="openauth_referrer" value=""/>
-</form>
-
-</body>
-</html>
diff --git a/modules/oauth/htdocs/logout/index.html b/modules/oauth/htdocs/logout/index.html
deleted file mode 100644
index 8cf7860..0000000
--- a/modules/oauth/htdocs/logout/index.html
+++ /dev/null
@@ -1,51 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-
-<html>
-<head>
-<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0"/>
-<meta name="apple-mobile-web-app-capable" content="yes"/>
-<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
-<link rel="stylesheet" type="text/css" href="/ui-min.css"/>
-<title>Sign out</title>
-</head>
-<body>
-<h1>Sign out</h1>
-<br/>
-
-<form name="signout" action="/login" method="GET">
-<script type="text/javascript">
-function clearauthcookie() {
- document.cookie = 'TuscanyOpenAuth=; expires=' + new Date(1970,01,01).toGMTString() + '; domain=.' + domainname(window.location.hostname) + '; path=/';
- document.cookie = 'TuscanyOAuth1=; expires=' + new Date(1970,01,01).toGMTString() + '; domain=.' + domainname(window.location.hostname) + '; path=/';
- document.cookie = 'TuscanyOAuth2=; expires=' + new Date(1970,01,01).toGMTString() + '; domain=.' + domainname(window.location.hostname) + '; path=/';
- document.cookie = 'TuscanyOpenIDAuth=; expires=' + new Date(1970,01,01).toGMTString() + '; domain=.' + domainname(window.location.hostname) + '; path=/';
- return true;
-}
-
-function submitSignout() {
- clearauthcookie();
- document.signout.submit();
- return true;
-}
-</script>
-<input type="button" onclick="submitSignout()" value="Sign out"/>
-</form>
-</body>
-</html>
diff --git a/modules/oauth/htdocs/public/index.html b/modules/oauth/htdocs/public/index.html
deleted file mode 100644
index 24db147..0000000
--- a/modules/oauth/htdocs/public/index.html
+++ /dev/null
@@ -1,35 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-
-<html>
-<head>
-<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0"/>
-<meta name="apple-mobile-web-app-capable" content="yes"/>
-<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
-<link rel="stylesheet" type="text/css" href="/ui-min.css"/>
-<title>Unprotected area</title>
-</head>
-<body>
-<h1>Unprotected area - It works!</h1>
-<p><a href="/info">User info</a></p>
-<p><a href="/login">Sign in</a></p>
-<p><a href="/logout">Sign out</a></p>
-<p><a href="/">Protected area</a></p>
-</body>
-</html>
diff --git a/modules/oauth/mod-oauth1.cpp b/modules/oauth/mod-oauth1.cpp
deleted file mode 100644
index d2c7cf7..0000000
--- a/modules/oauth/mod-oauth1.cpp
+++ /dev/null
@@ -1,691 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-/**
- * HTTPD module for OAuth 1.0 authentication.
- */
-
-#include <stdlib.h>
-#include <sys/stat.h>
-
-extern "C" {
-#include <oauth.h>
-}
-
-#define WANT_HTTPD_LOG 1
-#include "string.hpp"
-#include "stream.hpp"
-#include "list.hpp"
-#include "tree.hpp"
-#include "value.hpp"
-#include "monad.hpp"
-#include "parallel.hpp"
-#include "../json/json.hpp"
-#include "../http/httpd.hpp"
-#include "../http/http.hpp"
-#include "../http/openauth.hpp"
-#include "../../components/cache/memcache.hpp"
-
-extern "C" {
-extern module AP_MODULE_DECLARE_DATA mod_tuscany_oauth1;
-}
-
-namespace tuscany {
-namespace oauth1 {
-
-/**
- * Server configuration.
- */
-class ServerConf {
-public:
- ServerConf(apr_pool_t* p, server_rec* s) : p(p), server(s) {
- }
-
- const gc_pool p;
- server_rec* server;
- string ca;
- string cert;
- string key;
- list<list<value> > appkeys;
- list<string> mcaddrs;
- memcache::MemCached mc;
- perthread_ptr<http::CURLSession> cs;
-};
-
-/**
- * Authentication provider configuration.
- */
-class AuthnProviderConf {
-public:
- AuthnProviderConf() : name(), provider(NULL) {
- }
- AuthnProviderConf(const string name, const authn_provider* provider) : name(name), provider(provider) {
- }
-
- string name;
- const authn_provider* provider;
-};
-
-/**
- * Directory configuration.
- */
-class DirConf {
-public:
- DirConf(apr_pool_t* p, char* d) : p(p), dir(d), enabled(false), login("") {
- }
-
- const gc_pool p;
- const char* dir;
- bool enabled;
- string login;
- list<list<value> > scopeattrs;
- list<AuthnProviderConf> apcs;
-};
-
-/**
- * Run the authnz hooks to authenticate a request.
- */
-const failable<int> checkAuthnzProviders(const string& user, request_rec* r, const list<AuthnProviderConf>& apcs) {
- if (isNil(apcs))
- return mkfailure<int>("Authentication failure for: " + user, HTTP_UNAUTHORIZED);
- const AuthnProviderConf apc = car<AuthnProviderConf>(apcs);
- if (apc.provider == NULL || !apc.provider->check_password)
- return checkAuthnzProviders(user, r, cdr(apcs));
-
- apr_table_setn(r->notes, AUTHN_PROVIDER_NAME_NOTE, c_str(apc.name));
- const authn_status auth_result = apc.provider->check_password(r, c_str(string("/oauth1/") + user), "password");
- apr_table_unset(r->notes, AUTHN_PROVIDER_NAME_NOTE);
- if (auth_result != AUTH_GRANTED)
- return checkAuthnzProviders(user, r, cdr(apcs));
- return OK;
-}
-
-const failable<int> checkAuthnz(const string& user, request_rec* r, const list<AuthnProviderConf>& apcs) {
- if (substr(user, 0, 1) == "/")
- return mkfailure<int>(string("Encountered FakeBasicAuth spoof: ") + user, HTTP_UNAUTHORIZED);
-
- if (isNil(apcs)) {
- const authn_provider* provider = (const authn_provider*)ap_lookup_provider(AUTHN_PROVIDER_GROUP, AUTHN_DEFAULT_PROVIDER, AUTHN_PROVIDER_VERSION);
- return checkAuthnzProviders(user, r, mklist<AuthnProviderConf>(AuthnProviderConf(AUTHN_DEFAULT_PROVIDER, provider)));
- }
- return checkAuthnzProviders(user, r, apcs);
-}
-
-/**
- * Return the user info for a session.
- */
-const failable<value> userInfo(const value& sid, const memcache::MemCached& mc) {
- return memcache::get(mklist<value>("tuscanyOAuth1", sid), mc);
-}
-
-/**
- * Handle an authenticated request.
- */
-const failable<int> authenticated(const list<list<value> >& userinfo, const bool check, request_rec* r, const list<list<value> >& scopeattrs, const list<AuthnProviderConf>& apcs) {
- debug(userinfo, "modoauth2::authenticated::userinfo");
-
- if (isNil(scopeattrs)) {
-
- // Store user id in an environment variable
- const list<value> id = assoc<value>("id", userinfo);
- if (isNil(id) || isNil(cdr(id)))
- return mkfailure<int>("Couldn't retrieve user id");
- apr_table_set(r->subprocess_env, "OAUTH2_ID", apr_pstrdup(r->pool, c_str(cadr(id))));
-
- // If the request user field has not been mapped to another attribute, map the
- // OAuth id attribute to it
- if (r->user == NULL || r->user[0] == '\0')
- r->user = apr_pstrdup(r->pool, c_str(cadr(id)));
-
- // Run the authnz hooks to check the authenticated user
- if (check)
- return checkAuthnz(r->user == NULL? "" : r->user, r, apcs);
- return OK;
- }
-
- // Store each configured OAuth scope attribute in an environment variable
- const list<value> a = car(scopeattrs);
- const list<value> v = assoc<value>(cadr(a), userinfo);
- if (!isNil(v) && !isNil(cdr(v))) {
-
- // Map the REMOTE_USER attribute to the request user field
- if (string(car(a)) == "REMOTE_USER")
- r->user = apr_pstrdup(r->pool, c_str(cadr(v)));
- else
- apr_table_set(r->subprocess_env, apr_pstrdup(r->pool, c_str(car(a))), apr_pstrdup(r->pool, c_str(cadr(v))));
- }
- return authenticated(userinfo, check, r, cdr(scopeattrs), apcs);
-}
-
-/**
- * Convert a query string containing oauth args to an authorization header.
- */
-const string header(const string& qs, const string& redir, const string& verif) {
- const list<list<value> > args = httpd::queryArgs(qs);
- ostringstream hdr;
- hdr << "Authorization: OAuth "
- << "oauth_nonce=\"" << string(cadr(assoc<value>("oauth_nonce", args))) << "\", ";
-
- if (length(redir) != 0)
- hdr << "oauth_callback=\"" << httpd::escape(redir) << "\", ";
-
- hdr << "oauth_signature_method=\"" << string(cadr(assoc<value>("oauth_signature_method", args))) << "\", "
- << "oauth_timestamp=\"" << string(cadr(assoc<value>("oauth_timestamp", args))) << "\", "
- << "oauth_consumer_key=\"" << string(cadr(assoc<value>("oauth_consumer_key", args))) << "\", ";
-
- const list<value> atok = assoc<value>("oauth_token", args);
- if (!isNil(atok) && !isNil(cdr(atok)))
- hdr << "oauth_token=\"" << string(cadr(atok)) << "\", ";
-
- if (length(verif) != 0)
- hdr << "oauth_verifier=\"" << verif << "\", ";
-
- hdr << "oauth_signature=\"" << string(cadr(assoc<value>("oauth_signature", args))) << "\", "
- << "oauth_version=\"" << string(cadr(assoc<value>("oauth_version", args))) << "\"";
- debug(str(hdr), "modoauth1::authheader");
- return str(hdr);
-}
-
-
-/**
- * Sign a request.
- */
-const list<string> sign(const string& verb, const string& uri, const list<value> appkey, const string& tok, const string& sec) {
- char* qs = NULL;
- char* suri = oauth_sign_url2(c_str(uri), &qs, OA_HMAC, c_str(verb), c_str(car(appkey)), c_str(cadr(appkey)), length(tok) != 0? c_str(tok) : NULL, length(sec) != 0? c_str(sec) : NULL);
- const list<string> res = mklist<string>(suri, qs);
- free(suri);
- free(qs);
- return res;
-}
-
-/**
- * Handle an authorize request.
- */
-const failable<int> authorize(const list<list<value> >& args, request_rec* r, const list<list<value> >& appkeys, const memcache::MemCached& mc) {
- // Extract authorize, access_token, client ID and info URIs
- const list<value> ref = assoc<value>("openauth_referrer", args);
- if (isNil(ref) || isNil(cdr(ref)))
- return mkfailure<int>("Missing openauth_referrer parameter");
- const list<value> req = assoc<value>("oauth1_request_token", args);
- if (isNil(req) || isNil(cdr(req)))
- return mkfailure<int>("Missing oauth1_request_token parameter");
- const list<value> auth = assoc<value>("oauth1_authorize", args);
- if (isNil(auth) || isNil(cdr(auth)))
- return mkfailure<int>("Missing oauth1_authorize parameter");
- const list<value> tok = assoc<value>("oauth1_access_token", args);
- if (isNil(tok) || isNil(cdr(tok)))
- return mkfailure<int>("Missing oauth1_access_token parameter");
- const list<value> cid = assoc<value>("oauth1_client_id", args);
- if (isNil(cid) || isNil(cdr(cid)))
- return mkfailure<int>("Missing oauth1_client_id parameter");
- const list<value> info = assoc<value>("oauth1_info", args);
- if (isNil(info) || isNil(cdr(info)))
- return mkfailure<int>("Missing oauth1_info parameter");
-
- // Build the redirect URI
- const list<list<value> > redirargs = mklist<list<value> >(tok, cid, info, ref);
- const string redir = httpd::url("/oauth1/access_token/", r) + string("?") + http::queryString(redirargs);
- debug(redir, "modoauth1::authorize::redir");
-
- // Lookup client app configuration
- const list<value> app = assoc<value>(cadr(cid), appkeys);
- if (isNil(app) || isNil(cdr(app)))
- return mkfailure<int>(string("client id not found: ") + cadr(cid));
- list<value> appkey = cadr(app);
-
- // Build and sign the request token URI
- const string requri = httpd::unescape(cadr(req)) + string("&") + http::queryString(mklist<list<value> >(mklist<value>("oauth_callback", httpd::escape(redir))));
- const list<string> srequri = sign("POST", requri, appkey, "", "");
- debug(srequri, "modoauth1::authorize::srequri");
-
- // Put the args into an oauth header
- const string reqhdr = header(cadr(srequri), redir, "");
-
- // Send the request token request
- char* pres = oauth_http_post2(c_str(car(srequri)), "", c_str(reqhdr));
- if (pres == NULL)
- return mkfailure<int>("Couldn't send request token request");
- const string res(pres);
- free(pres);
- debug(res, "modoauth1::authorize::res");
- const list<list<value> > resargs = httpd::queryArgs(res);
-
- // Retrieve the request token
- const list<value> conf = assoc<value>("oauth_callback_confirmed", resargs);
- if (isNil(conf) || isNil(cdr(conf)) || cadr(conf) != "true")
- return mkfailure<int>("Couldn't confirm oauth_callback");
- const list<value> tv = assoc<value>("oauth_token", resargs);
- if (isNil(tv) || isNil(cdr(tv)))
- return mkfailure<int>("Couldn't retrieve oauth_token");
- const list<value> sv = assoc<value>("oauth_token_secret", resargs);
- if (isNil(sv) || isNil(cdr(sv)))
- return mkfailure<int>("Couldn't retrieve oauth_token_secret");
-
- // Store the request token in memcached
- const failable<bool> prc = memcache::put(mklist<value>("tuscanyOAuth1Token", cadr(tv)), cadr(sv), mc);
- if (!hasContent(prc))
- return mkfailure<int>(prc);
-
- // Redirect to the authorize URI
- const string authuri = httpd::unescape(cadr(auth)) + string("?") + http::queryString(mklist<list<value> >(tv));
- debug(authuri, "modoauth1::authorize::authuri");
- return httpd::externalRedirect(authuri, r);
-}
-
-/**
- * Extract user info from a profile/info response.
- * TODO This currently only works for Twitter, Foursquare and LinkedIn.
- * User profile parsing needs to be made configurable.
- */
-const failable<list<value> > profileUserInfo(const value& cid, const string& info) {
- string b = substr(info, 0, 1);
- if (b == "[") {
- // Twitter JSON profile
- js::JSContext cx;
- const list<value> infov(json::jsonValues(content(json::readJSON(mklist<string>(info), cx))));
- if (isNil(infov))
- return mkfailure<list<value> >("Couldn't retrieve user info");
- debug(infov, "modoauth1::access_token::info");
- const list<value> uv = assoc<value>("user", car(infov));
- debug(uv, "modoauth1::access_token::userInfo");
- if (isNil(uv) || isNil(cdr(uv)))
- return mkfailure<list<value> >("Couldn't retrieve user info");
- const list<value> iv = cdr(uv);
- return cons<value>(mklist<value>("realm", cid), iv);
- }
- if (b == "{") {
- // Foursquare JSON profile
- js::JSContext cx;
- const list<value> infov(json::jsonValues(content(json::readJSON(mklist<string>(info), cx))));
- if (isNil(infov))
- return mkfailure<list<value> >("Couldn't retrieve user info");
- debug(infov, "modoauth1::access_token::info");
- const list<value> uv = assoc<value>("user", infov);
- debug(uv, "modoauth1::access_token::userInfo");
- if (isNil(uv) || isNil(cdr(uv)))
- return mkfailure<list<value> >("Couldn't retrieve user info");
- const list<value> iv = cdr(uv);
- return cons<value>(mklist<value>("realm", cid), iv);
- }
- if (b == "<") {
- // XML profile
- const list<value> infov = elementsToValues(readXML(mklist<string>(info)));
- if (isNil(infov))
- return mkfailure<list<value> >("Couldn't retrieve user info");
- debug(infov, "modoauth1::access_token::info");
- const list<value> pv = car(infov);
- debug(pv, "modoauth1::access_token::userInfo");
- if (isNil(pv) || isNil(cdr(pv)))
- return mkfailure<list<value> >("Couldn't retrieve user info");
- const list<value> iv = cdr(pv);
- return cons<value>(mklist<value>("realm", cid), iv);
- }
- return mkfailure<list<value> >("Couldn't retrieve user info");
-}
-
-/**
- * Handle an access_token request.
- */
-const failable<int> accessToken(const list<list<value> >& args, request_rec* r, const list<list<value> >& appkeys, const list<list<value> >& scopeattrs, const list<AuthnProviderConf>& apcs, const memcache::MemCached& mc) {
-
- // Extract access_token URI, client ID and verification code
- const list<value> ref = assoc<value>("openauth_referrer", args);
- if (isNil(ref) || isNil(cdr(ref)))
- return mkfailure<int>("Missing openauth_referrer parameter");
- const list<value> tok = assoc<value>("oauth1_access_token", args);
- if (isNil(tok) || isNil(cdr(tok)))
- return mkfailure<int>("Missing oauth1_access_token parameter");
- const list<value> cid = assoc<value>("oauth1_client_id", args);
- if (isNil(cid) || isNil(cdr(cid)))
- return mkfailure<int>("Missing oauth1_client_id parameter");
- const list<value> info = assoc<value>("oauth1_info", args);
- if (isNil(info) || isNil(cdr(info)))
- return mkfailure<int>("Missing oauth1_info parameter");
- const list<value> tv = assoc<value>("oauth_token", args);
- if (isNil(tv) || isNil(cdr(tv)))
- return mkfailure<int>("Missing oauth_token parameter");
- const list<value> vv = assoc<value>("oauth_verifier", args);
- if (isNil(vv) || isNil(cdr(vv)))
- return mkfailure<int>("Missing oauth_verifier parameter");
-
- // Lookup client app configuration
- const list<value> app = assoc<value>(cadr(cid), appkeys);
- if (isNil(app) || isNil(cdr(app)))
- return mkfailure<int>(string("client id not found: ") + cadr(cid));
- list<value> appkey = cadr(app);
-
- // Retrieve the request token from memcached
- const failable<value> sv = memcache::get(mklist<value>("tuscanyOAuth1Token", cadr(tv)), mc);
- if (!hasContent(sv))
- return mkfailure<int>(sv);
-
- // Build and sign access token request URI
- const string tokuri = httpd::unescape(cadr(tok)) + string("?") + http::queryString(mklist<list<value> >(vv));
- const list<string> stokuri = sign("POST", tokuri, appkey, cadr(tv), content(sv));
- debug(stokuri, "modoauth1::access_token::stokuri");
-
- // Put the args into an oauth header
- string tokhdr = header(cadr(stokuri), "", cadr(vv));
-
- // Send the access token request
- char* ptokres = oauth_http_post2(c_str(car(stokuri)), "", c_str(tokhdr));
- if (ptokres == NULL)
- return mkfailure<int>("Couldn't post access_token request");
- const string tokres(ptokres);
- free(ptokres);
- debug(tokres, "modoauth1::access_token::res");
- const list<list<value> > tokresargs = httpd::queryArgs(tokres);
-
- // Retrieve the access token
- const list<value> atv = assoc<value>("oauth_token", tokresargs);
- if (isNil(atv) || isNil(cdr(atv)))
- return mkfailure<int>("Couldn't retrieve oauth_token");
- const list<value> asv = assoc<value>("oauth_token_secret", tokresargs);
- if (isNil(asv) || isNil(cdr(asv)))
- return mkfailure<int>("Couldn't retrieve oauth_token_secret");
- debug(atv, "modoauth1::access_token::token");
-
- // Build and sign user profile request URI
- const string profuri = httpd::unescape(cadr(info));
- const list<string> sprofuri = sign("GET", profuri, appkey, cadr(atv), cadr(asv));
- debug(sprofuri, "modoauth1::access_token::sprofuri");
-
- // Put the args into an oauth header
- string profhdr = header(cadr(sprofuri), "", "");
-
- // Send the user profile request
- char* pprofres = oauth_http_get2(c_str(car(sprofuri)), NULL, c_str(profhdr));
- if (pprofres == NULL)
- return mkfailure<int>("Couldn't get user info");
- const string profres(pprofres);
- free(pprofres);
- debug(profres, "modoauth1::access_token::profres");
-
- // Retrieve the user info from the profile
- const failable<list<value> > userinfo = profileUserInfo(cadr(cid), profres);
- if (!hasContent(userinfo))
- return mkfailure<int>(userinfo);
-
- // Validate the authenticated user
- const failable<int> authrc = authenticated(content(userinfo), true, r, scopeattrs, apcs);
- if (!hasContent(authrc))
- return authrc;
-
- // Store user info in memcached keyed by session ID
- const value sid = string("OAuth1_") + mkrand();
- const failable<bool> prc = memcache::put(mklist<value>("tuscanyOAuth1", sid), content(userinfo), mc);
- if (!hasContent(prc))
- return mkfailure<int>(prc);
-
- // Send session ID to the client in a cookie
- debug(c_str(openauth::cookie("TuscanyOAuth1", sid, httpd::hostName(r))), "modoauth1::access_token::setcookie");
- apr_table_set(r->err_headers_out, "Set-Cookie", c_str(openauth::cookie("TuscanyOAuth1", sid, httpd::hostName(r))));
- return httpd::externalRedirect(httpd::url(httpd::unescape(cadr(ref)), r), r);
-}
-
-/**
- * Check user authentication.
- */
-static int checkAuthn(request_rec *r) {
- gc_scoped_pool pool(r->pool);
-
- // Decline if we're not enabled or AuthType is not set to Open
- const DirConf& dc = httpd::dirConf<DirConf>(r, &mod_tuscany_oauth1);
- if (!dc.enabled)
- return DECLINED;
- const char* atype = ap_auth_type(r);
- if (atype == NULL || strcasecmp(atype, "Open"))
- return DECLINED;
- debug_httpdRequest(r, "modoauth1::checkAuthn::input");
- debug(atype, "modopenauth::checkAuthn::auth_type");
-
- // Get the server configuration
- const ServerConf& sc = httpd::serverConf<ServerConf>(r, &mod_tuscany_oauth1);
-
- // Get session id from the request
- const maybe<string> sid = openauth::sessionID(r, "TuscanyOAuth1");
- if (hasContent(sid)) {
- // Decline if the session id was not created by this module
- if (substr(content(sid), 0, 7) != "OAuth1_")
- return DECLINED;
-
- // Extract the user info from the auth session
- const failable<value> userinfo = userInfo(content(sid), sc.mc);
- if (!hasContent(userinfo))
- return httpd::reportStatus(mkfailure<int>(userinfo));
- r->ap_auth_type = const_cast<char*>(atype);
- return httpd::reportStatus(authenticated(content(userinfo), false, r, dc.scopeattrs, dc.apcs));
- }
-
- // Get the request args
- const list<list<value> > args = httpd::queryArgs(r);
-
- // Handle OAuth authorize request step
- if (string(r->uri) == "/oauth1/authorize/") {
- r->ap_auth_type = const_cast<char*>(atype);
- return httpd::reportStatus(authorize(args, r, sc.appkeys, sc.mc));
- }
-
- // Handle OAuth access_token request step
- if (string(r->uri) == "/oauth1/access_token/") {
- r->ap_auth_type = const_cast<char*>(atype);
- const failable<int> authrc = accessToken(args, r, sc.appkeys, dc.scopeattrs, dc.apcs, sc.mc);
-
- // Redirect to the login page if user is not authorized
- if (!hasContent(authrc) && rcode(authrc) == HTTP_UNAUTHORIZED)
- return httpd::reportStatus(openauth::login(dc.login, string("/"), 1, r));
-
- return httpd::reportStatus(authrc);
- }
-
- // Redirect to the login page, unless we have a session id or an authorization
- // header from another module
- if (apr_table_get(r->headers_in, (PROXYREQ_PROXY == r->proxyreq) ? "Proxy-Authorization" : "Authorization") != NULL)
- return DECLINED;
- if (hasContent(openauth::sessionID(r, "TuscanyOpenIDAuth")) ||
- hasContent(openauth::sessionID(r, "TuscanyOpenAuth")) ||
- hasContent(openauth::sessionID(r, "TuscanyOAuth2")))
- return DECLINED;
- if ((substr(string(r->uri), 0, 8) == "/oauth2/") || !isNil(assoc<value>("openid_identifier", args)))
- return DECLINED;
-
- r->ap_auth_type = const_cast<char*>(atype);
- return httpd::reportStatus(openauth::login(dc.login, value(), value(), r));
-}
-
-/**
- * Process the module configuration.
- */
-int postConfigMerge(ServerConf& mainsc, server_rec* s) {
- if (s == NULL)
- return OK;
- ServerConf& sc = httpd::serverConf<ServerConf>(s, &mod_tuscany_oauth1);
- debug(httpd::serverName(s), "modoauth1::postConfigMerge::serverName");
-
- // Merge configuration from main server
- if (isNil(sc.appkeys))
- sc.appkeys = mainsc.appkeys;
- if (isNil(sc.mcaddrs))
- sc.mcaddrs = mainsc.mcaddrs;
- sc.mc = mainsc.mc;
- sc.cs = mainsc.cs;
-
- return postConfigMerge(mainsc, s->next);
-}
-
-int postConfig(apr_pool_t* p, unused apr_pool_t* plog, unused apr_pool_t* ptemp, server_rec* s) {
- gc_scoped_pool pool(p);
-
- ServerConf& sc = httpd::serverConf<ServerConf>(s, &mod_tuscany_oauth1);
- debug(httpd::serverName(s), "modoauth1::postConfig::serverName");
-
- // Merge server configurations
- return postConfigMerge(sc, s);
-}
-
-/**
- * Lambda function that creates a new CURL session.
- */
-class newsession {
-public:
- newsession(const string& ca, const string& cert, const string& key) : ca(ca), cert(cert), key(key) {
- }
-
- const gc_ptr<http::CURLSession> operator()() const {
- return new (gc_new<http::CURLSession>()) http::CURLSession(ca, cert, key, "", 0);
- }
-
-private:
- const string ca;
- const string cert;
- const string key;
-};
-
-/**
- * Child process initialization.
- */
-void childInit(apr_pool_t* p, server_rec* s) {
- gc_scoped_pool pool(p);
-
- ServerConf* psc = (ServerConf*)ap_get_module_config(s->module_config, &mod_tuscany_oauth1);
- if(psc == NULL) {
- cfailure << "[Tuscany] Due to one or more errors mod_tuscany_oauth1 loading failed. Causing apache to stop loading." << endl;
- exit(APEXIT_CHILDFATAL);
- }
- ServerConf& sc = *psc;
-
- // Connect to Memcached
- if (isNil(sc.mcaddrs))
- sc.mc = *(new (gc_new<memcache::MemCached>()) memcache::MemCached("localhost", 11211));
- else
- sc.mc = *(new (gc_new<memcache::MemCached>()) memcache::MemCached(sc.mcaddrs));
-
- // Setup a CURL session
- sc.cs = perthread_ptr<http::CURLSession>(lambda<gc_ptr<http::CURLSession>()>(newsession(sc.ca, sc.cert, sc.key)));
-
- // Merge the updated configuration into the virtual hosts
- postConfigMerge(sc, s->next);
-}
-
-/**
- * Configuration commands.
- */
-const char* confAppKey(cmd_parms *cmd, unused void *c, const char *arg1, const char* arg2, const char* arg3) {
- gc_scoped_pool pool(cmd->pool);
- ServerConf& sc = httpd::serverConf<ServerConf>(cmd, &mod_tuscany_oauth1);
- sc.appkeys = cons<list<value> >(mklist<value>(arg1, mklist<value>(arg2, arg3)), sc.appkeys);
- return NULL;
-}
-const char* confMemcached(cmd_parms *cmd, unused void *c, const char *arg) {
- gc_scoped_pool pool(cmd->pool);
- ServerConf& sc = httpd::serverConf<ServerConf>(cmd, &mod_tuscany_oauth1);
- sc.mcaddrs = cons<string>(arg, sc.mcaddrs);
- return NULL;
-}
-const char* confEnabled(cmd_parms *cmd, void *c, const int arg) {
- gc_scoped_pool pool(cmd->pool);
- DirConf& dc = httpd::dirConf<DirConf>(c);
- dc.enabled = (bool)arg;
- return NULL;
-}
-const char* confLogin(cmd_parms *cmd, void *c, const char* arg) {
- gc_scoped_pool pool(cmd->pool);
- DirConf& dc = httpd::dirConf<DirConf>(c);
- dc.login = arg;
- return NULL;
-}
-const char* confCAFile(cmd_parms *cmd, unused void *c, const char *arg) {
- gc_scoped_pool pool(cmd->pool);
- ServerConf& sc = httpd::serverConf<ServerConf>(cmd, &mod_tuscany_oauth1);
- sc.ca = arg;
- return NULL;
-}
-const char* confCertFile(cmd_parms *cmd, unused void *c, const char *arg) {
- gc_scoped_pool pool(cmd->pool);
- ServerConf& sc = httpd::serverConf<ServerConf>(cmd, &mod_tuscany_oauth1);
- sc.cert = arg;
- return NULL;
-}
-const char* confCertKeyFile(cmd_parms *cmd, unused void *c, const char *arg) {
- gc_scoped_pool pool(cmd->pool);
- ServerConf& sc = httpd::serverConf<ServerConf>(cmd, &mod_tuscany_oauth1);
- sc.key = arg;
- return NULL;
-}
-const char* confScopeAttr(cmd_parms *cmd, void* c, const char* arg1, const char* arg2) {
- gc_scoped_pool pool(cmd->pool);
- DirConf& dc = httpd::dirConf<DirConf>(c);
- dc.scopeattrs = cons<list<value> >(mklist<value>(arg1, arg2), dc.scopeattrs);
- return NULL;
-}
-const char* confAuthnProvider(cmd_parms *cmd, void *c, const char* arg) {
- gc_scoped_pool pool(cmd->pool);
- DirConf& dc = httpd::dirConf<DirConf>(c);
-
- // Lookup and cache the Authn provider
- const authn_provider* provider = (authn_provider*)ap_lookup_provider(AUTHN_PROVIDER_GROUP, arg, AUTHN_PROVIDER_VERSION);
- if (provider == NULL)
- return apr_psprintf(cmd->pool, "Unknown Authn provider: %s", arg);
- if (!provider->check_password)
- return apr_psprintf(cmd->pool, "The '%s' Authn provider doesn't support password authentication", arg);
- dc.apcs = append<AuthnProviderConf>(dc.apcs, mklist<AuthnProviderConf>(AuthnProviderConf(arg, provider)));
- return NULL;
-}
-
-/**
- * HTTP server module declaration.
- */
-const command_rec commands[] = {
- AP_INIT_ITERATE("AuthOAuthProvider", (const char*(*)())confAuthnProvider, NULL, OR_AUTHCFG, "Auth providers for a directory or location"),
- AP_INIT_TAKE3("AddAuthOAuth1AppKey", (const char*(*)())confAppKey, NULL, RSRC_CONF, "OAuth 1.0 name app-id app-key"),
- AP_INIT_ITERATE("AddAuthOAuthMemcached", (const char*(*)())confMemcached, NULL, RSRC_CONF, "Memcached server host:port"),
- AP_INIT_FLAG("AuthOAuth", (const char*(*)())confEnabled, NULL, OR_AUTHCFG, "OAuth 1.0 authentication On | Off"),
- AP_INIT_TAKE1("AuthOAuthLoginPage", (const char*(*)())confLogin, NULL, OR_AUTHCFG, "OAuth 1.0 login page"),
- AP_INIT_TAKE1("AuthOAuthSSLCACertificateFile", (const char*(*)())confCAFile, NULL, RSRC_CONF, "OAUth 1.0 SSL CA certificate file"),
- AP_INIT_TAKE1("AuthOAuthSSLCertificateFile", (const char*(*)())confCertFile, NULL, RSRC_CONF, "OAuth 1.0 SSL certificate file"),
- AP_INIT_TAKE1("AuthOAuthSSLCertificateKeyFile", (const char*(*)())confCertKeyFile, NULL, RSRC_CONF, "OAuth 1.0 SSL certificate key file"),
- AP_INIT_TAKE2("AddAuthOAuth1ScopeAttr", (const char*(*)())confScopeAttr, NULL, OR_AUTHCFG, "OAuth 1.0 scope attribute"),
- {NULL, NULL, NULL, 0, NO_ARGS, NULL}
-};
-
-void registerHooks(unused apr_pool_t *p) {
- ap_hook_post_config(postConfig, NULL, NULL, APR_HOOK_MIDDLE);
- ap_hook_child_init(childInit, NULL, NULL, APR_HOOK_MIDDLE);
- ap_hook_check_authn(checkAuthn, NULL, NULL, APR_HOOK_MIDDLE, AP_AUTH_INTERNAL_PER_CONF);
-}
-
-}
-}
-
-extern "C" {
-
-module AP_MODULE_DECLARE_DATA mod_tuscany_oauth1 = {
- STANDARD20_MODULE_STUFF,
- // dir config and merger
- tuscany::httpd::makeDirConf<tuscany::oauth1::DirConf>, NULL,
- // server config and merger
- tuscany::httpd::makeServerConf<tuscany::oauth1::ServerConf>, NULL,
- // commands and hooks
- tuscany::oauth1::commands, tuscany::oauth1::registerHooks
-};
-
-}
diff --git a/modules/oauth/mod-oauth2.cpp b/modules/oauth/mod-oauth2.cpp
deleted file mode 100644
index e384a0e..0000000
--- a/modules/oauth/mod-oauth2.cpp
+++ /dev/null
@@ -1,564 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-/**
- * HTTPD module for OAuth 2.0 authentication.
- */
-
-#include <sys/stat.h>
-
-#define WANT_HTTPD_LOG 1
-#include "string.hpp"
-#include "stream.hpp"
-#include "list.hpp"
-#include "tree.hpp"
-#include "value.hpp"
-#include "monad.hpp"
-#include "parallel.hpp"
-#include "../http/httpd.hpp"
-#include "../http/http.hpp"
-#include "../http/openauth.hpp"
-#include "../../components/cache/memcache.hpp"
-
-extern "C" {
-extern module AP_MODULE_DECLARE_DATA mod_tuscany_oauth2;
-}
-
-namespace tuscany {
-namespace oauth2 {
-
-/**
- * Server configuration.
- */
-class ServerConf {
-public:
- ServerConf(apr_pool_t* p, server_rec* s) : p(p), server(s) {
- }
-
- const gc_pool p;
- server_rec* server;
- string ca;
- string cert;
- string key;
- list<list<value> > appkeys;
- list<string> mcaddrs;
- memcache::MemCached mc;
- perthread_ptr<http::CURLSession> cs;
-};
-
-/**
- * Authentication provider configuration.
- */
-class AuthnProviderConf {
-public:
- AuthnProviderConf() : name(), provider(NULL) {
- }
- AuthnProviderConf(const string name, const authn_provider* provider) : name(name), provider(provider) {
- }
-
- string name;
- const authn_provider* provider;
-};
-
-/**
- * Directory configuration.
- */
-class DirConf {
-public:
- DirConf(apr_pool_t* p, char* d) : p(p), dir(d), enabled(false), login("") {
- }
-
- const gc_pool p;
- const char* dir;
- bool enabled;
- string login;
- list<list<value> > scopeattrs;
- list<AuthnProviderConf> apcs;
-};
-
-/**
- * Run the authnz hooks to authenticate a request.
- */
-const failable<int> checkAuthnzProviders(const string& user, request_rec* r, const list<AuthnProviderConf>& apcs) {
- if (isNil(apcs))
- return mkfailure<int>("Authentication failure for: " + user, HTTP_UNAUTHORIZED);
- const AuthnProviderConf apc = car<AuthnProviderConf>(apcs);
- if (apc.provider == NULL || !apc.provider->check_password)
- return checkAuthnzProviders(user, r, cdr(apcs));
-
- apr_table_setn(r->notes, AUTHN_PROVIDER_NAME_NOTE, c_str(apc.name));
- const authn_status auth_result = apc.provider->check_password(r, c_str(string("/oauth2/") + user), "password");
- apr_table_unset(r->notes, AUTHN_PROVIDER_NAME_NOTE);
- if (auth_result != AUTH_GRANTED)
- return checkAuthnzProviders(user, r, cdr(apcs));
- return OK;
-}
-
-const failable<int> checkAuthnz(const string& user, request_rec* r, const list<AuthnProviderConf>& apcs) {
- if (substr(user, 0, 1) == "/")
- return mkfailure<int>(string("Encountered FakeBasicAuth spoof: ") + user, HTTP_UNAUTHORIZED);
-
- if (isNil(apcs)) {
- const authn_provider* provider = (const authn_provider*)ap_lookup_provider(AUTHN_PROVIDER_GROUP, AUTHN_DEFAULT_PROVIDER, AUTHN_PROVIDER_VERSION);
- return checkAuthnzProviders(user, r, mklist<AuthnProviderConf>(AuthnProviderConf(AUTHN_DEFAULT_PROVIDER, provider)));
- }
- return checkAuthnzProviders(user, r, apcs);
-}
-
-/**
- * Return the user info for a session.
- */
-const failable<value> userInfo(const value& sid, const memcache::MemCached& mc) {
- return memcache::get(mklist<value>("tuscanyOAuth2", sid), mc);
-}
-
-/**
- * Handle an authenticated request.
- */
-const failable<int> authenticated(const list<list<value> >& userinfo, const bool check, request_rec* r, const list<list<value> >& scopeattrs, const list<AuthnProviderConf>& apcs) {
- debug(userinfo, "modoauth2::authenticated::userinfo");
-
- if (isNil(scopeattrs)) {
-
- // Store user id in an environment variable
- const list<value> id = assoc<value>("id", userinfo);
- if (isNil(id) || isNil(cdr(id)))
- return mkfailure<int>("Couldn't retrieve user id");
- apr_table_set(r->subprocess_env, "OAUTH2_ID", apr_pstrdup(r->pool, c_str(cadr(id))));
-
- // If the request user field has not been mapped to another attribute, map the
- // OAuth id attribute to it
- if (r->user == NULL || r->user[0] == '\0')
- r->user = apr_pstrdup(r->pool, c_str(cadr(id)));
-
- // Run the authnz hooks to check the authenticated user
- if (check)
- return checkAuthnz(r->user == NULL? "" : r->user, r, apcs);
- return OK;
- }
-
- // Store each configured OAuth scope attribute in an environment variable
- const list<value> a = car(scopeattrs);
- const list<value> v = assoc<value>(cadr(a), userinfo);
- if (!isNil(v) && !isNil(cdr(v))) {
-
- // Map the REMOTE_USER attribute to the request user field
- if (string(car(a)) == "REMOTE_USER")
- r->user = apr_pstrdup(r->pool, c_str(cadr(v)));
- else
- apr_table_set(r->subprocess_env, apr_pstrdup(r->pool, c_str(car(a))), apr_pstrdup(r->pool, c_str(cadr(v))));
- }
- return authenticated(userinfo, check, r, cdr(scopeattrs), apcs);
-}
-
-/**
- * Handle an authorize request.
- */
-const failable<int> authorize(const list<list<value> >& args, request_rec* r, const list<list<value> >& appkeys) {
- // Extract authorize, access_token, client ID and info URIs
- const list<value> ref = assoc<value>("openauth_referrer", args);
- if (isNil(ref) || isNil(cdr(ref)))
- return mkfailure<int>("Missing openauth_referrer parameter");
- const list<value> auth = assoc<value>("oauth2_authorize", args);
- if (isNil(auth) || isNil(cdr(auth)))
- return mkfailure<int>("Missing oauth2_authorize parameter");
- const list<value> tok = assoc<value>("oauth2_access_token", args);
- if (isNil(tok) || isNil(cdr(tok)))
- return mkfailure<int>("Missing oauth2_access_token parameter");
- const list<value> cid = assoc<value>("oauth2_client_id", args);
- if (isNil(cid) || isNil(cdr(cid)))
- return mkfailure<int>("Missing oauth2_client_id parameter");
- const list<value> info = assoc<value>("oauth2_info", args);
- if (isNil(info) || isNil(cdr(info)))
- return mkfailure<int>("Missing oauth2_info parameter");
- const list<value> scope = assoc<value>("oauth2_scope", args);
- if (isNil(scope) || isNil(cdr(scope)))
- return mkfailure<int>("Missing oauth2_scope parameter");
- const list<value> display = assoc<value>("oauth2_display", args);
-
- // Build the redirect URI
- const string redir = httpd::url("/oauth2/access_token/", r);
- debug(redir, "modoauth2::authorize::redir");
-
- // Build the state URI
- const list<list<value> > stargs = mklist<list<value> >(tok, cid, info, ref);
- const string state = http::queryString(stargs);
- debug(state, "modoauth2::authorize::state");
-
- // Lookup client app configuration
- const list<value> app = assoc<value>(cadr(cid), appkeys);
- if (isNil(app) || isNil(cdr(app)))
- return mkfailure<int>(string("client id not found: ") + cadr(cid));
- list<value> appkey = cadr(app);
-
- // Redirect to the authorize URI
- const list<value> adisplay = (isNil(display) || isNil(cdr(display)))? list<value>() : mklist<value>("display", cadr(display));
- const list<list<value> > aargs = mklist<list<value> >(mklist<value>("response_type", "code"), mklist<value>("client_id", car(appkey)), mklist<value>("scope", cadr(scope)), adisplay, mklist<value>("redirect_uri", httpd::escape(redir)), mklist<value>("state", httpd::escape(state)));
- const string uri = httpd::unescape(cadr(auth)) + string("?") + http::queryString(aargs);
- debug(uri, "modoauth2::authorize::uri");
- return httpd::externalRedirect(uri, r);
-}
-
-/**
- * Extract user info from a profile/info response.
- * TODO This currently only works for Facebook and Gowalla.
- * User profile parsing needs to be made configurable.
- */
-const failable<list<value> > profileUserInfo(const value& cid, const list<value>& info) {
- return cons<value>(mklist<value>("realm", cid), info);
-}
-
-/**
- * Handle an access_token request.
- */
-const failable<int> accessToken(const list<list<value> >& args, request_rec* r, const list<list<value> >& appkeys, const perthread_ptr<http::CURLSession>& cs, const list<list<value> >& scopeattrs, const list<AuthnProviderConf>& apcs, const memcache::MemCached& mc) {
-
- // Extract access_token URI, client ID and authorization code parameters
- const list<value> state = assoc<value>("state", args);
- if (isNil(state) || isNil(cdr(state)))
- return mkfailure<int>("Missing state parameter");
- const list<list<value> >& stargs = httpd::queryArgs(httpd::unescape(cadr(state)));
- const list<value> ref = assoc<value>("openauth_referrer", stargs);
- if (isNil(ref) || isNil(cdr(ref)))
- return mkfailure<int>("Missing openauth_referrer parameter");
- const list<value> tok = assoc<value>("oauth2_access_token", stargs);
- if (isNil(tok) || isNil(cdr(tok)))
- return mkfailure<int>("Missing oauth2_access_token parameter");
- const list<value> cid = assoc<value>("oauth2_client_id", stargs);
- if (isNil(cid) || isNil(cdr(cid)))
- return mkfailure<int>("Missing oauth2_client_id parameter");
- const list<value> info = assoc<value>("oauth2_info", stargs);
- if (isNil(info) || isNil(cdr(info)))
- return mkfailure<int>("Missing oauth2_info parameter");
- const list<value> code = assoc<value>("code", args);
- if (isNil(code) || isNil(cdr(code)))
- return mkfailure<int>("Missing code parameter");
-
- // Lookup client app configuration
- const list<value> app = assoc<value>(cadr(cid), appkeys);
- if (isNil(app) || isNil(cdr(app)))
- return mkfailure<int>(string("client id not found: ") + cadr(cid));
- list<value> appkey = cadr(app);
-
- // Build the redirect URI
- const string redir = httpd::url("/oauth2/access_token/", r);
- debug(redir, "modoauth2::access_token::redir");
-
- // Request access token
- const list<list<value> > targs = mklist<list<value> >(mklist<value>("client_id", car(appkey)), mklist<value>("redirect_uri", httpd::escape(redir)), mklist<value>("client_secret", cadr(appkey)), code, mklist<value>("grant_type", "authorization_code"));
- const string tqs = http::queryString(targs);
- debug(tqs, "modoauth2::access_token::tokenqs");
- const string turi = httpd::unescape(cadr(tok));
- debug(turi, "modoauth2::access_token::tokenuri");
- const value tval = mklist<value>(string("application/x-www-form-urlencoded;charset=UTF-8"), mklist<value>(tqs));
- const failable<value> ftr = http::post(tval, turi, *(cs));
- if (!hasContent(ftr))
- return mkfailure<int>(ftr);
- const value tr = content(ftr);
- debug(tr, "modoauth2::access_token::response");
- if (!isList(tr) || isNil(tr))
- return mkfailure<int>("Empty access token");
- const list<value> tv = isString(car<value>(tr)) ?
- assoc<value>("access_token", httpd::queryArgs(join("", convertValues<string>(cadr<value>(tr))))) :
- assoc<value>("access_token", tr);
- if (isNil(tv) || isNil(cdr(tv)))
- return mkfailure<int>("Couldn't retrieve access_token");
- debug(tv, "modoauth2::access_token::token");
-
- // Request user info
- // TODO Make this step configurable
- const list<list<value> > iargs = mklist<list<value> >(tv);
- const string iuri = httpd::unescape(cadr(info)) + string("?") + http::queryString(iargs);
- debug(iuri, "modoauth2::access_token::infouri");
- const failable<value> profres = http::get(iuri, *(cs));
- if (!hasContent(profres))
- return mkfailure<int>("Couldn't retrieve user info");
- debug(content(profres), "modoauth2::access_token::info");
-
- // Retrieve the user info from the profile
- const failable<list<value> > userinfo = profileUserInfo(cadr(cid), content(profres));
- if (!hasContent(userinfo))
- return mkfailure<int>(userinfo);
-
- // Validate the authenticated user
- const failable<int> authrc = authenticated(content(userinfo), true, r, scopeattrs, apcs);
- if (!hasContent(authrc))
- return authrc;
-
- // Store user info in memcached keyed by a session ID
- const value sid = string("OAuth2_") + mkrand();
- const failable<bool> prc = memcache::put(mklist<value>("tuscanyOAuth2", sid), content(userinfo), mc);
- if (!hasContent(prc))
- return mkfailure<int>(prc);
-
- // Send the session ID to the client in a cookie
- debug(c_str(openauth::cookie("TuscanyOAuth2", sid, httpd::hostName(r))), "modoauth2::access_token::setcookie");
- apr_table_set(r->err_headers_out, "Set-Cookie", c_str(openauth::cookie("TuscanyOAuth2", sid, httpd::hostName(r))));
- return httpd::externalRedirect(httpd::url(httpd::unescape(cadr(ref)), r), r);
-}
-
-/**
- * Check user authentication.
- */
-static int checkAuthn(request_rec *r) {
- gc_scoped_pool pool(r->pool);
-
- // Decline if we're not enabled or AuthType is not set to Open
- const DirConf& dc = httpd::dirConf<DirConf>(r, &mod_tuscany_oauth2);
- if (!dc.enabled)
- return DECLINED;
- const char* atype = ap_auth_type(r);
- if (atype == NULL || strcasecmp(atype, "Open"))
- return DECLINED;
- debug_httpdRequest(r, "modoauth2::checkAuthn::input");
- debug(atype, "modopenauth::checkAuthn::auth_type");
-
- // Get the server configuration
- const ServerConf& sc = httpd::serverConf<ServerConf>(r, &mod_tuscany_oauth2);
-
- // Get session id from the request
- const maybe<string> sid = openauth::sessionID(r, "TuscanyOAuth2");
- if (hasContent(sid)) {
- // Decline if the session id was not created by this module
- if (substr(content(sid), 0, 7) != "OAuth2_")
- return DECLINED;
-
- // Extract the user info from the auth session
- const failable<value> userinfo = userInfo(content(sid), sc.mc);
- if (!hasContent(userinfo))
- return httpd::reportStatus(mkfailure<int>(userinfo));
- r->ap_auth_type = const_cast<char*>(atype);
- return httpd::reportStatus(authenticated(content(userinfo), false, r, dc.scopeattrs, dc.apcs));
- }
-
- // Get the request args
- const list<list<value> > args = httpd::queryArgs(r);
-
- // Handle OAuth authorize request step
- if (string(r->uri) == "/oauth2/authorize/") {
- r->ap_auth_type = const_cast<char*>(atype);
- return httpd::reportStatus(authorize(args, r, sc.appkeys));
- }
-
- // Handle OAuth access_token request step
- if (string(r->uri) == "/oauth2/access_token/") {
- r->ap_auth_type = const_cast<char*>(atype);
- const failable<int> authrc = accessToken(args, r, sc.appkeys, sc.cs, dc.scopeattrs, dc.apcs, sc.mc);
-
- // Redirect to the login page if user is not authorized
- if (!hasContent(authrc) && rcode(authrc) == HTTP_UNAUTHORIZED)
- return httpd::reportStatus(openauth::login(dc.login, string("/"), 1, r));
-
- return httpd::reportStatus(authrc);
- }
-
- // Redirect to the login page, unless we have a session id or an authorization
- // header from another module
- if (apr_table_get(r->headers_in, (PROXYREQ_PROXY == r->proxyreq) ? "Proxy-Authorization" : "Authorization") != NULL)
- return DECLINED;
- if (hasContent(openauth::sessionID(r, "TuscanyOpenIDAuth")) ||
- hasContent(openauth::sessionID(r, "TuscanyOpenAuth")) ||
- hasContent(openauth::sessionID(r, "TuscanyOAuth1")))
- return DECLINED;
- if ((substr(string(r->uri), 0, 8) == "/oauth1/") || !isNil(assoc<value>("openid_identifier", args)))
- return DECLINED;
-
- r->ap_auth_type = const_cast<char*>(atype);
- return httpd::reportStatus(openauth::login(dc.login, value(), value(), r));
-}
-
-/**
- * Process the module configuration.
- */
-int postConfigMerge(ServerConf& mainsc, server_rec* s) {
- if (s == NULL)
- return OK;
- ServerConf& sc = httpd::serverConf<ServerConf>(s, &mod_tuscany_oauth2);
- debug(httpd::serverName(s), "modoauth2::postConfigMerge::serverName");
-
- // Merge configuration from main server
- if (isNil(sc.appkeys))
- sc.appkeys = mainsc.appkeys;
- if (isNil(sc.mcaddrs))
- sc.mcaddrs = mainsc.mcaddrs;
- sc.mc = mainsc.mc;
- sc.cs = mainsc.cs;
-
- return postConfigMerge(mainsc, s->next);
-}
-
-int postConfig(apr_pool_t* p, unused apr_pool_t* plog, unused apr_pool_t* ptemp, server_rec* s) {
- gc_scoped_pool pool(p);
-
- ServerConf& sc = httpd::serverConf<ServerConf>(s, &mod_tuscany_oauth2);
- debug(httpd::serverName(s), "modoauth2::postConfig::serverName");
-
- // Merge server configurations
- return postConfigMerge(sc, s);
-}
-
-/**
- * Lambda function that creates a new CURL session.
- */
-class newsession {
-public:
- newsession(const string& ca, const string& cert, const string& key) : ca(ca), cert(cert), key(key) {
- }
-
- const gc_ptr<http::CURLSession> operator()() const {
- return new (gc_new<http::CURLSession>()) http::CURLSession(ca, cert, key, "", 0);
- }
-
-private:
- const string ca;
- const string cert;
- const string key;
-};
-
-/**
- * Child process initialization.
- */
-void childInit(apr_pool_t* p, server_rec* s) {
- gc_scoped_pool pool(p);
-
- ServerConf* psc = (ServerConf*)ap_get_module_config(s->module_config, &mod_tuscany_oauth2);
- if(psc == NULL) {
- cfailure << "[Tuscany] Due to one or more errors mod_tuscany_oauth2 loading failed. Causing apache to stop loading." << endl;
- exit(APEXIT_CHILDFATAL);
- }
- ServerConf& sc = *psc;
-
- // Connect to Memcached
- if (isNil(sc.mcaddrs))
- sc.mc = *(new (gc_new<memcache::MemCached>()) memcache::MemCached("localhost", 11211));
- else
- sc.mc = *(new (gc_new<memcache::MemCached>()) memcache::MemCached(sc.mcaddrs));
-
- // Setup a CURL session
- sc.cs = perthread_ptr<http::CURLSession>(lambda<gc_ptr<http::CURLSession>()>(newsession(sc.ca, sc.cert, sc.key)));
-
- // Merge the updated configuration into the virtual hosts
- postConfigMerge(sc, s->next);
-}
-
-/**
- * Configuration commands.
- */
-const char* confAppKey(cmd_parms *cmd, unused void *c, const char *arg1, const char* arg2, const char* arg3) {
- gc_scoped_pool pool(cmd->pool);
- ServerConf& sc = httpd::serverConf<ServerConf>(cmd, &mod_tuscany_oauth2);
- sc.appkeys = cons<list<value> >(mklist<value>(arg1, mklist<value>(arg2, arg3)), sc.appkeys);
- return NULL;
-}
-const char* confMemcached(cmd_parms *cmd, unused void *c, const char *arg) {
- gc_scoped_pool pool(cmd->pool);
- ServerConf& sc = httpd::serverConf<ServerConf>(cmd, &mod_tuscany_oauth2);
- sc.mcaddrs = cons<string>(arg, sc.mcaddrs);
- return NULL;
-}
-const char* confEnabled(cmd_parms *cmd, void *c, const int arg) {
- gc_scoped_pool pool(cmd->pool);
- DirConf& dc = httpd::dirConf<DirConf>(c);
- dc.enabled = (bool)arg;
- return NULL;
-}
-const char* confLogin(cmd_parms *cmd, void *c, const char* arg) {
- gc_scoped_pool pool(cmd->pool);
- DirConf& dc = httpd::dirConf<DirConf>(c);
- dc.login = arg;
- return NULL;
-}
-const char* confCAFile(cmd_parms *cmd, unused void *c, const char *arg) {
- gc_scoped_pool pool(cmd->pool);
- ServerConf& sc = httpd::serverConf<ServerConf>(cmd, &mod_tuscany_oauth2);
- sc.ca = arg;
- return NULL;
-}
-const char* confCertFile(cmd_parms *cmd, unused void *c, const char *arg) {
- gc_scoped_pool pool(cmd->pool);
- ServerConf& sc = httpd::serverConf<ServerConf>(cmd, &mod_tuscany_oauth2);
- sc.cert = arg;
- return NULL;
-}
-const char* confCertKeyFile(cmd_parms *cmd, unused void *c, const char *arg) {
- gc_scoped_pool pool(cmd->pool);
- ServerConf& sc = httpd::serverConf<ServerConf>(cmd, &mod_tuscany_oauth2);
- sc.key = arg;
- return NULL;
-}
-const char* confScopeAttr(cmd_parms *cmd, void* c, const char* arg1, const char* arg2) {
- gc_scoped_pool pool(cmd->pool);
- DirConf& dc = httpd::dirConf<DirConf>(c);
- dc.scopeattrs = cons<list<value> >(mklist<value>(arg1, arg2), dc.scopeattrs);
- return NULL;
-}
-const char* confAuthnProvider(cmd_parms *cmd, void *c, const char* arg) {
- gc_scoped_pool pool(cmd->pool);
- DirConf& dc = httpd::dirConf<DirConf>(c);
-
- // Lookup and cache the Authn provider
- const authn_provider* provider = (authn_provider*)ap_lookup_provider(AUTHN_PROVIDER_GROUP, arg, AUTHN_PROVIDER_VERSION);
- if (provider == NULL)
- return apr_psprintf(cmd->pool, "Unknown Authn provider: %s", arg);
- if (!provider->check_password)
- return apr_psprintf(cmd->pool, "The '%s' Authn provider doesn't support password authentication", arg);
- dc.apcs = append<AuthnProviderConf>(dc.apcs, mklist<AuthnProviderConf>(AuthnProviderConf(arg, provider)));
- return NULL;
-}
-
-/**
- * HTTP server module declaration.
- */
-const command_rec commands[] = {
- AP_INIT_ITERATE("AuthOAuthProvider", (const char*(*)())confAuthnProvider, NULL, OR_AUTHCFG, "Auth providers for a directory or location"),
- AP_INIT_TAKE3("AddAuthOAuth2AppKey", (const char*(*)())confAppKey, NULL, RSRC_CONF, "OAuth 2.0 name app-id app-key"),
- AP_INIT_ITERATE("AddAuthOAuthMemcached", (const char*(*)())confMemcached, NULL, RSRC_CONF, "Memcached server host:port"),
- AP_INIT_FLAG("AuthOAuth", (const char*(*)())confEnabled, NULL, OR_AUTHCFG, "OAuth 2.0 authentication On | Off"),
- AP_INIT_TAKE1("AuthOAuthLoginPage", (const char*(*)())confLogin, NULL, OR_AUTHCFG, "OAuth 2.0 login page"),
- AP_INIT_TAKE1("AuthOAuthSSLCACertificateFile", (const char*(*)())confCAFile, NULL, RSRC_CONF, "OAUth 2.0 SSL CA certificate file"),
- AP_INIT_TAKE1("AuthOAuthSSLCertificateFile", (const char*(*)())confCertFile, NULL, RSRC_CONF, "OAuth 2.0 SSL certificate file"),
- AP_INIT_TAKE1("AuthOAuthSSLCertificateKeyFile", (const char*(*)())confCertKeyFile, NULL, RSRC_CONF, "OAuth 2.0 SSL certificate key file"),
- AP_INIT_TAKE2("AddAuthOAuth2ScopeAttr", (const char*(*)())confScopeAttr, NULL, OR_AUTHCFG, "OAuth 2.0 scope attribute"),
- {NULL, NULL, NULL, 0, NO_ARGS, NULL}
-};
-
-void registerHooks(unused apr_pool_t *p) {
- ap_hook_post_config(postConfig, NULL, NULL, APR_HOOK_MIDDLE);
- ap_hook_child_init(childInit, NULL, NULL, APR_HOOK_MIDDLE);
- ap_hook_check_authn(checkAuthn, NULL, NULL, APR_HOOK_MIDDLE, AP_AUTH_INTERNAL_PER_CONF);
-}
-
-}
-}
-
-extern "C" {
-
-module AP_MODULE_DECLARE_DATA mod_tuscany_oauth2 = {
- STANDARD20_MODULE_STUFF,
- // dir config and merger
- tuscany::httpd::makeDirConf<tuscany::oauth2::DirConf>, NULL,
- // server config and merger
- tuscany::httpd::makeServerConf<tuscany::oauth2::ServerConf>, NULL,
- // commands and hooks
- tuscany::oauth2::commands, tuscany::oauth2::registerHooks
-};
-
-}
diff --git a/modules/oauth/oauth-conf b/modules/oauth/oauth-conf
deleted file mode 100755
index 26e6540..0000000
--- a/modules/oauth/oauth-conf
+++ /dev/null
@@ -1,108 +0,0 @@
-#!/bin/sh
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Generate an OAuth server conf
-here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here`
-mkdir -p $1
-root=`echo "import os; print os.path.realpath('$1')" | python`
-
-uname=`uname -s`
-if [ $uname = "Darwin" ]; then
- libsuffix=".dylib"
-else
- libsuffix=".so"
-fi
-
-conf=`cat $root/conf/httpd.conf | grep "# Generated by: httpd-conf"`
-host=`echo $conf | awk '{ print $6 }'`
-
-sslconf=`cat $root/conf/httpd.conf | grep "# Generated by: httpd-ssl-conf"`
-if [ "$sslconf" = "" ]; then
- sslsuffix=""
-else
- sslsuffix="-ssl"
-fi
-
-if [ "$2" = "" ]; then
- providers="file"
-else
- providers="$2 file"
-fi
-
-# Configure HTTPD mod_tuscany_oauth module
-cat >>$root/conf/modules.conf <<EOF
-# Generated by: oauth-conf $*
-# Load support for OAuth authentication
-LoadModule mod_tuscany_oauth2 $here/libmod_tuscany_oauth2$libsuffix
-
-EOF
-
-# Disallow public access to server resources
-cat >$root/conf/noauth$sslsuffix.conf <<EOF
-# Generated by: oauth-conf $*
-# Disallow public access to server resources
-
-EOF
-
-# Configure OAuth authentication
-cat >>$root/conf/locauth$sslsuffix.conf <<EOF
-# Generated by: oauth-conf $*
-# Enable OAuth authentication
-<Location />
-AuthType Open
-AuthName "$host"
-AuthOAuthProvider socache $providers
-AuthnCacheProvideFor $providers
-AuthnCacheContext /
-Require valid-user
-AuthOAuth On
-AuthOAuthLoginPage /login/
-AddAuthOAuth2ScopeAttr REALM realm
-AddAuthOAuth2ScopeAttr REMOTE_USER email
-AddAuthOAuth2ScopeAttr EMAIL email
-AddAuthOAuth2ScopeAttr NICKNAME name
-AddAuthOAuth2ScopeAttr FULLNAME name
-AddAuthOAuth2ScopeAttr FIRSTNAME first_name
-AddAuthOAuth2ScopeAttr LASTNAME last_name
-AddAuthOAuth2ScopeAttr FULLNAME name
-</Location>
-
-EOF
-
-cat >>$root/conf/auth.conf <<EOF
-# Configure OAuth App keys
-Include $root/cert/oauth-keys.conf
-
-EOF
-
-mkdir -p $root/cert
-cat >$root/cert/oauth-keys.conf <<EOF
-# Generated by: oauth-conf $*
-# OAuth App keys
-
-EOF
-
-if [ -d "$HOME/.oauth" ]; then
- cat >>$root/conf/auth.conf <<EOF
-# Configure OAuth App keys
-Include $HOME/.oauth/*-key.conf
-
-EOF
-fi
-
diff --git a/modules/oauth/oauth-memcached-conf b/modules/oauth/oauth-memcached-conf
deleted file mode 100755
index 0f5196b..0000000
--- a/modules/oauth/oauth-memcached-conf
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/bin/sh
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here`
-mkdir -p $1
-root=`echo "import os; print os.path.realpath('$1')" | python`
-host=$2
-port=$3
-
-sslconf=`cat $root/conf/httpd.conf | grep "# Generated by: httpd-ssl-conf"`
-if [ "$sslconf" = "" ]; then
- sslsuffix=""
-else
- sslsuffix="-ssl"
-fi
-
-# Configure HTTPD mod_tuscany_oauth module cache
-cat >>$root/conf/auth.conf <<EOF
-# Generated by: oauth-memcached-conf $*
-AddAuthOAuthMemcached $host:$port
-
-EOF
-
diff --git a/modules/oauth/oauth.composite b/modules/oauth/oauth.composite
deleted file mode 100644
index 1c30de7..0000000
--- a/modules/oauth/oauth.composite
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
--->
-<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
- targetNamespace="http://tuscany.apache.org/xmlns/sca/components"
- name="oauth">
-
- <component name="Protected">
- <implementation.widget location="protected/index.html"/>
- <reference name="userInfo" target="UserInfo"/>
- </component>
-
- <component name="UserInfo">
- <implementation.scheme script="user-info.scm"/>
- <service name="info">
- <binding.jsonrpc uri="info"/>
- </service>
- <property name="user">?</property>
- <property name="email">?</property>
- <property name="nickname">?</property>
- <property name="fullname">?</property>
- <property name="firstname">?</property>
- <property name="lastname">?</property>
- <property name="realm">?</property>
- </component>
-
-</composite>
diff --git a/modules/oauth/oauth1-appkey-conf b/modules/oauth/oauth1-appkey-conf
deleted file mode 100755
index 67b02ad..0000000
--- a/modules/oauth/oauth1-appkey-conf
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/sh
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here`
-mkdir -p $1
-root=`echo "import os; print os.path.realpath('$1')" | python`
-name=$2
-id=$3
-secret=$4
-
-# Configure an OAuth 1.0 app key
-mkdir -p $root/cert
-umask 0007
-
-cat >>$root/cert/oauth-keys.conf <<EOF
-# Generated by: oauth1-appkey-conf $*
-AddAuthOAuth1AppKey $name $id $secret
-
-EOF
-
diff --git a/modules/oauth/oauth12-conf b/modules/oauth/oauth12-conf
deleted file mode 100755
index 43c879f..0000000
--- a/modules/oauth/oauth12-conf
+++ /dev/null
@@ -1,115 +0,0 @@
-#!/bin/sh
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Generate an OAuth server conf
-here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here`
-mkdir -p $1
-root=`echo "import os; print os.path.realpath('$1')" | python`
-
-uname=`uname -s`
-if [ $uname = "Darwin" ]; then
- libsuffix=".dylib"
-else
- libsuffix=".so"
-fi
-
-conf=`cat $root/conf/httpd.conf | grep "# Generated by: httpd-conf"`
-host=`echo $conf | awk '{ print $6 }'`
-
-sslconf=`cat $root/conf/httpd.conf | grep "# Generated by: httpd-ssl-conf"`
-if [ "$sslconf" = "" ]; then
- sslsuffix=""
-else
- sslsuffix="-ssl"
-fi
-
-if [ "$2" = "" ]; then
- providers="file"
-else
- providers="$2 file"
-fi
-
-# Configure HTTPD mod_tuscany_oauth module
-cat >>$root/conf/modules.conf <<EOF
-# Generated by: oauth12-conf $*
-# Load support for OAuth authentication
-LoadModule mod_tuscany_oauth1 $here/libmod_tuscany_oauth1$libsuffix
-LoadModule mod_tuscany_oauth2 $here/libmod_tuscany_oauth2$libsuffix
-
-EOF
-
-# Disallow public access to server resources
-cat >$root/conf/noauth$sslsuffix.conf <<EOF
-# Generated by: oauth12-conf $*
-# Disallow public access to server resources
-
-EOF
-
-# Configure OAuth authentication
-cat >>$root/conf/locauth$sslsuffix.conf <<EOF
-# Generated by: oauth12-conf $*
-# Enable OAuth authentication
-<Location />
-AuthType Open
-AuthName "$host"
-AuthOAuthProvider socache $providers
-AuthnCacheProvideFor $providers
-AuthnCacheContext /
-Require valid-user
-AuthOAuth On
-AuthOAuthLoginPage /login/
-AddAuthOAuth2ScopeAttr REALM realm
-AddAuthOAuth2ScopeAttr REMOTE_USER email
-AddAuthOAuth2ScopeAttr EMAIL email
-AddAuthOAuth2ScopeAttr NICKNAME name
-AddAuthOAuth2ScopeAttr FULLNAME name
-AddAuthOAuth2ScopeAttr FIRSTNAME first_name
-AddAuthOAuth2ScopeAttr LASTNAME last_name
-AddAuthOAuth1ScopeAttr REALM realm
-AddAuthOAuth1ScopeAttr REMOTE_USER email
-AddAuthOAuth1ScopeAttr EMAIL email
-AddAuthOAuth1ScopeAttr NICKNAME screen_name
-AddAuthOAuth2ScopeAttr FULLNAME name
-AddAuthOAuth1ScopeAttr FIRSTNAME first-name
-AddAuthOAuth1ScopeAttr LASTNAME last-name
-</Location>
-
-EOF
-
-cat >>$root/conf/auth.conf <<EOF
-# Configure OAuth App keys
-Include $root/cert/oauth-keys.conf
-
-EOF
-
-mkdir -p $root/cert
-cat >$root/cert/oauth-keys.conf <<EOF
-# Generated by: oauth12-conf $*
-# OAuth App keys
-
-EOF
-
-if [ -d "$HOME/.oauth" ]; then
- cat >>$root/conf/auth.conf <<EOF
-# Configure OAuth App keys
-Include $HOME/.oauth/*-key.conf
-
-EOF
-fi
-
diff --git a/modules/oauth/oauth2-appkey-conf b/modules/oauth/oauth2-appkey-conf
deleted file mode 100755
index 0d67e6f..0000000
--- a/modules/oauth/oauth2-appkey-conf
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/sh
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here`
-mkdir -p $1
-root=`echo "import os; print os.path.realpath('$1')" | python`
-name=$2
-id=$3
-secret=$4
-
-# Configure an OAuth 2.0 app key
-mkdir -p $root/cert
-umask 0007
-
-cat >>$root/cert/oauth-keys.conf <<EOF
-# Generated by: oauth2-appkey-conf $*
-AddAuthOAuth2AppKey $name $id $secret
-
-EOF
-
diff --git a/modules/oauth/start-mixed-test b/modules/oauth/start-mixed-test
deleted file mode 100755
index 478f2cc..0000000
--- a/modules/oauth/start-mixed-test
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/bin/sh
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# For this module to work, add the www.example.com domain to your /etc/hosts as follows:
-# 127.0.0.1 www.example.com
-
-# Test supporting both OpenID and OAuth in the same app
-here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here`
-
-# Setup
-rm -rf tmp
-../../components/cache/memcached-start tmp 11212
-../../components/cache/memcached-start tmp 11213
-
-../../modules/http/ssl-ca-conf tmp www.example.com
-../../modules/http/ssl-cert-conf tmp www.example.com
-../../modules/http/httpd-conf tmp www.example.com 8090 htdocs
-../../modules/http/httpd-ssl-conf tmp 8453
-
-../openid/openid-conf tmp
-../openid/openid-step2-conf tmp
-../openid/openid-memcached-conf tmp www.example.com 11212
-../openid/openid-memcached-conf tmp www.example.com 11213
-
-./oauth12-conf tmp
-./oauth-memcached-conf tmp www.example.com 11212
-./oauth-memcached-conf tmp www.example.com 11213
-
-# Configure your app keys here
-./oauth1-appkey-conf tmp twitter.com app2345 secret7890
-./oauth1-appkey-conf tmp linkedin.com app3456 secret4567
-./oauth2-appkey-conf tmp facebook.com app1234 secret6789
-./oauth2-appkey-conf tmp github.com app5678 secret8901
-
-../../modules/http/open-auth-conf tmp
-
-# For this test to work you need to add your oauth and openid user ids to
-# the password file with a dummy 'password' password, and to the group
-# of authorized users
-../../modules/http/passwd-auth-conf tmp foo foo
-../../modules/http/group-auth-conf tmp foo
-../../modules/http/passwd-auth-conf tmp /openid/123456 password
-../../modules/http/group-auth-conf tmp 123456
-../../modules/http/passwd-auth-conf tmp /oauth2/jane@example.com password
-../../modules/http/group-auth-conf tmp jane@example.com
-
-../../modules/server/server-conf tmp
-../../modules/server/scheme-conf tmp
-cat >>tmp/conf/httpd.conf <<EOF
-SCAContribution `pwd`/
-SCAComposite oauth.composite
-
-Alias /login/index.html $here/htdocs/login/mixed.html
-
-EOF
-
-../../modules/http/httpd-start tmp
-
diff --git a/modules/oauth/start-test b/modules/oauth/start-test
deleted file mode 100755
index cadbed2..0000000
--- a/modules/oauth/start-test
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/bin/sh
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# For this module to work, add the www.example.com domain to your /etc/hosts as follows:
-# 127.0.0.1 www.example.com
-
-# Setup
-rm -rf tmp
-#../../ubuntu/ip-redirect-all 80 8090
-#../../ubuntu/ip-redirect-all 443 8453
-
-../../components/cache/memcached-start tmp 11212
-../../components/cache/memcached-start tmp 11213
-
-../../modules/http/ssl-ca-conf tmp www.example.com
-../../modules/http/ssl-cert-conf tmp www.example.com
-../../modules/http/httpd-conf tmp www.example.com 8090 htdocs
-../../modules/http/httpd-ssl-conf tmp 8453
-
-./oauth12-conf tmp
-./oauth-memcached-conf tmp www.example.com 11212
-./oauth-memcached-conf tmp www.example.com 11213
-
-# Configure your app keys here
-./oauth1-appkey-conf tmp twitter.com app2345 secret7890
-./oauth1-appkey-conf tmp linkedin.com app3456 secret4567
-./oauth2-appkey-conf tmp facebook.com app1234 secret6789
-./oauth2-appkey-conf tmp github.com app5678 secret8901
-
-# For this test to work you need to add your oauth user id to the
-# password file with a dummy 'password' password, and to the group
-# of authorized users
-../../modules/http/passwd-auth-conf tmp /oauth2/jane@example.com password
-../../modules/http/group-auth-conf tmp jane@example.com
-
-../../modules/server/server-conf tmp
-../../modules/server/scheme-conf tmp
-cat >>tmp/conf/httpd.conf <<EOF
-SCAContribution `pwd`/
-SCAComposite oauth.composite
-EOF
-
-../../modules/http/httpd-start tmp
-
diff --git a/modules/oauth/stop-test b/modules/oauth/stop-test
deleted file mode 100755
index 4b8a73e..0000000
--- a/modules/oauth/stop-test
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/sh
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Cleanup
-../../modules/http/httpd-stop tmp
-
-../../components/cache/memcached-stop tmp 11212
-../../components/cache/memcached-stop tmp 11213
diff --git a/modules/oauth/user-info.scm b/modules/oauth/user-info.scm
deleted file mode 100644
index 4960a0a..0000000
--- a/modules/oauth/user-info.scm
+++ /dev/null
@@ -1,36 +0,0 @@
-; Licensed to the Apache Software Foundation (ASF) under one
-; or more contributor license agreements. See the NOTICE file
-; distributed with this work for additional information
-; regarding copyright ownership. The ASF licenses this file
-; to you under the Apache License, Version 2.0 (the
-; "License"); you may not use this file except in compliance
-; with the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing,
-; software distributed under the License is distributed on an
-; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-; KIND, either express or implied. See the License for the
-; specific language governing permissions and limitations
-; under the License.
-
-; OAuth support test case
-
-(define (get id user email nickname fullname firstname lastname realm) (list "text/html" (list
- "<html><body><p>The following info is generated on the server:</p><div>User: " (user) "</div><div>Email: " (email) "</div><div>Nickname: " (nickname) "</div><div>Fullname: " (fullname) "</div><div>Firstname: " (firstname) "</div><div>Lastname: " (lastname) "</div><div>Realm: " (realm) "</div></body></html>")))
-
-(define (getuser user email nickname fullname firstname lastname realm) (user))
-
-(define (getemail user email nickname fullname firstname lastname realm) (email))
-
-(define (getnickname user email nickname fullname firstname lastname realm) (nickname))
-
-(define (getfullname user email nickname fullname firstname lastname realm) (fullname))
-
-(define (getfirstname user email nickname fullname firstname lastname realm) (firstname))
-
-(define (getlastname user email nickname fullname firstname lastname realm) (lastname))
-
-(define (getrealm user email nickname fullname firstname lastname realm) (realm))
-
diff --git a/modules/openid/Makefile.am b/modules/openid/Makefile.am
deleted file mode 100644
index a46dd56..0000000
--- a/modules/openid/Makefile.am
+++ /dev/null
@@ -1,32 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-
-if WANT_OPENID
-
-dist_mod_SCRIPTS = openid-conf openid-step2-conf openid-memcached-conf
-moddir = $(prefix)/modules/openid
-
-mod_DATA = openid.prefix
-openid.prefix: $(top_builddir)/config.status
- echo ${MODAUTHOPENID_PREFIX} >openid.prefix
-
-EXTRA_DIST = openid.composite user-info.scm htdocs/index.html htdocs/login/index.html htdocs/logout/index.html htdocs/public/index.html
-
-dist_noinst_SCRIPTS = start-test stop-test
-
-endif
diff --git a/modules/openid/htdocs/index.html b/modules/openid/htdocs/index.html
deleted file mode 100644
index e5b1618..0000000
--- a/modules/openid/htdocs/index.html
+++ /dev/null
@@ -1,57 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-
-<html>
-<head>
-<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0"/>
-<meta name="apple-mobile-web-app-capable" content="yes"/>
-<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
-<link rel="stylesheet" type="text/css" href="/ui-min.css"/>
-<script type="text/javascript" src="/all-min.js"></script>
-
-<script type="text/javascript">
-var protected = sca.component("Protected");
-var userInfo = sca.defun(sca.reference(protected, "userInfo"), "getuser", "getemail", "getrealm");
-var user = userInfo.getuser();
-var email = userInfo.getemail();
-var realm = userInfo.getrealm();
-</script>
-
-<title>Protected area</title>
-</head>
-
-<body>
-<h1>Protected area - It works!</h1>
-<p>The following info is returned by a JSONRPC service:</p>
-<div id="user"></div>
-<div id="email"></div>
-<div id="realm"></div>
-
-<script type="text/javascript">
-document.getElementById('user').innerHTML="User: " + user;
-document.getElementById('email').innerHTML="Email: " + email;
-document.getElementById('realm').innerHTML="Realm: " + realm;
-</script>
-
-<p><a href="info">User info</a></p>
-<p><a href="login">Sign in</a></p>
-<p><a href="logout">Sign out</a></p>
-<p><a href="public">Public area</a></p>
-</body>
-</html>
diff --git a/modules/openid/htdocs/login/index.html b/modules/openid/htdocs/login/index.html
deleted file mode 100644
index 00b0bfd..0000000
--- a/modules/openid/htdocs/login/index.html
+++ /dev/null
@@ -1,148 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-
-<html>
-<head>
-<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0"/>
-<meta name="apple-mobile-web-app-capable" content="yes"/>
-<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
-<link rel="stylesheet" type="text/css" href="/ui-min.css"/>
-<title>Sign in</title>
-</head>
-<body>
-<h1>Sign in with an OpenID provider</h1>
-<br/>
-
-<script type="text/javascript">
-function queryParams() {
- qp = new Array();
- qs = window.location.search.substring(1).split('&');
- for (i = 0; i < qs.length; i++) {
- e = qs[i].indexOf('=');
- if (e > 0)
- qp[qs[i].substring(0, e)] = unescape(qs[i].substring(e + 1));
- }
- return qp;
-}
-
-function openidReferrer() {
- r = queryParams()['openauth_referrer'];
- if (typeof(r) == 'undefined')
- return r;
- q = r.indexOf('?');
- if (q > 0)
- return r.substring(0, q);
- return r;
-}
-
-if (typeof(openidReferrer()) == 'undefined') {
- document.location = '/';
-}
-
-function clearauthcookie() {
- document.cookie = 'TuscanyOpenAuth=; expires=' + new Date(1970,01,01).toGMTString() + '; domain=.' + domainname(window.location.hostname) + '; path=/';
- document.cookie = 'TuscanyOAuth1=; expires=' + new Date(1970,01,01).toGMTString() + '; domain=.' + domainname(window.location.hostname) + '; path=/';
- document.cookie = 'TuscanyOAuth2=; expires=' + new Date(1970,01,01).toGMTString() + '; domain=.' + domainname(window.location.hostname) + '; path=/';
- document.cookie = 'TuscanyOpenIDAuth=; expires=' + new Date(1970,01,01).toGMTString() + '; domain=.' + domainname(window.location.hostname) + '; path=/';
- return true;
-}
-
-function submitSignin(w) {
- clearauthcookie();
- document.signin.openid_identifier.value = w();
- document.signin.action = openidReferrer();
- document.signin.submit();
-}
-
-
-function withGoogle() {
- return 'https://www.google.com/accounts/o8/id';
-}
-
-function withYahoo() {
- return 'https://me.yahoo.com/';
-}
-
-function withMyOpenID() {
- return 'http://www.myopenid.com/xrds';
-}
-
-function withVerisign() {
- return 'https://pip.verisignlabs.com/';
-}
-
-function withMySpace() {
- return 'https://api.myspace.com/openid';
-}
-
-function withGoogleApps() {
- return 'https://www.google.com/accounts/o8/site-xrds?ns=2&hd=' + document.fields.domain.value;
-}
-
-function withLivejournal() {
- return 'http://' + document.fields.ljuser.value + '.livejournal.com';
-}
-
-function withBlogspot() {
- return 'http://' + document.fields.bsuser.value + '.blogspot.com';
-}
-
-function withBlogger() {
- return 'http://' + document.fields.bguser.value + '.blogger.com';
-}
-
-function withXRDSEndpoint() {
- return document.fields.endpoint.value;
-}
-</script>
-
-<form name="signin" action="/" method="GET">
-<input type="hidden" name="openid_identifier" value="https://www.google.com/accounts/o8/id"/>
-</form>
-
-<form name="fields">
-<p>Sign in with your Google account<br/><input type="button" onclick="submitSignin(withGoogle)" value="Sign in"/></p>
-<p>Sign in with your Yahoo account<br/><input type="button" onclick="submitSignin(withYahoo)" value="Sign in"/></p>
-<p>Sign in with your MyOpenID account<br/><input type="button" onclick="submitSignin(withMyOpenID)" value="Sign in"/></p>
-<p>Sign in with your Verisign account<br/><input type="button" onclick="submitSignin(withVerisign)" value="Sign in"/></p>
-<p>Sign in with your MySpace account<br/><input type="button" onclick="submitSignin(withMySpace)" value="Sign in"/></p>
-
-<p>Sign in with a Google apps domain<br/>
-<input type="text" size="20" name="domain" value="example.com"/><br/>
-<input type="button" onclick="submitSignin(withGoogleApps)" value="Sign in"/></p>
-
-<p>Sign in with your Livejournal account<br/>
-<input type="text" size="10" name="ljuser" value=""/><br/>
-<input type="button" onclick="submitSignin(withLivejournal)" value="Sign in"/></p>
-
-<p>Sign in with your Blogspot account<br/>
-<input type="text" size="10" name="bsuser" value=""/><br/>
-<input type="button" onclick="submitSignin(withBlogspot)" value="Sign in"/></p>
-
-<p>Sign in with your Blogger account<br/>
-<input type="text" size="10" name="bguser" value=""/><br/>
-<input type="button" onclick="submitSignin(withBlogger)" value="Sign in"/></p>
-
-<p>Sign in with an OpenID endpoint<br/>
-<input type="text" size="50" name="endpoint" value="https://www.google.com/accounts/o8/id"/><br/>
-<input type="button" onclick="submitSignin(withXRDSEndpoint)" value="Sign in"/></p>
-</form>
-
-</body>
-</html>
diff --git a/modules/openid/htdocs/logout/index.html b/modules/openid/htdocs/logout/index.html
deleted file mode 100644
index 8cf7860..0000000
--- a/modules/openid/htdocs/logout/index.html
+++ /dev/null
@@ -1,51 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-
-<html>
-<head>
-<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0"/>
-<meta name="apple-mobile-web-app-capable" content="yes"/>
-<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
-<link rel="stylesheet" type="text/css" href="/ui-min.css"/>
-<title>Sign out</title>
-</head>
-<body>
-<h1>Sign out</h1>
-<br/>
-
-<form name="signout" action="/login" method="GET">
-<script type="text/javascript">
-function clearauthcookie() {
- document.cookie = 'TuscanyOpenAuth=; expires=' + new Date(1970,01,01).toGMTString() + '; domain=.' + domainname(window.location.hostname) + '; path=/';
- document.cookie = 'TuscanyOAuth1=; expires=' + new Date(1970,01,01).toGMTString() + '; domain=.' + domainname(window.location.hostname) + '; path=/';
- document.cookie = 'TuscanyOAuth2=; expires=' + new Date(1970,01,01).toGMTString() + '; domain=.' + domainname(window.location.hostname) + '; path=/';
- document.cookie = 'TuscanyOpenIDAuth=; expires=' + new Date(1970,01,01).toGMTString() + '; domain=.' + domainname(window.location.hostname) + '; path=/';
- return true;
-}
-
-function submitSignout() {
- clearauthcookie();
- document.signout.submit();
- return true;
-}
-</script>
-<input type="button" onclick="submitSignout()" value="Sign out"/>
-</form>
-</body>
-</html>
diff --git a/modules/openid/htdocs/public/index.html b/modules/openid/htdocs/public/index.html
deleted file mode 100644
index 24db147..0000000
--- a/modules/openid/htdocs/public/index.html
+++ /dev/null
@@ -1,35 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-
-<html>
-<head>
-<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0"/>
-<meta name="apple-mobile-web-app-capable" content="yes"/>
-<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
-<link rel="stylesheet" type="text/css" href="/ui-min.css"/>
-<title>Unprotected area</title>
-</head>
-<body>
-<h1>Unprotected area - It works!</h1>
-<p><a href="/info">User info</a></p>
-<p><a href="/login">Sign in</a></p>
-<p><a href="/logout">Sign out</a></p>
-<p><a href="/">Protected area</a></p>
-</body>
-</html>
diff --git a/modules/openid/openid-conf b/modules/openid/openid-conf
deleted file mode 100755
index 7f986fc..0000000
--- a/modules/openid/openid-conf
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/bin/sh
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Generate an OpenID server conf
-here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here`
-mkdir -p $1
-root=`echo "import os; print os.path.realpath('$1')" | python`
-
-conf=`cat $root/conf/httpd.conf | grep "# Generated by: httpd-conf"`
-host=`echo $conf | awk '{ print $6 }'`
-openid_prefix=`cat $here/openid.prefix`
-
-sslconf=`cat $root/conf/httpd.conf | grep "# Generated by: httpd-ssl-conf"`
-if [ "$sslconf" = "" ]; then
- sslsuffix=""
-else
- sslsuffix="-ssl"
-fi
-
-if [ "$2" = "" ]; then
- providers="file"
-else
- providers="$2"
-fi
-
-# Configure HTTPD mod_auth_openid module
-cat >>$root/conf/modules.conf <<EOF
-# Generated by: openid-conf $*
-# Load support for OpenID authentication
-LoadModule authopenid_module $openid_prefix/modules/mod_auth_openid.so
-
-EOF
-
-# Disallow public access to server resources
-cat >$root/conf/noauth$sslsuffix.conf <<EOF
-# Generated by: openid-auth-conf $*
-# Disallow public access to server resources
-
-EOF
-
-# Configure OpenID authentication
-cat >>$root/conf/locauth$sslsuffix.conf <<EOF
-# Generated by: openid-conf $*
-# Enable OpenID authentication
-<Location />
-AuthType Open
-AuthName "$host"
-#AuthOpenIDProvider socache $providers
-#AuthnCacheProvideFor $providers
-#AuthnCacheContext /
-Require valid-user
-AuthOpenIDEnabled On
-AuthOpenIDCookiePath /
-AuthOpenIDCookieName TuscanyOpenIDAuth
-AuthOpenIDLoginPage /login/
-AuthOpenIDAXAdd REMOTE_USER http://axschema.org/contact/email
-AuthOpenIDAXAdd EMAIL http://axschema.org/contact/email
-AuthOpenIDAXAdd FULLNAME http://axschema.org/namePerson
-AuthOpenIDAXAdd NICKNAME http://axschema.org/namePerson/friendly
-AuthOpenIDAXAdd FIRSTNAME http://axschema.org/namePerson/first
-AuthOpenIDAXAdd LASTNAME http://axschema.org/namePerson/last
-</Location>
-
-EOF
-
-cat >>$root/conf/pubauth$sslsuffix.conf <<EOF
-# Generated by: openid-conf $*
-# Allow public access to /openid location
-<Location /openid>
-AuthType None
-Require all granted
-</Location>
-
-EOF
-
diff --git a/modules/openid/openid-memcached-conf b/modules/openid/openid-memcached-conf
deleted file mode 100755
index fc56ee7..0000000
--- a/modules/openid/openid-memcached-conf
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/sh
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here`
-mkdir -p $1
-root=`echo "import os; print os.path.realpath('$1')" | python`
-host=$2
-port=$3
-
-# Configure HTTPD mod_auth_openid module cache
-cat >>$root/conf/auth.conf <<EOF
-# Generated by: openid-cache-conf $*
-AddAuthOpenIDMemcached $host:$port
-
-EOF
-
diff --git a/modules/openid/openid-step2-conf b/modules/openid/openid-step2-conf
deleted file mode 100755
index f6ac968..0000000
--- a/modules/openid/openid-step2-conf
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/bin/sh
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Generate an OpenID Step2 server conf
-here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here`
-mkdir -p $1
-root=`echo "import os; print os.path.realpath('$1')" | python`
-
-conf=`cat $root/conf/httpd.conf | grep "# Generated by: httpd-conf"`
-host=`echo $conf | awk '{ print $6 }'`
-
-sslconf=`cat $root/conf/httpd.conf | grep "# Generated by: httpd-ssl-conf"`
-if [ "$sslconf" = "" ]; then
- sslsuffix=""
-else
- sslsuffix="-ssl"
-fi
-
-# Configure HTTPD to serve OpenID XRDS and LRDD documents
-cat >>$root/conf/locauth$sslsuffix.conf <<EOF
-# Generated by: openid-step2-conf $*
-# Serve OpenID XRDS document
-Alias /openid $root/conf/openid.xrds
-<Location /openid>
-ForceType application/xrds+xml
-</Location>
-
-# Serve OpenID LRDD document
-Alias /.well-known/host-meta $root/conf/openid.lrdd
-<Location /.well-known/host-meta>
-ForceType text/plain
-</Location>
-
-EOF
-
-cat >>$root/conf/pubauth$sslsuffix.conf <<EOF
-# Generated by: openid-step2-conf $*
-# Allow access to /.well-known/host-meta location
-<Location /.well-known/host-meta>
-AuthType None
-Require all granted
-</Location>
-
-EOF
-
-# Generate OpenID XRDS document
-cat >$root/conf/openid.xrds <<EOF
-<?xml version="1.0" encoding="UTF-8"?>
-<xrds:XRDS xmlns:xrds="xri://\$xrds" xmlns="xri://\$xrd*(\$v*2.0)">
-<XRD>
-<CanonicalID>$host</CanonicalID>
-<Service priority="0">
-<Type>http://specs.openid.net/auth/2.0/server</Type>
-<Type>http://specs.openid.net/auth/2.0/signon</Type>
-<Type>http://openid.net/srv/ax/1.0</Type>
-<Type>http://specs.openid.net/extensions/ui/1.0/mode/popup</Type>
-<Type>http://specs.openid.net/extensions/ui/1.0/icon</Type>
-<Type>http://specs.openid.net/extensions/pape/1.0</Type>
-<URI>https://www.google.com/a/$host/o8/ud?be=o8</URI>
-</Service>
-</XRD>
-</xrds:XRDS>
-EOF
-
-# Generate OpenID LRDD document
-cat >$root/conf/openid.lrdd <<EOF
-Link: <https://www.google.com/accounts/o8/site-xrds?hd=$host>; rel="describedby http://reltype.google.com/openid/xrd-op"; type="application/xrds+xml"
-EOF
-
diff --git a/modules/openid/openid.composite b/modules/openid/openid.composite
deleted file mode 100644
index 6931673..0000000
--- a/modules/openid/openid.composite
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
--->
-<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
- targetNamespace="http://tuscany.apache.org/xmlns/sca/components"
- name="openid">
-
- <component name="Protected">
- <implementation.widget location="protected/index.html"/>
- <reference name="userInfo" target="UserInfo"/>
- </component>
-
- <component name="UserInfo">
- <implementation.scheme script="user-info.scm"/>
- <service name="info">
- <binding.jsonrpc uri="info"/>
- </service>
- <property name="user">anonymous</property>
- <property name="email">anonymous@example.com</property>
- <property name="realm">example.com</property>
- </component>
-
-</composite>
diff --git a/modules/openid/start-test b/modules/openid/start-test
deleted file mode 100755
index 56ebbc3..0000000
--- a/modules/openid/start-test
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/bin/sh
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Setup
-rm -rf tmp
-../../components/cache/memcached-start tmp 11212
-../../components/cache/memcached-start tmp 11213
-
-../../modules/http/ssl-ca-conf tmp localhost
-../../modules/http/ssl-cert-conf tmp localhost
-../../modules/http/httpd-conf tmp localhost 8090 htdocs
-../../modules/http/httpd-ssl-conf tmp 8453
-
-./openid-conf tmp
-./openid-memcached-conf tmp localhost 11212
-./openid-memcached-conf tmp localhost 11213
-./openid-step2-conf tmp
-
-# For this test to work you need to add your openid user id to the
-# password file with a dummy 'password' password, and to the group
-# of authorized users
-../../modules/http/passwd-auth-conf tmp /openid/jane@example.com password
-../../modules/http/group-auth-conf tmp jane@example.com
-
-../../modules/server/server-conf tmp
-../../modules/server/scheme-conf tmp
-cat >>tmp/conf/httpd.conf <<EOF
-SCAContribution `pwd`/
-SCAComposite openid.composite
-EOF
-
-../../modules/http/httpd-start tmp
-
diff --git a/modules/openid/stop-test b/modules/openid/stop-test
deleted file mode 100755
index 4b8a73e..0000000
--- a/modules/openid/stop-test
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/sh
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Cleanup
-../../modules/http/httpd-stop tmp
-
-../../components/cache/memcached-stop tmp 11212
-../../components/cache/memcached-stop tmp 11213
diff --git a/modules/openid/user-info.scm b/modules/openid/user-info.scm
deleted file mode 100644
index b1ef74c..0000000
--- a/modules/openid/user-info.scm
+++ /dev/null
@@ -1,28 +0,0 @@
-; Licensed to the Apache Software Foundation (ASF) under one
-; or more contributor license agreements. See the NOTICE file
-; distributed with this work for additional information
-; regarding copyright ownership. The ASF licenses this file
-; to you under the Apache License, Version 2.0 (the
-; "License"); you may not use this file except in compliance
-; with the License. You may obtain a copy of the License at
-;
-; http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing,
-; software distributed under the License is distributed on an
-; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-; KIND, either express or implied. See the License for the
-; specific language governing permissions and limitations
-; under the License.
-
-; OpenID support test case
-
-(define (get id user email realm) (list "text/html" (list
- "<html><body><p>The following info is generated on the server:</p><div>User: " (user) "</div><div>Email: " (email) "</div><div>Realm: " (realm) "</div></body></html>")))
-
-(define (getuser user email realm) (user))
-
-(define (getemail user email realm) (email))
-
-(define (getrealm user email realm) (realm))
-
diff --git a/modules/python/Makefile.am b/modules/python/Makefile.am
deleted file mode 100644
index 80c3097..0000000
--- a/modules/python/Makefile.am
+++ /dev/null
@@ -1,57 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-
-if WANT_PYTHON
-
-INCLUDES = -I${PYTHON_INCLUDE}
-
-incl_HEADERS = *.hpp
-incldir = $(prefix)/include/modules/python
-
-dist_mod_SCRIPTS = python-conf
-moddir = $(prefix)/modules/python
-
-prefix_DATA = python.prefix
-prefixdir = $(prefix)/modules/python
-python.prefix: $(top_builddir)/config.status
- echo ${PYTHON_PREFIX} >python.prefix
-
-EXTRA_DIST = domain-test.composite client-test.py server-test.py
-
-mod_LTLIBRARIES = libmod_tuscany_python.la
-libmod_tuscany_python_la_SOURCES = mod-python.cpp
-libmod_tuscany_python_la_LDFLAGS = -lxml2 -lcurl -lmozjs -L${PYTHON_LIB} -R${PYTHON_LIB} -lpython${PYTHON_VERSION}
-noinst_DATA = libmod_tuscany_python${libsuffix}
-libmod_tuscany_python${libsuffix}:
- ln -s .libs/libmod_tuscany_python${libsuffix}
-
-python_test_SOURCES = python-test.cpp
-python_test_LDFLAGS = -L${PYTHON_LIB} -R${PYTHON_LIB} -lpython${PYTHON_VERSION}
-
-python_shell_SOURCES = python-shell.cpp
-python_shell_LDFLAGS = -L${PYTHON_LIB} -R${PYTHON_LIB} -lpython${PYTHON_VERSION}
-
-client_test_SOURCES = client-test.cpp
-client_test_LDFLAGS = -lxml2 -lcurl -lmozjs
-
-dist_noinst_SCRIPTS = server-test wiring-test
-noinst_PROGRAMS = python-test client-test
-mod_PROGRAMS = python-shell
-TESTS = python-test server-test
-
-endif
diff --git a/modules/python/client-test.cpp b/modules/python/client-test.cpp
deleted file mode 100644
index 21fda53..0000000
--- a/modules/python/client-test.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-/**
- * Test HTTP client functions.
- */
-
-#include "stream.hpp"
-#include "string.hpp"
-#include "../server/client-test.hpp"
-
-int main() {
- tuscany::cout << "Testing..." << tuscany::endl;
- tuscany::server::testURI = "http://localhost:8090/python";
-
- tuscany::server::testServer();
-
- tuscany::cout << "OK" << tuscany::endl;
-
- return 0;
-}
diff --git a/modules/python/client-test.py b/modules/python/client-test.py
deleted file mode 100644
index 3c7183e..0000000
--- a/modules/python/client-test.py
+++ /dev/null
@@ -1,40 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-import unittest
-
-# JSON-RPC test case
-
-def echo(x, ref):
- e1 = ref("echo", x)
- e2 = ref.echo(x)
- assert e1 == e2
- return e1
-
-# ATOMPub test case
-
-def get(id, ref):
- return ref.get(id);
-
-def post(collection, item, ref):
- return ref.post(collection, item)
-
-def put(id, item, ref):
- return ref.put(id, item)
-
-def delete(id, ref):
- return ref.delete(id)
diff --git a/modules/python/domain-test.composite b/modules/python/domain-test.composite
deleted file mode 100644
index b96ef8c..0000000
--- a/modules/python/domain-test.composite
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
--->
-<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
- targetNamespace="http://domain/test"
- name="domain-test">
-
- <component name="python-test">
- <implementation.python script="server-test.py"/>
- <service name="test">
- <binding.http uri="python"/>
- </service>
- </component>
-
- <component name="client-test">
- <implementation.python script="client-test.py"/>
- <service name="client">
- <binding.http uri="client"/>
- </service>
- <reference name="ref" target="python-test">
- <binding.http/>
- </reference>
- </component>
-
-</composite>
diff --git a/modules/python/driver.hpp b/modules/python/driver.hpp
deleted file mode 100644
index a5d5541..0000000
--- a/modules/python/driver.hpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef tuscany_python_driver_hpp
-#define tuscany_python_driver_hpp
-
-/**
- * Python evaluator main driver loop.
- */
-
-#include "string.hpp"
-#include "stream.hpp"
-#include "monad.hpp"
-#include "../scheme/driver.hpp"
-#include "eval.hpp"
-
-namespace tuscany {
-namespace python {
-
-const value evalDriverLoop(PyObject* script, istream& in, ostream& out, PythonRuntime& py) {
- scheme::promptForInput(scheme::evalInputPrompt, out);
- value input = scheme::readValue(in);
- if (isNil(input))
- return input;
- const failable<value> output = evalScript(input, script, py);
- scheme::announceOutput(scheme::evalOutputPrompt, out);
- scheme::userPrint(content(output), out);
- return evalDriverLoop(script, in, out, py);
-}
-
-const bool evalDriverRun(const char* path, istream& in, ostream& out) {
- PythonRuntime py;
- scheme::setupDisplay(out);
- ifstream is(path);
- failable<PyObject*> script = readScript(moduleName(path), path, is, py);
- if (!hasContent(script))
- return true;
- evalDriverLoop(content(script), in, out, py);
- releaseScript(content(script), py);
- return true;
-}
-
-}
-}
-#endif /* tuscany_python_driver_hpp */
diff --git a/modules/python/eval.hpp b/modules/python/eval.hpp
deleted file mode 100644
index 5c0be7d..0000000
--- a/modules/python/eval.hpp
+++ /dev/null
@@ -1,740 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef tuscany_python_eval_hpp
-#define tuscany_python_eval_hpp
-
-/**
- * Python script evaluation logic.
- */
-#if PYTHON_VERSION == 27
-#undef _POSIX_C_SOURCE
-#undef _XOPEN_SOURCE
-#include <python2.7/Python.h>
-#include <python2.7/frameobject.h>
-#include <python2.7/traceback.h>
-#else
-#undef _POSIX_C_SOURCE
-#undef _XOPEN_SOURCE
-#include <python2.6/Python.h>
-#include <python2.6/frameobject.h>
-#include <python2.6/traceback.h>
-#endif
-
-#include "list.hpp"
-#include "value.hpp"
-
-namespace tuscany {
-namespace python {
-
-class PythonThreadIn;
-class PythonThreadOut;
-class PythonRuntimeLock;
-class PythonRuntime;
-
-/**
- * Maintain a garbage collected reference to a Python object.
- */
-const bool pyIncRef(PyObject* o);
-const bool pyDecRef(PyObject* o, PythonRuntime* py);
-
-/**
- * Write to debug log from Python.
- */
-const value pyDebug(const list<value>& args) {
- debug(args, "python::debug");
- return true;
-}
-
-/**
- * Represent a Python runtime.
- */
-
-class PythonRuntime {
-public:
- PythonRuntime() {
- debug("python::pythonruntime");
-
- // Save current process id
-#ifdef WANT_THREADS
- pthread_mutex_init(&mutex, NULL);
- pthread_mutex_init(&pidmutex, NULL);
-#endif
- pid = processId();
-
- // Initialize the Python interpreter
-#ifdef IS_DARWIN
- debug("python::pythonruntime::initialize");
- Py_SetPythonHome(const_cast<char*>(PYTHON_PREFIX));
- Py_InitializeEx(0);
-#else
- if (!Py_IsInitialized()) {
- debug("python::pythonruntime::initialize");
- Py_SetPythonHome(const_cast<char*>(PYTHON_PREFIX));
- Py_InitializeEx(0);
- }
-#endif
-
-#ifdef WANT_THREADS
- // Initialize the Python thread support
-#ifdef IS_DARWIN
- PyEval_InitThreads();
- PyEval_ReleaseLock();
-#else
- if (!PyEval_ThreadsInitialized()) {
- PyEval_InitThreads();
- PyEval_ReleaseLock();
- }
-#endif
-#endif
-
-#ifdef WANT_THREADS
- PyGILState_STATE gstate = PyGILState_Ensure();
-#endif
-
- // Set default interpreter args
- const char* arg0 = "";
- PySys_SetArgv(0, const_cast<char**>(&arg0));
-
- // Install debug log function
- PyObject* mkPyLambda(const lambda<value(const list<value>&)>& l, PythonRuntime* py);
- PyObject* pyd= mkPyLambda(pyDebug, this);
- PyObject* sys = PyImport_ImportModule("sys");
- PyObject_SetAttrString(sys, "debug", pyd);
- pyDecRef(pyd, this);
- pyDecRef(sys, this);
-
-#ifdef WANT_THREADS
- PyGILState_Release(gstate);
-#endif
- }
-
- ~PythonRuntime() {
- }
-
-private:
-#ifdef WANT_THREADS
- pthread_mutex_t mutex;
- pthread_mutex_t pidmutex;
-#endif
- unsigned long pid;
-
- friend class PythonThreadIn;
- friend class PythonThreadOut;
- friend class PythonRuntimeLock;
-};
-
-/**
- * Return the last python error.
- */
-const string lastErrorTrace(PyObject *trace) {
- if (trace == NULL)
- return "";
- PyTracebackObject* tb = (PyTracebackObject*)trace;
- const int limit = 16;
- int depth = 0;
- PyTracebackObject *tb1 = tb;
- while (tb1 != NULL) {
- depth++;
- tb1 = tb1->tb_next;
- }
- ostringstream os;
- while (tb != NULL) {
- if (depth <= limit)
- os << ", File " << PyString_AsString(tb->tb_frame->f_code->co_filename) <<
- " line " << tb->tb_lineno << " in " << PyString_AsString(tb->tb_frame->f_code->co_name);
- depth--;
- tb = tb->tb_next;
- }
- return str(os);
-}
-
-const string lastError(PythonRuntime* py) {
- if(PyErr_Occurred()) {
- PyObject* type = NULL;
- PyObject* val = NULL;
- PyObject* trace = NULL;
- PyErr_Fetch(&type, &val, &trace);
- if (type != NULL && val != NULL) {
- PyObject* stype = PyObject_Repr(type);
- PyObject* sval = PyObject_Repr(val);
- string msg = string() + PyString_AsString(stype) + " : " + PyString_AsString(sval) + lastErrorTrace(trace);
- pyDecRef(stype, py);
- pyDecRef(sval, py);
- PyErr_Restore(type, val, trace);
- PyErr_Clear();
- return msg;
- }
- PyErr_Restore(type, val, trace);
- PyErr_Clear();
- return "Unknown Python error";
- }
- return "";
-}
-
-/**
- * Represent a lock on the Python runtime.
- */
-class PythonRuntimeLock {
-public:
- PythonRuntimeLock(PythonRuntime* py) : py(py) {
-#ifdef WANT_THREADS
- pthread_mutex_lock(&py->mutex);
-#endif
- }
-
- ~PythonRuntimeLock() {
-#ifdef WANT_THREADS
- pthread_mutex_unlock(&py->mutex);
-#endif
- }
-
-private:
- PythonRuntime* py;
-};
-
-/**
- * Represent a thread calling into the Python interpreter.
- */
-class PythonThreadIn {
-public:
- PythonThreadIn(PythonRuntime* py) : py(py) {
-
- // Reinitialize Python thread support after a fork
- const unsigned long pid = processId();
-#ifdef WANT_THREADS
- if (pid != py->pid) {
- pthread_mutex_lock(&py->pidmutex);
- if (pid != py->pid) {
- debug("python::gil::afterfork");
- PyOS_AfterFork();
- PyEval_ReleaseLock();
- debug("python::gil::afterforked");
- py->pid = pid;
- }
- pthread_mutex_unlock(&py->pidmutex);
- }
-
- // Acquire the Python GIL
- //debug("python::gil::ensure");
- gstate = PyGILState_Ensure();
- //debug("python::gil::ensured");
-#else
- if (pid != py->pid) {
- debug("python::afterfork");
- PyOS_AfterFork();
- debug("python::afterforked");
- py->pid = pid;
- }
-#endif
- }
-
- ~PythonThreadIn() {
- // Run Python cyclic reference garbage collector
- //const size_t c = PyGC_Collect();
- //debug(c, "python::gc::collect::c");
-
-#ifdef WANT_THREADS
- // Release the Python GIL
- //debug("python::gil::release");
- PyGILState_Release(gstate);
- //debug("python::gil::released");
-#endif
- }
-
-private:
- PythonRuntime* py;
-#ifdef WANT_THREADS
- PyGILState_STATE gstate;
-#endif
-};
-
-/**
- * Represent a thread calling out of the Python interpreter.
- */
-class PythonThreadOut {
-public:
- PythonThreadOut(PythonRuntime* py) : py(py) {
-#ifdef WANT_THREADS
- //debug("python::gil::save");
- tstate = PyEval_SaveThread();
- //debug("python::gil::saved");
-#endif
- }
-
- ~PythonThreadOut() {
-#ifdef WANT_THREADS
- //debug("python::gil::restore");
- PyEval_RestoreThread(tstate);
- //debug("python::gil::restored");
-#endif
- }
-
-private:
- PythonRuntime* py;
-#ifdef WANT_THREADS
- PyThreadState* tstate;
-#endif
-};
-
-/**
- * A gargabe collected Python object reference.
- */
-class PyGCRef {
-public:
- PyGCRef(PyObject* o, PythonRuntime* py) : o(o), py(py) {
- }
-
- ~PyGCRef() {
- if (o == NULL)
- return;
- PythonThreadIn pyin(py);
- Py_DECREF(o);
- }
-
-private:
- PyObject* o;
- PythonRuntime* py;
-};
-
-/**
- * Maintain a garbage collected reference to a Python object.
- */
-const bool pyIncRef(PyObject* o) {
- if (o == NULL)
- return true;
- Py_INCREF(o);
- return true;
-}
-
-const bool pyDecRef(unused PyObject* o, unused PythonRuntime* py) {
- if (o == NULL)
- return true;
- //new (gc_new<PyGCRef>()) PyGCRef(o, py);
- Py_DECREF(o);
- return true;
-}
-
-/**
- * Declare conversion functions.
- */
-PyObject* valueToPyObject(const value& v, PythonRuntime* py);
-const value pyObjectToValue(PyObject *o, PythonRuntime* py);
-PyObject* valuesToPyTuple(const list<value>& v, PythonRuntime* py);
-const list<value> pyTupleToValues(PyObject* o, PythonRuntime* py);
-
-/**
- * Callable python type used to represent a lambda expression.
- */
-typedef struct {
- PyObject_HEAD
- lambda<value(const list<value>&)>* func;
- PythonRuntime* py;
-} pyLambda;
-
-PyObject *mkPyLambda(const lambda<value(const list<value>&)>& l, PythonRuntime* py);
-
-void pyLambda_dealloc(PyObject* self) {
- //debug(self, "python::pylambda_dealloc");
- PyObject_Del(self);
-}
-
-const string pyRepr(PyObject* o, PythonRuntime* py) {
- PyObject* r = PyObject_Repr(o);
- const string s = PyString_AsString(r);
- pyDecRef(r, py);
- return s;
-}
-
-const value pyLambda_callout(const pyLambda* pyl, const list<value>& args, PythonRuntime* py) {
- PythonThreadOut pyout(py);
- return (*(pyl->func))(args);
-}
-
-PyObject* pyLambda_call(PyObject* self, PyObject* args, unused PyObject* kwds) {
- debug("python::call");
- const pyLambda* pyl = (const pyLambda*)self;
- const value result = pyLambda_callout(pyl, pyTupleToValues(args, pyl->py), pyl->py);
- debug(result, "python::call::result");
- PyObject *pyr = valueToPyObject(result, pyl->py);
- return pyr;
-}
-
-struct pyProxy {
- const value name;
- const lambda<value(const list<value>&)> func;
-
- pyProxy(const value& name, const lambda<value(const list<value>&)>& func) : name(name), func(func) {
- }
-
- const value operator()(const list<value>& args) const {
- debug(name, "python::proxy::name");
- const value result = func(cons<value>(name, args));
- debug(result, "python::proxy::result");
- return result;
- }
-};
-
-PyObject* pyLambda_getattr(PyObject *self, PyObject *attrname) {
- const string name = PyString_AsString(attrname);
- if (substr(name, 0, 1) == "_")
- return PyObject_GenericGetAttr(self, attrname);
-
- if (name == "eval") {
- pyIncRef(self);
- return self;
- }
-
- const pyLambda* pyl = (pyLambda*)self;
- debug(name, "python::getattr::name");
- PyObject* pyr = mkPyLambda(pyProxy(name, *(pyl->func)), pyl->py);
- return pyr;
-}
-
- PyTypeObject pyLambda_type = {
- PyVarObject_HEAD_INIT(NULL, 0)
- "lambda", /*tp_name*/
- sizeof(pyLambda), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- /* methods */
- (destructor)pyLambda_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- (ternaryfunc)pyLambda_call, /*tp_call*/
- 0, /*tp_str*/
- (binaryfunc)pyLambda_getattr, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- 0, /*tp_doc*/
- 0, /*tp_traverse*/
- 0, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- 0, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- 0, /*tp_init*/
- 0, /*tp_alloc*/
- 0, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0 /*tp_version_tag*/
-};
-
-
-/**
- * Create a new python object representing a lambda expression.
- */
-PyObject *mkPyLambda(const lambda<value(const list<value>&)>& l, PythonRuntime* py) {
- pyLambda* pyl = PyObject_New(pyLambda, &pyLambda_type);
- if (pyl != NULL) {
- pyl->func = new (gc_new<lambda<value(const list<value>&)> >()) lambda<value(const list<value>&)>(l);
- pyl->py = py;
- }
- //debug(pyl, "python::mkpylambda");
- return (PyObject*)pyl;
-}
-
-/**
- * Convert a list of values to a python list.
- */
-PyObject* valuesToPyListHelper(PyObject* l, const list<value>& v, PythonRuntime* py) {
- if (isNil(v))
- return l;
- PyObject* pyv = valueToPyObject(car(v), py);
- PyList_Append(l, pyv);
- pyDecRef(pyv, py);
- return valuesToPyListHelper(l, cdr(v), py);
-}
-
-PyObject* valuesToPyTuple(const list<value>& v, PythonRuntime* py) {
- PyObject* pyl = valuesToPyListHelper(PyList_New(0), v, py);
- PyObject* pyt = PyList_AsTuple(pyl);
- pyDecRef(pyl, py);
- return pyt;
-}
-
-/**
- * Convert a value to a python object.
- */
-PyObject* valueToPyObject(const value& v, PythonRuntime* py) {
- switch (type(v)) {
- case value::List:
- return valuesToPyTuple(v, py);
- case value::Lambda:
- return mkPyLambda(v, py);
- case value::Symbol:
- return PyString_FromString(c_str(string("'") + v));
- case value::String: {
- const string s = (string)v;
- return PyString_FromStringAndSize(c_str(s), length(s));
- }
- case value::Number:
- return PyFloat_FromDouble((double)v);
- case value::Bool: {
- PyObject* b = (bool)v? Py_True : Py_False;
- pyIncRef(b);
- return b;
- }
- default: {
- PyObject* n = Py_None;
- pyIncRef(n);
- return n;
- }
- }
-}
-
-/**
- * Convert a python tuple to a list of values.
- */
-const list<value> pyTupleToValuesHelper(PyObject* o, const size_t i, const size_t size, PythonRuntime* py) {
- if (i == size)
- return list<value>();
- return cons(pyObjectToValue(PyTuple_GetItem(o, i), py), pyTupleToValuesHelper(o, i + 1, size, py));
-}
-
-const list<value> pyTupleToValues(PyObject* o, PythonRuntime* py) {
- return pyTupleToValuesHelper(o, 0, PyTuple_Size(o), py);
-}
-
-/**
- * Lambda function used to represent a python callable object.
- */
-struct pyCallable {
- PyObject* func;
- PythonRuntime* py;
- bool owner;
-
- pyCallable(PyObject* func, PythonRuntime* py) : func(func), py(py), owner(true) {
- pyIncRef(func);
- }
-
- pyCallable(const pyCallable& c) : func(c.func), py(c.py), owner(false) {
- }
-
- const pyCallable& operator=(const pyCallable& c) {
- if(this == &c)
- return *this;
- func = c.func;
- py = c.py;
- owner = false;
- return *this;
- }
-
- ~pyCallable() {
- if (!owner)
- return;
- pyDecRef(func, py);
- }
-
- const value operator()(const list<value>& args) const {
- PythonThreadIn pyin(py);
- if (debug_islogging()) {
- PyObject* rfunc = PyObject_Repr(func);
- char* s = NULL;
- Py_ssize_t l = 0;
- PyString_AsStringAndSize(rfunc, &s, &l);
- debug(string(s, l), "python::operator()::func");
- pyDecRef(rfunc, py);
- }
- PyObject* pyargs = valuesToPyTuple(args, py);
- if (debug_islogging()) {
- PyObject* rargs = PyObject_Repr(pyargs);
- char* s = NULL;
- Py_ssize_t l = 0;
- PyString_AsStringAndSize(rargs, &s, &l);
- debug(string(s, l), "python::operator()::args");
- pyDecRef(rargs, py);
- }
-
- PyObject* result = PyObject_CallObject(func, pyargs);
- pyDecRef(pyargs, py);
-
- const value v = pyObjectToValue(result, py);
- pyDecRef(result, py);
- return v;
- }
-};
-
-/**
- * Convert a python object to a value.
- */
-const value pyObjectToValue(PyObject *o, PythonRuntime* py) {
- if (o == NULL)
- return value();
- if (PyString_Check(o)) {
- char* s = NULL;
- Py_ssize_t l = 0;
- PyString_AsStringAndSize(o, &s, &l);
- if (l != 0 && *s == '\'')
- return value(s + 1);
- return value(string(s, l));
- }
- if (PyBool_Check(o))
- return value(o == Py_True);
- if (PyInt_Check(o))
- return value((double)PyInt_AsLong(o));
- if (PyLong_Check(o))
- return value((double)PyLong_AsLong(o));
- if (PyFloat_Check(o))
- return value((double)PyFloat_AsDouble(o));
- if (PyTuple_Check(o))
- return pyTupleToValues(o, py);
- if (PyObject_TypeCheck(o, &pyLambda_type))
- return *(((pyLambda*)o)->func);
- if (PyCallable_Check(o))
- return lambda<value(const list<value>&)>(pyCallable(o, py));
- return value();
-}
-
-/**
- * Convert a python script path to a module name.
- */
-const string moduleName(const string& path) {
- return join(".", tokenize("/", substr(path, 0, length(path) -3)));
-}
-
-/**
- * Evaluate an expression against a script provided as a python object.
- */
-const failable<value> evalScript(const value& expr, PyObject* script, PythonRuntime& py) {
- PythonThreadIn pyin(&py);
-
- // Get the requested function
- PyObject* func = PyObject_GetAttrString(script, c_str(car<value>(expr)));
- if (func == NULL) {
-
- // The start, stop, and restart functions are optional
- const value fn = car<value>(expr);
- if (fn == "start" || fn == "stop") {
- PyErr_Clear();
- return value(lambda<value(const list<value>&)>());
- }
-
- return mkfailure<value>(string("Couldn't find function: ") + car<value>(expr) + " : " + lastError(&py));
- }
- if (!PyCallable_Check(func)) {
- pyDecRef(func, &py);
- return mkfailure<value>(string("Couldn't find callable function: ") + car<value>(expr));
- }
-
- // Convert args to python objects
- PyObject* args = valuesToPyTuple(cdr<value>(expr), &py);
-
- // Call the function
- PyObject* result = PyObject_CallObject(func, args);
- if (result == NULL) {
- const string msg = lastError(&py);
- pyDecRef(func, &py);
- pyDecRef(args, &py);
- return mkfailure<value>(string("Function call failed: ") + car<value>(expr) + " : " + msg);
- }
- pyDecRef(func, &py);
- pyDecRef(args, &py);
-
- // Convert python result to a value
- const value v = pyObjectToValue(result, &py);
- pyDecRef(result, &py);
- return v;
-}
-
-/**
- * Read a python script from an input stream.
- */
-const failable<PyObject*> readScript(const string& name, const string& path, istream& is, PythonRuntime& py) {
- PythonThreadIn pyin(&py);
-
- // Lookup already loaded module
- PyObject *mods = PyImport_GetModuleDict();
- PyObject *emod = PyDict_GetItemString(mods, const_cast<char*>(c_str(name)));
- if (emod != NULL)
- return emod;
-
- // Compile and import new module
- debug(name, "python::readScript::compile::name");
- debug(path, "python::readScript::compile::path");
- const list<string> ls = streamList(is);
- ostringstream os;
- write(ls, os);
- PyObject* code = Py_CompileStringFlags(c_str(str(os)), c_str(path), Py_file_input, NULL);
- if (code == NULL)
- return mkfailure<PyObject*>(string("Couldn't compile script: ") + path + " : " + lastError(&py));
- PyObject* mod = PyImport_ExecCodeModuleEx(const_cast<char*>(c_str(name)), code, const_cast<char*>(c_str(path)));
- if (mod == NULL) {
- const string msg = lastError(&py);
- pyDecRef(code, &py);
- return mkfailure<PyObject*>(string("Couldn't import module: ") + path + " : " + msg);
- }
- pyDecRef(code, &py);
- pyDecRef(mod, &py);
-
- // Lookup the loaded module
- PyObject *lmod = PyDict_GetItemString(mods, const_cast<char*>(c_str(name)));
- if (lmod != NULL)
- return lmod;
-
- return mkfailure<PyObject*>(string("Couldn't lookup module: ") + path);
-}
-
-/**
- * Release a python script.
- */
-const failable<bool> releaseScript(unused PyObject* script, PythonRuntime& py) {
- PythonThreadIn pyin(&py);
- // No need to decref the script here, as it's referenced only once from sys.modules
- return true;
-}
-
-/**
- * Evaluate an expression against a script provided as an input stream.
- */
-const failable<value> evalScript(const value& expr, istream& is, PythonRuntime& py) {
- const value uuid = mkuuid();
- failable<PyObject*> script = readScript(string("script") + string(uuid), string("script") + string(uuid) + string(".py"), is, py);
- if (!hasContent(script))
- return mkfailure<value>(script);
- return evalScript(expr, content(script), py);
-}
-
-}
-}
-#endif /* tuscany_python_eval_hpp */
diff --git a/modules/python/mod-python.cpp b/modules/python/mod-python.cpp
deleted file mode 100644
index 956edf1..0000000
--- a/modules/python/mod-python.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-/**
- * HTTPD module used to eval Python component implementations.
- */
-
-#define WANT_HTTPD_LOG 1
-#include "string.hpp"
-#include "function.hpp"
-#include "list.hpp"
-#include "value.hpp"
-#include "monad.hpp"
-#include "../server/mod-cpp.hpp"
-#include "../server/mod-eval.hpp"
-#include "mod-python.hpp"
-
-namespace tuscany {
-namespace server {
-namespace modeval {
-
-/**
- * Apply a lifecycle start or restart event.
- */
-struct pythonLifecycle {
- python::PythonRuntime& py;
- pythonLifecycle(python::PythonRuntime& py) : py(py) {
- }
- const value operator()(const list<value>& params) const {
- const value func = car(params);
- if (func == "pythonRuntime")
- return (gc_ptr<value>)(value*)&py;
- return lambda<value(const list<value>&)>();
- }
-};
-
-const value applyLifecycle(unused const list<value>& params) {
-
- // Create a Python runtime
- python::PythonRuntime& py = *(new (gc_new<python::PythonRuntime>()) python::PythonRuntime());
-
- // Return the function to invoke on subsequent events
- return failable<value>(lambda<value(const list<value>&)>(pythonLifecycle(py)));
-}
-
-/**
- * Evaluate a Python component implementation and convert it to an applicable
- * lambda function.
- */
-const failable<lambda<value(const list<value>&)> > evalImplementation(const string& path, const value& impl, const list<value>& px, const lambda<value(const list<value>&)>& lifecycle) {
- const string itype(elementName(impl));
- if (contains(itype, ".python")) {
- const value* p = (gc_ptr<value>)lifecycle(mklist<value>("pythonRuntime"));
- return modpython::evalImplementation(path, impl, px, *(python::PythonRuntime*)p);
- }
- if (contains(itype, ".cpp"))
- return modcpp::evalImplementation(path, impl, px);
- if (contains(itype, ".widget"))
- return mkfailure<lambda<value(const list<value>&)> >(string("Unsupported implementation type: ") + itype, -1, false);
- return mkfailure<lambda<value(const list<value>&)> >(string("Unsupported implementation type: ") + itype);
-}
-
-}
-}
-}
diff --git a/modules/python/mod-python.hpp b/modules/python/mod-python.hpp
deleted file mode 100644
index e6effb9..0000000
--- a/modules/python/mod-python.hpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef tuscany_modpython_hpp
-#define tuscany_modpython_hpp
-
-/**
- * Evaluation functions used by mod-eval to evaluate Python
- * component implementations.
- */
-
-#include "string.hpp"
-#include "stream.hpp"
-#include "function.hpp"
-#include "list.hpp"
-#include "value.hpp"
-#include "monad.hpp"
-#include "eval.hpp"
-
-namespace tuscany {
-namespace server {
-namespace modpython {
-
-/**
- * Apply a Python component implementation function.
- */
-struct applyImplementation {
- PyObject* impl;
- const list<value> px;
- python::PythonRuntime& py;
- applyImplementation(PyObject* impl, const list<value>& px, python::PythonRuntime& py) : impl(impl), px(px), py(py) {
- }
- const value operator()(const list<value>& params) const {
- const value expr = append<value>(params, px);
- debug(expr, "modeval::python::applyImplementation::input");
- const failable<value> res = python::evalScript(expr, impl, py);
- const value val = !hasContent(res)? mklist<value>(value(), reason(res), rcode(res)) : mklist<value>(content(res));
- debug(val, "modeval::python::applyImplementation::result");
- return val;
- }
-};
-
-/**
- * Evaluate a Python component implementation and convert it to an applicable
- * lambda function.
- */
-const failable<lambda<value(const list<value>&)> > evalImplementation(const string& path, const value& impl, const list<value>& px, python::PythonRuntime& py) {
- const string spath(attributeValue("script", impl));
- const string fpath(path + spath);
- ifstream is(fpath);
- if (fail(is))
- return mkfailure<lambda<value(const list<value>&)> >(string("Could not read implementation: ") + fpath);
- const failable<PyObject*> script = python::readScript(python::moduleName(spath), fpath, is, py);
- if (!hasContent(script))
- return mkfailure<lambda<value(const list<value>&)> >(script);
- return lambda<value(const list<value>&)>(applyImplementation(content(script), px, py));
-}
-
-}
-}
-}
-
-#endif /* tuscany_modpython_hpp */
diff --git a/modules/python/python-conf b/modules/python/python-conf
deleted file mode 100755
index 359d596..0000000
--- a/modules/python/python-conf
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/sh
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Generate a Python server conf
-here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here`
-mkdir -p $1
-root=`echo "import os; print os.path.realpath('$1')" | python`
-
-uname=`uname -s`
-if [ $uname = "Darwin" ]; then
- libsuffix=".dylib"
-else
- libsuffix=".so"
-fi
-
-cat >>$root/conf/modules.conf <<EOF
-# Generated by: python-conf $*
-# Support for Python SCA components
-LoadModule mod_tuscany_eval $here/libmod_tuscany_python$libsuffix
-
-EOF
diff --git a/modules/python/python-shell.cpp b/modules/python/python-shell.cpp
deleted file mode 100644
index 89b47b8..0000000
--- a/modules/python/python-shell.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-/**
- * Python script evaluator shell, used for interactive testing of scripts.
- */
-
-#include <assert.h>
-#include "gc.hpp"
-#include "stream.hpp"
-#include "string.hpp"
-#include "driver.hpp"
-
-int main(const int argc, char** argv) {
- tuscany::gc_scoped_pool pool;
- if (argc != 2) {
- tuscany::cerr << "Usage: python-shell <script.py>" << tuscany::endl;
- return 1;
- }
- tuscany::python::evalDriverRun(argv[1], tuscany::cin, tuscany::cout);
- return 0;
-}
diff --git a/modules/python/python-test.cpp b/modules/python/python-test.cpp
deleted file mode 100644
index 29a66cc..0000000
--- a/modules/python/python-test.cpp
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-/**
- * Test Python script evaluator.
- */
-
-#include <assert.h>
-#include "stream.hpp"
-#include "string.hpp"
-#include "driver.hpp"
-#include "parallel.hpp"
-#include "perf.hpp"
-
-namespace tuscany {
-namespace python {
-
-const string testPythonAdd =
- "def add(x, y):\n"
- " return x + y\n";
-
-bool testEvalExpr() {
- gc_scoped_pool pool;
- PythonRuntime py;
-
- istringstream is(testPythonAdd);
- failable<PyObject*> script = readScript("script1", "script1.py", is, py);
- assert(hasContent(script));
-
- const value exp = mklist<value>("add", 2, 3);
- const failable<value> r = evalScript(exp, content(script), py);
- assert(hasContent(r));
- assert(content(r) == value(5));
-
- releaseScript(content(script), py);
- return true;
-}
-
-const string testPythonMap =
- "def addmap(x, y):\n"
- " return tuple(map(lambda i: i + y, x))\n";
-
-bool testEvalList() {
- gc_scoped_pool pool;
- PythonRuntime py;
-
- istringstream is(testPythonMap);
- failable<PyObject*> script = readScript("script2", "script2.py", is, py);
- assert(hasContent(script));
-
- const value exp = mklist<value>("addmap", mklist<value>(1, 2, 3), 1);
- const failable<value> r = evalScript(exp, content(script), py);
- assert(hasContent(r));
- assert(car<value>(content(r)) == value(2));
- assert(cadr<value>(content(r)) == value(3));
- assert(caddr<value>(content(r)) == value(4));
-
- releaseScript(content(script), py);
- return true;
-}
-
-const value mult(const list<value>& args) {
- const double x = car(args);
- const double y = cadr(args);
- return x * y;
-}
-
-const string testReturnLambda(
- "def mul(x, y):\n"
- " return x * y\n"
- "\n"
- "def testReturnLambda():\n"
- " return mul\n");
-
-const string testCallLambda(
- "def testCallLambda(l, x, y):\n"
- " return l(x, y)\n");
-
-bool testEvalLambda() {
- gc_scoped_pool pool;
- PythonRuntime py;
-
- const value trl = mklist<value>("testReturnLambda");
- istringstream trlis(testReturnLambda);
- const failable<value> trlv = evalScript(trl, trlis, py);
-
- assert(hasContent(trlv));
- assert(isLambda(content(trlv)));
- const lambda<value(const list<value>&)> trll(content(trlv));
- assert(trll(mklist<value>(2, 3)) == value(6));
-
- istringstream tclis(testCallLambda);
- const value tcl = mklist<value>("testCallLambda", content(trlv), 2, 3);
- const failable<value> tclv = evalScript(tcl, tclis, py);
- assert(hasContent(tclv));
- assert(content(tclv) == value(6));
-
- istringstream tcelis(testCallLambda);
- const value tcel = mklist<value>("testCallLambda", lambda<value(const list<value>&)>(mult), 3, 4);
- const failable<value> tcelv = evalScript(tcel, tcelis, py);
- assert(hasContent(tcelv));
- assert(content(tcelv) == value(12));
- return true;
-}
-
-struct testEvalReadAdd {
- PythonRuntime& py;
- testEvalReadAdd(PythonRuntime& py) : py(py) {
- }
- const bool operator()() const {
- istringstream is(testPythonAdd);
- failable<PyObject*> script = readScript("script3", "script3.py", is, py);
- assert(hasContent(script));
-
- const value exp = mklist<value>("add", 2, 3);
- const failable<value> r = evalScript(exp, content(script), py);
- assert(hasContent(r));
- assert(content(r) == value(5));
-
- releaseScript(content(script), py);
- return true;
- }
-};
-
-struct testEvalAdd {
- PyObject* script;
- PythonRuntime& py;
- testEvalAdd(PyObject* script, PythonRuntime& py) : script(script), py(py) {
- }
- const bool operator()() const {
- const value exp = mklist<value>("add", 2, 3);
- const failable<value> r = evalScript(exp, script, py);
- assert(hasContent(r));
- assert(content(r) == value(5));
- return true;
- }
-};
-
-bool testEvalPerf() {
- gc_scoped_pool pool;
- PythonRuntime py;
-
- const lambda<bool()> erl = lambda<bool()>(testEvalReadAdd(py));
- cout << "Python read + eval test " << time(erl, 5, 10000) << " ms" << endl;
-
- istringstream is(testPythonAdd);
- failable<PyObject*> script = readScript("script4", "script4.py", is, py);
- assert(hasContent(script));
-
- const lambda<bool()> el = lambda<bool()>(testEvalAdd(content(script), py));
- cout << "Python eval test " << time(el, 5, 10000) << " ms" << endl;
-
- releaseScript(content(script), py);
- return true;
-}
-
-#ifdef WANT_THREADS
-
-struct testReadEvalAddLoop {
- PythonRuntime& py;
- testReadEvalAddLoop(PythonRuntime& py) : py(py) {
- }
- const bool operator()() const {
- for (int i = 0; i < 100; i++) {
- istringstream is(testPythonAdd);
- failable<PyObject*> script = readScript("script6", "script6.py", is, py);
- assert(hasContent(script));
-
- const value exp = mklist<value>("add", 2, 3);
- const failable<value> r = evalScript(exp, content(script), py);
- assert(hasContent(r));
- assert(content(r) == value(5));
-
- releaseScript(content(script), py);
- }
- return true;
- }
-};
-
-struct testEvalAddLoop {
- PyObject* script;
- PythonRuntime& py;
- testEvalAddLoop(PyObject* script, PythonRuntime& py) : script(script), py(py) {
- }
- const bool operator()() const {
- for (int i = 0; i < 100; i++) {
- const value exp = mklist<value>("add", 2, 3);
- const failable<value> r = evalScript(exp, script, py);
- assert(hasContent(r));
- assert(content(r) == value(5));
- }
- return true;
- }
-};
-
-const list<future<bool> > submitReadEvals(worker& w, const int max, const int i, PythonRuntime& py) {
- if (i == max)
- return list<future<bool> >();
- const lambda<bool()> func = lambda<bool()>(testReadEvalAddLoop(py));
- return cons(submit(w, func), submitReadEvals(w, max, i + 1, py));
-}
-
-const list<future<bool> > submitEvals(worker& w, const int max, const int i, PyObject* script, PythonRuntime& py) {
- if (i == max)
- return list<future<bool> >();
- const lambda<bool()> func = lambda<bool()>(testEvalAddLoop(script, py));
- return cons(submit(w, func), submitEvals(w, max, i + 1, script, py));
-}
-
-bool checkEvalResults(const list<future<bool> > r) {
- if (isNil(r))
- return true;
- assert(car(r) == true);
- return checkEvalResults(cdr(r));
-}
-
-struct testReadEvalThreads {
- worker& w;
- const int max;
- PythonRuntime& py;
- testReadEvalThreads(worker& w, const int max, PythonRuntime& py) : w(w), max(max), py(py) {
- }
- const bool operator()() const {
- const list<future<bool> > r(submitReadEvals(w, max, 0, py));
- checkEvalResults(r);
- return true;
- }
-};
-
-struct testEvalThreads {
- worker& w;
- const int max;
- PyObject* script;
- PythonRuntime& py;
- testEvalThreads(worker& w, const int max, PyObject* script, PythonRuntime& py) : w(w), max(max), script(script), py(py) {
- }
- const bool operator()() const {
- const list<future<bool> > r(submitEvals(w, max, 0, script, py));
- checkEvalResults(r);
- return true;
- }
-};
-
-bool testThreads() {
- gc_scoped_pool pool;
- PythonRuntime py;
-
- const int max = 100;
- worker w(max);
-
- const lambda<bool()> elr = lambda<bool()>(testReadEvalThreads(w, max, py));
- cout << "Python eval + read thread test " << time(elr, 1, 1) / 10000.0 << " ms" << endl;
-
- istringstream is(testPythonAdd);
- failable<PyObject*> script = readScript("script7", "script7.py", is, py);
- assert(hasContent(script));
-
- const lambda<bool()> el = lambda<bool()>(testEvalThreads(w, max, content(script), py));
- cout << "Python eval thread test " << time(el, 1, 1) / 10000.0 << " ms" << endl;
-
- releaseScript(content(script), py);
- return true;
-}
-
-#endif
-
-}
-}
-
-int main() {
- tuscany::gc_scoped_pool p;
- tuscany::cout << "Testing..." << tuscany::endl;
-
- tuscany::python::testEvalExpr();
- tuscany::python::testEvalList();
- tuscany::python::testEvalLambda();
- tuscany::python::testEvalLambda();
- tuscany::python::testEvalLambda();
- tuscany::python::testEvalPerf();
-#ifdef WANT_THREADS
- tuscany::python::testThreads();
-#endif
-
- tuscany::cout << "OK" << tuscany::endl;
- return 0;
-}
diff --git a/modules/python/server-test b/modules/python/server-test
deleted file mode 100755
index 6ab5823..0000000
--- a/modules/python/server-test
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/sh
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Setup
-rm -rf tmp
-../http/httpd-conf tmp localhost 8090 ../server/htdocs
-../http/httpd-event-conf tmp
-../server/server-conf tmp
-./python-conf tmp
-cat >>tmp/conf/httpd.conf <<EOF
-SCAContribution `pwd`/
-SCAComposite domain-test.composite
-EOF
-
-../http/httpd-start tmp
-sleep 2
-
-# Test
-./client-test 2>/dev/null
-rc=$?
-
-# Cleanup
-../http/httpd-stop tmp
-sleep 2
-exit $rc
diff --git a/modules/python/server-test.py b/modules/python/server-test.py
deleted file mode 100644
index da5d216..0000000
--- a/modules/python/server-test.py
+++ /dev/null
@@ -1,42 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# JSON-RPC test case
-
-def echo(x):
- return x
-
-# ATOMPub test case
-
-def get(id):
- if id == ():
- return (("'feed", ("'title", "Sample Feed"), ("'id", "123456789"), ("'entry",
- ((("'title", "Item"), ("'id", "111"), ("'content", ("'item", ("'name", "Apple"), ("'currencyCode", "USD"), ("'currencySymbol", "$"), ("'price", 2.99)))),
- (("'title", "Item"), ("'id", "222"), ("'content", ("'item", ("'name", "Orange"), ("'currencyCode", "USD"), ("'currencySymbol", "$"), ("'price", 3.55)))),
- (("'title", "Item"), ("'id", "333"), ("'content", ("'item", ("'name", "Pear"), ("'currencyCode", "USD"), ("'currencySymbol", "$"), ("'price", 1.55))))))),)
-
- content = ("'content", ("'item", ("'name", "Apple"), ("'currencyCode", "USD"), ("'currencySymbol", "$"), ("'price", 2.99)))
- return (("'entry", ("'title", "Item"), ("'id", id[0]), content),)
-
-def post(collection, item):
- return ("123456789",)
-
-def put(id, item):
- return True
-
-def delete(id):
- return True
diff --git a/modules/python/wiring-test b/modules/python/wiring-test
deleted file mode 100755
index 899c3eb..0000000
--- a/modules/python/wiring-test
+++ /dev/null
@@ -1,80 +0,0 @@
-#!/bin/sh
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-echo "Testing..."
-here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here`
-curl_prefix=`cat $here/../http/curl.prefix`
-
-# Setup
-rm -rf tmp
-../http/httpd-conf tmp localhost 8090 ../server/htdocs
-../http/httpd-event-conf tmp
-../server/server-conf tmp
-./python-conf tmp
-cat >>tmp/conf/httpd.conf <<EOF
-SCAContribution `pwd`/
-SCAComposite domain-test.composite
-EOF
-
-../http/httpd-start tmp
-sleep 2
-
-# Test HTTP GET
-$curl_prefix/bin/curl http://localhost:8090/index.html 2>/dev/null >tmp/index.html
-diff tmp/index.html ../server/htdocs/index.html
-rc=$?
-
-# Test ATOMPub
-if [ "$rc" = "0" ]; then
- $curl_prefix/bin/curl http://localhost:8090/client/ >tmp/feed.xml 2>/dev/null
- diff tmp/feed.xml ../server/htdocs/test/feed.xml
- rc=$?
-fi
-if [ "$rc" = "0" ]; then
- $curl_prefix/bin/curl http://localhost:8090/client/111 >tmp/entry.xml 2>/dev/null
- diff tmp/entry.xml ../server/htdocs/test/entry.xml
- rc=$?
-fi
-if [ "$rc" = "0" ]; then
- $curl_prefix/bin/curl http://localhost:8090/client/ -X POST -H "Content-type: application/atom+xml" --data @../server/htdocs/test/entry.xml 2>/dev/null
- rc=$?
-fi
-if [ "$rc" = "0" ]; then
- $curl_prefix/bin/curl http://localhost:8090/client/111 -X PUT -H "Content-type: application/atom+xml" --data @../server/htdocs/test/entry.xml 2>/dev/null
- rc=$?
-fi
-if [ "$rc" = "0" ]; then
- $curl_prefix/bin/curl http://localhost:8090/client/111 -X DELETE 2>/dev/null
- rc=$?
-fi
-
-# Test JSON-RPC
-if [ "$rc" = "0" ]; then
- $curl_prefix/bin/curl http://localhost:8090/client/ -X POST -H "Content-type: application/json-rpc" --data @../server/htdocs/test/json-request.txt >tmp/json-result.txt 2>/dev/null
- diff tmp/json-result.txt ../server/htdocs/test/json-result.txt
- rc=$?
-fi
-
-# Cleanup
-../http/httpd-stop tmp
-sleep 2
-if [ "$rc" = "0" ]; then
- echo "OK"
-fi
-exit $rc
diff --git a/modules/rss/Makefile.am b/modules/rss/Makefile.am
deleted file mode 100644
index 06a67f3..0000000
--- a/modules/rss/Makefile.am
+++ /dev/null
@@ -1,25 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-incl_HEADERS = *.hpp
-incldir = $(prefix)/include/modules/rss
-
-rss_test_SOURCES = rss-test.cpp
-rss_test_LDFLAGS = -lxml2
-
-noinst_PROGRAMS = rss-test
-TESTS = rss-test
diff --git a/modules/rss/rss-test.cpp b/modules/rss/rss-test.cpp
deleted file mode 100644
index be1dcac..0000000
--- a/modules/rss/rss-test.cpp
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-/**
- * Test RSS data conversion functions.
- */
-
-#include <assert.h>
-#include "stream.hpp"
-#include "string.hpp"
-#include "rss.hpp"
-
-namespace tuscany {
-namespace rss {
-
-ostream* writer(const string& s, ostream* os) {
- (*os) << s;
- return os;
-}
-
-const string itemEntry("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- "<item>\n"
- " <title>fruit</title>\n"
- " <link>cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b</link>\n"
- " <description>\n"
- " <item>\n"
- " <name>Apple</name>\n"
- " <price>$2.99</price>\n"
- " </item>\n"
- " </description>\n"
- "</item>\n");
-
-const string itemTextEntry("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- "<item>\n"
- " <title>fruit</title>\n"
- " <link>cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b</link>\n"
- " <description>Apple</description>\n"
- "</item>\n");
-
-const string itemNoDescriptionEntry("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- "<item>\n"
- " <title>fruit</title>\n"
- " <link>cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b</link>\n"
- "</item>\n");
-
-const string incompleteEntry("<item>\n"
- " <title>fruit</title>\n"
- " <description>\n"
- " <Item xmlns=\"http://services/\">\n"
- " <name xmlns=\"\">Orange</name>\n"
- " <price xmlns=\"\">3.55</price>\n"
- " </Item>\n"
- " </description>\n"
- "</item>");
-
-const string completedEntry("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- "<item>\n"
- " <title>fruit</title>\n"
- " <link></link>\n"
- " <description>\n"
- " <Item xmlns=\"http://services/\">\n"
- " <name xmlns=\"\">Orange</name>\n"
- " <price xmlns=\"\">3.55</price>\n"
- " </Item>\n"
- " </description>\n"
- "</item>\n");
-
-bool testEntry() {
- {
- const list<value> i = list<value>() + element + value("item")
- + value(list<value>() + element + value("name") + value(string("Apple")))
- + value(list<value>() + element + value("price") + value(string("$2.99")));
- const list<value> a = list<value>() + (list<value>() + element + value("entry")
- + value(list<value>() + element + value("title") + value(string("fruit")))
- + value(list<value>() + element + value("id") + value(string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b")))
- + value(list<value>() + element + value("content") + value(i)));
- ostringstream os;
- writeRSSEntry<ostream*>(writer, &os, a);
- assert(str(os) == itemEntry);
- }
- {
- const list<value> a = list<value>() + (list<value>() + element + value("entry")
- + value(list<value>() + element + value("title") + value(string("fruit")))
- + value(list<value>() + element + value("id") + value(string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b")))
- + value(list<value>() + element + value("content") + value(string("Apple"))));
- ostringstream os;
- writeRSSEntry<ostream*>(writer, &os, a);
- assert(str(os) == itemTextEntry);
- }
- {
- const list<value> a = list<value>() + (list<value>() + element + value("entry")
- + value(list<value>() + element + value("title") + value(string("fruit")))
- + value(list<value>() + element + value("id") + value(string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"))));
- ostringstream os;
- writeRSSEntry<ostream*>(writer, &os, a);
- assert(str(os) == itemNoDescriptionEntry);
- }
- {
- const list<value> a = content(readRSSEntry(mklist(itemEntry)));
- ostringstream os;
- writeRSSEntry<ostream*>(writer, &os, a);
- assert(str(os) == itemEntry);
- }
- {
- const list<value> a = content(readRSSEntry(mklist(itemTextEntry)));
- ostringstream os;
- writeRSSEntry<ostream*>(writer, &os, a);
- assert(str(os) == itemTextEntry);
- }
- {
- const list<value> a = content(readRSSEntry(mklist(itemNoDescriptionEntry)));
- ostringstream os;
- writeRSSEntry<ostream*>(writer, &os, a);
- assert(str(os) == itemNoDescriptionEntry);
- }
- {
- const list<value> a = content(readRSSEntry(mklist(incompleteEntry)));
- ostringstream os;
- writeRSSEntry<ostream*>(writer, &os, a);
- assert(str(os) == completedEntry);
- }
- return true;
-}
-
-const string emptyFeed("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- "<rss version=\"2.0\">\n"
- " <channel>\n"
- " <title>Feed</title>\n"
- " <link>1234</link>\n"
- " <description>Feed</description>\n"
- " </channel>\n"
- "</rss>\n");
-
-const string itemFeed("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- "<rss version=\"2.0\">\n"
- " <channel>\n"
- " <title>Feed</title>\n"
- " <link>1234</link>\n"
- " <description>Feed</description>\n"
- " <item>\n"
- " <title>fruit</title>\n"
- " <link>cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b</link>\n"
- " <description>\n"
- " <item>\n"
- " <name>Apple</name>\n"
- " <price>$2.99</price>\n"
- " </item>\n"
- " </description>\n"
- " </item>\n"
- " <item>\n"
- " <title>fruit</title>\n"
- " <link>cart-53d67a61-aa5e-4e5e-8401-39edeba8b83c</link>\n"
- " <description>\n"
- " <item>\n"
- " <name>Orange</name>\n"
- " <price>$3.55</price>\n"
- " </item>\n"
- " </description>\n"
- " </item>\n"
- " </channel>\n"
- "</rss>\n");
-
-bool testFeed() {
- {
- const list<value> a = list<value>() + (list<value>() + element + value("feed")
- + value(list<value>() + element + value("title") + value(string("Feed")))
- + value(list<value>() + element + value("id") + value(string("1234"))));
- ostringstream os;
- writeRSSFeed<ostream*>(writer, &os, a);
- assert(str(os) == emptyFeed);
- }
- {
- const list<value> a = content(readRSSFeed(mklist(emptyFeed)));
- ostringstream os;
- writeRSSFeed<ostream*>(writer, &os, a);
- assert(str(os) == emptyFeed);
- }
- {
- const list<value> i1 = list<value>() + element + "item"
- + (list<value>() + element + "name" + "Apple")
- + (list<value>() + element + "price" + "$2.99");
-
- const list<value> i2 = list<value>() + element + "item"
- + (list<value>() + element + "name" + "Orange")
- + (list<value>() + element + "price" + "$3.55");
-
- const list<value> i = list<value>()
- + value(list<value>() + element + value("entry")
- + value(list<value>() + element + value("title") + value(string("fruit")))
- + value(list<value>() + element + value("id") + value(string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b")))
- + value(list<value>() + element + value("content") + value(i1)))
- + value(list<value>() + element + value("entry")
- + value(list<value>() + element + value("title") + value(string("fruit")))
- + value(list<value>() + element + value("id") + value(string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83c")))
- + value(list<value>() + element + value("content") + value(i2)));
-
- const list<value> a = list<value>() + (append<value>(list<value>() + element + value("feed")
- + value(list<value>() + element + value("title") + value(string("Feed")))
- + value(list<value>() + element + value("id") + value("1234")),
- i));
-
- ostringstream os;
- writeRSSFeed<ostream*>(writer, &os, a);
- assert(str(os) == itemFeed);
- }
- {
- const list<value> a = content(readRSSFeed(mklist(itemFeed)));
- ostringstream os;
- writeRSSFeed<ostream*>(writer, &os, a);
- assert(str(os) == itemFeed);
- }
- {
- const list<value> a = elementsToValues(content(readRSSFeed(mklist(itemFeed))));
- ostringstream os;
- writeRSSFeed<ostream*>(writer, &os, valuesToElements(a));
- assert(str(os) == itemFeed);
- }
- return true;
-}
-
-}
-}
-
-int main() {
- tuscany::gc_scoped_pool p;
- tuscany::cout << "Testing..." << tuscany::endl;
-
- tuscany::rss::testEntry();
- tuscany::rss::testFeed();
-
- tuscany::cout << "OK" << tuscany::endl;
-
- return 0;
-}
diff --git a/modules/rss/rss.hpp b/modules/rss/rss.hpp
deleted file mode 100644
index c62d137..0000000
--- a/modules/rss/rss.hpp
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-#ifndef tuscany_rss_hpp
-#define tuscany_rss_hpp
-
-/**
- * RSS data conversion functions.
- */
-
-#include "string.hpp"
-#include "list.hpp"
-#include "value.hpp"
-#include "monad.hpp"
-#include "xml.hpp"
-
-namespace tuscany {
-namespace rss {
-
-/**
- * Tags used to tag feed and entry elements.
- */
-const value feed("feed");
-const value entry("entry");
-
-/**
- * Convert a list of elements to a list of element values representing an RSS entry.
- */
-const list<value> entryElementValues(const list<value>& e) {
- const list<value> lt = filter<value>(selector(mklist<value>(element, "title")), e);
- const value t = isNil(lt)? value(emptyString) : elementValue(car(lt));
- const list<value> li = filter<value>(selector(mklist<value>(element, "link")), e);
- const value i = isNil(li)? value(emptyString) : elementValue(car(li));
- const list<value> ld = filter<value>(selector(mklist<value>(element, "description")), e);
- return append<value>(list<value>() + element + entry
- + value(list<value>() + element + value("title") + t)
- + value(list<value>() + element + value("id") + i),
- isNil(ld)? list<value>() : mklist<value>(value(list<value>() + element + value("content") + elementValue(car(ld)))));
-}
-
-/**
- * Convert a list of elements to a list of element values representing ATOM entries.
- */
-const list<value> entriesElementValues(const list<value>& e) {
- if (isNil(e))
- return e;
- return cons<value>(entryElementValues(car(e)), entriesElementValues(cdr(e)));
-}
-
-/**
- * Return true if a list of strings contains an RSS feed.
- */
-const bool isRSSFeed(const list<string>& ls) {
- if (!isXML(ls))
- return false;
- return contains(car(ls), "<rss");
-}
-
-/**
- * Convert a list of strings to a list of values representing an RSS entry.
- */
-const failable<list<value> > readRSSEntry(const list<string>& ilist) {
- const list<value> e = readXML(ilist);
- if (isNil(e))
- return mkfailure<list<value> >("Empty entry");
- return mklist<value>(entryElementValues(car(e)));
-}
-
-/**
- * Convert a list of strings to a list of values representing an RSS feed.
- */
-const failable<list<value> > readRSSFeed(const list<string>& ilist) {
- const list<value> f = readXML(ilist);
- if (isNil(f))
- return mkfailure<list<value> >("Empty feed");
- const list<value> c = filter<value>(selector(mklist<value>(element, "channel")), car(f));
- const list<value> t = filter<value>(selector(mklist<value>(element, "title")), car(c));
- const list<value> i = filter<value>(selector(mklist<value>(element, "link")), car(c));
- const list<value> e = filter<value>(selector(mklist<value>(element, "item")), car(c));
- return mklist<value>(append<value>(list<value>() + element + feed
- + value(list<value>() + element + value("title") + elementValue(car(t)))
- + value(list<value>() + element + value("id") + elementValue(car(i))),
- entriesElementValues(e)));
-}
-
-/**
- * Convert a list of element values representing an RSS entry to a list of elements.
- */
-const list<value> entryElement(const list<value>& l) {
- const value title = elementValue(elementChild("title", l));
- const value id = elementValue(elementChild("id", l));
- const value content = elementChild("content", l);
- const bool text = isNil(content)? false : elementHasValue(content);
- return append<value>(list<value>()
- + element + "item"
- + (list<value>() + element + "title" + title)
- + (list<value>() + element + "link" + id),
- isNil(content)?
- list<value>() :
- mklist<value>(append<value>(list<value>() + element + "description",
- text? mklist<value>(elementValue(content)) : elementChildren(content))));
-}
-
-/**
- * Convert a list of values representing RSS entries to a list of elements.
- */
-const list<value> entriesElements(const list<value>& l) {
- if (isNil(l))
- return l;
- return cons<value>(entryElement(car(l)), entriesElements(cdr(l)));
-}
-
-/**
- * Convert a list of values representing an RSS entry to an RSS entry.
- * The first two values in the list are the entry id and title.
- */
-template<typename R> const failable<R> writeRSSEntry(const lambda<R(const string&, const R)>& reduce, const R& initial, const list<value>& ll) {
- const list<value> l = isNil(ll)? ll : (list<value>)car(ll);
- return writeXML<R>(reduce, initial, mklist<value>(entryElement(l)));
-}
-
-const failable<list<string> > writeRSSEntry(const list<value>& l) {
- const failable<list<string> > ls = writeRSSEntry<list<string> >(rcons<string>, list<string>(), l);
- if (!hasContent(ls))
- return ls;
- return reverse(list<string>(content(ls)));
-}
-
-/**
- * Convert a list of values representing an RSS feed to an RSS feed.
- * The first two values in the list are the feed id and title.
- */
-template<typename R> const failable<R> writeRSSFeed(const lambda<R(const string&, const R)>& reduce, const R& initial, const list<value>& ll) {
- const list<value> l = isNil(ll)? ll : (list<value>)car(ll);
- const list<value> lt = filter<value>(selector(mklist<value>(element, "title")), l);
- const value t = isNil(lt)? value(emptyString) : elementValue(car(lt));
- const list<value> li = filter<value>(selector(mklist<value>(element, "id")), l);
- const value i = isNil(li)? value(emptyString) : elementValue(car(li));
- const list<value> c = list<value>()
- + (list<value>() + element + "title" + t)
- + (list<value>() + element + "link" + i)
- + (list<value>() + element + "description" + t);
-
- // Write RSS entries
- const list<value> le = filter<value>(selector(mklist<value>(element, entry)), l);
- if (isNil(le)) {
- const list<value> fe = list<value>()
- + element + "rss" + (list<value>() + attribute + "version" + "2.0")
- + append(list<value>() + element + "channel", c);
- return writeXML<R>(reduce, initial, mklist<value>(fe));
- }
-
- // Write a single RSS entry element with a list of values
- if (!isNil(le) && !isNil(car(le)) && isList(car<value>(caddr<value>(car(le))))) {
- const list<value> ce = append(c, entriesElements(caddr<value>(car(le))));
- const list<value> fe = list<value>()
- + element + "rss" + (list<value>() + attribute + "version" + "2.0")
- + append(list<value>() + element + "channel", ce);
- return writeXML<R>(reduce, initial, mklist<value>(fe));
- }
-
- // Write separate RSS entry elements
- const list<value> ce = append(c, entriesElements(le));
- const list<value> fe = list<value>()
- + element + "rss" + (list<value>() + attribute + "version" + "2.0")
- + append(list<value>() + element + "channel", ce);
- return writeXML<R>(reduce, initial, mklist<value>(fe));
-}
-
-/**
- * Convert a list of values representing an RSS feed to a list of strings.
- * The first two values in the list are the feed id and title.
- */
-const failable<list<string> > writeRSSFeed(const list<value>& l) {
- const failable<list<string> > ls = writeRSSFeed<list<string>>(rcons<string>, list<string>(), l);
- if (!hasContent(ls))
- return ls;
- return reverse(list<string>(content(ls)));
-}
-
-}
-}
-
-#endif /* tuscany_rss_hpp */
diff --git a/modules/wsgi/Makefile.am b/modules/wsgi/Makefile.am
deleted file mode 100644
index 43cffb2..0000000
--- a/modules/wsgi/Makefile.am
+++ /dev/null
@@ -1,58 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-if WANT_PYTHON
-
-INCLUDES = -I${PYTHON_INCLUDE}
-
-dist_mod_SCRIPTS = composite.py wsgi-start wsgi-stop gae-start gae-stop
-moddir = $(prefix)/modules/wsgi
-
-dist_mod_DATA = app.yaml scdl.py util.py elemutil.py xmlutil.py atomutil.py jsonutil.py httputil.py rssutil.py
-
-noinst_DATA = target.stamp
-
-target.stamp: app.yaml *.py *.composite htdocs/*
- mkdir -p target
- cp app.yaml *.py *.composite target
- cp -R htdocs target/htdocs
- touch target.stamp
-
-clean-local:
- rm -rf target.stamp target
-
-prefix_DATA = gae.prefix
-prefixdir=$(prefix)/modules/wsgi
-gae.prefix: $(top_builddir)/config.status
- echo ${GAE_PREFIX} >gae.prefix
-
-EXTRA_DIST = domain-test.composite *.py htdocs/test/*.xml htdocs/test/*.txt htdocs/*.html
-
-client_test_SOURCES = client-test.cpp
-client_test_LDFLAGS = -lxml2 -lcurl -lmozjs
-
-noinst_PROGRAMS = client-test
-
-dist_noinst_SCRIPTS = util-test wsgi-test wiring-test http-test server-test
-TESTS = util-test
-
-if WANT_GAE
-dist_noinst_SCRIPTS += gae-test
-TESTS += wsgi-test wiring-test http-test server-test gae-test
-endif
-
-endif
diff --git a/modules/wsgi/app.yaml b/modules/wsgi/app.yaml
deleted file mode 100644
index bc70ace..0000000
--- a/modules/wsgi/app.yaml
+++ /dev/null
@@ -1,50 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-application: sca-wsgi
-version: 1
-runtime: python
-api_version: 1
-skip_files:
-- ^(.*/)?app\.yaml
-- ^(.*/)?app\.yml
-- ^(.*/)?index\.yaml
-- ^(.*/)?index\.yml
-- ^(.*/)?#.*#
-- ^(.*/)?.*~
-- ^(.*/)?.*\.py[co]
-- ^(.*/)?.*/RCS/.*
-- ^(.*/)?\..*
-- ^(.*/)?.*-test$
-- ^(.*/)?.*\.cpp$
-- ^(.*/)?.*\.o$
-- ^(.*/)?core$
-- ^(.*/)?.*\.out$
-- ^(.*/)?.*\.log$
-- ^(.*/)?Makefile.*
-- ^(.*/)?tmp/.*
-- ^(.*/)?wsgi-start
-- ^(.*/)?wsgi-stop
-
-handlers:
-- url: /(.*\.(html|js|png))
- static_files: htdocs/\1
- upload: htdocs/(.*\.(html|js|png))
-
-- url: /.*
- script: composite.py
-
diff --git a/modules/wsgi/atom-test.py b/modules/wsgi/atom-test.py
deleted file mode 100755
index 9ada53b..0000000
--- a/modules/wsgi/atom-test.py
+++ /dev/null
@@ -1,156 +0,0 @@
-#!/usr/bin/python
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Test ATOM data conversion functions
-
-import unittest
-from elemutil import *
-from atomutil import *
-
-itemEntry = \
- "<?xml version=\'1.0\' encoding=\'UTF-8\'?>\n" \
- "<entry xmlns=\"http://www.w3.org/2005/Atom\">" \
- "<title type=\"text\">item</title>" \
- "<id>cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b</id>" \
- "<content type=\"application/xml\">" \
- "<item>" \
- "<name>Apple</name><price>$2.99</price>" \
- "</item>" \
- "</content>" \
- "<link href=\"cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b\" />" \
- "</entry>\n"
-
-textEntry = \
- "<?xml version=\'1.0\' encoding=\'UTF-8\'?>\n" \
- "<entry xmlns=\"http://www.w3.org/2005/Atom\">" \
- "<title type=\"text\">item</title>" \
- "<id>cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b</id>" \
- "<content type=\"text\">" \
- "Apple" \
- "</content>" \
- "<link href=\"cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b\" />" \
- "</entry>\n"
-
-incompleteEntry = \
- "<entry xmlns=\"http://www.w3.org/2005/Atom\">" \
- "<title>item</title><content type=\"text/xml\">" \
- "<Item xmlns=\"http://services/\">" \
- "<name xmlns=\"\">Orange</name>" \
- "<price xmlns=\"\">3.55</price>" \
- "</Item>" \
- "</content>" \
- "</entry>"
-
-completedEntry = \
- "<?xml version=\'1.0\' encoding=\'UTF-8\'?>\n" \
- "<entry xmlns=\"http://www.w3.org/2005/Atom\">" \
- "<title type=\"text\">item</title>" \
- "<id />" \
- "<content type=\"application/xml\">" \
- "<Item xmlns=\"http://services/\">" \
- "<name xmlns=\"\">Orange</name>" \
- "<price xmlns=\"\">3.55</price>" \
- "</Item>" \
- "</content><link href=\"\" />" \
- "</entry>\n"
-
-def testEntry():
- i = (element, "'item", (element, "'name", "Apple"), (element, "'price", "$2.99"))
- a = ((element, "'entry", (element, "'title", "item"), (element, "'id", "cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"), (element, "'content", i)),)
- s = writeATOMEntry(a);
- assert car(s) == itemEntry
-
- a2 = readATOMEntry((itemEntry,))
- s2 = writeATOMEntry(a2)
- assert car(s2) == itemEntry
-
- a3 = readATOMEntry((textEntry,))
- s3 = writeATOMEntry(a3)
- assert car(s3) == textEntry
-
- a4 = readATOMEntry((incompleteEntry,))
- s4 = writeATOMEntry(a4)
- assert car(s4) == completedEntry
- return True
-
-emptyFeed = \
- "<?xml version=\'1.0\' encoding=\'UTF-8\'?>\n" \
- "<feed xmlns=\"http://www.w3.org/2005/Atom\">" \
- "<title type=\"text\">Feed</title>" \
- "<id>1234</id>" \
- "</feed>\n"
-
-itemFeed = \
- "<?xml version=\'1.0\' encoding=\'UTF-8\'?>\n" \
- "<feed xmlns=\"http://www.w3.org/2005/Atom\">" \
- "<title type=\"text\">Feed</title>" \
- "<id>1234</id>" \
- "<entry xmlns=\"http://www.w3.org/2005/Atom\">" \
- "<title type=\"text\">item</title>" \
- "<id>cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b</id>" \
- "<content type=\"application/xml\">" \
- "<item>" \
- "<name>Apple</name><price>$2.99</price>" \
- "</item>" \
- "</content>" \
- "<link href=\"cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b\" />" \
- "</entry>" \
- "<entry xmlns=\"http://www.w3.org/2005/Atom\">" \
- "<title type=\"text\">item</title>" \
- "<id>cart-53d67a61-aa5e-4e5e-8401-39edeba8b83c</id>" \
- "<content type=\"application/xml\">" \
- "<item>" \
- "<name>Orange</name><price>$3.55</price>" \
- "</item>" \
- "</content>" \
- "<link href=\"cart-53d67a61-aa5e-4e5e-8401-39edeba8b83c\" />" \
- "</entry>" \
- "</feed>\n"
-
-def testFeed():
- a = ((element, "'feed", (element, "'title", "Feed"), (element, "'id", "1234")),)
- s = writeATOMFeed(a)
- assert car(s) == emptyFeed
-
- a2 = readATOMFeed((emptyFeed,))
- s2 = writeATOMFeed(a2)
- assert car(s2) == emptyFeed
-
- i3 = ((element, "'entry", (element, "'title", "item"), (element, "'id", "cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"),
- (element, "'content", (element, "'item", (element, "'name", "Apple"), (element, "'price", "$2.99")))),
- (element, "'entry", (element, "'title", "item"), (element, "'id", "cart-53d67a61-aa5e-4e5e-8401-39edeba8b83c"),
- (element, "'content", (element, "'item", (element, "'name", "Orange"), (element, "'price", "$3.55")))))
- a3 = (append((element, "'feed", (element, "'title", "Feed"), (element, "'id", "1234")), i3),)
- s3 = writeATOMFeed(a3)
- assert car(s3) == itemFeed
-
- a4 = readATOMFeed((itemFeed,));
- s4 = writeATOMFeed(a4);
- assert car(s4) == itemFeed
-
- a5 = elementsToValues(readATOMFeed((itemFeed,)));
- s5 = writeATOMFeed(valuesToElements(a5));
- assert car(s5) == itemFeed
- return True
-
-if __name__ == "__main__":
- print "Testing..."
- testEntry()
- testFeed()
- print "OK"
-
diff --git a/modules/wsgi/atomutil.py b/modules/wsgi/atomutil.py
deleted file mode 100644
index ad6425f..0000000
--- a/modules/wsgi/atomutil.py
+++ /dev/null
@@ -1,120 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# ATOM data conversion functions
-
-from util import *
-from elemutil import *
-from xmlutil import *
-
-# Convert a list of elements to a list of values representing an ATOM entry
-def entryElementValues(e):
- lt = filter(selector((element, "'title")), e)
- t = "" if isNil(lt) else elementValue(car(lt))
- li = filter(selector((element, "'id")), e)
- i = "" if isNil(li) else elementValue(car(li))
- lc = filter(selector((element, "'content")), e)
- return append((element, "'entry", (element, "'title", t), (element, "'id", i)),
- () if isNil(lc) else ((element, "'content", elementValue(car(lc))),))
-
-# Convert a list of elements to a list of values representing ATOM entries
-def entriesElementValues(e):
- if isNil(e):
- return e
- return cons(entryElementValues(car(e)), entriesElementValues(cdr(e)))
-
-# Convert a list of strings to a list of values representing an ATOM entry
-def readATOMEntry(l):
- e = readXML(l)
- if isNil(e):
- return ()
- return (entryElementValues(car(e)),)
-
-# Return true if a list of strings represents an ATOM feed
-def isATOMFeed(l):
- if not isXML(l):
- return False
- return contains(car(l), "<feed") and contains(car(l), "=\"http://www.w3.org/2005/Atom\"")
-
-# Return true if a list of strings represents an ATOM entry
-def isATOMEntry(l):
- if not isXML(l):
- return False
- return contains(car(l), "<entry") and not contains(car(l), "<feed") and contains(car(l), "=\"http://www.w3.org/2005/Atom\"")
-
-# Convert a list of strings to a list of values representing an ATOM feed
-def readATOMFeed(l):
- f = readXML(l)
- if isNil(f):
- return ()
- t = filter(selector((element, "'title")), car(f))
- i = filter(selector((element, "'id")), car(f))
- e = filter(selector((element, "'entry")), car(f))
- return (append(
- (element, "'feed", (element, "'title", elementValue(car(t))), (element, "'id", elementValue(car(i)))),
- entriesElementValues(e)),)
-
-# Convert a list of values representy an ATOM entry to a list of elements
-def entryElement(l):
- title = elementValue(namedElementChild("'title", l))
- id = elementValue(namedElementChild("'id", l))
- content = namedElementChild("'content", l)
- text = False if isNil(content) else elementHasValue(content)
- return append(append(
- (element, "'entry", (attribute, "'xmlns", "http://www.w3.org/2005/Atom"),
- (element, "'title", (attribute, "'type", "text"), title),
- (element, "'id", id)),
- () if isNil(content) else (append(
- (element, "'content", (attribute, "'type", "text" if text else "application/xml")), (elementValue(content),) if text else elementChildren(content)),)),
- ((element, "'link", (attribute, "'href", id)),))
-
-# Convert a list of values representing ATOM entries to a list of elements
-def entriesElements(l):
- if isNil(l):
- return l
- return cons(entryElement(car(l)), entriesElements(cdr(l)))
-
-# Convert a list of values representing an ATOM entry to an ATOM entry
-def writeATOMEntry(ll):
- l = ll if isNil(ll) else car(ll)
- return writeXML((entryElement(l),), True)
-
-# Convert a list of values representing an ATOM feed to an ATOM feed
-def writeATOMFeed(ll):
- l = ll if isNil(ll) else car(ll)
- lt = filter(selector((element, "'title")), l)
- t = '' if isNil(lt) else elementValue(car(lt))
- li = filter(selector((element, "'id")), l)
- i = '' if isNil(li) else elementValue(car(li))
- f = (element, "'feed", (attribute, "'xmlns", "http://www.w3.org/2005/Atom"),
- (element, "'title", (attribute, "'type", "text"), t),
- (element, "'id", i))
-
- # Write ATOM entries
- le = filter(selector((element, "'entry")), l)
- if isNil(le):
- return writeXML((f,), True)
-
- # Write a single ATOM entry element with a list of values
- if not isNil(le) and not isNil(car(le)) and isList(car(caddr(car(le)))):
- fe = append(f, entriesElements(caddr(car(le))))
- return writeXML((fe,), True)
-
- # Write separate ATOM entry elements
- fe = append(f, entriesElements(le))
- return writeXML((fe,), True)
-
diff --git a/modules/wsgi/client-test.cpp b/modules/wsgi/client-test.cpp
deleted file mode 100644
index da4fff9..0000000
--- a/modules/wsgi/client-test.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/* $Rev$ $Date$ */
-
-/**
- * Test HTTP client functions.
- */
-
-#include "stream.hpp"
-#include "string.hpp"
-#include "../server/client-test.hpp"
-
-int main(const int argc, const char** argv) {
- tuscany::cout << "Testing..." << tuscany::endl;
- tuscany::server::testURI = argc < 2? "http://localhost:8090/wsgi" : argv[1];
- tuscany::server::testBlobs = false;
-
- tuscany::server::testServer();
-
- tuscany::cout << "OK" << tuscany::endl;
-
- return 0;
-}
diff --git a/modules/wsgi/client-test.py b/modules/wsgi/client-test.py
deleted file mode 100644
index 867222e..0000000
--- a/modules/wsgi/client-test.py
+++ /dev/null
@@ -1,40 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-import unittest
-
-# JSON-RPC test case
-
-def echo(x, ref):
- e1 = ref("echo", x)
- e2 = ref.echo(x)
- assert e1 == e2
- return e1
-
-# ATOMPub test case
-
-def get(id, ref):
- return ref.get(id)
-
-def post(collection, item, ref):
- return ref.post(collection, item)
-
-def put(id, item, ref):
- return ref.put(id, item)
-
-def delete(id, ref):
- return ref.delete(id)
diff --git a/modules/wsgi/composite.py b/modules/wsgi/composite.py
deleted file mode 100755
index baea7aa..0000000
--- a/modules/wsgi/composite.py
+++ /dev/null
@@ -1,272 +0,0 @@
-#!/usr/bin/python
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Composite deployment and integration with WSGI
-
-from wsgiref.simple_server import make_server
-from wsgiref.handlers import CGIHandler
-from wsgiref.util import request_uri
-from wsgiref.util import FileWrapper
-from os import environ
-import os.path
-import hashlib
-from sys import stderr, argv
-from util import *
-from scdl import *
-from atomutil import *
-from jsonutil import *
-
-# Cache the deployed components between requests
-comps = None
-
-# Return the path of an HTTP request
-def requestPath(e):
- return e.get("PATH_INFO", "")
-
-# Return the method of an HTTP request
-def requestMethod(e):
- return e.get("REQUEST_METHOD", "")
-
-# Return the method of an HTTP request
-def requestContentType(e):
- return e.get("CONTENT_TYPE", "")
-
-# Return the request body input stream
-def requestBody(e):
- i = e.get("wsgi.input", None)
- if i == None:
- return ()
- l = int(e.get("CONTENT_LENGTH", "0"))
- return (i.read(l),)
-
-def requestIfNoneMatch(e):
- return e.get("HTTP_IF_NONE_MATCH", "");
-
-# Hash a list of strings into an MD5 signature
-def md5update(md, s):
- if isNil(s):
- return md.hexdigest()
- md.update(car(s))
- return md5update(md, cdr(s))
-
-def md5(s):
- return md5update(hashlib.md5(), s)
-
-# Return an HTTP success result
-def result(e, r, st, h = (), b = None):
- if st == 201:
- r("201 Created", list(h))
- return ()
-
- if st == 200:
- if b == None:
- r("200 OK", list(h))
- return ()
-
- # Handle etags to minimize bandwidth usage
- md = md5(b)
- if (md == requestIfNoneMatch(e)):
- r("304 Not Modified", list((("Etag", md), ("Expires", "Tue, 01 Jan 1980 00:00:00 GMT"))))
- return ()
- r("200 OK", list(h + (("Etag", md), ("Expires", "Tue, 01 Jan 1980 00:00:00 GMT"))))
- return b
-
- if st == 301:
- r("301 Moved Permanently", list(h))
-
- return failure(e, r, 500)
-
-# Return an HTTP failure result
-def failure(e, r, st):
- s = "404 Not Found" if st == 404 else str(st) + " " + "Internal Server Error"
- r(s, list((("Content-type", "text/html"),)))
- return ("<html><head><title>"+ s + "</title></head><body><h1>" + s[4:] + "</h1></body></html>",)
-
-# Return a static file
-def fileresult(e, r, ct, f):
-
- # Read the file, return a 404 if not found
- p = "htdocs" + f
- if not os.path.exists(p):
- return failure(e, r, 404)
- c = tuple(FileWrapper(open("htdocs" + f)))
-
- # Handle etags to minimize bandwidth usage
- md = md5(c)
- r("200 OK", list((("Content-type", ct),("Etag", md))))
- return c
-
-# Converts the args received in a POST to a list of key value pairs
-def postArgs(a):
- if isNil(a):
- return ((),)
- l = car(a);
- return cons(l, postArgs(cdr(a)))
-
-# Return the URL used to sign out
-def signout(ruri):
- try:
- from google.appengine.api import users
- return users.create_logout_url(ruri)
- except:
- return None
-
-# Return the URL used to sign in
-def signin(ruri):
- try:
- from google.appengine.api import users
- return users.create_login_url(ruri)
- except:
- return None
-
-# WSGI application function
-def application(e, r):
- m = requestMethod(e)
- fpath = requestPath(e)
-
- # Serve static files
- if m == "GET":
- if fpath.endswith(".html"):
- return fileresult(e, r, "text/html", fpath)
- if fpath.endswith(".css"):
- return fileresult(e, r, "text/css", fpath)
- if fpath.endswith(".js"):
- return fileresult(e, r, "application/x-javascript", fpath)
- if fpath.endswith(".png"):
- return fileresult(e, r, "image/png", fpath)
- if fpath == "/":
- return result(e, r, 301, (("Location", "/index.html"),))
-
- # Debug hook
- if fpath == "/debug":
- return result(e, r, 200, (("Content-type", "text/plain"),), ("Debug",))
-
- # Sign in and out
- if fpath == "/login":
- redir = signin("/")
- if redir:
- return result(e, r, 301, (("Location", redir),))
- if fpath == "/logout":
- redir = signout(signin("/"))
- if redir:
- return result(e, r, 301, (("Location", redir),))
-
- # Find the requested component
- path = tokens(fpath)
- uc = uriToComponent(path, comps)
- uri = car(uc)
- if uri == None:
- return failure(e, r, 404)
- comp = cadr(uc)
-
- # Call the requested component function
- id = path[len(uri):]
- if m == "GET":
- v = comp("get", id)
-
- # Write a simple value as a JSON value
- if not isList(v):
- return result(e, r, 200, (("Content-type", "application/json"),), writeJSON(valuesToElements((("'value", v),))))
-
- # Write an empty list as a JSON empty value
- if not isList(v):
- return result(e, r, 200, (("Content-type", "application/json"),), writeJSON(()))
-
- # Write content-type / content-list pair
- if isString(car(v)) and not isNil(cdr(v)) and isList(cadr(v)):
- return result(e, r, 200, (("Content-type", car(v)),), cadr(v))
-
- # Convert list of values to element values
- ve = valuesToElements(v)
-
- # Write an assoc result as a JSON value
- if isList(car(ve)) and not isNil(car(ve)):
- el = car(ve)
- if isSymbol(car(el)) and car(el) == element and not isNil(cdr(el)) and isSymbol(cadr(el)):
- if cadr(el) == "'feed":
- return result(e, r, 200, (("Content-type", "application/atom+xml"),), writeATOMFeed(ve))
- if cadr(el) == "'entry":
- return result(e, r, 200, (("Content-type", "application/atom+xml"),), writeATOMEntry(ve))
-
- # Write a JSON value
- return result(e, r, 200, (("Content-type", "application/json"),), writeJSON(ve))
-
- if m == "POST":
- ct = requestContentType(e)
-
- # Handle a JSON-RPC function call
- if contains(ct, "application/json-rpc") or contains(ct, "text/plain") or contains(ct, "application/x-www-form-urlencoded"):
- print >> stderr, "Handling JSON-RPC request"
- json = elementsToValues(readJSON(requestBody(e)))
- args = postArgs(json)
- jid = cadr(assoc("'id", args))
- func = funcName(cadr(assoc("'method", args)))
- params = cadr(assoc("'params", args))
- v = comp(func, *params)
- return result(e, r, 200, (("Content-type", "application/json-rpc"),), jsonResult(jid, v))
-
- # Handle an ATOM entry POST
- if contains(ct, "application/atom+xml"):
- ae = elementsToValues(readATOMEntry(requestBody(e)))
- v = comp("post", id, ae)
- if isNil(v):
- return failure(e, r, 500)
- return result(e, r, 201, (("Location", request_uri(e) + "/" + "/".join(v)),))
- return failure(e, r, 500)
-
- if m == "PUT":
- # Handle an ATOM entry PUT
- ae = elementsToValues(readATOMEntry(requestBody(e)))
- v = comp("put", id, ae)
- if v == False:
- return failure(e, r, 404)
- return result(e, r, 200)
-
- if m == "DELETE":
- v = comp("delete", id)
- if v == False:
- return failure(e, r, 404)
- return result(e, r, 200)
-
- return failure(e, r, 500)
-
-# Return the WSGI server type
-def serverType(e):
- return e.get("SERVER_SOFTWARE", "")
-
-def main():
- # Read the deployed composite and evaluate the configured components
- global comps
- if comps == None:
- domain = "domain.composite" if os.path.exists("domain.composite") else "domain-test.composite"
- comps = evalComponents(components(parse(domain)))
-
- # Handle the WSGI request with the WSGI runtime
- st = serverType(environ)
- if contains(st, "App Engine") or contains(st, "Development"):
- from google.appengine.ext.webapp.util import run_wsgi_app
- run_wsgi_app(application)
- elif st != "":
- CGIHandler().run(application)
- else:
- make_server("", int(argv[1]), application).serve_forever()
-
-# Run the WSGI application
-if __name__ == "__main__":
- main()
-
diff --git a/modules/wsgi/domain-test.composite b/modules/wsgi/domain-test.composite
deleted file mode 100644
index 6786286..0000000
--- a/modules/wsgi/domain-test.composite
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
--->
-<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
- targetNamespace="http://domain/test"
- name="domain-test">
-
- <component name="wsgi-test">
- <implementation.python script="server-test.py"/>
- <service name="test">
- <binding.http uri="wsgi"/>
- </service>
- </component>
-
- <component name="client-test">
- <implementation.python script="client-test.py"/>
- <service name="client">
- <binding.http uri="client"/>
- </service>
- <reference name="ref" target="wsgi-test">
- <binding.http/>
- </reference>
- </component>
-
-</composite>
diff --git a/modules/wsgi/elemutil.py b/modules/wsgi/elemutil.py
deleted file mode 100644
index 00b76c5..0000000
--- a/modules/wsgi/elemutil.py
+++ /dev/null
@@ -1,168 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Functions to help represent data as lists of elements and attributes
-
-from util import *
-
-element = "'element"
-attribute = "'attribute"
-atsign = "'@"
-
-# Return true if a value is an element
-def isElement(v):
- if not isList(v) or isNil(v) or v == None or car(v) != element:
- return False
- return True
-
-# Return true if a value is an attribute
-def isAttribute(v):
- if not isList(v) or isNil(v) or v == None or car(v) != attribute:
- return False
- return True
-
-# Return the name of attribute
-def attributeName(l):
- return cadr(l)
-
-# Return the value of attribute
-def attributeValue(l):
- return caddr(l)
-
-# Return the name of an element
-def elementName(l):
- return cadr(l)
-
-# Return true if an element has children
-def elementHasChildren(l):
- return not isNil(cddr(l))
-
-# Return the children of an element
-def elementChildren(l):
- return cddr(l)
-
-# Return true if an element has a value
-def elementHasValue(l):
- r = reverse(l)
- if isSymbol(car(r)):
- return False
- if isList(car(r)) and not isNil(car(r)) and isSymbol(car(car(r))):
- return False
- return True
-
-# Return the value of an element
-def elementValue(l):
- return car(reverse(l))
-
-# Convert an element to a value
-def elementToValueIsList(v):
- if not isList(v):
- return False
- return isNil(v) or not isSymbol(car(v))
-
-def elementToValue(t):
- if isTaggedList(t, attribute):
- return (atsign + attributeName(t)[1:], attributeValue(t))
- if isTaggedList(t, element):
- if elementHasValue(t):
- if not elementToValueIsList(elementValue(t)):
- return (elementName(t), elementValue(t))
- return cons(elementName(t), (elementsToValues(elementValue(t)),))
- return cons(elementName(t), elementsToValues(elementChildren(t)))
- if not isList(t):
- return t
- return elementsToValues(t)
-
-# Convert a list of elements to a list of values
-def elementToValueIsSymbol(v):
- if not isList(v):
- return False
- if (isNil(v)):
- return False
- if not isSymbol(car(v)):
- return False
- return True
-
-def elementToValueGroupValues(v, l):
- if isNil(l) or not elementToValueIsSymbol(v) or not elementToValueIsSymbol(car(l)):
- return cons(v, l)
- if car(car(l)) != car(v):
- return cons(v, l)
- if not elementToValueIsList(cadr(car(l))):
- g = (car(v), (cdr(v), cdr(car(l))))
- return elementToValueGroupValues(g, cdr(l))
- g = (car(v), cons(cdr(v), cadr(car(l))))
- return elementToValueGroupValues(g, cdr(l))
-
-def elementsToValues(e):
- if isNil(e):
- return e
- return elementToValueGroupValues(elementToValue(car(e)), elementsToValues(cdr(e)))
-
-# Convert a value to an element
-def valueToElement(t):
- if isList(t) and not isNil(t) and isSymbol(car(t)):
- n = car(t)
- v = () if isNil(cdr(t)) else cadr(t)
- if not isList(v):
- if n[0:2] == atsign:
- return (attribute, "'" + n[2:], v)
- return (element, n, v)
- if isNil(v) or not isSymbol(car(v)):
- return cons(element, cons(n, (valuesToElements(v),)))
- return cons(element, cons(n, valuesToElements(cdr(t))))
- if not isList(t):
- return t
- return valuesToElements(t)
-
-# Convert a list of values to a list of elements
-def valuesToElements(l):
- if isNil(l):
- return l
- return cons(valueToElement(car(l)), valuesToElements(cdr(l)))
-
-# Return a selector lambda function which can be used to filter elements
-def evalSelect(s, v):
- if isNil(s):
- return True
- if isNil(v):
- return False
- if car(s) != car(v):
- return False
- return evalSelect(cdr(s), cdr(v))
-
-def selector(s):
- return lambda v: evalSelect(s, v)
-
-# Return the value of the attribute with the given name
-def namedAttributeValue(name, l):
- f = filter(lambda v: isAttribute(v) and attributeName(v) == name, l)
- if isNil(f):
- return None
- return caddr(car(f))
-
-# Return child elements with the given name
-def namedElementChildren(name, l):
- return filter(lambda v: isElement(v) and elementName(v) == name, l)
-
-# Return the child element with the given name
-def namedElementChild(name, l):
- f = namedElementChildren(name, l)
- if isNil(f):
- return None
- return car(f)
-
diff --git a/modules/wsgi/gae-start b/modules/wsgi/gae-start
deleted file mode 100755
index 44008d1..0000000
--- a/modules/wsgi/gae-start
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/sh
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Start Google AppEngine server
-here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here`
-root=`echo "import os; print os.path.realpath('$1')" | python`
-port=$2
-
-python_prefix=`cat $here/../python/python.prefix`
-gae_prefix=`cat $here/gae.prefix`
-cd $root
-$python_prefix/bin/python $gae_prefix/dev_appserver.py -a 0.0.0.0 -p $port $root &
-
diff --git a/modules/wsgi/gae-stop b/modules/wsgi/gae-stop
deleted file mode 100755
index 5bb2965..0000000
--- a/modules/wsgi/gae-stop
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/sh
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Stop Google AppEngine server
-here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here`
-root=`echo "import os; print os.path.realpath('$1')" | python`
-port=$2
-
-python_prefix=`cat $here/../python/python.prefix`
-gae_prefix=`cat $here/gae.prefix`
-py="$python_prefix/bin/python $gae_prefix/dev_appserver.py -a 0.0.0.0 -p $port $root"
-
-k=`ps -ef | grep -v grep | grep "${py}" | awk '{ print $2 }'`
-if [ "$k" != "" ]; then
- kill $k
-fi
-
diff --git a/modules/wsgi/gae-test b/modules/wsgi/gae-test
deleted file mode 100755
index 5cdbbe3..0000000
--- a/modules/wsgi/gae-test
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/sh
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Setup
-./gae-start target 8090 2>/dev/null
-sleep 2
-
-# Test
-./client-test 2>/dev/null
-rc=$?
-
-# Cleanup
-./gae-stop target 8090
-exit $rc
diff --git a/modules/wsgi/htdocs/index.html b/modules/wsgi/htdocs/index.html
deleted file mode 100644
index cc7237b..0000000
--- a/modules/wsgi/htdocs/index.html
+++ /dev/null
@@ -1,31 +0,0 @@
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
--->
-<html>
-<head>
-<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0"/>
-<meta name="apple-mobile-web-app-capable" content="yes"/>
-<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
-<link rel="stylesheet" type="text/css" href="/ui-min.css"/>
-<title>It works</title>
-</head>
-<body>
-<h1>It works!</h1>
-</body>
-</html>
-
diff --git a/modules/wsgi/htdocs/test/entry.xml b/modules/wsgi/htdocs/test/entry.xml
deleted file mode 100644
index d26a46f..0000000
--- a/modules/wsgi/htdocs/test/entry.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<entry xmlns="http://www.w3.org/2005/Atom"><title type="text">Item</title><id>111</id><content type="application/xml"><item><name>Apple</name><currencyCode>USD</currencyCode><currencySymbol>$</currencySymbol><price>2.99</price></item></content><link href="111" /></entry>
diff --git a/modules/wsgi/htdocs/test/feed.xml b/modules/wsgi/htdocs/test/feed.xml
deleted file mode 100644
index 0be99f6..0000000
--- a/modules/wsgi/htdocs/test/feed.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<feed xmlns="http://www.w3.org/2005/Atom"><title type="text">Sample Feed</title><id>123456789</id><entry xmlns="http://www.w3.org/2005/Atom"><title type="text">Item</title><id>111</id><content type="application/xml"><item><name>Apple</name><currencyCode>USD</currencyCode><currencySymbol>$</currencySymbol><price>2.99</price></item></content><link href="111" /></entry><entry xmlns="http://www.w3.org/2005/Atom"><title type="text">Item</title><id>222</id><content type="application/xml"><item><name>Orange</name><currencyCode>USD</currencyCode><currencySymbol>$</currencySymbol><price>3.55</price></item></content><link href="222" /></entry><entry xmlns="http://www.w3.org/2005/Atom"><title type="text">Item</title><id>333</id><content type="application/xml"><item><name>Pear</name><currencyCode>USD</currencyCode><currencySymbol>$</currencySymbol><price>1.55</price></item></content><link href="333" /></entry></feed>
diff --git a/modules/wsgi/htdocs/test/json-request.txt b/modules/wsgi/htdocs/test/json-request.txt
deleted file mode 100644
index b4bd07f..0000000
--- a/modules/wsgi/htdocs/test/json-request.txt
+++ /dev/null
@@ -1 +0,0 @@
-{"id":1,"method":"echo","params":["Hello"]}
diff --git a/modules/wsgi/htdocs/test/json-result.txt b/modules/wsgi/htdocs/test/json-result.txt
deleted file mode 100644
index 121bf74..0000000
--- a/modules/wsgi/htdocs/test/json-result.txt
+++ /dev/null
@@ -1 +0,0 @@
-{"id":1,"result":"Hello"}
\ No newline at end of file
diff --git a/modules/wsgi/http-test b/modules/wsgi/http-test
deleted file mode 100755
index d6c6085..0000000
--- a/modules/wsgi/http-test
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/sh
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Setup
-rm -rf tmp
-mkdir -p tmp
-./wsgi-start target 8090 2>/dev/null
-sleep 2
-
-# Test JSON-RPC
-here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here`
-python_prefix=`cat $here/../python/python.prefix`
-export LD_LIBRARY_PATH=$python_prefix/lib:$LD_LIBRARY_PATH
-
-$python_prefix/bin/python http-test.py
-rc=$?
-
-# Cleanup
-./wsgi-stop target 8090
-sleep 2
-exit $rc
diff --git a/modules/wsgi/http-test.py b/modules/wsgi/http-test.py
deleted file mode 100755
index 45a1ecd..0000000
--- a/modules/wsgi/http-test.py
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/usr/bin/python
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# HTTP client proxy functions
-
-from httputil import *
-
-def testClient():
- c = mkclient("http://localhost:8090/wsgi")
- assert c.echo("Hey") == "Hey"
- return True
-
-if __name__ == "__main__":
- print "Testing..."
- testClient()
- print "OK"
-
diff --git a/modules/wsgi/httputil.py b/modules/wsgi/httputil.py
deleted file mode 100644
index 842460c..0000000
--- a/modules/wsgi/httputil.py
+++ /dev/null
@@ -1,196 +0,0 @@
-#!/usr/bin/python
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# HTTP client proxy functions
-
-from httplib import HTTPConnection, HTTPSConnection
-from urlparse import urlparse
-from StringIO import StringIO
-import os.path
-from string import strip
-from base64 import b64encode
-from sys import stderr
-from util import *
-from elemutil import *
-import atomutil
-import jsonutil
-import rssutil
-import xmlutil
-
-# JSON request id
-id = 1
-
-# Make a callable HTTP client
-class client:
- def __init__(self, url):
- self.url = urlparse(url)
-
- def __call__(self, func, *args):
- print >> stderr, "Client proxy call", func, args
-
- # Connect to the configured URL
- c, headers = connect(self.url)
-
- # handle a GET request
- if func == "get":
- u = requesturi(self.url, car(args))
- print >> stderr, "Client GET request", u
- c.request("GET", u, None, headers)
- res = c.getresponse()
- print >> stderr, "Client status", res.status
- if res.status != 200:
- return None
- ct = res.getheader("Content-type", "text/plain")
- ls = (res.read(),)
-
- if atomutil.isATOMEntry(ls):
- # Read an ATOM entry
- v = atomutil.entryValue(atomutil.readATOMEntry(ls))
- print >> stderr, "Client result", v
- return v
-
- if contains(ct, "application/atom+xml") or atomutil.isATOMFeed(ls):
- # Read an ATOM feed
- v = atomutil.feedValues(atomutil.readATOMFeed(ls))
- print >> stderr, "Client result", v
- return v
-
- if contains(ct, "application/rss+xml") or rssutil.isRSSFeed(ls):
- # Read an RSS feed
- v = rssutil.feedValues(rssutil.readRSSFeed(ls))
- print >> stderr, "Client result", v
- return v
-
- if contains(ct, "text/javascript") or contains(ct, "application/json") or jsonutil.isJSON(ls):
- # Read a JSON document
- v = elementsToValues(jsonutil.readJSON(ls))
- print >> stderr, "Client result", v
- return v
-
- if contains(ct, "text/xml") or contains(ct, "application/xml") or xmlutil.isXML(ls):
- # Read an XML document
- v = elementsToValues(xmlutil.readXML(ls))
- print >> stderr, "Client result", v
- return v
-
- # Return the content type and a content list
- v = (ct, ls)
- print >> stderr, "Client result", v
- return v
-
- # handle a POST request
- if func == "post":
- u = requesturi(self.url, car(args))
- print >> stderr, "Client POST request", u
- req = StringIO()
- writeStrings(atomutil.writeATOMEntry(atomutil.entryValuesToElements(cadr(args))), req)
- headers["Content-type"] = "application/atom+xml"
- c.request("POST", u, req.getvalue(), headers)
- res = c.getresponse()
- print >> stderr, "Client status", res.status
- if res.status != 200 and res.status != 201:
- return None
- loc = res.getheader("Location")
- if loc == None:
- return None
- return loc[(loc.rfind('/') + 1):]
-
- # handle a PUT request
- if func == "put":
- u = requesturi(self.url, car(args))
- print >> stderr, "Client PUT request", u
- req = StringIO()
- writeStrings(atomutil.writeATOMEntry(atomutil.entryValuesToElements(cadr(args))), req)
- headers["Content-type"] = "application/atom+xml"
- c.request("PUT", u, req.getvalue(), headers)
- res = c.getresponse()
- print >> stderr, "Client status", res.status
- if res.status != 200:
- return None
- return True
-
- # handle a DELETE request
- if func == "delete":
- u = requesturi(self.url, car(args))
- print >> stderr, "Client DELETE request", u
- c.request("DELETE", u, None, headers)
- res = c.getresponse()
- print >> stderr, "Client status", res.status
- if res.status != 200:
- return None
- return True
-
- # handle a JSON-RPC request
- u = requesturi(self.url, ())
- print >> stderr, "Client JSON-RPC request", u
- global id
- req = StringIO()
- writeStrings(jsonutil.jsonRequest(id, func, args), req)
- id = id + 1
- headers["Content-type"] = "application/json-rpc"
- c.request("POST", u, req.getvalue(), headers)
- res = c.getresponse()
- print >> stderr, "Client status", res.status
- if res.status != 200:
- return None
- v = jsonutil.jsonResultValue((res.read(),))
- print >> stderr, "Client result", v
- return v
-
- def __getattr__(self, name):
- if name[0] == '_':
- raise AttributeError()
- if name == "eval":
- return self
- l = lambda *args: self.__call__(name, *args)
- self.__dict__[name] = l
- return l
-
- def __repr__(self):
- return repr((self.url,))
-
-def mkclient(url):
- return client(url)
-
-# Connect to a URL, return a connection and any authorization headers
-def connect(url):
- if url.scheme == "https":
-
- # With HTTPS, use a cerficate or HTTP basic authentication
- if os.path.exists("server.key"):
- c = HTTPSConnection(url.hostname, 443 if url.port == None else url.port, "server.key", "server.crt")
- return c, {}
- else:
- c = HTTPSConnection(url.hostname, 443 if url.port == None else url.port)
-
- # For HTTP basic authentication the user and password may be
- # provided by htpasswd.py
- try:
- import htpasswd
- auth = 'Basic ' + b64encode(htpasswd.user + ':' + htpasswd.passwd)
- return c, {"Authorization": auth}
- except:
- return c, {}
- else:
- c = HTTPConnection(url.hostname, 80 if url.port == None else url.port)
- return c, {}
-
-# Convert a URL and arg to a request URI
-def requesturi(url, arg):
- return url.path + path(arg) + ("" if url.query == "" else "?" + url.query)
-
diff --git a/modules/wsgi/json-test.py b/modules/wsgi/json-test.py
deleted file mode 100755
index 2f2a755..0000000
--- a/modules/wsgi/json-test.py
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/usr/bin/python
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Test JSON data conversion functions
-
-import unittest
-from elemutil import *
-from jsonutil import *
-
-def testJSON():
- ad = ((attribute, "'city", "san francisco"), (attribute, "'state", "ca"))
- ac = ((element, "'id", "1234"), (attribute, "'balance", 1000))
- cr = ((attribute, "'name", "jdoe"), cons(element, cons("'address", ad)), cons(element, cons("'account", ac)))
- c = (cons(element, cons("'customer", cr)),)
- s = writeJSON(c);
- assert car(s) == "{\"customer\":{\"account\":{\"@balance\":1000,\"id\":\"1234\"},\"@name\":\"jdoe\",\"address\":{\"@city\":\"san francisco\",\"@state\":\"ca\"}}}"
-
- phones = ("408-1234", "650-1234")
- l = ((element, "'phones", phones), (element, "'lastName", "test\ttab"), (attribute, "'firstName", "test1"))
- s2 = writeJSON(l);
- assert car(s2) == "{\"phones\":[\"408-1234\",\"650-1234\"],\"@firstName\":\"test1\",\"lastName\":\"test\\ttab\"}"
-
- r = readJSON(s2)
- assert r == ((element, "'lastName", "test\ttab"), (attribute, "'firstName", "test1"), (element, "'phones", phones))
- w = writeJSON(r)
- assert car(w) == "{\"lastName\":\"test\\ttab\",\"@firstName\":\"test1\",\"phones\":[\"408-1234\",\"650-1234\"]}"
-
- l4 = (("'ns1:echoString", ("'@xmlns:ns1", "http://ws.apache.org/axis2/services/echo"), ("'text", "Hello World!")),)
- s4 = writeJSON(valuesToElements(l4))
- assert car(s4) == "{\"ns1:echoString\":{\"@xmlns:ns1\":\"http://ws.apache.org/axis2/services/echo\",\"text\":\"Hello World!\"}}"
-
- r4 = elementsToValues(readJSON(s4))
- assert r4 == (("'ns1:echoString", ("'text", 'Hello World!'), ("'@xmlns:ns1", 'http://ws.apache.org/axis2/services/echo')),)
- return True
-
-def testJSONRPC():
- return True
-
-if __name__ == "__main__":
- print "Testing..."
- testJSON()
- testJSONRPC()
- print "OK"
-
diff --git a/modules/wsgi/jsonutil.py b/modules/wsgi/jsonutil.py
deleted file mode 100644
index 849b444..0000000
--- a/modules/wsgi/jsonutil.py
+++ /dev/null
@@ -1,154 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# JSON data conversion functions
-
-try:
- import json
-except:
- from django.utils import simplejson as json
-
-from StringIO import StringIO
-from util import *
-from elemutil import *
-
-# Return true if a list represents a JS array
-def isJSArray(l):
- if isNil(l):
- return True
- v = car(l)
- if isSymbol(v):
- return False
- if isList(v):
- if not isNil(v) and isSymbol(car(v)):
- return False
- return True
-
-# Converts JSON properties to values
-def jsPropertiesToValues(propertiesSoFar, o, i):
- if isNil(i):
- return propertiesSoFar
- p = car(i)
- jsv = o[p]
- v = jsValToValue(jsv)
-
- if isinstance(p, basestring):
- n = str(p)
- if n[0:1] == "@":
- return jsPropertiesToValues(cons((attribute, "'" + n[1:], v), propertiesSoFar), o, cdr(i))
- if isList(v) and not isJSArray(v):
- return jsPropertiesToValues(cons(cons(element, cons("'" + n, v)), propertiesSoFar), o, cdr(i))
- return jsPropertiesToValues(cons((element, "'" + n, v), propertiesSoFar), o, cdr(i))
- return jsPropertiesToValues(cons(v, propertiesSoFar), o, cdr(i))
-
-# Converts a JSON val to a value
-def jsValToValue(jsv):
- if jsv is None:
- return None
- if isinstance(jsv, dict):
- return jsPropertiesToValues((), jsv, tuple(jsv.keys()))
- if isList(jsv):
- return jsPropertiesToValues((), jsv, tuple(reversed(range(0, len(jsv)))))
- if isinstance(jsv, basestring):
- return str(jsv)
- return jsv
-
-# Return true if a list of strings contains a JSON document
-def isJSON(l):
- if isNil(l):
- return False
- s = car(l)[0:1]
- return s == "[" or s == "{"
-
-# Convert a list of strings representing a JSON document to a list of values
-def readJSON(l):
- s = StringIO()
- writeStrings(l, s)
- val = json.loads(s.getvalue())
- return jsValToValue(val)
-
-# Convert a list of values to JSON array elements
-def valuesToJSElements(a, l, i):
- if isNil(l):
- return a
- pv = valueToJSVal(car(l))
- a[i] = pv
- return valuesToJSElements(a, cdr(l), i + 1)
-
-# Convert a value to a JSON value
-def valueToJSVal(v):
- if not isList(v):
- return v
- if isJSArray(v):
- return valuesToJSElements(list(range(0, len(v))), v, 0)
- return valuesToJSProperties({}, v)
-
-# Convert a list of values to JSON properties
-def valuesToJSProperties(o, l):
- if isNil(l):
- return o
- token = car(l)
- if isTaggedList(token, attribute):
- pv = valueToJSVal(attributeValue(token))
- o["@" + attributeName(token)[1:]] = pv
- elif isTaggedList(token, element):
- if elementHasValue(token):
- pv = valueToJSVal(elementValue(token))
- o[elementName(token)[1:]] = pv
- else:
- child = {}
- o[elementName(token)[1:]] = child
- valuesToJSProperties(child, elementChildren(token))
- return valuesToJSProperties(o, cdr(l))
-
-# Convert a list of values to a list of strings representing a JSON document
-def writeJSON(l):
- if isJSArray(l):
- jsv = valuesToJSElements(list(range(0, len(l))), l, 0)
- else:
- jsv = valuesToJSProperties({}, l)
- s = json.dumps(jsv, separators=(',',':'))
- return (s,)
-
-# Convert a list + params to a JSON-RPC request
-def jsonRequest(id, func, params):
- r = (("'id", id), ("'method", func), ("'params", params))
- return writeJSON(valuesToElements(r))
-
-# Convert a value to a JSON-RPC result
-def jsonResult(id, val):
- return writeJSON(valuesToElements((("'id", id), ("'result", val))))
-
-# Convert a JSON-RPC result to a value
-def jsonResultValue(s):
- jsres = readJSON(s)
- res = elementsToValues(jsres)
- val = cadr(assoc("'result", res))
- if isList(val) and not isJSArray(val):
- return (val,)
- return val
-
-# Return a portable function name from a JSON-RPC function name
-def funcName(f):
- if f.startswith("."):
- return f[1:]
- if f.startswith("system."):
- return f[7:]
- if f.startswith("Service."):
- return f[8:]
- return f
-
diff --git a/modules/wsgi/rss-test.py b/modules/wsgi/rss-test.py
deleted file mode 100755
index e8a094b..0000000
--- a/modules/wsgi/rss-test.py
+++ /dev/null
@@ -1,170 +0,0 @@
-#!/usr/bin/python
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Test RSS data conversion functions
-
-import unittest
-from elemutil import *
-from rssutil import *
-
-itemEntry = \
- "<?xml version=\'1.0\' encoding=\'UTF-8\'?>\n" \
- "<item>" \
- "<title>fruit</title>" \
- "<link>cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b</link>" \
- "<description>" \
- "<item>" \
- "<name>Apple</name><price>$2.99</price>" \
- "</item>" \
- "</description>" \
- "</item>\n"
-
-textEntry = \
- "<?xml version=\'1.0\' encoding=\'UTF-8\'?>\n" \
- "<item>" \
- "<title>fruit</title>" \
- "<link>cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b</link>" \
- "<description>" \
- "Apple" \
- "</description>" \
- "</item>\n"
-
-incompleteEntry = \
- "<item>" \
- "<title>fruit</title><description>" \
- "<fruit xmlns=\"http://services/\">" \
- "<name xmlns=\"\">Orange</name>" \
- "<price xmlns=\"\">3.55</price>" \
- "</fruit>" \
- "</description>" \
- "</item>"
-
-completedEntry = \
- "<?xml version=\'1.0\' encoding=\'UTF-8\'?>\n" \
- "<item>" \
- "<title>fruit</title>" \
- "<link />" \
- "<description>" \
- "<fruit xmlns=\"http://services/\">" \
- "<name xmlns=\"\">Orange</name>" \
- "<price xmlns=\"\">3.55</price>" \
- "</fruit>" \
- "</description>" \
- "</item>\n"
-
-def testEntry():
- i = (element, "'item", (element, "'name", "Apple"), (element, "'price", "$2.99"))
- a = ("fruit", "cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b", i)
- s = writeRSSEntry(a);
- assert car(s) == itemEntry
-
- a2 = readRSSEntry((itemEntry,))
- s2 = writeRSSEntry(a2)
- assert car(s2) == itemEntry
-
- a3 = readRSSEntry((textEntry,))
- s3 = writeRSSEntry(a3)
- assert car(s3) == textEntry
-
- a4 = readRSSEntry((incompleteEntry,))
- s4 = writeRSSEntry(a4)
- assert car(s4) == completedEntry
- return True
-
-emptyFeed = \
- "<?xml version=\'1.0\' encoding=\'UTF-8\'?>\n" \
- "<rss version=\"2.0\">" \
- "<channel>" \
- "<title>Feed</title>" \
- "<link>1234</link>" \
- "<description>Feed</description>" \
- "</channel>" \
- "</rss>\n"
-
-itemFeed = \
- "<?xml version=\'1.0\' encoding=\'UTF-8\'?>\n" \
- "<rss version=\"2.0\">" \
- "<channel>" \
- "<title>Feed</title>" \
- "<link>1234</link>" \
- "<description>Feed</description>" \
- "<item>" \
- "<title>fruit</title>" \
- "<link>cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b</link>" \
- "<description>" \
- "<item>" \
- "<name>Apple</name><price>$2.99</price>" \
- "</item>" \
- "</description>" \
- "</item>" \
- "<item>" \
- "<title>fruit</title>" \
- "<link>cart-53d67a61-aa5e-4e5e-8401-39edeba8b83c</link>" \
- "<description>" \
- "<item>" \
- "<name>Orange</name><price>$3.55</price>" \
- "</item>" \
- "</description>" \
- "</item>" \
- "</channel>" \
- "</rss>\n"
-
-def testFeed():
- s = writeRSSFeed(("Feed", "1234"))
- assert car(s) == emptyFeed
-
- a2 = readRSSFeed((emptyFeed,))
- s2 = writeRSSFeed(a2)
- assert car(s2) == emptyFeed
-
- i3 = (("fruit", "cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b",
- (element, "'item", (element, "'name", "Apple"), (element, "'price", "$2.99"))),
- ("fruit", "cart-53d67a61-aa5e-4e5e-8401-39edeba8b83c",
- (element, "'item", (element, "'name", "Orange"), (element, "'price", "$3.55"))))
- a3 = cons("Feed", cons("1234", i3))
- s3 = writeRSSFeed(a3)
- assert car(s3) == itemFeed
-
- i4 = (("fruit", "cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b",
- valueToElement(("'item", ("'name", "Apple"), ("'price", "$2.99")))),
- ("fruit", "cart-53d67a61-aa5e-4e5e-8401-39edeba8b83c",
- valueToElement(("'item", ("'name", "Orange"), ("'price", "$3.55")))))
- a4 = cons("Feed", cons("1234", i4))
- s4 = writeRSSFeed(a4)
- assert car(s4) == itemFeed
-
- a5 = readRSSFeed((itemFeed,));
- s5 = writeRSSFeed(a5);
- assert car(s5) == itemFeed
-
- i6 = (("fruit", "cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b",
- (("'name", "Apple"), ("'price", "$2.99"))),
- ("fruit", "cart-53d67a61-aa5e-4e5e-8401-39edeba8b83c",
- (("'name", "Orange"), ("'price", "$3.55"))))
- a6 = cons("Feed", cons("1234", i6))
- s6 = writeRSSFeed(feedValuesToElements(a6))
- assert car(s6) == itemFeed
-
- return True
-
-if __name__ == "__main__":
- print "Testing..."
- testEntry()
- testFeed()
- print "OK"
-
diff --git a/modules/wsgi/rssutil.py b/modules/wsgi/rssutil.py
deleted file mode 100644
index 984d71b..0000000
--- a/modules/wsgi/rssutil.py
+++ /dev/null
@@ -1,117 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# RSS data conversion functions
-
-from util import *
-from elemutil import *
-from xmlutil import *
-
-# Convert a list of elements to a list of values representing an RSS entry
-def entryElementsToValues(e):
- lt = filter(selector((element, "'title")), e)
- t = "" if isNil(lt) else elementValue(car(lt))
- li = filter(selector((element, "'link")), e)
- i = "" if isNil(li) else elementValue(car(li))
- lc = filter(selector((element, "'description")), e)
- return (t, i, elementValue(car(lc)))
-
-# Convert a list of elements to a list of values representing RSS entries
-def entriesElementsToValues(e):
- if isNil(e):
- return e
- return cons(entryElementsToValues(car(e)), entriesElementsToValues(cdr(e)))
-
-# Convert a list of strings to a list of values representing an RSS entry
-def readRSSEntry(l):
- e = readXML(l)
- if isNil(e):
- return ()
- return entryElementsToValues(car(e))
-
-# Convert a list of values representy an RSS entry to a value
-def entryValue(e):
- v = elementsToValues((caddr(e),))
- return cons(car(e), (cadr(e), cdr(car(v))))
-
-# Return true if a list of strings represents an RSS feed
-def isRSSFeed(l):
- if not isXML(l):
- return False
- return contains(car(l), "<rss")
-
-# Convert a list of strings to a list of values representing an RSS feed
-def readRSSFeed(l):
- f = readXML(l)
- if isNil(f):
- return ()
- c = filter(selector((element, "'channel")), car(f))
- t = filter(selector((element, "'title")), car(c))
- i = filter(selector((element, "'link")), car(c))
- e = filter(selector((element, "'item")), car(c))
- if isNil(e):
- return (elementValue(car(t)), elementValue(car(i)))
- return cons(elementValue(car(t)), cons(elementValue(car(i)), entriesElementsToValues(e)))
-
-# Convert an RSS feed containing elements to an RSS feed containing values
-def feedValuesLoop(e):
- if (isNil(e)):
- return e
- return cons(entryValue(car(e)), feedValuesLoop(cdr(e)))
-
-def feedValues(e):
- return cons(car(e), cons(cadr(e), feedValuesLoop(cddr(e))))
-
-# Convert a list of values representy an RSS entry to a list of elements
-def entryElement(l):
- return (element, "'item",
- (element, "'title", car(l)),
- (element, "'link", cadr(l)),
- (element, "'description", caddr(l)))
-
-# Convert a list of values representing RSS entries to a list of elements
-def entriesElements(l):
- if isNil(l):
- return l
- return cons(entryElement(car(l)), entriesElements(cdr(l)))
-
-# Convert a list of values representing an RSS entry to an RSS entry
-def writeRSSEntry(l):
- return writeXML((entryElement(l),), True)
-
-# Convert a list of values representing an RSS feed to an RSS feed
-def writeRSSFeed(l):
- c = ((element, "'title", car(l)),
- (element, "'link", cadr(l)),
- (element, "'description", car(l)))
- ce = c if isNil(cddr(l)) else append(c, entriesElements(cddr(l)))
- fe = (element, "'rss", (attribute, "'version", "2.0"), append((element, "'channel"), ce))
- return writeXML((fe,), True)
-
-# Convert an RSS entry containing a value to an RSS entry containing an item element
-def entryValuesToElements(v):
- return cons(car(v), cons(cadr(v), valuesToElements((cons("'item", caddr(v)),))))
-
-# Convert an RSS feed containing values to an RSS feed containing elements
-def feedValuesToElementsLoop(v):
- if isNil(v):
- return v
- return cons(entryValuesToElements(car(v)), feedValuesToElementsLoop(cdr(v)))
-
-def feedValuesToElements(v):
- return cons(car(v), cons(cadr(v), feedValuesToElementsLoop(cddr(v))))
-
diff --git a/modules/wsgi/scdl.py b/modules/wsgi/scdl.py
deleted file mode 100644
index 97c2f7d..0000000
--- a/modules/wsgi/scdl.py
+++ /dev/null
@@ -1,272 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# SCDL parsing functions
-
-from xml.etree.cElementTree import iterparse
-from sys import stderr
-from os import environ
-from util import *
-from httputil import *
-
-# Element tree utility functions, used to parse SCDL documents
-def parse(file):
- return map(lambda x: x, iterparse(file, events=("start", "end")))
-
-def evt(e):
- return car(e)
-
-def elt(e):
- return cadr(e)
-
-def att(e):
- return elt(e).attrib
-
-def text(e):
- return elt(e).text
-
-def match(e, ev, tag):
- return evt(e) == ev and elt(e).tag.find("}" + tag) != -1
-
-# Make a callable component
-class component:
- def __init__(self, name, impl, svcs, refs, props):
- self.name = name
- self.impl = impl
- self.mod = None
- self.svcs = svcs
- self.refs = refs
- self.props = props
- self.proxies = ()
-
- def __call__(self, func, *args):
- return self.mod.__getattribute__(func)(*(args + self.proxies))
-
- def __getattr__(self, name):
- if name[0] == '_':
- raise AttributeError()
- if name == "eval":
- return self
- l = lambda *args: self.__call__(name, *args)
- self.__dict__[name] = l
- return l
-
- def __repr__(self):
- return repr((self.name, self.impl, self.mod, self.svcs, self.refs, self.props, self.proxies))
-
-def mkcomponent(name, impl, svcs, refs, props):
- return component(name, impl, svcs, refs, props)
-
-# Return the Python module name of a component implementation
-def implementation(e):
- if len(e) == 0 or match(car(e), "end", "component") == True:
- return ""
- if match(car(e), "start", "implementation.python") == False:
- return implementation(cdr(e))
- if "script" in att(car(e)):
- s = att(car(e))["script"]
- return s[0:len(s) - 3]
- return None
-
-# Return the URI of a binding under a SCDL service or reference element
-def binding(e):
- if len(e) == 0 or match(car(e), "end", "reference") == True or match(car(e), "end", "service") == True:
- return ()
- if match(car(e), "start", "binding.") == False:
- return binding(cdr(e))
- return att(car(e))["uri"]
-
-# Return the list of references under a SCDL component element
-def references(e):
- if len(e) == 0 or match(car(e), "end", "component") == True:
- return ()
- if match(car(e), "start", "reference") == False:
- return references(cdr(e))
- if "target" in att(car(e)):
- return cons((att(car(e))["name"], car(tokens(att(car(e))["target"]))), references(cdr(e)))
- return cons((att(car(e))["name"], binding(e)), references(cdr(e)))
-
-# Return the list of properties under a SCDL component element
-def properties(e):
- if len(e) == 0 or match(car(e), "end", "component") == True:
- return ()
- if match(car(e), "start", "property") == False:
- return properties(cdr(e))
- return cons((att(car(e))["name"], text(car(e))), properties(cdr(e)))
-
-# Return the list of services under a SCDL component element
-def services(e):
- if len(e) == 0 or match(car(e), "end", "component") == True:
- return ()
- if match(car(e), "start", "service") == False:
- return services(cdr(e))
- return cons(tokens(binding(e)), services(cdr(e)))
-
-# Return the name attribute of a SCDL element
-def name(e):
- return att(car(e))["name"]
-
-# Return the list of components under a SCDL composite element
-def components(e):
- if len(e) == 0:
- return ()
- if match(car(e), "start", "component") == False:
- return components(cdr(e))
- n = name(e)
- return cons(mkcomponent(n, implementation(e), services(e), references(e), properties(e)), components(cdr(e)))
-
-# Find a component with a given name
-def nameToComponent(name, comps):
- if comps == ():
- return None
- if car(comps).name == name:
- return car(comps)
- return nameToComponent(name, cdr(comps))
-
-# Find the URI matching a given URI in a list of service URIs
-def matchingURI(u, svcs):
- if svcs == ():
- return None
- if car(svcs) == u[0:len(car(svcs))]:
- return car(svcs)
- return matchingURI(u, cdr(svcs))
-
-# Return the (service URI, component) pair matching a given URI
-def uriToComponent(u, comps):
- if car(u) == "components":
- return componentURIToComponent(u, comps)
- if car(u) == "references":
- return referenceURIToComponent(u, comps)
- return serviceURIToComponent(u, comps)
-
-def serviceURIToComponent(u, comps):
- if comps == ():
- return (None, None)
- m = matchingURI(u, car(comps).svcs)
- if m != None:
- return (m, car(comps))
- return serviceURIToComponent(u, cdr(comps))
-
-def componentURIToComponent(u, comps):
- comp = nameToComponent(cadr(u), comps)
- if comps == None:
- return (None, None)
- return (u[0:2], comp)
-
-def referenceURIToComponent(u, comps):
- sc = nameToComponent(cadr(u), comps)
- if sc == None:
- return (None, None)
-
- def referenceToComponent(r, refs):
- if refs == ():
- return None
- if r == car(car(refs)):
- return cadr(car(refs))
- return referenceToComponent(r, cdr(refs))
-
- tn = referenceToComponent(caddr(u), sc.refs)
- if tn == None:
- return (None, None)
- tc = nameToComponent(tn, comps)
- if tc == None:
- return (None, None)
- return (u[0:3], tc)
-
-# Evaluate a reference, return a proxy to the resolved component or an
-# HTTP client configured with the reference target uri
-def evalReference(r, comps):
- t = cadr(r)
- if t.startswith("http://") or t.startswith("https://"):
- return mkclient(t)
- return nameToComponent(t, comps)
-
-# Make a callable property
-class property:
- def __init__(self, name, l):
- self.name = name
- self.l = l
-
- def __call__(self, *args):
- return self.l(*args)
-
- def __getattr__(self, name):
- if name == "eval":
- return self
- raise AttributeError()
-
- def __repr__(self):
- return repr((self.name, self.l()))
-
-def mkproperty(name, l):
- return property(name, l)
-
-# Evaluate a property, return a lambda function returning the property
-# value. The host, user, realm, nickname and email properties are configured
-# with the values from the HTTP request, if any.
-def evalProperty(p):
- if car(p) == "host":
- return mkproperty(car(p), lambda: hostProperty(cadr(p), environ))
- if car(p) == "user":
- return mkproperty(car(p), lambda: userProperty(cadr(p)))
- if car(p) == "realm":
- return mkproperty(car(p), lambda: hostProperty(cadr(p), environ))
- if car(p) == "nickname":
- return mkproperty(car(p), lambda: nicknameProperty(cadr(p)))
- if car(p) == "email":
- return mkproperty(car(p), lambda: emailProperty(cadr(p)))
- return mkproperty(car(p), lambda: cadr(p))
-
-def currentUser():
- try:
- from google.appengine.api import users
- return users.get_current_user()
- except:
- return None
-
-def userProperty(v):
- user = currentUser()
- return user.federated_identity() if user else v
-
-def nicknameProperty(v):
- user = currentUser()
- return user.nickname() if user else v
-
-def hostProperty(v, e):
- return e.get("HTTP_HOST", e.get("SERVER_NAME", v)).split(":")[0]
-
-def emailProperty(v):
- user = currentUser()
- return user.email() if user else v
-
-# Evaluate a component, resolve its implementation, references and
-# properties
-def evalComponent(comp, comps):
- comp.mod = __import__(comp.impl)
-
- # Make a list of proxy lambda functions for the component references and properties
- # A reference proxy is the callable lambda function of the component wired to the reference
- # A property proxy is a lambda function that returns the value of the property
- print >> stderr, "evalComponent", comp.impl, comp.svcs, comp.refs, comp.props
- comp.proxies = tuple(map(lambda r: evalReference(r, comps), comp.refs)) + tuple(map(lambda p: evalProperty(p), comp.props))
-
- return comp
-
-# Evaluate a list of components
-def evalComponents(comps):
- return tuple(map(lambda c: evalComponent(c, comps), comps))
-
diff --git a/modules/wsgi/server-test b/modules/wsgi/server-test
deleted file mode 100755
index 20b0287..0000000
--- a/modules/wsgi/server-test
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/sh
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Setup
-./wsgi-start target 8090 2>/dev/null
-sleep 2
-
-# Test
-./client-test 2>/dev/null
-rc=$?
-
-# Cleanup
-./wsgi-stop target 8090
-exit $rc
diff --git a/modules/wsgi/server-test.py b/modules/wsgi/server-test.py
deleted file mode 100644
index 610ec05..0000000
--- a/modules/wsgi/server-test.py
+++ /dev/null
@@ -1,45 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# JSON-RPC test case
-
-def echo(x):
- return x
-
-# ATOMPub test case
-
-def get(id):
- if id == ("index.html",):
- return ("text/plain", ("It works!",))
-
- if id == ():
- return (("'feed", ("'title", "Sample Feed"), ("'id", "123456789"), ("'entry",
- ((("'title", "Item"), ("'id", "111"), ("'content", ("'item", ("'name", "Apple"), ("'currencyCode", "USD"), ("'currencySymbol", "$"), ("'price", 2.99)))),
- (("'title", "Item"), ("'id", "222"), ("'content", ("'item", ("'name", "Orange"), ("'currencyCode", "USD"), ("'currencySymbol", "$"), ("'price", 3.55)))),
- (("'title", "Item"), ("'id", "333"), ("'content", ("'item", ("'name", "Pear"), ("'currencyCode", "USD"), ("'currencySymbol", "$"), ("'price", 1.55))))))),)
-
- content = ("'content", ("'item", ("'name", "Apple"), ("'currencyCode", "USD"), ("'currencySymbol", "$"), ("'price", 2.99)))
- return (("'entry", ("'title", "Item"), ("'id", id[0]), content),)
-
-def post(collection, item):
- return ("123456789",)
-
-def put(id, item):
- return True
-
-def delete(id):
- return True
diff --git a/modules/wsgi/stream-test.py b/modules/wsgi/stream-test.py
deleted file mode 100755
index 2cff038..0000000
--- a/modules/wsgi/stream-test.py
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/python
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Test stream functions
-
-import unittest
-from util import *
-
-def testStream():
-
- s = cons_stream(0, lambda: cons_stream(1, lambda: cons(2, ())))
- assert len(s) == 3
- assert car(s) == 0
- assert cadr(s) == 1
- assert len(cdr(s)) == 2
- assert s[0] == 0
- assert s[1] == 1
- assert s[2] == 2
- assert s[:1] == (0, 1)
- assert s[:5] == (0, 1, 2)
- assert s[2:5] == (2,)
- assert s[4:5] == ()
- assert s[0:] == (0, 1, 2)
- assert (0, 1, 2) == s[0:]
-
- return True
-
-if __name__ == "__main__":
- print "Testing..."
- testStream()
- print "OK"
-
diff --git a/modules/wsgi/util-test b/modules/wsgi/util-test
deleted file mode 100755
index 3bdfc01..0000000
--- a/modules/wsgi/util-test
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/bin/sh
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Run Python util test cases
-here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here`
-python_prefix=`cat $here/../python/python.prefix`
-export LD_LIBRARY_PATH=$python_prefix/lib:$LD_LIBRARY_PATH
-
-$python_prefix/bin/python stream-test.py
-rc=$?
-if [ "$rc" = "0" ]; then
- $python_prefix/bin/python xml-test.py
- rc=$?
-fi
-if [ "$rc" = "0" ]; then
- $python_prefix/bin/python atom-test.py
- rc=$?
-fi
-if [ "$rc" = "0" ]; then
- $python_prefix/bin/python rss-test.py
- rc=$?
-fi
-if [ "$rc" = "0" ]; then
- $python_prefix/bin/python json-test.py
- rc=$?
-fi
-
-exit $rc
diff --git a/modules/wsgi/util.py b/modules/wsgi/util.py
deleted file mode 100644
index 24467fd..0000000
--- a/modules/wsgi/util.py
+++ /dev/null
@@ -1,164 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Simple utility functions
-from sys import maxint
-
-# Scheme-like lists
-def cons(a, b):
- return (a,) + b
-
-def car(l):
- return l[0]
-
-def first(l):
- return car(l)
-
-def cdr(l):
- return l[1:]
-
-def rest(l):
- return cdr(l)
-
-def cadr(l):
- return car(cdr(l))
-
-def cddr(l):
- return cdr(cdr(l))
-
-def caddr(l):
- return car(cddr(l))
-
-def cdddr(l):
- return cdr(cdr(cdr(l)))
-
-def cadddr(l):
- return car(cdddr(l))
-
-def append(a, b):
- return a + b
-
-def reverse(l):
- r = list(l)
- r.reverse()
- return tuple(r)
-
-def isNil(l):
- if isinstance(l, streampair):
- return l.isNil()
- return l == ()
-
-def isSymbol(v):
- return isinstance(v, basestring) and v[0:1] == "'"
-
-def isString(v):
- return isinstance(v, basestring) and v[0:1] != "'"
-
-def isList(v):
- if getattr(v, '__iter__', False) == False:
- return False
- if isinstance(v, basestring) or isinstance(v, dict):
- return False
- return True
-
-def isTaggedList(v, t):
- return isList(v) and not isNil(v) and car(v) == t
-
-
-# Scheme-like streams
-class streampair(object):
- def __init__(self, car, cdr):
- self.car = car
- self.cdr = cdr
-
- def __repr__(self):
- return repr(self[0:len(self)])
-
- def isNil(self):
- return self.cdr == ()
-
- def __len__(self):
- if self.cdr == ():
- return 0
- return 1 + len(self.cdr())
-
- def __getitem__(self, i):
- if i == 0:
- return self.car
- return self.cdr()[i - 1]
-
- def __getslice__(self, i, j):
- if isNil(self):
- return ()
- if i > 0:
- if j == maxint:
- return self.cdr()[i - 1: j]
- return self.cdr()[i - 1: j - 1]
- if j == maxint:
- return self
- if j == 0:
- return (self.car,)
- return (self.car,) + self.cdr()[: j - 1]
-
- def __eq__(self, other):
- sl = len(self)
- ol = len(other)
- if sl != ol:
- return False
- return self[0: sl] == other[0: ol]
-
- def __ne__(self, other):
- return not self.__eq__(other)
-
-def cons_stream(car, cdr):
- return streampair(car, cdr)
-
-
-# Scheme-like associations
-def assoc(k, l):
- if l == ():
- return None
-
- if k == car(car(l)):
- return car(l)
- return assoc(k, cdr(l))
-
-# Currying / partial function application
-def curry(f, *args):
- return lambda *a: f(*(args + a))
-
-# Convert a path represented as a list of values to a string
-def path(p):
- if isNil(p):
- return ""
- return "/" + car(p) + path(cdr(p))
-
-# Split a path into a list of segments
-def tokens(path):
- return tuple(filter(lambda s: len(s) != 0, path.split("/")))
-
-# Return true if s1 contains s2
-def contains(s1, s2):
- return s1.find(s2) != -1
-
-# Write a list of strings to a stream
-def writeStrings(l, os):
- if l == ():
- return os
- os.write(car(l))
- return writeStrings(cdr(l), os)
-
diff --git a/modules/wsgi/wiring-test b/modules/wsgi/wiring-test
deleted file mode 100755
index cbecc20..0000000
--- a/modules/wsgi/wiring-test
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/bin/sh
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-echo "Testing..."
-here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here`
-curl_prefix=`cat $here/../http/curl.prefix`
-uri=$1
-if [ "$uri" = "" ]; then
- uri="http://localhost:8090"
-fi
-
-# Setup
-rm -rf tmp
-mkdir -p tmp
-./wsgi-start target 8090 2>/dev/null
-sleep 2
-
-# Test HTTP GET
-$curl_prefix/bin/curl $uri/index.html 2>/dev/null >tmp/index.html
-diff tmp/index.html htdocs/index.html
-rc=$?
-
-# Test ATOMPub
-if [ "$rc" = "0" ]; then
- $curl_prefix/bin/curl $uri/client/ >tmp/feed.xml 2>/dev/null
- diff tmp/feed.xml htdocs/test/feed.xml
- rc=$?
-fi
-if [ "$rc" = "0" ]; then
- $curl_prefix/bin/curl $uri/client/111 >tmp/entry.xml 2>/dev/null
- diff tmp/entry.xml htdocs/test/entry.xml
- rc=$?
-fi
-if [ "$rc" = "0" ]; then
- $curl_prefix/bin/curl $uri/client/ -X POST -H "Content-type: application/atom+xml" --data @htdocs/test/entry.xml 2>/dev/null
- rc=$?
-fi
-if [ "$rc" = "0" ]; then
- $curl_prefix/bin/curl $uri/client/111 -X PUT -H "Content-type: application/atom+xml" --data @htdocs/test/entry.xml 2>/dev/null
- rc=$?
-fi
-if [ "$rc" = "0" ]; then
- $curl_prefix/bin/curl $uri/client/111 -X DELETE 2>/dev/null
- rc=$?
-fi
-
-# Test JSON-RPC
-if [ "$rc" = "0" ]; then
- $curl_prefix/bin/curl $uri/client/ -X POST -H "Content-type: application/json-rpc" --data @htdocs/test/json-request.txt >tmp/json-result.txt 2>/dev/null
- diff tmp/json-result.txt htdocs/test/json-result.txt
- rc=$?
-fi
-
-# Cleanup
-./wsgi-stop target 8090
-sleep 2
-if [ "$rc" = "0" ]; then
- echo "OK"
-fi
-exit $rc
diff --git a/modules/wsgi/wsgi-start b/modules/wsgi/wsgi-start
deleted file mode 100755
index 1bda4f3..0000000
--- a/modules/wsgi/wsgi-start
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/sh
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Start WSGI server
-here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here`
-root=`echo "import os; print os.path.realpath('$1')" | python`
-port=$2
-
-python_prefix=`cat $here/../python/python.prefix`
-cd $root
-export LD_LIBRARY_PATH=$python_prefix/lib:$LD_LIBRARY_PATH
-$python_prefix/bin/python composite.py $port &
-
diff --git a/modules/wsgi/wsgi-stop b/modules/wsgi/wsgi-stop
deleted file mode 100755
index 3d388ac..0000000
--- a/modules/wsgi/wsgi-stop
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/sh
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Stop WSGI server
-here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here`
-root=`echo "import os; print os.path.realpath('$1')" | python`
-port=$2
-
-python_prefix=`cat $here/../python/python.prefix`
-py="$python_prefix/bin/python composite.py $port"
-
-k=`ps -ef | grep -v grep | grep "${py}" | awk '{ print $2 }'`
-if [ "$k" != "" ]; then
- kill $k
-fi
-
diff --git a/modules/wsgi/wsgi-test b/modules/wsgi/wsgi-test
deleted file mode 100755
index f8334b3..0000000
--- a/modules/wsgi/wsgi-test
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/bin/sh
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-echo "Testing..."
-here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here`
-curl_prefix=`cat $here/../http/curl.prefix`
-
-# Setup
-rm -rf tmp
-mkdir -p tmp
-./wsgi-start target 8090 2>/dev/null
-sleep 2
-
-# Test HTTP GET
-$curl_prefix/bin/curl http://localhost:8090/index.html 2>/dev/null >tmp/index.html
-diff tmp/index.html htdocs/index.html
-rc=$?
-
-# Test ATOMPub
-if [ "$rc" = "0" ]; then
- $curl_prefix/bin/curl http://localhost:8090/wsgi/ >tmp/feed.xml 2>/dev/null
- diff tmp/feed.xml htdocs/test/feed.xml
- rc=$?
-fi
-if [ "$rc" = "0" ]; then
- $curl_prefix/bin/curl http://localhost:8090/wsgi/111 >tmp/entry.xml 2>/dev/null
- diff tmp/entry.xml htdocs/test/entry.xml
- rc=$?
-fi
-if [ "$rc" = "0" ]; then
- $curl_prefix/bin/curl http://localhost:8090/wsgi/ -X POST -H "Content-type: application/atom+xml" --data @htdocs/test/entry.xml 2>/dev/null
- rc=$?
-fi
-if [ "$rc" = "0" ]; then
- $curl_prefix/bin/curl http://localhost:8090/wsgi/111 -X PUT -H "Content-type: application/atom+xml" --data @htdocs/test/entry.xml 2>/dev/null
- rc=$?
-fi
-if [ "$rc" = "0" ]; then
- $curl_prefix/bin/curl http://localhost:8090/wsgi/111 -X DELETE 2>/dev/null
- rc=$?
-fi
-
-# Test JSON-RPC
-if [ "$rc" = "0" ]; then
- $curl_prefix/bin/curl http://localhost:8090/wsgi/ -X POST -H "Content-type: application/json-rpc" --data @htdocs/test/json-request.txt >tmp/json-result.txt 2>/dev/null
- diff tmp/json-result.txt htdocs/test/json-result.txt
- rc=$?
-fi
-
-# Cleanup
-./wsgi-stop target 8090
-sleep 2
-if [ "$rc" = "0" ]; then
- echo "OK"
-fi
-exit $rc
diff --git a/modules/wsgi/xml-test.py b/modules/wsgi/xml-test.py
deleted file mode 100755
index f60322b..0000000
--- a/modules/wsgi/xml-test.py
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/usr/bin/python
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Test XML handling functions
-
-import unittest
-from elemutil import *
-from xmlutil import *
-
-customerXML = \
- "<?xml version=\'1.0\' encoding=\'UTF-8\'?>\n" \
- "<customer>" \
- "<name>jdoe</name>" \
- "<address><city>san francisco</city><state>ca</state></address>" \
- "<account><id>1234</id><balance>1000</balance></account>" \
- "<account><id>6789</id><balance>2000</balance></account>" \
- "<account><id>4567</id><balance>3000</balance></account>" \
- "</customer>\n"
-
-def testElements():
- ad = (("'city", "san francisco"), ("'state", "ca"))
- ac1 = (("'id", "1234"), ("'balance", 1000))
- ac2 = (("'id", "6789"), ("'balance", 2000))
- ac3 = (("'id", "4567"), ("'balance", 3000))
- c = (("'customer", ("'name", "jdoe"), cons("'address", ad), ("'account", (ac1, ac2, ac3))),)
- e = valuesToElements(c)
- v = elementsToValues(e)
- assert v == c
- s = writeXML(e, True)
- assert car(s) == customerXML
-
- c2 = (("'customer", ("'name", "jdoe"), cons("'address", ad), cons("'account", ac1), cons("'account", ac2), cons("'account", ac3)),)
- e2 = valuesToElements(c2);
- v2 = elementsToValues(e2);
- s2 = writeXML(e2, True)
- assert car(s2) == customerXML
-
- c3 = readXML((customerXML,))
- v3 = elementsToValues(c3)
- e3 = valuesToElements(v3)
- s3 = writeXML(e3, True)
- assert car(s3) == customerXML
- return True
-
-def testValues():
- l = (("'ns1:echoString", ("'@xmlns:ns1", "http://ws.apache.org/axis2/services/echo"), ("'text", "Hello World!")),)
- e = valuesToElements(l)
- lx = writeXML(e, True)
- x = readXML(lx)
- v = elementsToValues(x)
- assert v == l
- return True
-
-if __name__ == "__main__":
- print "Testing..."
- testElements()
- testValues()
- print "OK"
-
diff --git a/modules/wsgi/xmlutil.py b/modules/wsgi/xmlutil.py
deleted file mode 100644
index 83b1cf2..0000000
--- a/modules/wsgi/xmlutil.py
+++ /dev/null
@@ -1,124 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# XML handling functions
-
-from StringIO import StringIO
-from xml.parsers import expat
-import xml.etree.ElementTree as et
-from util import *
-from elemutil import *
-
-# Read a list of XML attributes
-def readAttributes(a):
- if a == ():
- return a
- return cons((attribute, "'" + car(car(a)), cadr(car(a))), readAttributes(cdr(a)))
-
-# Read an XML element
-def readElement(e):
- a = tuple(e.items())
- c = tuple(e.getchildren())
- l = (element, "'" + e.tag) + readAttributes(a) + readElements(c)
- if e.text == None or c != ():
- return l
- return l + (e.text,)
-
-# Read a list of XML elements
-def readElements(l):
- if l == ():
- return l
- return cons(readElement(car(l)), readElements(cdr(l)))
-
-# Return true if a list of strings represents an XML document
-def isXML(l):
- if isNil(l):
- return False
- if car(l)[0:5] != "<?xml":
- return False
- return True
-
-# Parse a list of strings representing an XML document
-class NamespaceParser(et.XMLTreeBuilder):
- def __init__(self):
- et.XMLTreeBuilder.__init__(self)
- self._parser = parser = expat.ParserCreate(None)
- parser.DefaultHandlerExpand = self._default
- parser.StartElementHandler = self._start
- parser.EndElementHandler = self._end
- parser.CharacterDataHandler = self._data
- try:
- parser.buffer_text = 1
- except AttributeError:
- pass
- try:
- parser.ordered_attributes = 1
- parser.specified_attributes = 1
- parser.StartElementHandler = self._start_list
- except AttributeError:
- pass
-
-def parseXML(l):
- s = StringIO()
- writeStrings(l, s)
- parser = NamespaceParser()
- parser.feed(s.getvalue())
- return parser.close()
-
-# Read a list of values from a list of strings representing an XML document
-def readXML(l):
- e = parseXML(l)
- return (readElement(e),)
-
-# Write a list of XML element and attribute tokens
-def expandElementValues(n, l):
- if isNil(l):
- return l
- return cons(cons(element, cons(n, car(l))), expandElementValues(n, cdr(l)))
-
-def writeList(l, xml):
- if isNil(l):
- return xml
- token = car(l)
- if isTaggedList(token, attribute):
- xml.attrib[attributeName(token)[1:]] = str(attributeValue(token))
- elif isTaggedList(token, element):
- if elementHasValue(token):
- v = elementValue(token)
- if isList(v):
- e = expandElementValues(elementName(token), v)
- writeList(e, xml)
- else:
- child = et.Element(elementName(token)[1:])
- writeList(elementChildren(token), child)
- xml.append(child)
- else:
- child = et.Element(elementName(token)[1:])
- writeList(elementChildren(token), child)
- xml.append(child)
- else:
- xml.text = str(token)
- writeList(cdr(l), xml)
- return xml
-
-# Convert a list of values to a list of strings representing an XML document
-def writeXML(l, xmlTag):
- e = writeList(l, [])
- if not xmlTag:
- return (et.tostring(car(e)),)
- return (et.tostring(car(e), "UTF-8") + "\n",)
-