summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/modules
diff options
context:
space:
mode:
Diffstat (limited to 'sca-cpp/trunk/modules')
-rwxr-xr-xsca-cpp/trunk/modules/http/http-test2
-rwxr-xr-xsca-cpp/trunk/modules/http/httpd-ca-conf5
-rwxr-xr-xsca-cpp/trunk/modules/http/httpd-cert-conf3
-rwxr-xr-xsca-cpp/trunk/modules/http/httpd-conf6
-rwxr-xr-xsca-cpp/trunk/modules/http/httpd-ssl-conf19
-rwxr-xr-xsca-cpp/trunk/modules/http/httpd-test2
-rwxr-xr-xsca-cpp/trunk/modules/java/server-test2
-rwxr-xr-xsca-cpp/trunk/modules/java/wiring-test2
-rwxr-xr-xsca-cpp/trunk/modules/python/server-test2
-rwxr-xr-xsca-cpp/trunk/modules/python/wiring-test2
-rwxr-xr-xsca-cpp/trunk/modules/server/httpd-test2
-rwxr-xr-xsca-cpp/trunk/modules/server/server-test2
-rwxr-xr-xsca-cpp/trunk/modules/server/wiring-test2
-rw-r--r--sca-cpp/trunk/modules/wsgi/httputil.py32
14 files changed, 45 insertions, 38 deletions
diff --git a/sca-cpp/trunk/modules/http/http-test b/sca-cpp/trunk/modules/http/http-test
index 9f65b37eec..0db47fe189 100755
--- a/sca-cpp/trunk/modules/http/http-test
+++ b/sca-cpp/trunk/modules/http/http-test
@@ -18,7 +18,7 @@
# under the License.
# Setup
-./httpd-conf tmp 8090 htdocs
+./httpd-conf tmp localhost 8090 htdocs
./httpd-start tmp
sleep 2
diff --git a/sca-cpp/trunk/modules/http/httpd-ca-conf b/sca-cpp/trunk/modules/http/httpd-ca-conf
index 20efb441b5..f59ff71d46 100755
--- a/sca-cpp/trunk/modules/http/httpd-ca-conf
+++ b/sca-cpp/trunk/modules/http/httpd-ca-conf
@@ -21,11 +21,8 @@
here=`readlink -f $0`; here=`dirname $here`
root=`readlink -f $1`
host=$2
-if [ "$host" = "" ]; then
- host=`hostname -f`
-fi
-# Don't regenerate the certificate if it already exists
+# Don't override existing certificate
if [ -f $root/conf/ca.crt ]; then
return 0
fi
diff --git a/sca-cpp/trunk/modules/http/httpd-cert-conf b/sca-cpp/trunk/modules/http/httpd-cert-conf
index be357554fb..7bf22d4668 100755
--- a/sca-cpp/trunk/modules/http/httpd-cert-conf
+++ b/sca-cpp/trunk/modules/http/httpd-cert-conf
@@ -21,9 +21,6 @@
here=`readlink -f $0`; here=`dirname $here`
root=`readlink -f $1`
host=$2
-if [ "$host" = "" ]; then
- host=`hostname -f`
-fi
# Don't regenerate the certificate if it already exists
if [ -f $root/conf/server.crt ]; then
diff --git a/sca-cpp/trunk/modules/http/httpd-conf b/sca-cpp/trunk/modules/http/httpd-conf
index 3ed27c6680..fa3ce09fc9 100755
--- a/sca-cpp/trunk/modules/http/httpd-conf
+++ b/sca-cpp/trunk/modules/http/httpd-conf
@@ -20,9 +20,9 @@
# Generate a minimal HTTPD configuration
here=`readlink -f $0`; here=`dirname $here`
root=`readlink -f $1`
-port=$2
-htdocs=`readlink -f $3`
-host=`hostname -f`
+host=$2
+port=$3
+htdocs=`readlink -f $4`
user=`id -un`
group=`id -gn`
diff --git a/sca-cpp/trunk/modules/http/httpd-ssl-conf b/sca-cpp/trunk/modules/http/httpd-ssl-conf
index 6660ad9792..b064dc02dc 100755
--- a/sca-cpp/trunk/modules/http/httpd-ssl-conf
+++ b/sca-cpp/trunk/modules/http/httpd-ssl-conf
@@ -20,13 +20,9 @@
# Generate a minimal HTTPD SSL configuration
here=`readlink -f $0`; here=`dirname $here`
root=`readlink -f $1`
-port=$2
-if [ "$port" != "80" ]; then
- sslport=`echo "$port + 443" | bc`
-else
- sslport="443"
-fi
-host=`hostname -f`
+host=$2
+sslport=$3
+htdocs=`readlink -f $4`
# Extract organization name from our CA certificate
org=`openssl x509 -noout -subject -nameopt multiline -in $root/conf/ca.crt | grep organizationName | awk -F "= " '{ print $2 }'`
@@ -61,7 +57,12 @@ SSLCACertificateFile "$root/conf/ca.crt"
SSLCertificateFile "$root/conf/server.crt"
SSLCertificateKeyFile "$root/conf/server.key"
BrowserMatch ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
+
+# Logging
CustomLog "$root/logs/ssl_request_log" "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
+LogFormat "%h %l %u %t %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" sslcombined
+CustomLog $root/logs/ssl_access_log sslcombined
+LogLevel warn
# Require clients to present either:
# a certificate signed with our CA certificate of authority
@@ -91,9 +92,7 @@ SCASSLCertificateKeyFile "$root/conf/server.key"
EOF
# Create test users for HTTP basic authentication
-htpasswd -bc $root/conf/httpd.passwd admin admin 2>/dev/null
-htpasswd -b $root/conf/httpd.passwd user password 2>/dev/null
-htpasswd -b $root/conf/httpd.passwd test test 2>/dev/null
+htpasswd -bc $root/conf/httpd.passwd test test 2>/dev/null
htpasswd -b $root/conf/httpd.passwd foo foo 2>/dev/null
htpasswd -b $root/conf/httpd.passwd bar bar 2>/dev/null
diff --git a/sca-cpp/trunk/modules/http/httpd-test b/sca-cpp/trunk/modules/http/httpd-test
index 952a58937a..ca6b3e19a1 100755
--- a/sca-cpp/trunk/modules/http/httpd-test
+++ b/sca-cpp/trunk/modules/http/httpd-test
@@ -20,7 +20,7 @@
echo "Testing..."
# Setup
-./httpd-conf tmp 8090 htdocs
+./httpd-conf tmp localhost 8090 htdocs
./httpd-start tmp
sleep 2
diff --git a/sca-cpp/trunk/modules/java/server-test b/sca-cpp/trunk/modules/java/server-test
index fbd12e5542..dba63a9525 100755
--- a/sca-cpp/trunk/modules/java/server-test
+++ b/sca-cpp/trunk/modules/java/server-test
@@ -18,7 +18,7 @@
# under the License.
# Setup
-../http/httpd-conf tmp 8090 ../server/htdocs
+../http/httpd-conf tmp localhost 8090 ../server/htdocs
../server/server-conf tmp
./java-conf tmp
cat >>tmp/conf/httpd.conf <<EOF
diff --git a/sca-cpp/trunk/modules/java/wiring-test b/sca-cpp/trunk/modules/java/wiring-test
index c0b6cbfd62..1300f56ffb 100755
--- a/sca-cpp/trunk/modules/java/wiring-test
+++ b/sca-cpp/trunk/modules/java/wiring-test
@@ -20,7 +20,7 @@
echo "Testing..."
# Setup
-../http/httpd-conf tmp 8090 ../server/htdocs
+../http/httpd-conf tmp localhost 8090 ../server/htdocs
../server/server-conf tmp
./java-conf tmp
cat >>tmp/conf/httpd.conf <<EOF
diff --git a/sca-cpp/trunk/modules/python/server-test b/sca-cpp/trunk/modules/python/server-test
index fe1ff7a486..b01f5f501d 100755
--- a/sca-cpp/trunk/modules/python/server-test
+++ b/sca-cpp/trunk/modules/python/server-test
@@ -18,7 +18,7 @@
# under the License.
# Setup
-../http/httpd-conf tmp 8090 ../server/htdocs
+../http/httpd-conf tmp localhost 8090 ../server/htdocs
../server/server-conf tmp
./python-conf tmp
cat >>tmp/conf/httpd.conf <<EOF
diff --git a/sca-cpp/trunk/modules/python/wiring-test b/sca-cpp/trunk/modules/python/wiring-test
index a3c85838fd..9f2aae342d 100755
--- a/sca-cpp/trunk/modules/python/wiring-test
+++ b/sca-cpp/trunk/modules/python/wiring-test
@@ -20,7 +20,7 @@
echo "Testing..."
# Setup
-../http/httpd-conf tmp 8090 ../server/htdocs
+../http/httpd-conf tmp localhost 8090 ../server/htdocs
../server/server-conf tmp
./python-conf tmp
cat >>tmp/conf/httpd.conf <<EOF
diff --git a/sca-cpp/trunk/modules/server/httpd-test b/sca-cpp/trunk/modules/server/httpd-test
index 86718f96c5..8ab3000f2a 100755
--- a/sca-cpp/trunk/modules/server/httpd-test
+++ b/sca-cpp/trunk/modules/server/httpd-test
@@ -20,7 +20,7 @@
echo "Testing..."
# Setup
-../http/httpd-conf tmp 8090 htdocs
+../http/httpd-conf tmp localhost 8090 htdocs
./server-conf tmp
./scheme-conf tmp
cat >>tmp/conf/httpd.conf <<EOF
diff --git a/sca-cpp/trunk/modules/server/server-test b/sca-cpp/trunk/modules/server/server-test
index e1d9932a5d..e53c7f5ef1 100755
--- a/sca-cpp/trunk/modules/server/server-test
+++ b/sca-cpp/trunk/modules/server/server-test
@@ -18,7 +18,7 @@
# under the License.
# Setup
-../http/httpd-conf tmp 8090 htdocs
+../http/httpd-conf tmp localhost 8090 htdocs
./server-conf tmp
./scheme-conf tmp
cat >>tmp/conf/httpd.conf <<EOF
diff --git a/sca-cpp/trunk/modules/server/wiring-test b/sca-cpp/trunk/modules/server/wiring-test
index 0deab33d68..ae4dce51e4 100755
--- a/sca-cpp/trunk/modules/server/wiring-test
+++ b/sca-cpp/trunk/modules/server/wiring-test
@@ -20,7 +20,7 @@
echo "Testing..."
# Setup
-../http/httpd-conf tmp 8090 htdocs
+../http/httpd-conf tmp localhost 8090 htdocs
./server-conf tmp
./scheme-conf tmp
cat >>tmp/conf/httpd.conf <<EOF
diff --git a/sca-cpp/trunk/modules/wsgi/httputil.py b/sca-cpp/trunk/modules/wsgi/httputil.py
index 92da7ec09c..77d19eabe2 100644
--- a/sca-cpp/trunk/modules/wsgi/httputil.py
+++ b/sca-cpp/trunk/modules/wsgi/httputil.py
@@ -22,6 +22,9 @@ 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 atomutil import *
from jsonutil import *
@@ -34,24 +37,35 @@ class client:
self.uri = urlparse(uri)
def __call__(self, func, *args):
- global id
- req = StringIO()
- writeStrings(jsonRequest(id, func, args), req)
- id = id + 1
- print "HTTP connect:", self.uri.hostname
+
+ # Connect to the configured URI
+ print >> stderr, "Client POST", self.uri.geturl()
c = None
+ headers = {"Content-type": "application/json-rpc"}
if self.uri.scheme == "https":
+
+ # With HTTPS, use a cerficate or HTTP basic authentication
if os.path.exists("server.key"):
c = HTTPSConnection(self.uri.hostname, 443 if self.uri.port == None else self.uri.port, "server.key", "server.crt")
else:
c = HTTPSConnection(self.uri.hostname, 443 if self.uri.port == None else self.uri.port)
+
+ # For HTTP basic authentication the user and password are
+ # provided by htpasswd.py
+ import htpasswd
+ auth = 'Basic ' + b64encode(htpasswd.user + ':' + htpasswd.passwd)
+ headers["Authorization"] = auth
else:
c = HTTPConnection(self.uri.hostname, 80 if self.uri.port == None else self.uri.port)
- print "HTTP connection:", c
- c.request("POST", self.uri.path, req.getvalue(), {"Content-type": "application/json-rpc"})
+
+ # POST the JSON-RPC request
+ global id
+ req = StringIO()
+ writeStrings(jsonRequest(id, func, args), req)
+ id = id + 1
+ c.request("POST", self.uri.path, req.getvalue(), headers)
res = c.getresponse()
- print "HTTP response:", res
- print "HTTP status:", res.status
+ print >> stderr, "Client status", res.status
if res.status != 200:
return None
return jsonResultValue((res.read(),))